summaryrefslogtreecommitdiff
path: root/configure.in
blob: 0212c916a2f2e9885ac9e350580efaffc37724cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
dnl# $Id$

AC_INIT(src/feature.h)
AM_INIT_AUTOMAKE(Eterm, 0.9.1)

dnl# Set some basic variables
DATE="`date '+%d %B %Y'`"
AC_SUBST(DATE)
BUILD_DATE="`date`"
AC_DEFINE_UNQUOTED(BUILD_DATE, "$BUILD_DATE")
AUTHORS="Michael Jennings (mej@eterm.org) "
AC_SUBST(AUTHORS)
AC_DEFINE_UNQUOTED(AUTHORS, "$AUTHORS")

dnl# Find RCS Ident info from source files
AC_DEFINE_UNQUOTED(ACTIONS_IDENT, "`grep '$''Id:' $srcdir/src/actions.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(BUTTONS_IDENT, "`grep '$''Id:' $srcdir/src/buttons.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(COMMAND_IDENT, "`grep '$''Id:' $srcdir/src/command.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(DRAW_IDENT, "`grep '$''Id:' $srcdir/src/draw.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(E_IDENT, "`grep '$''Id:' $srcdir/src/e.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(EVENTS_IDENT, "`grep '$''Id:' $srcdir/src/events.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(FONT_IDENT, "`grep '$''Id:' $srcdir/src/font.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(GRKELOT_IDENT, "`grep '$''Id:' $srcdir/src/grkelot.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(MAIN_IDENT, "`grep '$''Id:' $srcdir/src/main.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(MENUS_IDENT, "`grep '$''Id:' $srcdir/src/menus.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(MISC_IDENT, "`grep '$''Id:' $srcdir/src/misc.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(NETDISP_IDENT, "`grep '$''Id:' $srcdir/src/netdisp.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(OPTIONS_IDENT, "`grep '$''Id:' $srcdir/src/options.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(PIXMAP_IDENT, "`grep '$''Id:' $srcdir/src/pixmap.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(SCREEN_IDENT, "`grep '$''Id:' $srcdir/src/screen.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(SCROLLBAR_IDENT, "`grep '$''Id:' $srcdir/src/scrollbar.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(STARTUP_IDENT, "`grep '$''Id:' $srcdir/src/startup.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(SYSTEM_IDENT, "`grep '$''Id:' $srcdir/src/system.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(TERM_IDENT, "`grep '$''Id:' $srcdir/src/term.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(TIMER_IDENT, "`grep '$''Id:' $srcdir/src/timer.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(UTMP_IDENT, "`grep '$''Id:' $srcdir/src/utmp.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")
AC_DEFINE_UNQUOTED(WINDOWS_IDENT, "`grep '$''Id:' $srcdir/src/windows.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`")

dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
if test ! -z "${CFLAGS}" -o ! -z "${CCOPTS}"; then
  CFLAGS_GIVEN=1
else
  CFLAGS_GIVEN=0
fi

if test -z "${CFLAGS}"; then
    if test -z "${CCOPTS}"; then
	CCOPTS="-O"
    fi
    CFLAGS="$CCOPTS"
fi

AC_ARG_WITH(cc, [  --with-cc=compiler      force Eterm to build with a particular compiler (like pgcc, egcs, etc.)],
            CC=$withval, 
  if test -z "$CC"; then
    CC=check
  fi
)

if test "$CC" = "check"; then
  dnl# Check for Pentium compiler
  AC_CHECK_PROG(PGCC, pgcc, pgcc)

  if test ! -z "$PGCC"; then
    CC=$PGCC
  else
    unset CC
  fi
fi

AC_PROG_CC
AC_PROG_CPP

dnl# These must be run after AC_PROG_CC but before any other macros that use
dnl# the C compiler
AC_AIX
AC_ISC_POSIX
AC_MINIX

dnl# At least make the attempt to support CygWin32
AC_CYGWIN
AC_ARG_PROGRAM

AM_PROG_LIBTOOL

dnl# Where are we?
AC_MSG_CHECKING(for distribution root)
DIST_ROOT=`pwd`
AC_SUBST(DIST_ROOT)
AC_MSG_RESULT($DIST_ROOT)

AC_GCC_TRADITIONAL

dnl # If using gcc, use -O2.  If -g works with it, use that too
if test "${CFLAGS_GIVEN}" -ne 1; then
    if test "$GCC" = "yes"; then
	if test "$ac_cv_prog_cc_g" = "yes"; then
	    CCOPTS='-g -O2'
	else
	    CCOPTS='-O2'
	fi
	CFLAGS="$CCOPTS"
    fi
fi

AC_PROG_INSTALL

dnl# Check for host system type
AC_CANONICAL_HOST

dnl# Check the sanity of what we've done so far
AM_SANITY_CHECK

dnl# Most people don't want the developer-only clutter
AM_MAINTAINER_MODE

dnl# If it's there, what the hell?
AM_WITH_DMALLOC

dnl# Look for needed programs
AC_CHECK_PROG(SED, sed, sed, false)
AC_CHECK_PROG(RM, rm, rm, true)
AC_CHECK_PROG(CP, cp, cp, false)
AC_CHECK_PROG(CHMOD, chmod, chmod, true)
AC_CHECK_PROG(TAR, tar, tar, tar)
AC_CHECK_PROG(MKDIR, mkdir, mkdir, false)
AC_CHECK_PROG(CTAGS, ctags, ctags, true)
AC_CHECK_PROG(AR, ar, ar, false)
AC_CHECK_PROG(MV, mv, mv, true)
AC_CHECK_PROG(TIC, tic, tic, true)
AC_LN_S
AC_PATH_PROG(PERL, perl, /usr/bin/perl, $PATH:/usr/bin:/bin:/usr/local/bin:/usr/ccs/bin:/usr/contrib/bin)
AC_PATH_PROG(AWK, awk, /usr/bin/awk, $PATH:/usr/bin:/bin:/usr/local/bin:/usr/ccs/bin:/usr/contrib/bin)
export PERL AWK

AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(void *, 4)
AC_CHECK_SIZEOF(long long, 8)
AC_C_BIGENDIAN

AC_C_CONST
AC_C_INLINE
AC_PATH_XTRA

if test ! -z "$X_CFLAGS"; then
  if test -z "$CPPFLAGS"; then
    CPPFLAGS="$X_CFLAGS"
  else
    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  fi
fi
if test ! -z "$X_LIBS"; then
  if test -z "$LDFLAGS"; then
    LDFLAGS="$X_LIBS"
  else
    LDFLAGS="$LDFLAGS $X_LIBS"
  fi
fi

dnl# Checks for header files.
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h termios.h \
sys/ioctl.h sys/select.h sys/time.h \
sys/sockio.h sys/byteorder.h malloc.h \
utmpx.h unistd.h bsd/signal.h regex.h \
regexp.h stdarg.h X11/Xmu/Atoms.h \
X11/Sunkeysym.h)
AC_HEADER_TIME

dnl# Missing typedefs and replacements
AC_TYPE_MODE_T
AC_CHECK_TYPE(off_t, long)
AC_TYPE_PID_T
AC_TYPE_UID_T

dnl# Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(atexit _exit unsetenv setutent \
seteuid memmove putenv strsep setresuid setresgid \
memmem usleep snprintf strcasestr strcasechr \
strcasepbrk strrev)
dps_snprintf_oflow()
AC_CHECK_LIB(m, pow)

dnl# Portability checks for various functions
AC_SEARCH_LIBS(login, bsd ucb util)
AC_SEARCH_LIBS(logout, util)
AC_SEARCH_LIBS(getpwuid, sun)

dnl#
dnl# Utility stuff
dnl#
dnl# Did they want debugging?
AC_MSG_CHECKING(for debugging level)
AC_ARG_WITH(debugging, [  --with-debugging[=num]  enable debugging output, num is an integer 0-9],
              if test "$withval" = "yes"; then
                  withval=4
              else
                  :
              fi
              if test "$withval" != "no"; then 
                  echo "$withval"
                  AC_DEFINE_UNQUOTED(DEBUG, $withval)
              else
                  echo "no debugging"
                  AC_DEFINE_UNQUOTED(DEBUG, 0)
              fi, echo "4"
                  AC_DEFINE_UNQUOTED(DEBUG, 4)
)

AC_CHECK_FUNC(ptsname,
              HAVE_PTSNAME=yes
             )
AC_CHECK_FUNC(grantpt,
              HAVE_GRANTPT=yes
             )
AC_CHECK_FUNC(unlockpt,
              HAVE_UNLOCKPT=yes
             )
dnl# Check for the appropriate pty mechanism
AC_MSG_CHECKING(for pty mechanism)
PTY_MECH=""
if test -c /dev/ptc ; then
  AC_DEFINE(HAVE_DEV_PTC)
  PTY_MECH="AIX $PTY_MECH"
fi
if test -r /dev/ptmx -a ! -z "$HAVE_PTSNAME" -a ! -z "$HAVE_GRANTPT" -a ! -z "$HAVE_UNLOCKPT"; then
  AC_DEFINE(HAVE_DEV_PTMX)
  PTY_MECH="SVR4 $PTY_MECH"
fi
if test -c /dev/ptyp128 ; then
  AC_DEFINE(HAVE_SCO_PTYS)
  PTY_MECH="SCO $PTY_MECH"
fi
if test "X$PTY_MECH" = "X"; then
  AC_MSG_RESULT(generic pty's only)
else
  AC_MSG_RESULT($PTY_MECH)
fi
AC_MSG_CHECKING(for pty group)
AC_ARG_WITH(pty-group,
[  --with-pty-group[=gid]  specify the group that should own pty files],
            if test "$withval" = "yes"; then 
              PTY_GRP_NAME=`ls -1l /dev/pty* 2>/dev/null | head -n 1 | awk '{print $4}'`
              if test ! -z "$PTY_GRP_NAME"; then
                AC_MSG_RESULT($PTY_GRP_NAME)
                AC_DEFINE_UNQUOTED(PTY_GRP_NAME, "$PTY_GRP_NAME")
              else
                AC_MSG_RESULT(unable to determine.  This feature will not be enabled.)
              fi
            elif test "$withval" = "no"; then
              AC_MSG_RESULT(none)
            else
              AC_MSG_RESULT($withval)
              AC_DEFINE_UNQUOTED(PTY_GRP_NAME, "$withval")
            fi
            ,
            PTY_GRP_NAME=`ls -1l /dev/pty* 2>/dev/null | head -n 1 | awk '{print $4}'`
            if test ! -z "$PTY_GRP_NAME"; then
              AC_MSG_RESULT($PTY_GRP_NAME)
              AC_DEFINE_UNQUOTED(PTY_GRP_NAME, "$PTY_GRP_NAME")
            else
              AC_MSG_RESULT(none)
            fi
)
AC_MSG_CHECKING(for saved uids)
AC_ARG_WITH(saved-uids, [  --with(out)-saved-uids  specify that your OS has (does not have) saved uids, default is to guess],
            if test "$withval" = "yes"; then
                AC_MSG_RESULT(user specified yes)
                HAVE_SAVED_UIDS=1
            elif test "$withval" = "no"; then
                AC_MSG_RESULT(user specified no)
                HAVE_SAVED_UIDS=0
            fi
)
if test "x$HAVE_SAVED_UIDS" = "x"; then
    case `uname -s` in
        Linux | linux | GNU*Linux)  HAVE_SAVED_UIDS=1 ;;
        HP*UX | hp*ux)              HAVE_SAVED_UIDS=1 ;;
        AIX | aix)                  HAVE_SAVED_UIDS=1 ;;
        Solaris | SunOS | [Ss]un)   HAVE_SAVED_UIDS=1 ;;
        *BSD)                       HAVE_SAVED_UIDS=0 ;;
    esac
    if test "x$HAVE_SAVED_UIDS" = "x"; then
        AC_MSG_RESULT(unknown...assuming no support)
        HAVE_SAVED_UIDS=0
    elif test $HAVE_SAVED_UIDS -eq 1; then
        AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_SAVED_UIDS)
    else
        AC_MSG_RESULT(no)
    fi
