rxvtc needs only the c++ lib.
[dana/urxvt.git] / configure.ac
1 dnl#
2 dnl# Process this file with autoconf to produce a configure script.
3 dnl#
4
5 AC_INIT
6 AC_PREREQ(2.50)
7 AC_CONFIG_SRCDIR([src/feature.h])
8 AC_CONFIG_HEADER(config.h:config.h.in)
9
10 AC_CANONICAL_HOST
11
12 dnl RXVT version
13 changequote(, )dnl
14 VERSION=`sed -n -e 's/^.*[ \t]VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
15 DATE=`sed -n -e 's/^.*[ \t]DATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
16 dnl LIBVERSION=`sed -n -e 's/^.*[ \t]LIBVERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h`
17 changequote([, ])dnl
18 AC_SUBST(VERSION)dnl
19 AC_SUBST(DATE)dnl
20 AC_SUBST(LSMDATE)dnl
21 AC_SUBST(LIBVERSION)dnl
22 echo ""
23 echo "configuring for rxvt $VERSION"
24 echo ""
25
26 orig_CXXFLAGS="$CXXFLAGS"
27
28 dnl# Checks for programs.
29 dnl AC_MAKE_SET
30
31 AC_PROG_CC
32 AC_PROG_CXX
33 AC_PROG_CPP
34 AC_PROG_INSTALL
35
36 AC_AIX
37 AC_ISC_POSIX
38 AC_LANG(C++)
39
40 dnl check wether we can link with gcc -lsupc++
41 if test x$GCC = xyes && test x$GXX = xyes; then
42    dnl FreeBSD (at least up to 5.3) has a broken GCC, workaround it
43    AC_MSG_CHECKING([for working libsupc++])
44    save_CXX="$CXX"
45    save_LIBS="$LIBS"
46    CXX="$CC"
47    LIBS="$LIBS -lsupc++"
48    LINKER="$CC"
49    AC_LINK_IFELSE(
50       [AC_LANG_PROGRAM([struct test { }; void f() try { throw new test; } catch (...) { throw; }],[])],
51       [
52          AC_MSG_RESULT(ok)
53          CXXLIB="-lsupc++"
54       ],
55       [
56          AC_MSG_RESULT([no, making everything bigger and slower])
57          LIBS="$save_LIBS"
58          LINKER="$save_CXX"
59       ]
60    )
61    CXX="$save_CXX"
62 fi
63 AC_SUBST(LINKER,[$LINKER])
64 AC_SUBST(CXXLIB)
65
66 dnl# --------------------------------------------------------------------------
67 dnl# Supply default CXXFLAGS, if not specified by `CXXFLAGS=flags ./configure'
68 dnl#
69 if test -z "$orig_CXXFLAGS"; then
70   if test x$GCC = xyes && test "x$GXX" = xyes; then
71      CXXFLAGS="-g -O3 -fno-threadsafe-statics -fno-enforce-eh-specs"
72     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [], [CXXFLAGS="-g -O3"])
73   else
74     CXXFLAGS="-O"
75   fi
76   CFLAGS="$CXXFLAGS"
77 fi
78
79 AC_DEFINE(_GNU_SOURCE, 1, Use all glibc features.)
80
81 case $host in
82    *-*-solaris* )
83       AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Needed to get declarations for msg_control and msg_controllen on Solaris)
84       AC_DEFINE(_XOPEN_SOURCE,          2, Needed to get declarations for msg_control and msg_controllen on Solaris)
85       AC_DEFINE(__EXTENSIONS__,         1, Needed to get declarations for msg_control and msg_controllen on Solaris)
86       ;;
87 esac
88
89 dnl if test x$GXX = xyes; then
90 dnl    CXXFLAGS="$CXXFLAGS" dnl I once had -fno-exceptions, but I am using them now...
91 dnl fi
92
93 dnl# FreeBSD needs to link libxpg4
94 AC_CHECK_FUNC(setlocale,     [], [AC_CHECK_LIB(xpg4,   setlocale,     [LIBS="$LIBS -lxpg4"])])
95
96 dnl# solaris needs to link libnsl and socket
97 AC_CHECK_FUNC(gethostbyname, [], [AC_CHECK_LIB(nsl,    gethostbyname, [LIBS="$LIBS -lnsl"])])
98 AC_CHECK_FUNC(socket,        [], [AC_CHECK_LIB(socket, socket,        [LIBS="$LIBS -lsocket"])])
99
100 dnl AC_ENABLE_SHARED(no)dnl#    libtool
101 dnl AC_ENABLE_STATIC(yes)dnl#   libtool
102 dnl AC_PROG_LIBTOOL()dnl#               libtool
103
104 support_frills=yes
105 support_inheritpixmap=yes
106 support_tinting=yes
107 support_fading=yes
108 support_keepscrolling=yes
109 support_selectionscrolling=yes
110 support_mousewheel=yes
111 support_mouseslipwheel=yes
112 support_text_blink=yes
113 support_pointer_blank=yes
114 support_scroll_rxvt=yes
115 support_scroll_next=yes
116 support_scroll_xterm=yes
117 support_scroll_plain=yes
118 support_xim=yes
119 support_xpm=yes
120 support_afterimage=yes
121 support_afterstep=yes
122 support_xft=yes
123 support_unicode3=no
124 support_combining=yes
125 support_8bitctrls=no
126 support_iso14755=yes
127 support_styles=yes
128 support_perl=yes
129 codesets=all
130
131 dnl# --------------------------------------------------------------------------
132 dnl# CHECKING COMMAND LINE OPTIONS
133 dnl# --------------------------------------------------------------------------
134
135 if test "x$enable_shared" = xyes; then
136     AC_DEFINE(LIBRXVT, 1, Build shared library version - specify via configure only)
137     INSTALL_LIBRXVT=yes
138 fi
139 AC_SUBST(INSTALL_LIBRXVT)
140
141 AC_ARG_ENABLE(everything,
142   [  --enable-everything     enable standard non-multichoice features
143                      NOTE: this option is order dependent
144                      NOTE: automatically enabled with --enable-shared],
145   [
146     if test x$enableval = xno; then
147        support_frills=no
148        support_inheritpixmap=no
149        support_tinting=no
150        support_fading=no
151        support_keepscrolling=no
152        support_selectionscrolling=no
153        support_lastlog=no
154        support_mousewheel=no
155        support_mouseslipwheel=no
156        support_text_blink=no
157        support_pointer_blank=no
158        support_scroll_rxvt=no
159        support_scroll_next=no
160        support_scroll_xterm=no
161        support_scroll_plain=no
162        support_utmp=no
163        support_wtmp=no
164        support_xim=no
165        support_xpm=no
166        support_afterimage=no
167        support_afterstep=no
168        support_xft=no
169        support_unicode3=no
170        support_combining=no
171        support_8bitctrls=no
172        support_iso14755=no
173        support_styles=no
174        support_perl=no
175        codesets=
176     fi
177     if test x$enableval = xyes; then
178        support_frills=yes
179        support_inheritpixmap=yes
180        support_tinting=yes
181        support_fading=yes
182        support_keepscrolling=yes
183        support_selectionscrolling=yes
184        support_lastlog=yes
185        support_mousewheel=yes
186        support_mouseslipwheel=yes
187        support_text_blink=yes
188        support_pointer_blank=yes
189        support_scroll_rxvt=yes
190        support_scroll_next=yes
191        support_scroll_xterm=yes
192        support_scroll_plain=yes
193        support_utmp=yes
194        support_wtmp=yes
195        support_xim=yes
196        support_xpm=yes
197        support_afterimage=yes
198        support_afterstep=yes
199        support_xft=yes
200        support_unicode3=yes
201        support_combining=yes
202        #support_8bitctrls=yes
203        support_iso14755=yes
204        support_styles=yes
205        support_perl=yes
206        codesets=all
207     fi
208   ])
209
210 AC_ARG_ENABLE(unicode3,
211   [  --enable-unicode3       use 21 instead of 16 bits to represent unicode characters],
212   [if test x$enableval = xyes -o x$enableval = xno; then
213     support_unicode3=$enableval
214   fi])
215
216 AC_ARG_ENABLE(combining,
217   [  --enable-combining      enable composition of base and combining characters],
218   [if test x$enableval = xyes -o x$enableval = xno; then
219     support_combining=$enableval
220   fi])
221
222 AC_ARG_ENABLE(xft,
223   [  --enable-xft            enable xft support on systems that have it],
224   [if test x$enableval = xyes -o x$enableval = xno; then
225     support_xft=$enableval
226   fi])
227
228 AC_ARG_ENABLE(font-styles,
229   [  --enable-font-styles    enable bold and italic support],
230   [if test x$enableval = xyes -o x$enableval = xno; then
231     support_styles=$enableval
232   fi])
233
234 AC_ARG_ENABLE(xpm-background,
235   [  --enable-xpm-background enable background pixmaps],
236   [if test x$enableval = xyes -o x$enableval = xno; then
237     support_xpm=$enableval
238   fi])
239
240 AC_ARG_ENABLE(afterimage,
241   [  --enable-afterimage enable integration with libAfterImage for background images],
242   [if test x$enableval = xyes -o x$enableval = xno; then
243     support_afterimage=$enableval
244   fi])
245
246 AC_ARG_WITH(afterimage_config,
247   [  --with-afterimage-config=DIR  use libAfterImage config script in DIR],
248   [if test "x$withval" != x; then
249     afterimage_config=$withval/afterimage-config
250   fi])
251
252 AC_ARG_ENABLE(afterstep,
253   [  --enable-afterstep enable integration with AfterStep window manager],
254   [if test x$enableval = xyes -o x$enableval = xno; then
255     support_afterstep=$enableval
256   fi])
257
258 AC_ARG_ENABLE(transparency,
259   [  --enable-transparency   enable transparent backgrounds],
260   [if test x$enableval = xyes -o x$enableval = xno; then
261     support_inheritpixmap=$enableval
262   fi])
263
264 AC_ARG_ENABLE(tinting,
265   [  --enable-tinting        enable tinting of transparent bg],
266   [if test x$enableval = xyes -o x$enableval = xno; then
267     support_tinting=$enableval
268   fi])
269
270 AC_ARG_ENABLE(fading,
271   [  --enable-fading         enable colors fading when off focus],
272   [if test x$enableval = xyes -o x$enableval = xno; then
273     support_fading=$enableval
274   fi])
275
276 AC_ARG_ENABLE(rxvt-scroll,
277   [  --enable-rxvt-scroll    enable rxvt style scrollbar],
278   [if test x$enableval = xyes -o x$enableval = xno; then
279     support_scroll_rxvt=$enableval
280   fi])
281
282 AC_ARG_ENABLE(next-scroll,
283   [  --enable-next-scroll    enable NeXT style scrollbar],
284   [if test x$enableval = xyes -o x$enableval = xno; then
285     support_scroll_next=$enableval
286   fi])
287
288 AC_ARG_ENABLE(xterm-scroll,
289   [  --enable-xterm-scroll   enable Xterm style scrollbar],
290   [if test x$enableval = xyes -o x$enableval = xno; then
291     support_scroll_xterm=$enableval
292   fi])
293
294 AC_ARG_ENABLE(perl,
295   [  --enable-perl           enable embedded perl interpreter],
296   [if test x$enableval = xyes -o x$enableval = xno; then
297     support_perl=$enableval
298   fi])
299
300 AC_ARG_ENABLE(plain-scroll,
301   [  --enable-plain-scroll   enable plain style scrollbar],
302   [if test x$enableval = xyes -o x$enableval = xno; then
303     support_scroll_plain=$enableval
304   fi])
305
306 AC_ARG_WITH(codesets,
307   [  --with-codesets=NAME,.. compile in additional codesets (jp,jp_ext,kr,zh,zh_ext,all)],
308   [codesets="$withval"])
309
310 AC_ARG_ENABLE(xim,
311   [  --enable-xim            XIM (X Input Method) protocol support],
312   [if test x$enableval = xyes -o x$enableval = xno; then
313     support_xim=$enableval
314   fi])
315
316 AC_ARG_ENABLE(backspace-key,
317   [  --disable-backspace-key disable handling of the backspace key],
318   [if test x$enableval = xno; then
319     AC_DEFINE(NO_BACKSPACE_KEY, 1, Define if you don't want support for the backspace key)
320   fi])
321
322 AC_ARG_ENABLE(delete-key,
323   [  --disable-delete-key    disable handling of the delete key],
324   [if test x$enableval = xno; then
325     AC_DEFINE(NO_DELETE_KEY, 1, Define if you don't want support for the (non-keypad) delete key)
326   fi])
327
328 AC_ARG_ENABLE(resources,
329   [  --disable-resources     disable all resource checking],
330   [if test x$enableval = xno; then
331     AC_DEFINE(NO_RESOURCES, 1, Define if you don't want any resources read)
332   fi])
333
334 AC_ARG_ENABLE(8bitctrls,
335   [  --enable-8bitctrls      enable 8 bit control sequences (not recommended)],
336   [if test x$enableval = xyes -o x$enableval = xno; then
337     support_8bitctrls=$enableval
338   fi])
339
340 RESFALLBACK=Rxvt
341 AC_ARG_ENABLE(fallback,
342   [  --enable-fallback(=CLASS) fall back on CLASS resources in addition to URxvt ones (default: Rxvt)],
343   [
344    test x$enableval = xyes && enableval=Rxvt
345    test x$enableval = xno  && enableval=
346    RESFALLBACK="$enableval"
347   ])
348
349 if test x$RESFALLBACK != x; then
350    AC_DEFINE_UNQUOTED(RESFALLBACK, "$RESFALLBACK", [Fallback resource class])
351 fi
352
353 RESNAME=urxvt
354 AC_ARG_WITH(res-name,
355   [  --with-res-name=NAME    use this as default resource name (default: urxvt)],
356   [RESNAME="$withval"])
357 AC_DEFINE_UNQUOTED(RESNAME,"$RESNAME", [Default resource name])
358
359 RESCLASS=URxvt
360 AC_ARG_WITH(res-class,
361   [  --with-res-class=CLASS  use this as the resource class (default: URxvt)],
362   [RESCLASS="$withval"])
363 AC_DEFINE_UNQUOTED(RESCLASS,"$RESCLASS", [Resource class])
364
365 RXVTNAME=urxvt
366 AC_ARG_WITH(name,
367   [  --with-name=NAME        set the basename for the installed binaries (default: urxvt)],
368   [RXVTNAME="$withval"])
369 AC_DEFINE_UNQUOTED(RXVTNAME,"$RXVTNAME", [Binary base name])
370
371 RXVTNAME=`echo "$RXVTNAME"|sed "$program_transform_name"`
372 AC_SUBST(RXVTNAME)
373
374 AC_ARG_ENABLE(swapscreen,
375   [  --disable-swapscreen    disable swap screen support],
376   [if test x$enableval = xno; then
377     AC_DEFINE(NO_SECONDARY_SCREEN, 1, Disable the secondary screen. Many programs use the secondary screen as their workplace)
378   fi])
379
380 AC_ARG_ENABLE(iso14755,
381   [  --enable-iso14755       enable support for extended ISO 14755 modes],
382   [if test x$enableval = xyes -o x$enableval = xno; then
383     support_iso14755=$enableval
384   fi])
385
386 AC_ARG_ENABLE(frills,
387   [  --enable-frills         enable support for rarely used features],
388   [if test x$enableval = xyes -o x$enableval = xno; then
389     support_frills=$enableval
390   fi])
391
392 AC_ARG_ENABLE(keepscrolling,
393   [  --enable-keepscrolling  enable continual scrolling on scrollbar arrow press],
394   [if test x$enableval = xyes -o x$enableval = xno; then
395     support_keepscrolling=$enableval
396   fi])
397
398 AC_ARG_ENABLE(selectionscrolling,
399   [  --enable-selectionscrolling  enable scrolling during selections],
400   [if test x$enableval = xyes -o x$enableval = xno; then
401     support_selectionscrolling=$enableval
402   fi])
403
404 AC_ARG_ENABLE(mousewheel,
405   [  --enable-mousewheel     enable scrolling via mouse wheel or buttons 4 & 5],
406   [if test x$enableval = xyes -o x$enableval = xno; then
407     support_mousewheel=$enableval
408   fi])
409
410 AC_ARG_ENABLE(slipwheeling,
411   [  --enable-slipwheeling   enable slip wheel scrolling     (requires previous)],
412   [if test x$enableval = xyes -o x$enableval = xno; then
413     support_mouseslipwheel=$enableval
414   fi])
415
416 AC_ARG_ENABLE(smart-resize,
417   [  --enable-smart-resize   enable smart growth/shrink behaviour],
418   [if test x$enableval = xyes; then
419     AC_DEFINE(SMART_RESIZE, 1, Define to use "smart" resize behavior)
420   fi])
421
422 AC_ARG_ENABLE(text-blink,
423   [  --enable-text-blink     enable blinking text],
424   [if test x$enableval = xyes -o x$enableval = xno; then
425     support_text_blink=$enableval
426   fi])
427
428 AC_ARG_ENABLE(pointer-blank,
429   [  --enable-pointer-blank  enable pointer blank when typing or inactive pointer],
430   [if test x$enableval = xyes -o x$enableval = xno; then
431     support_pointer_blank=$enableval
432   fi])
433
434 AC_ARG_WITH(term,
435   [  --with-term=NAME        set the terminal to NAME (default: rxvt)],
436   [if test x$withval != x; then
437     AC_DEFINE_UNQUOTED(TERMENV, "$withval",Set TERM to the value given by configure) term="$withval"
438   fi])
439
440 AC_ARG_WITH(terminfo,
441   [  --with-terminfo=PATH    set the path to the terminfo tree to PATH],
442   [if test x$withval != x; then
443     AC_DEFINE_UNQUOTED(RXVT_TERMINFO, "$withval", Set TERMINFO value to the value given by configure) terminfo="$withval"
444   fi])
445
446 dnl# --------------------------------------------------------------------------
447
448 AC_PATH_PROG(CP, cp, cp)
449 AC_PATH_PROG(SED, sed, sed)
450 AC_PATH_PROG(ECHO, echo, echo)
451 AC_PATH_PROG(TIC, tic)
452
453 dnl# need a neat way to detect SVR4 or its features
454 dnl# in src/command.c we use these functions:
455 dnl# grantpt(), unlockpt(), ptsname(), which are defined in <sys/ptms.h>
456 dnl# - but are these also defined for other systems?
457
458 dnl# hack to find if this is SVR4 -- who knows?
459 dnl## AC_MSG_CHECKING(for SVR4)
460 dnl## AC_EGREP_CPP(yes,
461 dnl## [#if defined (SVR4) || defined (_SVR4) || defined (__svr4__)
462 dnl##   yes;
463 dnl## #endif
464 dnl## ], [AC_MSG_RESULT(yes); AC_DEFINE(PERHAPS_SVR4)], AC_MSG_RESULT(perhaps not?))
465
466 AC_PATH_XTRA
467
468 dnl# the only reasonable way to find libXpm is do-it-yourself
469 dnl# only check if we want xpm-background
470
471 LIBAFTERIMAGE_CFLAGS=
472 AFTERIMAGE_LIBS=
473 have_afterimage=
474
475 if test x$support_afterimage = xyes; then
476   support_afterimage=no
477
478   if test "x$afterimage_config" = "x" ; then
479     AC_PATH_PROG(afterimage_config, afterimage-config, no)
480   fi
481
482   AC_MSG_CHECKING(for libAfterImage)
483   if $afterimage_config --version >/dev/null 2>&1 ; then
484     LIBAFTERIMAGE_CFLAGS=`$afterimage_config --cflags`
485     AFTERIMAGE_LIBS=`$afterimage_config --libs`
486     if test "x$AFTERIMAGE_LIBS" != "x"; then
487       support_afterimage=yes
488     fi
489   fi
490
491   if test "x$support_afterimage" = "xyes"; then
492     AC_MSG_RESULT($AFTERIMAGE_LIBS)
493   else
494     AC_MSG_RESULT(no)
495   fi
496 fi
497
498 if test x$support_afterimage != xyes -a x$support_xpm = xyes ; then
499   VT_FIND_LIBXPM
500   if test x$no_xpm = xyes; then
501     support_xpm=needsmanualspecification
502   fi
503 fi
504
505 dnl# --------------------------------------------------------------------------
506 dnl# CHECKING FOR HEADER FILES
507 dnl# --------------------------------------------------------------------------
508 AC_HEADER_SYS_WAIT
509 AC_CHECK_HEADERS( \
510         assert.h \
511         fcntl.h \
512         stdarg.h \
513         stdlib.h \
514         string.h \
515         termios.h \
516         unistd.h \
517         sys/byteorder.h \
518         sys/ioctl.h \
519         sys/select.h \
520         sys/sockio.h \
521         sys/strredir.h \
522         sys/time.h \
523         stdint.h \
524         wchar.h \
525         cwchar \
526         clocale \
527 )
528
529 AC_HEADER_TIME
530
531 dnl# check to allow both <termios.h> and <sys/ioctl.h>
532 AC_CACHE_CHECK(whether termios.h and sys/ioctl.h may both be included, rxvt_cv_header_sysioctl,
533 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
534 #include <sys/ioctl.h>
535 #ifdef HAVE_TERMIOS_H
536 #include <termios.h>
537 #endif]], [[int a = ECHO;]])],[rxvt_cv_header_sysioctl=yes],[rxvt_cv_header_sysioctl=no])])
538
539 dnl# ELF systems may want to store paths for dynamic libraries.
540 dnl# Lets see if the compiler can accept "-Rpath" or "-Wl,-Rpath"
541 dnl# At least one version of SunOS wants "-R path" but it's not checked yet.
542 if test -n "$GCC"; then
543   LDARG="-Wl,"
544 else
545   LDARG=""
546 fi
547 changequote(, )dnl
548 R_TRANSLATE='s/-L\([^ ]*\)/-L\1 '$LDARG'-rpath '$LDARG'\1/g'
549 changequote([, ])dnl
550
551 ac_save_CFLAGS=$CFLAGS
552 ac_save_LIBS=$LIBS
553 CFLAGS="$CFLAGS $X_CFLAGS"
554 LIBS=`echo "$LIBS $X_LIBS $X_EXTRA_LIBS -lX11" | sed "$R_TRANSLATE"`
555 AC_CACHE_CHECK([for -rpath dynamic library path recording], rxvt_cv_rpath,
556 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>
557 #include <stdlib.h>
558 main()
559 {
560     exit(0);
561     (void) XOpenDisplay("foobar");
562 }]])],[rxvt_cv_rpath=yes],[rxvt_cv_rpath=no],[dnl
563   AC_MSG_WARN(You may need to check the LIBS line)])])
564 if test x$rxvt_cv_rpath != xyes; then
565   changequote(, )dnl
566   R_TRANSLATE='s/-L\([^ ]*\)/-L\1 '$LDARG'-R\1/g'
567   changequote([, ])dnl
568   LIBS=`echo "$ac_save_LIBS $X_LIBS $X_EXTRA_LIBS -lX11" | sed "$R_TRANSLATE"`
569   AC_CACHE_CHECK([for -R dynamic library path recording], rxvt_cv_R,
570 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>
571 #include <stdlib.h>
572 main()
573 {
574     exit(0);
575     (void) XOpenDisplay("foobar");
576 }]])],[rxvt_cv_R=yes],[rxvt_cv_R=no],[rxvt_cv_R=no])])
577   if test x$rxvt_cv_R != xyes; then
578     LIBS="$ac_save_LIBS $X_LIBS $X_EXTRA_LIBS -lX11"
579   fi
580 fi
581
582 AC_CACHE_CHECK([for XPointer], rxvt_cv_xpointer,
583 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XPointer dummy;]])],[rxvt_cv_xpointer=yes],[rxvt_cv_xpointer=no])])
584 if test x$rxvt_cv_xpointer = xyes; then
585   AC_DEFINE(HAVE_XPOINTER, 1, Define if you have XPointer typedef)
586 fi
587 LIBS=$ac_save_LIBS
588 CFLAGS=$ac_save_CFLAGS
589
590 AC_CACHE_CHECK([for XLIB_ILLEGAL_ACCESS], rxvt_xlib_illegal_access,
591 [AC_COMPILE_IFELSE(
592    [AC_LANG_PROGRAM([
593 #define XLIB_ILLEGAL_ACCESS
594 #include <X11/Xlib.h>
595    ],[
596       Display *dpy;
597       dpy->xdefaults = (char *)0;
598    ])],
599    [rxvt_xlib_illegal_access=yes],[rxvt_xlib_illegal_access=no]
600 )])
601 if test x$rxvt_xlib_illegal_access = xyes; then
602    AC_DEFINE(XLIB_ILLEGAL_ACCESS, 1, Define ONLY iff Xlib.h supports it)
603 fi
604
605 AC_C_CONST
606 AC_C_INLINE
607
608 dnl> AC_HEADER_STDC      dnl# skip this test, Sun always fails anyhow.
609
610 dnl# --------------------------------------------------------------------------
611 dnl# CHECKING FOR MISSING TYPEDEFS
612 dnl# --------------------------------------------------------------------------
613 dnl# Missing typedefs and replacements
614 AC_TYPE_MODE_T
615 dnl> AC_CHECK_TYPE(umode_t, int)
616 dnl> AC_CHECK_TYPE(off_t, long)
617 AC_TYPE_PID_T
618 AC_TYPE_UID_T
619
620 AC_CHECK_SIZEOF(short, 2)
621 AC_CHECK_SIZEOF(int, 4)
622 dnl AC_CHECK_SIZEOF(long, 4)
623 AC_CHECK_SIZEOF(long long, 8)
624 AC_CHECK_SIZEOF(int *, 4)
625
626 dnl# see usage below
627 AC_DEFUN([RXVT_CHECK_SIZE],
628   [AC_CACHE_CHECK([for $2], $1,
629     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>]], [[$2 dummy;]])],[$1=yes],[dnl
630 if test "$ac_cv_sizeof_char" -ge $3; then
631   $1="$4 char"
632 else
633   if test "$ac_cv_sizeof_short" -ge $3; then
634     $1="$4 short"
635   else
636     if test "$ac_cv_sizeof_int" -ge $3; then
637       $1="$4 int"
638     else
639       if test "$ac_cv_sizeof_long" -ge $3; then
640         $1="$4 long"
641       else
642         if test "$ac_cv_sizeof_long_long" -ge $3; then
643           $1="$4 long long"
644         else
645           $1="$4 $5" # we _must_ have a (possibly wrong) default
646         fi
647       fi
648     fi
649   fi
650 fi])])]
651 if test x"$$1" != xyes; then
652   $6="typedef $$1 $2;"
653 else
654   if test x"$4" = x; then
655     $6="/* typedef $5 $2; */"
656   else
657     $6="/* typedef $4 $5 $2; */"
658   fi
659 fi dnl
660 )
661 dnl#
662 dnl# Look for types the system may know about anyway.
663 dnl#
664 RXVT_CHECK_SIZE(rxvt_cv_int16_t, int16_t, 2, , short, rxvt_int16_typedef)
665 AC_SUBST(rxvt_int16_typedef)
666 RXVT_CHECK_SIZE(rxvt_cv_uint16_t, uint16_t, 2, unsigned, short, rxvt_uint16_typedef)
667 AC_SUBST(rxvt_uint16_typedef)
668 RXVT_CHECK_SIZE(rxvt_cv_int32_t, int32_t, 4, , int, rxvt_int32_typedef)
669 AC_SUBST(rxvt_int32_typedef)
670 RXVT_CHECK_SIZE(rxvt_cv_uint32_t, uint32_t, 4, unsigned, int, rxvt_uint32_typedef)
671 AC_SUBST(rxvt_uint32_typedef)
672 dnl RXVT_CHECK_SIZE(rxvt_cv_int64_t, int64_t, 8, , long long, rxvt_int64_typedef)
673 dnl AC_SUBST(rxvt_int64_typedef)
674 dnl RXVT_CHECK_SIZE(rxvt_cv_uint64_t, uint64_t, 8, unsigned, long long, rxvt_uint64_typedef)
675 dnl AC_SUBST(rxvt_uint64_typedef)
676 dnl#
677 dnl# Now look for another we use
678 dnl#
679 if test "$ac_cv_sizeof_int_p" -eq 8; then
680   rxvt_intp_define="#define intp_t int64_t"
681   rxvt_u_intp_define="#define u_intp_t u_int64_t"
682 else
683   if test "$ac_cv_sizeof_int_p" -eq 4; then
684     rxvt_intp_define="#define intp_t int32_t"
685     rxvt_u_intp_define="#define u_intp_t u_int32_t"
686   else
687     if test "$ac_cv_sizeof_int_p" -eq 2; then
688       rxvt_intp_define="#define intp_t int16_t"
689       rxvt_u_intp_define="#define u_intp_t u_int16_t"
690     else
691       rxvt_intp_define="#error set intp_t"
692       rxvt_u_intp_define="#error set u_intp_t"
693     fi
694   fi
695 fi
696 AC_SUBST(rxvt_intp_define)
697 AC_SUBST(rxvt_u_intp_define)
698
699 dnl# --------------------------------------------------------------------------
700 dnl# CHECKING FOR LIBRARY FUNCTIONS
701 dnl# --------------------------------------------------------------------------
702 AC_TYPE_SIGNAL
703 dnl> AC_FUNC_VPRINTF
704
705 AC_CHECK_FUNCS( \
706         unsetenv \
707         setutent \
708         on_exit \
709 )
710
711 UTMP_CHECK
712
713 dnl# --------------------------------------------------------------------------
714
715 dnl# find ttys/ttytab
716 AC_CACHE_CHECK(where ttys/ttytab is located, rxvt_cv_path_ttytab,
717 [for ttys_file in   dnl
718   /etc/ttys /etc/ttytab;
719 do
720   if test -f "$ttys_file" ; then
721     rxvt_cv_path_ttytab=$ttys_file
722     break
723   fi
724 done
725 ])
726 if test x$rxvt_cv_path_ttytab != x; then
727   AC_DEFINE_UNQUOTED(TTYTAB_FILENAME, "$rxvt_cv_path_ttytab", Define location of ttys/ttytab)
728 fi
729
730 dnl# --------------------------------------------------------------------------
731 dnl# --------------------------------------------------------------------------
732
733 dnl# this is a really hack test for some basic Xlocale stuff
734 ac_save_LIBS=$LIBS
735 ac_save_CFLAGS=$CFLAGS
736 CFLAGS="$CFLAGS $X_CFLAGS"
737 LIBS="$LIBS $X_LIBS $X_EXTRA_LIBS -lX11"
738 if test x$rxvt_cv_rpath = xyes -o x$rxvt_cv_R = xyes; then
739   LIBS=`echo $LIBS | sed "$R_TRANSLATE"`
740 fi
741 AC_CACHE_CHECK(for working Xlocale, rxvt_cv_func_xlocale,
742 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>
743 #include <stdlib.h>
744 main() {
745 char *p;
746 if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
747 exit (XSupportsLocale() ? 0 : 1);
748 else
749 exit (1);}]])],[dnl
750   rxvt_cv_func_xlocale=yes],[rxvt_cv_func_xlocale=no],[dnl
751   AC_MSG_WARN(Define NO_XLOCALE in config.h manually)])])
752 if test x$rxvt_cv_func_xlocale = xyes; then
753   AC_DEFINE(HAVE_XLOCALE, 1, Define if Xlocale support works)
754 fi
755
756 AC_CACHE_CHECK(for working X setlocale, rxvt_cv_func_xsetlocale,
757 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define X_LOCALE 1
758 #include <X11/Xlocale.h>]], [[setlocale(LC_CTYPE, "");]])],[rxvt_cv_func_xsetlocale=yes],[rxvt_cv_func_xsetlocale=no])])
759 if test x$rxvt_cv_func_xsetlocale = xyes; then
760   AC_DEFINE(HAVE_XSETLOCALE, 1, Define if setlocale (defined to Xsetlocale) works)
761 fi
762 LIBS=$ac_save_LIBS
763 CFLAGS=$ac_save_CFLAGS
764
765 AC_CACHE_CHECK(for working plain setlocale, rxvt_cv_func_setlocale,
766 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <clocale>]], [[setlocale(LC_CTYPE, "");]])],[rxvt_cv_func_setlocale=yes],[rxvt_cv_func_setlocale=no])])
767 if test x$rxvt_cv_func_setlocale = xyes; then
768   AC_DEFINE(HAVE_SETLOCALE, 1, Define if plain old setlocale works)
769 fi
770
771 AC_CACHE_CHECK(for working nl_langinfo, rxvt_cv_func_nl_langinfo,
772 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[nl_langinfo(CODESET);]])],[rxvt_cv_func_nl_langinfo=yes],[rxvt_cv_func_nl_langinfo=no])])
773 if test x$rxvt_cv_func_nl_langinfo = xyes; then
774   AC_DEFINE(HAVE_NL_LANGINFO, 1, Define if nl_langinfo(CODESET) works)
775 fi
776
777 SCM_RIGHTS_CHECK
778
779 AC_CACHE_CHECK(for broken XIM callback, rxvt_broken_ximcb,
780 [AC_COMPILE_IFELSE([
781 #include <X11/Xlib.h>
782
783 void im_destroy_cb (XIC unused1, XPointer client_data, XPointer unused3);
784
785 void f() {
786   XIMCallback cb;
787   cb.callback = im_destroy_cb;
788 }
789 ],rxvt_broken_ximcb=yes,rxvt_broken_ximcb=no)])
790
791 if test x$rxvt_broken_ximcb = xyes; then
792    AC_DEFINE(XIMCB_PROTO_BROKEN, 1, Define if your XIMCallback specifies XIC as first type.)
793 fi
794
795 PTY_CHECK
796
797 TTY_GROUP_CHECK
798
799 dnl# --------------------------------------------------------------------------
800 dnl# now add and remove other stuff
801 dnl# --------------------------------------------------------------------------
802 if test x$support_xft = xyes; then
803   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
804   if test $PKG_CONFIG != no && $PKG_CONFIG --exists xft; then
805     LIBS="$LIBS `$PKG_CONFIG xft --libs`"
806     CPPFLAGS="$CPPFLAGS `$PKG_CONFIG xft --cflags`"
807   else
808     AC_PATH_PROG(XFT_CONFIG, xft-config, no)
809     if test $XFT_CONFIG != no; then
810       LIBS="$LIBS `$XFT_CONFIG --libs`"
811       CPPFLAGS="$CPPFLAGS `$XFT_CONFIG --cflags`"
812     fi
813   fi
814
815   AC_CHECK_HEADERS(X11/Xft/Xft.h,,[support_xft=no])
816   AC_CHECK_LIB(Xft,XftDrawString32,,[support_xft=no])
817
818   if test x$support_xft = xyes; then
819     AC_DEFINE(XFT, 1, Define to enable xft support)
820   fi
821 fi
822 if test x$support_styles = xyes; then
823   AC_DEFINE(ENABLE_STYLES, 1, Define if you want bold and italic support)
824 fi
825 if test x$support_iso14755 = xyes; then
826   AC_DEFINE(ISO_14755, 1, Define if you want ISO 14755 extended support)
827 fi
828 if test x$support_8bitctrls = xyes; then
829   AC_DEFINE(EIGHT_BIT_CONTROLS, 1, Define if you want 8 bit control sequences)
830 fi
831 if test x$support_fading = xyes; then
832   AC_DEFINE(OFF_FOCUS_FADING, 1, Define if you want faded colors when focus is lost)
833 fi
834 if test x$support_tinting = xyes; then
835   AC_DEFINE(TINTING, 1, Define if you want your background to be tinted)
836 fi
837 if test x$support_inheritpixmap = xyes; then
838   AC_DEFINE(TRANSPARENT, 1, Define if you want your background to use the parent window background)
839 fi
840 if test x$support_keepscrolling = xno; then
841   AC_DEFINE(NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING, 1, Define for continual scrolling when you keep the scrollbar button pressed)
842 fi
843 if test x$support_selectionscrolling = xyes; then
844   AC_DEFINE(SELECTION_SCROLLING, 1, Define to allow scrolling when the selection moves to the top or bottom of the screen)
845 fi
846 if test x$support_frills = xyes; then
847   AC_DEFINE(ENABLE_FRILLS, 1, Define if you want handling for rarely used but handy features)
848 fi
849 if test x$support_mousewheel = xyes; then
850   AC_DEFINE(MOUSE_WHEEL, 1, Define to use wheel events (button4 and button5) to scroll)
851 fi
852 if test x$support_mouseslipwheel = xyes; then
853   AC_DEFINE(MOUSE_SLIP_WHEELING, 1, Define to have CTRL cause wheel events to accelerate scrolling. Release CTRL to halt scrolling)
854 fi
855 if test x$support_xim = xyes -o x$multichar_set = xyes; then
856   if test x$rxvt_cv_func_xlocale = xyes; then
857     AC_DEFINE(USE_XIM, 1, Define if you want to have XIM (X Input Method) protocol support - required for multibyte characters input)
858   fi
859 fi
860 if test x$support_xpm = xyes -o x$support_afterimage = xyes ; then
861   AC_DEFINE(XPM_BACKGROUND, 1, Define if you want to have sexy-looking background pixmaps. Needs libXpm or libAfterImage)
862 fi
863
864 if test x$support_afterimage = xyes; then
865   AC_DEFINE(HAVE_AFTERIMAGE, 1, Define if you want to use libAfterImage for image processing)
866 fi
867
868 if test x$support_afterstep = xyes; then
869   AC_DEFINE(AFTERSTEP_INTEGRATION, 1, Define if you want to integrate with AfterStep window manager)
870 fi
871
872 if test x$support_scroll_rxvt = xyes; then
873   AC_DEFINE(RXVT_SCROLLBAR, 1, Support Rxvt original style scrollbars)
874   scrolltypes="rxvt"
875 fi
876 if test x$support_scroll_next = xyes; then
877   AC_DEFINE(NEXT_SCROLLBAR, 1, Support NeXT style scrollbars)
878   scrolltypes="$scrolltypes next"
879 fi
880 if test x$support_scroll_xterm = xyes; then
881   AC_DEFINE(XTERM_SCROLLBAR, 1, Support Xterm style scrollbars)
882   scrolltypes="$scrolltypes xterm"
883 fi
884 if test x$support_scroll_plain = xyes; then
885   AC_DEFINE(PLAIN_SCROLLBAR, 1, Support plain style scrollbars)
886   scrolltypes="$scrolltypes plain"
887 fi
888 if test x$support_pointer_blank = xyes; then
889   AC_DEFINE(POINTER_BLANK, 1, Define if you want hide the pointer while typing)
890 fi
891 if test x$support_text_blink = xyes; then
892   AC_DEFINE(TEXT_BLINK, 1, Define if you want blinking text support)
893 fi
894 if test x$support_unicode3 = xyes; then
895   AC_DEFINE(UNICODE_3, 1, Define if you want to represent unicode characters outside plane 0)
896 fi
897 if test x$support_combining = xyes; then
898   AC_DEFINE(ENABLE_COMBINING, 1, Define if you want to automatically compose combining characters)
899 fi
900 if test x$codesets = xall; then
901   codesets=jp,jp-ext,kr,zh,zh-ext
902 fi
903 AC_DEFINE(ENCODING_EU, 1, Define if you want european extended codesets)
904 AC_DEFINE(ENCODING_VN, 1, Define if you want vietnamese codesets)
905 for codeset in `echo $codesets | tr "[a-z,\\-]" "[A-Z _]"`; do
906   case "$codeset" in
907     JP     ) AC_DEFINE(ENCODING_JP,     1, Define if you want japanese codesets) ;;
908     JP_EXT ) AC_DEFINE(ENCODING_JP_EXT, 1, Define if you want extended japanese codesets) ;;
909     KR     ) AC_DEFINE(ENCODING_KR,     1, Define if you want korean codesets) ;;
910     ZH     ) AC_DEFINE(ENCODING_ZH,     1, Define if you want chinese codesets) ;;
911     ZH_EXT ) AC_DEFINE(ENCODING_ZH_EXT, 1, Define if you want extended chinese codesets) ;;
912   esac
913 done
914
915 IF_PERL=\#
916 if test x$support_perl = xyes; then
917   AC_PATH_PROG(PERL, perl5)
918   AC_PATH_PROG(PERL, perl)
919
920   AC_MSG_CHECKING(for $PERL suitability)
921   if $PERL -MExtUtils::Embed -e "use v5.8" >/dev/null 2>/dev/null; then
922
923      save_CXXFLAGS="$CXXFLAGS"
924      save_LIBS="$LIBS"
925      CXXFLAGS="$CXXFLAGS `$PERL -MExtUtils::Embed -e ccopts`"
926      LIBS="$LIBS `$PERL -MExtUtils::Embed -e ldopts`"
927      AC_TRY_LINK([
928 #include <EXTERN.h>
929 #include <perl.h>
930 #include <XSUB.h>
931 ],[
932      PerlInterpreter *perl = perl_alloc ();
933 ],[rxvt_perl_link=yes],[rxvt_perl_link=no])
934      CXXFLAGS="$save_CXXFLAGS"
935      LIBS="$save_LIBS"
936
937      if test x$rxvt_perl_link = xyes; then
938         AC_MSG_RESULT(ok)
939         AC_DEFINE(ENABLE_PERL, 1, Define if you can embed a perl interpreter)
940         IF_PERL=
941         PERL_O=rxvtperl.o
942         PERLFLAGS="`$PERL -MExtUtils::Embed -e ccopts`"
943         PERLLIB="`$PERL -MExtUtils::Embed -e ldopts`"
944         PERLPRIVLIBEXP="`$PERL -MConfig -e 'print $Config{privlibexp}'`"
945      else
946         AC_MSG_ERROR([no, unable to link])
947      fi
948   else
949      AC_MSG_ERROR([no working perl found, or perl not version >= 5.8])
950   fi
951 fi
952 AC_SUBST(PERLLIB)
953 AC_SUBST(PERLFLAGS)
954 AC_SUBST(PERLPRIVLIBEXP)
955 AC_SUBST(PERL)
956 AC_SUBST(IF_PERL)
957 AC_SUBST(PERL_O)
958
959 if test x$support_perl = xyes; then
960    support_frills=yes
961 fi
962
963 AC_SUBST(CFLAGS)
964 AC_SUBST(CPPFLAGS)
965 AC_SUBST(LDFLAGS)
966 AC_SUBST(X_CFLAGS)
967
968 dnl# Attack the libs
969 if test x$rxvt_cv_rpath = xyes -o x$rxvt_cv_R = xyes; then
970   LIBS=`echo $LIBS | sed "$R_TRANSLATE"`
971   X_LIBS=`echo $X_LIBS | sed "$R_TRANSLATE"`
972   X_EXTRA_LIBS=`echo $X_EXTRA_LIBS | sed "$R_TRANSLATE"`
973   XPM_LIBS=`echo $XPM_LIBS | sed "$R_TRANSLATE"`
974 fi
975 AC_SUBST(LIBS)
976 AC_SUBST(X_LIBS)
977 AC_SUBST(X_EXTRA_LIBS)
978
979 AC_SUBST(LIBAFTERIMAGE_CFLAGS)
980 AC_SUBST(AFTERIMAGE_LIBS)
981
982 AC_ARG_PROGRAM
983
984 dnl# test for "sun" or "__sun__" before include sys_ioctl
985
986 dnl# revert HAVE_BLAH_H into a "#include <blah.h>"
987 AC_DEFUN([RXVT_DEFINE_TO_INCLUDE], dnl
988 [if test "$$3" = "$4" -o "$$5" = "$6"; then
989   $1="#include <$2>"
990 else
991   $1="/* #include <$2> */"
992 fi dnl
993 AC_SUBST($1)])
994
995 RXVT_DEFINE_TO_INCLUDE(include_stdint_h, stdint.h, ac_cv_header_stdint_h, yes, notset, dontmatch)
996 RXVT_DEFINE_TO_INCLUDE(include_stdarg_h, cstdarg, ac_cv_header_stdarg_h, yes, notset, dontmatch)
997 RXVT_DEFINE_TO_INCLUDE(include_stdlib_h, cstdlib, ac_cv_header_stdlib_h, yes, notset, dontmatch)
998 RXVT_DEFINE_TO_INCLUDE(include_unistd_h, unistd.h, ac_cv_header_unistd_h, yes, notset, dontmatch)
999 RXVT_DEFINE_TO_INCLUDE(include_string_h, cstring, ac_cv_header_string_h, yes, notset, dontmatch)
1000 RXVT_DEFINE_TO_INCLUDE(include_fcntl_h, fcntl.h, ac_cv_header_fcntl_h, yes, notset, dontmatch)
1001 RXVT_DEFINE_TO_INCLUDE(include_util_h, util.h, ac_cv_header_util_h, yes, notset, dontmatch)
1002 RXVT_DEFINE_TO_INCLUDE(include_assert_h, assert.h, ac_cv_header_assert_h, yes, notset, dontmatch)
1003 RXVT_DEFINE_TO_INCLUDE(include_sys_ioctl_h, sys/ioctl.h, rxvt_cv_header_sysioctl, yes, notset, dontmatch)
1004 RXVT_DEFINE_TO_INCLUDE(include_sys_select_h, sys/select.h, ac_cv_header_sys_select_h, yes, notset, dontmatch)
1005 RXVT_DEFINE_TO_INCLUDE(include_sys_strredir_h, sys/strredir.h, ac_cv_header_sys_strredir_h, yes, notset, dontmatch)
1006 RXVT_DEFINE_TO_INCLUDE(include_sys_time_h, sys/time.h, ac_cv_header_sys_time_h, yes, notset, dontmatch)
1007 RXVT_DEFINE_TO_INCLUDE(include_time_h, time.h, ac_cv_header_sys_time_h, no, ac_cv_header_time, yes)
1008
1009 AC_CONFIG_FILES([Makefile \
1010 doc/Makefile \
1011 src/Makefile \
1012 src/rxvtlib.h \
1013 ])
1014 AC_OUTPUT
1015
1016 echo "Configuration:
1017
1018   Rxvt version:               $VERSION : $DATE
1019   Source code location:       $srcdir
1020   Install path:               ${prefix}/bin
1021   Compiler:                   $CXX
1022   Compiler flags:             $CXXFLAGS
1023   Linker:                     $LINKER"
1024
1025 if test x$support_xpm = xyes; then
1026   echo "  Xpm library:                $XPM_LIBS"
1027 fi
1028
1029 if test x$support_afterimage = xyes; then
1030   echo "  AfterImage support:         yes"
1031 fi
1032
1033 if test x$support_afterstep = xyes; then
1034   echo "  AfterStep integration:      yes"
1035 fi
1036
1037 if test x$term != x; then
1038   echo "  set TERM to:                $term"
1039 fi
1040 if test x$terminfo != x; then
1041   echo "  set TERMINFO to:            $terminfo"
1042 fi
1043 echo "  default resource name:      $RESNAME"
1044 echo "  resource class:             $RESCLASS"
1045 if test x$RESFALLBACK != x; then
1046    echo "  resource class fallback:    $RESFALLBACK"
1047 fi
1048 echo
1049 echo "  embedded perl:              $support_perl"
1050 echo
1051 if test x$support_xpm = xneedsmanualspecification; then
1052   echo ".----------------------------------------------------------------."
1053   echo ". WARNING: --enable-xpm-background was specified however the     ."
1054   echo ".          XPM includes files and libraries could not be found.  ."
1055   echo ".          XPM backgrounds are now being DISABLED!  If you want  ."
1056   echo ".          to use them you should rerun   configure   with the   ."
1057   echo ".          appropriate --with-xpm-includes=/path/to/xpm/includes ."
1058   echo ".          and --with-xpm-library=/path/to/xpm/library lines.    ."
1059   echo ".----------------------------------------------------------------."
1060 fi
1061 if test x$support_xim = xyes -a x$rxvt_cv_func_xlocale = xno; then
1062   echo ".----------------------------------------------------------------."
1063   echo ". WARNING: --enable-xim was specified however the locale support ."
1064   echo ".          functions could not be found.                         ."
1065   echo ".          XIM is now being DISABLED!                            ."
1066   echo ".----------------------------------------------------------------."
1067 fi
1068
1069 echo "*** Optionally check src/feature.h for further, rarely used options ***"
1070 echo
1071