fi

dnl#
dnl# X LIBRARIES
dnl#
AC_CHECK_LIB(X11, XOpenDisplay, , [
echo "ERROR:  You need libX11 to build Eterm.  Verify that you have libX11.a or";
echo "        libX11.so installed and that it is located in the X libraries";
echo "        directory shown above.  If it is in a different directory, try using";
echo "        the --x-libraries parameter to configure.";
             AC_MSG_ERROR([Fatal:  libX11 not found.])])
AC_CHECK_LIB(Xext, XextAddDisplay, , [
echo "ERROR:  You need libXext to build Eterm.  Verify that you have libXext.a or";
echo "        libXext.so installed and that it is located in the X libraries";
echo "        directory shown above.  If it is in a different directory, try using";
echo "        the --x-libraries parameter to configure.";
             AC_MSG_ERROR([Fatal:  libXext not found.])])

AC_CHECK_LIB(Xext, XShapeQueryExtension, AC_DEFINE(HAVE_X_SHAPE_EXT))

# check if we need X_LOCALE definition
AC_CHECK_LIB(X11, _Xsetlocale, , AC_DEFINE(NO_XLOCALE))

# For multibyte selection handling
if test "$MULTICHAR_ENCODING" != "none"; then
  AC_CHECK_LIB(Xmu, XmuInternAtom)
fi

# check X11R6 for XIM
if test "$XIM" = "TRUE"; then
  AC_CHECK_LIB(X11, XRegisterIMInstantiateCallback, AC_DEFINE(USE_X11R6_XIM))
fi

dnl#
dnl# FEATURES
dnl#
AC_MSG_CHECKING(if Pablo support is wanted)
AC_ARG_WITH(pablo,
[  --with-pablo[=DIR]      compile with Pablo I/O Tracing support (using Pablo prefix DIR)],
            if test "$withval" != "no"; then 
              AC_MSG_RESULT(yes)
              if test "$withval" != "yes"; then
                CPPFLAGS="$CPPFLAGS -I${withval}/include"
                LDFLAGS="$LDFLAGS -L${withval}/lib"
              fi
              AC_CHECK_HEADER(IOTrace.h, 
                              AC_CHECK_LIB(PabloTraceExt, initIOTrace,
                                           AC_DEFINE(IOTRACE)
                                           LIBS="$LIBS -lPabloTraceExt -lPabloTrace"
                                           echo "Pablo support enabled.  Headers in ${withval}/include.  Libraries in ${withval}/lib."
                                           , 
                                           echo "*** ERROR:  Pablo support was requested but the Pablo libraries could not be"
                                           echo "***         found.  Please check config.log for further information."
                                           echo "***         Pablo support will NOT be included."
                                           , -lPabloTrace)
                              ,
                              echo "*** ERROR:  Pablo support was requested but the Pablo header files could not be"
                              echo "***         found.  Please check the value you passed to --with-pablo."
                              echo "***         Pablo support will NOT be included.")
            else
              AC_MSG_RESULT(no)
            fi, AC_MSG_RESULT(no)
)
AC_MSG_CHECKING(if profiling macros should be included)
AC_ARG_ENABLE(profile,
[  --enable-profile        compile with code profiling macros enabled],
            if test "$enableval" = "yes"; then 
              AC_MSG_RESULT(yes)
              AC_DEFINE(ENABLE_PROFILE)
            else
              AC_MSG_RESULT(no)
            fi, AC_MSG_RESULT(no)
)
AC_MSG_CHECKING(for pixmap support)
AC_ARG_WITH(imlib,
[  --with-imlib[=DIR]      compile with Imlib support (Imlib residing in DIR/lib) (default)],
            if test "$withval" != "no"; then 
              AC_MSG_RESULT(yes)
              if test "$withval" != "yes"; then
                CPPFLAGS="$CPPFLAGS -I${withval}/include"
                LDFLAGS="$LDFLAGS -L${withval}/lib"
              fi
              USE_IMLIB=1
            else
              AC_MSG_RESULT(no)
              GRLIBS=""
              USE_IMLIB=0
              AC_WARN(*** Pixmap support has been disabled at your request.  This ***)
              AC_WARN(*** is generally a bad idea since it really doesn't save    ***)
              AC_WARN(*** much memory.  And the developers almost never test that ***)
              AC_WARN(*** configuration.  So I'd reconsider if I were you....     ***)
            fi, AC_MSG_RESULT(yes)
                USE_IMLIB=1
)
if test $USE_IMLIB -eq 1 ; then
  AC_CHECK_LIB(dl, dlopen, GRLIBS="-ldl", , $GRLIBS)
  AC_CHECK_LIB(ttf, TT_Init_FreeType, GRLIBS="-lttf $GRLIBS", , $GRLIBS)
  AC_CHECK_LIB(Imlib2, imlib_create_image,
               GRLIBS="-lImlib2 $GRLIBS"
               AC_DEFINE(HAVE_LIBIMLIB2)
               AC_DEFINE(PIXMAP_SUPPORT)
               AC_DEFINE(BACKING_STORE)
              ,
               AC_WARN(*** Pixmap support has been disabled because Imlib2 was not found ***)
               AC_WARN(*** or could not be linked.  Eterm should still work, but it will ***)
               AC_WARN(*** not be very happy.  Check config.log for more detailed        ***)
               AC_WARN(*** information on why my attempt to link with Imlib2 failed.     ***)
              , $GRLIBS)

fi

AC_MSG_CHECKING(for transparency support)
AC_ARG_ENABLE(trans,
[  --enable-trans          compile with transparency support],
            if test "$enableval" != "no"; then 
              AC_MSG_RESULT(yes)
              AC_DEFINE(PIXMAP_OFFSET)
            else
              AC_MSG_RESULT(no)
            fi, AC_MSG_RESULT(yes)
                AC_DEFINE(PIXMAP_OFFSET)
)

AC_MSG_CHECKING(for MMX support)
HAVE_MMX=""
AC_ARG_ENABLE(mmx, [  --enable-mmx            enable MMX assembly routines],
               test "x$enableval" = "xyes" && HAVE_MMX="yes"
              ,
               if test x$build_os = xlinux-gnu; then
                 grep mmx /proc/cpuinfo >/dev/null 2>&1 && HAVE_MMX="yes"
               fi
              )
if test "x$HAVE_MMX" = "xyes"; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_MMX)
else
  AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(HAVE_MMX, test "x$HAVE_MMX" = "xyes")

dnl#
dnl# LibAST
dnl#
AC_CHECK_LIB(ast, libast_malloc, FOUND_LIBAST=1, FOUND_LIBAST=0, $GRLIBS)
if test "$FOUND_LIBAST" -eq "1"; then
  AC_CHECK_PROG(LIBAST_CONFIG, libast-config, libast-config, false)
  test "$LIBAST_CONFIG" = "false" && FOUND_LIBAST=0
fi

if test "$FOUND_LIBAST" -ne "1"; then
  echo "ERROR:  You need the LibAST package to build Eterm.  If you already have it,";
  echo "        you may have it installed in a strange place, or you may need to run";
  echo "        /sbin/ldconfig.  If you don't have it, I can download it for you.";
  echo "        Shall I retrieve and build LibAST now (y/n)?";
  read ANS
  if test "x$ANS" = "xy" -o "x$ANS" = "xyes" -o "x$ANS" = "xY" -o "x$ANS" = "xYES"; then
    if test -d CVS ; then
      # Download from CVS server
      CVSROOT=":pserver:anonymous@cvs.enlightenment.sourceforge.net:/cvsroot/enlightenment"
      grep $CVSROOT $HOME/.cvspass >/dev/null 2>&1 || cvs -d $CVSROOT login
      cvs -z3 -d $CVSROOT co -d libast eterm/libast
      (cd libast && ./autogen.sh $ac_configure_args && make install && cd .. && rm -rf libast)
      if test $? -ne 0; then
        echo 'ERROR:  Unable to auto-get libast, sorry.' 1>&2
        exit 1
      fi
      FOUND_LIBAST=1
      AC_CHECK_PROG(LIBAST_CONFIG, libast-config, libast-config, false)
      test "$LIBAST_CONFIG" = "false" && FOUND_LIBAST=0
    else
      # Download tarball
      :
    fi
  fi
fi
if test "$FOUND_LIBAST" -eq "1"; then
  if test ! -z "$LIBAST_CONFIG"; then
    GRLIBS="-last $GRLIBS"
    AC_DEFINE(HAVE_LIBAST)
    test "$prefix" = "NONE" && prefix="`$LIBAST_CONFIG --prefix`"
    CPPFLAGS="$CPPFLAGS `$LIBAST_CONFIG --cppflags`"
    LDFLAGS="$LDFLAGS `$LIBAST_CONFIG --ldflags`"
    SUPPORT_FLAGS="`$LIBAST_CONFIG --support`"
    for i in $SUPPORT_FLAGS ; do
      case $i in
        MMX)
          AC_DEFINE(LIBAST_MMX_SUPPORT)
          ;;
        X11)
          AC_DEFINE(LIBAST_X11_SUPPORT)
          ;;
        Imlib2)
          AC_DEFINE(LIBAST_IMLIB2_SUPPORT)
          ;;
      esac
    done
  fi
else
  AC_MSG_ERROR(Fatal:  libast not found.)
fi

AC_MSG_CHECKING(for utmp support)
AC_ARG_ENABLE(utmp,
[  --enable-utmp           compile with utmp support],
            if test "$enableval" != "no"; then 
              AC_MSG_RESULT(yes)
              UTMP=1
              AC_DEFINE(UTMP_SUPPORT)
            else
              AC_MSG_RESULT(no)
              UTMP=0
            fi, AC_MSG_RESULT(yes)
                AC_DEFINE(UTMP_SUPPORT)
                UTMP=1
)
if test $UTMP -eq 1; then
  AC_CHECK_LIB(utempter, addToUtmp)
fi
AC_MSG_CHECKING(for backspace key configuration)
AC_ARG_WITH(backspace,
[  --with-backspace=KEY    force backspace to send KEY (KEY is either \"bs\" for ^H or \"del\" for ^?)],
            if test "$withval" = "bs"; then 
              AC_MSG_RESULT(forcing Backspace to send Ctrl-H)
              AC_DEFINE(FORCE_BACKSPACE)
            elif test "$withval" = "del"; then 
              AC_MSG_RESULT(forcing Backspace to send Ctrl-?)
              AC_DEFINE(FORCE_DELETE)
            else
              AC_MSG_RESULT(default)
            fi, AC_MSG_RESULT(default)
)
AC_MSG_CHECKING(for delete key configuration)
AC_ARG_WITH(delete,
[  --with-delete=SETTING   force delete to SETTING (\"server\" to use the X server value always,
                          \"execute\" to send the old default execute escape sequence,
                          or a quoted string to use a specific string)],
            if test "$withval" = "server"; then
              AC_MSG_RESULT(X server value)
              AC_DEFINE(NO_DELETE_KEY)
            elif test "$withval" = "no"; then
              AC_MSG_RESULT(X server value)
              AC_DEFINE(NO_DELETE_KEY)
            elif test "$withval" = "execute"; then
              AC_MSG_RESULT(send execute sequence)
            else
              AC_MSG_RESULT(forcing Delete to send "$withval")
              AC_DEFINE_UNQUOTED(KS_DELETE, "$withval")
            fi, AC_MSG_RESULT(default)
                AC_DEFINE_UNQUOTED(KS_DELETE, "\177")
)
XTERM_HOME="\033\133H"
LINUX_HOME="\033\1331~"
AC_MSG_CHECKING(for home key configuration)
AC_ARG_WITH(home,
[  --with-home=SEQUENCE    specify which sequence to use for the Home key ("xterm", "linux", or "vt102")],
            if test "$withval" = "xterm"; then 
              AC_MSG_RESULT(emulate xterm)
              AC_DEFINE_UNQUOTED(KS_HOME, "$XTERM_HOME")
            elif test "$withval" = "linux"; then 
              AC_MSG_RESULT(emulate linux console/vt220)
              AC_DEFINE_UNQUOTED(KS_HOME, "$LINUX_HOME")
            else
              AC_MSG_RESULT(default vt102)
            fi, AC_MSG_RESULT(default)
)
XTERM_END="\033\133F"
LINUX_END="\033\1334~"
AC_MSG_CHECKING(for end key configuration)
AC_ARG_WITH(end,
[  --with-end=SEQUENCE     specify which sequence to use for the End key ("xterm", "linux", or "vt102")],
            if test "$withval" = "xterm"; then 
              AC_MSG_RESULT(emulate xterm)
              AC_DEFINE_UNQUOTED(KS_END, "$XTERM_END")
            elif test "$withval" = "linux"; then 
              AC_MSG_RESULT(emulate linux console/vt220)
              AC_DEFINE_UNQUOTED(KS_END, "$LINUX_END")
            else
              AC_MSG_RESULT(default vt102)
            fi, AC_MSG_RESULT(default)
)
MULTICHAR_ENCODING=""
AC_MSG_CHECKING(for multi-charset support)
AC_ARG_ENABLE(multi-charset,
[  --enable-multi-charset  compile with multibyte font support],
            if test "$enableval" = "no"; then
              MULTI_CHARSET_TYPE=""
            else
              MULTI_CHARSET_TYPE="$enableval"
            fi,
            if (xlsfonts | grep 10646 >/dev/null 2>&1); then
              MULTI_CHARSET_TYPE="unicode"
            else
              MULTI_CHARSET_TYPE=""
            fi
           )

if test "x$MULTI_CHARSET_TYPE" != "x"; then
  if test "$MULTI_CHARSET_TYPE" = "kanji"; then
    AC_MSG_RESULT(kanji)
    AC_DEFINE(MULTI_CHARSET)
    DEF_FONT_IDX=0
    MULTICHAR_ENCODING="eucj"
    FONT0="fixed"
    FONT1="8x16"
    FONT2="9x18"
    FONT3="12x24"
    FONT4="13x26"
    MFONT0="k14"
    MFONT1="jiskan16"
    MFONT2="jiskan18"
    MFONT3="jiskan24"
    MFONT4="jiskan26"
  elif test "$MULTI_CHARSET_TYPE" = "euc-kr" -o "$MULTI_CHARSET_TYPE" = "euckr"; then 
    AC_MSG_RESULT(euckr)
    AC_DEFINE(MULTI_CHARSET)
    DEF_FONT_IDX=1
    MULTICHAR_ENCODING="euckr"
    FONT0="7x14"
    FONT1="8x16"
    FONT2="9x18"
    FONT3="10x20"
    FONT4="12x24"
    MFONT0="-*-gulim-medium-r-normal--14-*-*-*-*-140-ksc5601.1987-0"
    MFONT1="-*-gulim-medium-r-normal--16-*-*-*-*-160-ksc5601.1987-0"
    MFONT2="-*-gulim-medium-r-normal--18-*-*-*-*-180-ksc5601.1987-0"
    MFONT3="-*-gulim-medium-r-normal--20-*-*-*-*-200-ksc5601.1987-0"
    MFONT4="-*-gulim-medium-r-normal--24-*-*-*-*-240-ksc5601.1987-0"
  elif test "$MULTI_CHARSET_TYPE" = "unicode" -o "$MULTI_CHARSET_TYPE" = "utf-8" -o "$MULTI_CHARSET_TYPE" = "utf8"; then 
    AC_MSG_RESULT(ISO-10646)
    AC_DEFINE(MULTI_CHARSET)
    DEF_FONT_IDX=2
    MULTICHAR_ENCODING="iso-10646"
    MFONT0="-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso10646-1"
    MFONT1="-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso10646-1"
    MFONT2="-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1"
    MFONT3="-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1"
    MFONT4="-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1"
    FONT0="5x7"
    FONT1="6x10"
    FONT2="fixed"
    FONT3="8x13"
    FONT4="9x15"
  elif test "$MULTI_CHARSET_TYPE" = "big5"; then
    AC_MSG_RESULT(big5)
    AC_DEFINE(MULTI_CHARSET)
    DEF_FONT_IDX=0
    MULTICHAR_ENCODING="big5"
    FONT0="8x16"
    FONT1="9x18"
    FONT2="10x20"
    FONT3="12x24"
    FONT4="13x26"
    MFONT0="-*-ming-medium-r-normal--16-*-*-*-c-*-big5-0"
    MFONT1="-*-ming-medium-r-normal--18-*-*-*-c-*-big5-0"
    MFONT2="-*-ming-medium-r-normal--20-*-*-*-c-*-big5-0"
    MFONT3="-*-ming-medium-r-normal--24-*-*-*-c-*-big5-0"
    MFONT4="-*-ming-medium-r-normal--26-*-*-*-c-*-big5-0"
  else
    MULTI_CHARSET_TYPE=""
  fi
fi
if test "x$MULTI_CHARSET_TYPE" = "x"; then
  AC_MSG_RESULT(no)
  DEF_FONT_IDX=2
  MULTICHAR_ENCODING=none
  MFONT0=none
  MFONT1=none
  MFONT2=none
  MFONT3=none
  MFONT4=none
  FONT0="5x7"
  FONT1="6x10"
  FONT2="fixed"
  FONT3="8x13"
  FONT4="9x15"
fi

AC_DEFINE_UNQUOTED(DEF_FONT_IDX, $DEF_FONT_IDX)
AC_DEFINE_UNQUOTED(FONT0, "$FONT0")
AC_DEFINE_UNQUOTED(FONT1, "$FONT1")
AC_DEFINE_UNQUOTED(FONT2, "$FONT2")
AC_DEFINE_UNQUOTED(FONT3, "$FONT3")
AC_DEFINE_UNQUOTED(FONT4, "$FONT4")
AC_SUBST(DEF_FONT_IDX)
AC_SUBST(FONT0)
AC_SUBST(FONT1)
AC_SUBST(FONT2)
AC_SUBST(FONT3)
AC_SUBST(FONT4)
export FONT0 FONT1 FONT2 FONT3 FONT4 DEF_FONT_IDX

AC_DEFINE_UNQUOTED(MULTICHAR_ENCODING, "$MULTICHAR_ENCODING")
AC_DEFINE_UNQUOTED(MFONT0, "$MFONT0")
AC_DEFINE_UNQUOTED(MFONT1, "$MFONT1")
AC_DEFINE_UNQUOTED(MFONT2, "$MFONT2")
AC_DEFINE_UNQUOTED(MFONT3, "$MFONT3")
AC_DEFINE_UNQUOTED(MFONT4, "$MFONT4")
AC_SUBST(MULTICHAR_ENCODING)
AC_SUBST(MFONT0)
AC_SUBST(MFONT1)
AC_SUBST(MFONT2)
AC_SUBST(MFONT3)
AC_SUBST(MFONT4)
export MFONT0 MFONT1 MFONT2 MFONT3 MFONT4 MULTICHAR_ENCODING

AC_MSG_CHECKING(for XIM support)
AC_ARG_ENABLE(xim,
[  --enable-xim            compile with XIM support (default)],
            if test "$enableval" = "no"; then 
              AC_MSG_RESULT(no)
	      XIM="FALSE"
            else
              AC_MSG_RESULT(yes)
	      AC_DEFINE(USE_XIM)
	      XIM="TRUE"
            fi, AC_MSG_RESULT(yes)
	        AC_DEFINE(USE_XIM)
	        XIM="TRUE"
)

AC_MSG_CHECKING(for Greek keyboard support)
AC_ARG_ENABLE(greek,
[  --enable-greek          compile with support for Greek keyboards],
            if test "$enableval" = "yes"; then 
              AC_MSG_RESULT(yes)
              AC_DEFINE(GREEK_SUPPORT)
            else
              AC_MSG_RESULT(no)
            fi, AC_MSG_RESULT(no)
)

CONFIG_BUFF_SIZE=20480
AC_MSG_CHECKING(for the buffer size of the config file parser)
AC_ARG_WITH(config-buffer-size,
[  --with-config-buffer-size
                         specifies the size of the buffer Eterm uses for parsing the config file (default is 20 Kb)],
            if test "$withval" != "yes" -a "$withval" != "no"; then
              CONFIG_BUFF_SIZE=$withval
            fi)
AC_MSG_RESULT($CONFIG_BUFF_SIZE bytes)
AC_DEFINE_UNQUOTED(CONFIG_BUFF, $CONFIG_BUFF_SIZE)

AC_ARG_WITH(terminfo,
[  --without-terminfo      do not compile the Eterm terminfo file],
            if test "$withval" = "no"; then 
              TIC=true
            fi)

AC_ARG_WITH(theme-update,
[  --with-theme-update     existing themes will be forceably removed and new ones installed],
            if test "$withval" = "yes"; then 
              REMOVE_THEMES=yes
            else
              REMOVE_THEMES=no
            fi, REMOVE_THEMES=no
)
AC_SUBST(REMOVE_THEMES)

dnl# AC_MSG_CHECKING(which threads library to use)
dnl# AC_ARG_WITH(threads,
dnl# [  --with-threads[=STYLE]  compile with threads support, STYLE is either "posix" or blank
dnl#                           (disabled by default)],
dnl#             case $withval in
dnl#               [yes | posix )]
dnl#                 AC_MSG_RESULT(POSIX)
dnl#                 THREADS_LIB=posix
dnl#                 ;;
dnl#               [* )]
dnl#                 AC_MSG_RESULT(none)
dnl#                 ;;
dnl#             esac
dnl#  , AC_MSG_RESULT(none))
dnl# if test "$THREADS_LIB" = "posix"; then
dnl#   AC_CHECK_LIB(pthread, pthread_create, CPPFLAGS="$CPPFLAGS -D_REENTRANT" ; THREADLIBS="-lpthread"
dnl#                                        AC_DEFINE(USE_POSIX_THREADS)
dnl#                                        AC_DEFINE(MUTEX_SYNCH)
dnl#                , , -D_REENTRANT -L/usr/lib -L/lib -L/usr/local/lib)
dnl# fi

AC_PREFIX(Eterm)
AC_PREFIX(gcc)
if test "$prefix" = "NONE"; then
  prefix=$ac_default_prefix
fi
if test "$exec_prefix" = "NONE"; then
  exec_prefix=$prefix
fi

dnl Stack Tracing toys
AC_ARG_ENABLE(stack-trace, [  --disable-stack-trace   disable stack trace on abnormal termination],
  if test "$enableval" = "no"; then
    AC_DEFINE(NO_STACK_TRACE)
    NO_STACK_TRACE=1
  fi
)

if test "$NO_STACK_TRACE" != "1"; then
  AC_PATH_PROG(DBX, dbx, no)
  if test "$DBX" != "no"; then
    AC_DEFINE_UNQUOTED(DBX, "$DBX")
  fi
  AC_PATH_PROG(GDB, gdb, no)
  if test "$GDB" != "no"; then
    AC_DEFINE_UNQUOTED(GDB, "$GDB")
  fi
  AC_PATH_PROG(PSTACK, pstack, no, $PATH:/usr/proc/bin:/usr/sbin)
  if test "$PSTACK" != "no"; then
    AC_DEFINE_UNQUOTED(PSTACK, "$PSTACK")
  fi
  AC_CHECK_LIB(cl, U_STACK_TRACE, LIBS="$LIBS -lcl")
fi

AC_MSG_CHECKING(for Linux 2.1 or higher)
OS_NAME=`uname -s`
if test "$OS_NAME" = "Linux"; then
  OS_REV=`uname -r`
  OS_MAJOR=`echo $OS_REV | cut -d. -f1`
  OS_MINOR=`echo $OS_REV | cut -d. -f2`
  if test "$OS_MAJOR" -ge "2" -a "$OS_MINOR" -ge "1"; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(NEED_LINUX_HACK)
  else
    AC_MSG_RESULT(no)
  fi
else
  AC_MSG_RESULT(no)
fi

dnl# Enable/disable humor
AC_ARG_WITH(sense-of-humor, [  --without-sense-of-humor   Specify this if you have no sense of humor],
            if test "$withval" = "no"; then
              HUMOR=none
            fi)

if test -z "$HUMOR"; then
AC_CHECK_LIB(Kenny, life_signs, , [
  echo "  Oh my god, they killed Kenny!  You bastards!"
])
fi

CONFIG_SEARCH_PATH=`eval eval eval eval eval echo "${datadir}/$PACKAGE/themes:${datadir}/$PACKAGE"`
AC_DEFINE_UNQUOTED(CONFIG_SEARCH_PATH, "~/.Eterm/themes:~/.Eterm:$CONFIG_SEARCH_PATH")
# Do replacements on theme files and such.  All variables to be replaced
# by this routine MUST be exported before the awk script runs.
if test "X$PKGDATADIR" = "X" ; then
  PKGDATADIR=`eval eval eval eval echo "$datadir/$PACKAGE"`
fi
export PKGDATADIR
AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR")
if test "$GDB" != "no"; then
  GDB_CMD_FILE="$PKGDATADIR/gdb.scr"
  AC_DEFINE_UNQUOTED(GDB_CMD_FILE, "$GDB_CMD_FILE")
else
  GDB_CMD_FILE=""
fi
AC_SUBST(GDB_CMD_FILE)

CPPFLAGS=`eval eval eval eval eval echo "-I$includedir -I$prefix/include $CPPFLAGS"`
CPPFLAGS=`echo $CPPFLAGS | tr ' ' '\n' | uniq | grep -v NONE | tr '\n' ' '`
CFLAGS=${CFLAGS--O}
LDFLAGS=`eval eval eval eval eval echo "-L$libdir -L$prefix/lib ${LDFLAGS--O}"`
LDFLAGS=`echo $LDFLAGS | tr ' ' '\n' | uniq | grep -v NONE | tr '\n' ' '`
LIBS="$GRLIBS $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"

AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(THREADLIBS)

basedir=.

AM_CONFIG_HEADER(config.h)

AC_OUTPUT(Makefile bg/Makefile doc/Makefile utils/Makefile
          pix/Makefile src/Makefile themes/Makefile Eterm.spec)

# Mega evals to make sure all the relative variables get resolved.
BINDIR=`eval eval eval eval echo ${bindir}`
export BINDIR bindir prefix exec_prefix datadir PACKAGE

# The awk-fu below replaces @VAR@ in theme config files with the corresponding
# environment variables, kinda like AC_OUTPUT above.
changequote(%&, &%)dnl
%&
for i in utils/kEsetroot themes/Eterm/theme.cfg themes/auto/theme.cfg themes/cEterm/theme.cfg \
         themes/chooser/theme.cfg themes/emacs/theme.cfg themes/irc/theme.cfg themes/mutt/theme.cfg \
         themes/trans/theme.cfg ; do
  echo creating $i
  $AWK '{if (match($0,/@[A-Za-z0-9_]*@/)) {
           i=ENVIRON[substr($0,RSTART+1,RLENGTH-2)];
           outp=$0;
           gsub(/@[A-Za-z0-9_]*@/,i,outp);
           print outp;
         } else {
           print $0;
         }
        }' $srcdir/$i.in > $srcdir/$i
done
&%
changequote([, ])dnl

dnl If we're not building with Imlib support, don't build Esetroot
if test -z "$GRLIBS"; then
  sed -e 's/^bin_PROGRAMS.*$//g' $srcdir/doc/Makefile > $srcdir/doc/Makefile.new
  mv $srcdir/doc/Makefile.new $srcdir/doc/Makefile
fi

echo "
$PACKAGE $VERSION
Configuration:
--------------

  Source code location:       $srcdir
  Host System Type:           $host
  Preprocessor:               $CC $CPPFLAGS
  Compiler:	              $CC $CFLAGS
  Linker:                     $CC $LDFLAGS $LIBS
  Install path:		      $prefix

  See src/feature.h for further configuration information.

  Now type 'make' to build $PACKAGE $VERSION.
"