Deleted ecmascript code using SEE.
[elinks.git] / configure.in
blob9ec8d2159eafd41a1915d48749780527635abbe8
1 dnl Process this file with autoconf to produce a configure script.
3 dnl There are two types of comments in this file.
4 dnl Comments that refer to Autoconf macros begin with "dnl", and m4
5 dnl discards them.  Other comments begin with "#", and they get copied
6 dnl to the configure script, hopefully making it easier to read.
8 dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
9 dnl Autoconf 2.61 is installed in the computer that generates our nightly
10 dnl snapshots, so we need to be compatible with that.  (Also, some files
11 dnl in Autoconf 2.62 and 2.63 sources are not GPLv2 compatible.)
12 AC_PREREQ(2.61)
13 AC_INIT
14 AC_CONFIG_SRCDIR([src/main/main.c])
15 AC_CONFIG_AUX_DIR(config)
17 PACKAGE=elinks
18 VERSION=0.12pre5.GIT
19 AC_SUBST(PACKAGE)
20 AC_SUBST(VERSION)
21 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
22 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
23 AC_CONFIG_HEADERS(config.h)
25 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
26 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
27 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
29 MAKE=
31 for make in gnumake gmake make false; do
32         if test "x$MAKE" = x; then
33                 AC_PATH_PROGS(MAKE, "$make")
34         fi
35 done
37 builddir="`pwd`"
39 # Cleanup if we are configuring with a previous build in the tree
40 if test -e Makefile.config; then
41         AC_MSG_CHECKING([for previous build to clean])
42         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
43         AC_MSG_RESULT(done)
46 # ===================================================================
47 # Load feature configuration file and start logging features.
48 # ===================================================================
50 features="features.conf"
51 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
52 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
53 echo "Feature summary:" > features.log
55 # ===================================================================
56 # Checks for programs.
57 # ===================================================================
59 AC_PROG_CC
60 AC_PROG_AWK
61 AC_PATH_PROGS(AWK, "$AWK")
62 AC_PROG_RANLIB
63 AC_PROG_INSTALL
65 AC_PATH_PROGS(GIT, "git")
66 AC_PATH_PROGS(SPARSE, "sparse")
68 CONFIG_ASCIIDOC="no"
69 CONFIG_POD2HTML="no"
70 CONFIG_XMLTO="no"
71 CONFIG_JW="no"
73 if test "x$CONFIG_DOC" != xno; then
74         AC_PATH_PROGS(PYTHON, "python")
75         if test "x$PYTHON" != "x"; then
76                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
77                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
78                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
79         fi
81         AC_PATH_PROGS(XMLTO, "xmlto")
82         if test "x$XMLTO" != "x"; then
83                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
84                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
85                 EL_CONFIG(MAN_XMLTO, [man (groff)])
86         fi
88         AC_PATH_PROGS(JW, "jw")
89         if test "x$JW" != "x"; then
90                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
91                 EL_CONFIG(MANUAL_JW, [PDF])
92         fi
94         AC_PATH_PROGS(POD2HTML, "pod2html")
95         if test "x$POD2HTML" != "x"; then
96                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
97         fi
99         AC_PATH_PROGS(DOXYGEN, "doxygen")
100         if test "x$DOXYGEN" != "x"; then
101                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
102                 api_srcdir="$(cd "$srcdir" && pwd)/src"
103                 AC_SUBST(api_srcdir)
104         fi
107 AC_SUBST(CONFIG_ASCIIDOC)
108 AC_SUBST(CONFIG_DOXYGEN)
109 AC_SUBST(CONFIG_POD2HTML)
110 AC_SUBST(CONFIG_XMLTO)
111 AC_SUBST(CONFIG_JW)
113 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
114 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
115 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
116 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
118 # gcc specific options (to be continued at the bottom of configure)
119 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
120   # We want to see all warnings and live with none.
121   # We can't set up -Werror here as there may be some warnings in test
122   # suite of configure, and we don't want to fail them.
123   CFLAGS="$CFLAGS -Wall"
126 # ===================================================================
127 # Checks for special OSes.
128 # ===================================================================
130 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
131 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
133         AC_MSG_CHECKING([for $2])
135         for flag in $3; do
136                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
137 kill me!
138 #endif ]])],[$1=yes],[$1=no])
139                 if test "[$]$1" = yes; then
140                         EL_CONFIG([$1], [$2])
141                         break
142                 fi
143         done
145         AC_MSG_RESULT([$]$1)
148 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
149 AC_SUBST(CONFIG_OS_BEOS)
151 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
152 AC_SUBST(CONFIG_OS_RISCOS)
154 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
155 AC_SUBST(CONFIG_OS_WIN32)
157 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
158 AC_SUBST(CONFIG_OS_OS2)
159 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
161 AC_MSG_CHECKING([for UNIX])
162 dnl FIXME: some depend kind of mechanism
163 if test "$CONFIG_OS_BEOS" = no && \
164    test "$CONFIG_OS_RISCOS" = no && \
165    test "$CONFIG_OS_WIN32" = no && \
166    test "$CONFIG_OS_OS2" = no; then
167         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
168 else
169         CONFIG_OS_UNIX=no
171 AC_MSG_RESULT($CONFIG_OS_UNIX)
172 AC_SUBST(CONFIG_OS_UNIX)
174 # ===================================================================
175 # Checks for header files.
176 # ===================================================================
178 AC_HEADER_DIRENT
179 AC_HEADER_STDC
180 AC_HEADER_SYS_WAIT
181 AC_HEADER_TIME
183 AC_CHECK_HEADERS(wctype.h)
184 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
185 AC_CHECK_HEADERS(sigaction.h)
186 AC_CHECK_HEADERS(arpa/inet.h)
187 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
188 AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/in6_var.h)
189 AC_CHECK_HEADERS(ifaddrs.h)
190 AC_CHECK_HEADERS(sys/cygwin.h io.h)
191 AC_CHECK_HEADERS(sys/fmutex.h)
192 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
193 AC_CHECK_HEADERS(sys/resource.h)
194 AC_CHECK_HEADERS(sys/select.h)
195 AC_CHECK_HEADERS(sys/signal.h)
196 AC_CHECK_HEADERS(sys/socket.h)
197 AC_CHECK_HEADERS(sys/time.h)
198 AC_CHECK_HEADERS(sys/utsname.h)
199 AC_CHECK_HEADERS([net/if.h], [], [],
200 [[#ifdef HAVE_SYS_SOCKET_H
201 # include <sys/socket.h> /* <net/if.h> on Mac OS X 10.5.4 needs this */
202 #endif
204 AC_CHECK_HEADERS(stdint.h inttypes.h)
205 AC_CHECK_HEADERS(locale.h pwd.h)
206 AC_CHECK_HEADERS(termios.h)
209 AC_CHECK_HEADERS(sys/un.h,
210         [CONFIG_INTERLINK=yes
211          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
212         [CONFIG_INTERLINK=no])
213 AC_SUBST(CONFIG_INTERLINK)
215 # ===================================================================
216 # Checks for typedefs, structures, and compiler characteristics.
217 # ===================================================================
219 AC_STRUCT_TM
220 AC_C_CONST
221 AC_C_INLINE
222 AC_MSG_CHECKING([[for C99-conforming inline]])
223 AC_COMPILE_IFELSE([[
224         int add(int change);
226         static int sum;
228         inline int
229         add(int change)
230         {
231                 sum += change;
232                 return sum;
233         }
235         int
236         sub(int change)
237         {
238                 return add(-change);
239         }]],
240         [AC_MSG_RESULT([[yes]])
241          AC_DEFINE([NONSTATIC_INLINE], [inline],
242                 [Define as inline if the compiler lets you declare a function without inline, then define it with inline, and have that definition refer to identifiers with internal linkage.  This is allowed by C99 6.7.4p6 and 6.7.4p3 together.  Otherwise define as nothing.])],
243         [AC_MSG_RESULT([[no]])
244          AC_DEFINE([NONSTATIC_INLINE], [])])
245 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
247 AC_SYS_LARGEFILE
248 AC_TYPE_SIZE_T
249 AC_TYPE_OFF_T
250 EL_CHECK_TYPE(ssize_t, int)
251 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
252 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
253 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
254 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
255 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
257 AC_CHECK_SIZEOF(char, 1)
258 AC_CHECK_SIZEOF(short, 2)
259 AC_CHECK_SIZEOF(int, 4)
260 AC_CHECK_SIZEOF(long, 4)
261 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
262 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
264 # Check for variadic macros
265 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
266                 [#include <stdio.h>
267                  #define a(b,c...) printf(b,##c)],
268                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
270 # ===================================================================
271 # Checks for library functions.
272 # ===================================================================
274 AC_PROG_GCC_TRADITIONAL
275 AC_FUNC_MEMCMP
276 AC_FUNC_MMAP
277 AC_FUNC_STRFTIME
278 AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
279 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
280 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
281 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
282 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
283 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
284 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
285 AC_CHECK_FUNCS(gettimeofday clock_gettime)
287 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
289 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
290 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
291 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
293 # These aren't probably needed now, as they are commented in links.h.
294 # I've no idea about their historical background, but I keep them here
295 # just in the case they will help later. --pasky
296 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
297 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
298 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
299 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
301 if test x"$HAVE_RAISE" = x; then
302         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
303                 AC_MSG_ERROR([Unable to emulate raise()])
304         fi
307 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
308 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
309 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
310 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
311         EL_DEFINE(HAVE_VA_COPY, __va_copy)
314 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
315 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
316 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
317 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
318         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
321 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
322 AC_RUN_IFELSE([AC_LANG_SOURCE([[
323 #include <stdio.h>
324 #include <stdarg.h>
325 #include <stdlib.h>
326 #include <string.h>
328 char buf[8];
330 int bar(char *buf, const char *format, va_list ap)
332        return vsnprintf(buf, 0, format, ap);
335 void foo(const char *format, ...) {
336        va_list ap;
337        int len;
339        va_start(ap, format);
340        len = bar(buf, format, ap);
341        va_end(ap);
342        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
344        va_start(ap, format);
345        len = bar(buf, format, ap);
346        va_end(ap);
347        if ((len != 6) && (len != 7)) exit(1);
349        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
351        exit(0);
353 main() { foo("hello\n"); }
354 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
355 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
356         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
359 # OpenSSL and Lua frequently need dlopen
360 AC_CHECK_LIB(dl, dlopen)
362 # ===================================================================
363 # Checks for libraries.
364 # ===================================================================
366 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
367 if test "$cf_result" = no; then
368         AC_CHECK_LIB(socket, socket)
371 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
372 if test "$cf_result" = no; then
373         AC_CHECK_LIB(socket, setsockopt)
376 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
377 if test "$cf_result" = no; then
378         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
379         if test "$cf_result" = no; then
380                 AC_CHECK_LIB(nsl, gethostbyname)
381         else
382                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
383         fi
386 # ===================================================================
387 # Checks for packaging specific options.
388 # ===================================================================
390 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
391             [ if test "$withval" != no && test "$withval" != yes; then
392                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
393               fi ])
395 # ===================================================================
396 # Checks for a libraries, optional even if installed.
397 # ===================================================================
399 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
400 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
402         AC_MSG_CHECKING([for $2 support])
404         if test "[$]$1" != no; then
405                 AC_MSG_RESULT(yes)
406                 EL_SAVE_FLAGS
407                 if test -n "$withval" && test -d "$withval"; then
408                         # Be a little more careful when setting
409                         # include and lib directories. This way
410                         # $withval will work when includes are
411                         # there but the library is in the common
412                         # /usr/lib ... Does the right thing when
413                         # looking for gc on Debian.
414                         if test -d "$withval/include"; then
415                                 CFLAGS="$CFLAGS -I$withval/include"
416                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
417                         else
418                                 CFLAGS="$CFLAGS -I$withval"
419                                 CPPFLAGS="$CPPFLAGS -I$withval"
420                         fi
421                         if test -d "$withval/lib"; then
422                                 LDFLAGS="$LDFLAGS -L$withval/lib"
423                         fi
424                 fi
426                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
427                 if test "[$]$1" = yes; then
428                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
429                 fi
431                 if test "[$]$1" = yes; then
432                         EL_CONFIG([$1], [$2])
433                         LIBS="$LIBS -l$4"
434                 else
435                         if test -n "[$]WITHVAL_$1" &&
436                            test "[$]WITHVAL_$1" != xno; then
437                                 AC_MSG_ERROR([$2 not found])
438                         fi
439                         EL_RESTORE_FLAGS
440                 fi
441         else
442                 AC_MSG_RESULT(disabled)
443         fi
446 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
447 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
449         if test "x[$]$1" != xno; then $1=yes; fi
450         WITHVAL_$1=
452         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
453         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
454         if test "x[$]WITHVAL_$1" = xyes; then $1=yes; fi
456         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
458         EL_LOG_CONFIG([$1], [$2], [])
461 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
462         [  --without-gpm           disable gpm (mouse) support])
464 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
465 # enable automatic decoding of both zlib and gzip headers.  This
466 # feature was added in zlib 1.2.0.2; earlier versions return an error.
467 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
468 # that, even though ELinks does not actually call gzclearerr.
469 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
470         [  --without-zlib          disable zlib support])
472 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
473         [  --without-bzlib         disable bzlib support])
475 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
476         [  --without-idn           disable international domain names support])
478 if test "x${with_gc}" != xno; then
479         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
480                 [  --with-gc               enable Boehm's garbage collector])
483 # LZMA disabled by default, because of little usability and compilation problems
484 # with new xz
485 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
486         [  --with-lzma             enable lzma encoding support])
488 # ===================================================================
489 # Check for GSSAPI, optional even if installed.
490 # ===================================================================
492 enable_gssapi="no";
494 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
495             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
497 AC_MSG_CHECKING([for GSSAPI])
499 if test "$enable_gssapi" = "yes"; then
500         AC_MSG_RESULT(yes)
501         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
502         GSSAPI_LIBS=`krb5-config --libs gssapi`
503         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
504         LIBS="$GSSAPI_LIBS $LIBS"
505         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
506 else
507         AC_MSG_RESULT(no)
510 AC_SUBST(CONFIG_GSSAPI)
512 # ===================================================================
513 # Bookmark and XBEL support
514 # ===================================================================
516 EL_SAVE_FLAGS
518 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
519               [  --disable-bookmarks     disable bookmark support])
521 # Check whether --enable-xbel or --disable-xbel was given.
522 if test "x${enable_xbel}" != xno; then
523         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
525         if test "$HAVE_LIBEXPAT" = yes; then
526                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
527                 if test "$HAVE_LIBEXPAT" = yes; then
528                         LIBS="$LIBS -lexpat"
529                 fi
530         fi
534 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
535               [XBEL bookmarks],
536               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
538 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
539         EL_RESTORE_FLAGS
542 # ===================================================================
543 # Checks for BSD sysmouse
544 # ===================================================================
546 HAVE_SYSMOUSE_HEADER="no"
548 # Either of these header files provides the (same) sysmouse interface
549 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
551 # ===================================================================
552 # Checks for OS/2
553 # ===================================================================
555 if test "$CONFIG_OS_OS2" = yes; then
556         EL_CONFIG_OS_OS2
559 # ===================================================================
560 # Checks for Win32
561 # ===================================================================
563 if test "$CONFIG_OS_WIN32" = yes; then
564         EL_CONFIG_OS_WIN32
567 # ===================================================================
568 # Check for SpiderMonkey, optional even if installed.
569 # ===================================================================
571 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
572             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
573 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
575 EL_SAVE_FLAGS
576 cf_result=no
578 if test -z "$disable_spidermonkey"; then
579         if test ! -d "$withval"; then
580                 withval="";
581         fi
582         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
583                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
584                         for spidermonkeylib in js smjs mozjs; do
585                                 if test "$cf_result" = no &&
586                                    test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then
587                                         SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
588                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
590                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
591                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
592                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
594                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
595                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
596                                 fi
597                         done
598                 done
599         done
602 AC_MSG_RESULT($cf_result)
603 CONFIG_SPIDERMONKEY="$cf_result"
604 if test "$cf_result" = "yes"; then
605         AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]])
607 EL_RESTORE_FLAGS
609 if test "x$CONFIG_SPIDERMONKEY" = xyes; then
610         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
611 else
612         CONFIG_ECMASCRIPT_SMJS=no
615 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
616 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
619 # ===================================================================
620 # Optional Spidermonkey-based ECMAScript browser scripting
621 # ===================================================================
623 AC_ARG_ENABLE(sm-scripting,
624               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
625               [if test "$enableval" != no; then enableval="yes"; fi
626                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
628 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
629    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
630         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
631 else
632         CONFIG_SCRIPTING_SPIDERMONKEY=no
635 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
636    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
637         LIBS="$LIBS $SPIDERMONKEY_LIBS"
638         AC_SUBST(SPIDERMONKEY_LIBS)
639         AC_SUBST(SPIDERMONKEY_CFLAGS)
640         AC_SUBST(CONFIG_SPIDERMONKEY)
643 # ===================================================================
644 # Check for Guile, optional even if installed.
645 # ===================================================================
647 enable_guile="no";
649 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
650             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
652 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
653 # GUILE_FLAGS but I really don't want to require people to have Guile in order
654 # to compile CVS. Also, the macro seems to be really stupid regarding searching
655 # for Guile in $PATH etc. --pasky
657 AC_MSG_CHECKING([for Guile])
659 if test "$enable_guile" = "yes"; then
660         AC_MSG_RESULT(yes);
661         ## Based on the GUILE_FLAGS macro.
663         if test -d "$withval"; then
664                 GUILE_PATH="$withval:$PATH"
665         else
666                 GUILE_PATH="$PATH"
667         fi
669         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
671         ## First, let's just see if we can find Guile at all.
672         if test "$GUILE_CONFIG" != no; then
673                 cf_result="yes";
675                 GUILE_LIBS="`guile-config link`"
676                 GUILE_CFLAGS="`guile-config compile`"
677                 LIBS="$GUILE_LIBS $LIBS"
678                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
679                 AC_SUBST(GUILE_CFLAGS)
680                 cat <<EOF
681 ***********************************************************************
682 The Guile support is incomplete and not so well integrated to ELinks
683 yet. That means, e.g., that you have no Guile console and there might
684 not be all the necessary hooks. Also, the Guile interface is not too
685 well tested (success stories heartily welcomed!).  See
686 src/scripting/guile/README for further details and hints.
687 ***********************************************************************
689         else
690                 if test -n "$withval" && test "x$withval" != xno; then
691                         AC_MSG_ERROR([Guile not found])
692                 else
693                         AC_MSG_WARN([Guile support disabled])
694                 fi
695         fi
696 else
697         AC_MSG_RESULT(no);
700 # ===================================================================
701 # Check for Perl
702 # ===================================================================
703 enable_perl="no";
705 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
706             [
707 if test "$withval" = yes; then
708         # FIXME: If withval is a valid directory append it to PATH
709         # so that you can specify one of several perl installations.
710         withval="";
711         enable_perl=yes;
713             ])
715 AC_MSG_CHECKING([for Perl])
717 cf_result=no
719 EL_SAVE_FLAGS
721 if test "$enable_perl" = "yes"; then
722         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
723         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
724         LIBS="$PERL_LIBS $LIBS"
725         CFLAGS="$PERL_CFLAGS $CFLAGS"
726         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
727         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
728 #include <EXTERN.h>
729 #include <perl.h>
730 #include <perlapi.h>
731 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
734 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
736 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
737 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
738 #include <EXTERN.h>
739 #include <perl.h>
740 extern PerlInterpreter *my_perl;
741 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
742 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
743                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
744 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
746 if test "$cf_result" != "yes"; then
747         EL_RESTORE_FLAGS
748 else
749         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
751         CFLAGS="$CFLAGS_X"
752         CPPFLAGS="$CPPFLAGS_X"
753         AC_SUBST(PERL_LIBS)
754         AC_SUBST(PERL_CFLAGS)
757 # ===================================================================
758 # Check for Python
759 # ===================================================================
760 enable_python="no";
762 AC_ARG_WITH(python, [[  --with-python[=DIR]     enable Python support]],
763             [ if test "x$withval" != xno; then enable_python=yes; fi ])
765 EL_SAVE_FLAGS
766 cf_result=no
768 AC_MSG_CHECKING([for Python])
770 if test "$enable_python" = "yes"; then
771         AC_MSG_RESULT(yes);
773         if test -d "$withval"; then
774                 PYTHON_PATH="$withval:$PATH"
775         else
776                 PYTHON_PATH="$PATH"
777         fi
779         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
781         if test "$PYTHON" != no; then
782                 cf_result="yes";
784                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
785                 PYTHON_LIBS="`$PYTHON -c 'from distutils import sysconfig; var = sysconfig.get_config_var; print "%s %s %s -L%s -lpython%s" % (var("LINKFORSHARED"), var("LIBS"), var("SYSLIBS"), var("LIBPL"), var("VERSION"))'`"
786                 LIBS="$PYTHON_LIBS $LIBS"
787                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
788                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
790                 if test "$cf_result" != "yes"; then
791                         EL_RESTORE_FLAGS
792                 else
793                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
794                         AC_SUBST(PYTHON_LIBS)
795                         AC_SUBST(PYTHON_CFLAGS)
796                         CPPFLAGS="$CPPFLAGS_X"
797                         cat <<EOF
798 ***********************************************************************
799 The Python support is incomplete and not so well integrated to ELinks
800 yet. That means, e.g., that you have no Python console and there might
801 not be all the necessary hooks. Also, the Python interface is not too
802 well tested (success stories heartily welcomed!).
803 ***********************************************************************
805                 fi
806         else
807                 if test -n "$withval" && test "x$withval" != xno; then
808                         AC_MSG_ERROR([Python not found])
809                 else
810                         AC_MSG_WARN([Python support disabled])
811                 fi
812         fi
813 else
814         AC_MSG_RESULT(no);
818 # ===================================================================
819 # Check for Lua, optional even if installed.
820 # ===================================================================
822 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
823 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
825 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
826             [if test "$withval" = no; then disable_lua=yes; fi])
827 AC_MSG_CHECKING([for Lua])
829 EL_SAVE_FLAGS
830 cf_result=no
832 if test -z "$disable_lua"; then
833         if test ! -d "$withval"; then
834                 withval="";
835         fi
836         for luadir in "$withval" "" /usr /usr/local; do
837                 for suffix in "" 50; do
838                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
839                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
840                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
841                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
843                                 LIBS="$LUA_LIBS $LIBS_X"
844                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
845                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
847                                 # Check that it is a compatible Lua version
848                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
849                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
850                                                 luaopen_base(L);
851                                                 luaopen_table(L);
852                                                 luaopen_io(L);
853                                                 luaopen_string(L);
854                                                 luaopen_math(L);
855                                                 lua_pushboolean(L, 1);
856                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
857                         fi
858                 done
859         done
862 AC_MSG_RESULT($cf_result)
864 if test "$cf_result" != yes; then
865         EL_RESTORE_FLAGS
866 else
867         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
868         AC_CHECK_HEADERS(lauxlib.h)
870         CFLAGS="$CFLAGS_X"
871         CPPFLAGS="$CPPFLAGS_X"
872         AC_SUBST(LUA_LIBS)
873         AC_SUBST(LUA_CFLAGS)
876 # ===================================================================
877 # Check for TRE library
878 # ===================================================================
880 # This section only checks that --without-tre is not given and the
881 # library seems to work, and sets TRE_CFLAGS, TRE_LIBS, and
882 # tre_log.  It does not define CONFIG_TRE, and always resets
883 # LIBS and CFLAGS back to their original values.
885 # After any --enable-utf-8 and --disable-utf-8 options have been
886 # handled, a separate section decides whether to actually use TRE.
888 AC_ARG_WITH([[tre]], [[  --without-tre           disable TRE regex search support]])
889 if test "$with_tre" = no; then
890         AC_MSG_CHECKING([[for TRE]])
891         AC_MSG_RESULT([[disabled]])
892         tre_log="no (explicitly disabled)"
893 else
894         AC_MSG_CHECKING([[for TRE in pkg-config]])
895         if pkg-config tre; then
896                 TRE_CFLAGS=`pkg-config --cflags tre`
897                 TRE_LIBS=`pkg-config --libs tre`
898                 AC_MSG_RESULT([[yes]])
899         else
900                 # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
901                 # "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
902                 # so we look for the library even if pkg-config doesn't know about it.
903                 TRE_CFLAGS=
904                 TRE_LIBS=-ltre
905                 AC_MSG_RESULT([[no, but let's try defaults]])
906         fi
908         AC_MSG_CHECKING([[for TRE header and library]])
909         EL_SAVE_FLAGS
910         CFLAGS="$TRE_CFLAGS $CFLAGS"
911         LIBS="$TRE_LIBS $LIBS" # must be first, because of regfree conflict
912         AC_TRY_LINK([#include <tre/regex.h>],
913                     [regex_t re;
914                      regmatch_t match[1];
915                      regwcomp(&re, L"zap", REG_ICASE);
916                      regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
917                     [AC_MSG_RESULT([[yes]])
918                      tre_log="available"],
919                     [AC_MSG_RESULT([[no]])
920                      tre_log="no (TRE not found)"])
921         EL_RESTORE_FLAGS
924 # ===================================================================
925 # Check for Ruby, optional even if installed.
926 # ===================================================================
928 EL_CONFIG_SCRIPTING_RUBY
930 # ===================================================================
931 # Setup global scripting
932 # ===================================================================
934 EL_CONFIG_DEPENDS(CONFIG_SCRIPTING, [CONFIG_SCRIPTING_GUILE CONFIG_SCRIPTING_LUA CONFIG_SCRIPTING_PERL CONFIG_SCRIPTING_PYTHON CONFIG_SCRIPTING_RUBY CONFIG_SCRIPTING_SPIDERMONKEY], [Browser scripting])
935 AC_SUBST(CONFIG_SCRIPTING_GUILE)
936 AC_SUBST(CONFIG_SCRIPTING_LUA)
937 AC_SUBST(CONFIG_SCRIPTING_PERL)
938 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
939 AC_SUBST(CONFIG_SCRIPTING_RUBY)
940 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
941 AC_SUBST(CONFIG_SCRIPTING)
944 # ===================================================================
945 # Check for SSL support.
946 # ===================================================================
948 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
949 # is enabled, we won't try to use OpenSSL anymore.
951 # For wiping SSL hooks..
952 #ifdef CONFIG_SSL
954 chosen_ssl_library=""
956 AC_ARG_WITH(gnutls, [[  --without-gnutls        disable GNUTLS SSL support]])
957 AC_ARG_WITH(gnutls, [[  --with-gnutls           enable GNUTLS SSL support]],
958             [case "$with_gnutls" in
959                 "no")   : ;;
960                 "yes")  chosen_ssl_library="GNUTLS" ;;
961                 *)      chosen_ssl_library="GNUTLS"
962                         AC_MSG_WARN([[Support for --with-gnutls=DIR has been removed.
963 You may have to set the PKG_CONFIG_PATH environment variable instead.]]) ;;
964              esac])
966 AC_ARG_WITH(openssl, [[  --without-openssl       disable OpenSSL support]])
967 AC_ARG_WITH(openssl, [[  --with-openssl[=DIR]    enable OpenSSL support (default)]],
968             [case "$with_openssl" in
969                 "no")   : ;;
970                 *)      chosen_ssl_library="OpenSSL" ;;
971              esac])
973 # ---- OpenSSL
975 AC_MSG_CHECKING([for OpenSSL])
977 EL_SAVE_FLAGS
979 if test "$with_openssl" = no; then
980         cf_result="explicitly disabled"
982 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "OpenSSL"; then
983         cf_result="not used, because $chosen_ssl_library was chosen"
985 else
986         cf_result=no
987         for ssldir in "$with_openssl" "" /usr /usr/local/openssl \
988                          /usr/lib/openssl /usr/local/ssl \
989                          /usr/local/www /usr/lib/ssl /usr/local \
990                          /usr/pkg /opt /opt/openssl; do
991                 if test "$cf_result" = no; then
992                         if test -d "$ssldir"; then
993                                 OPENSSL_CFLAGS="-I$ssldir/include"
994                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
995                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
996                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
997 #                               # FIXME: This created serious portability problems. --pasky
998 #                               if test "$CC" == "gcc"; then
999 #                                       # I'm not sure about compatibility here. --pasky
1000 #                                       LIBS="$LIBS -R$ssldir/lib"
1001 #                               fi
1002                         else
1003                                 LIBS="-lssl -lcrypto $LIBS_X"
1004                         fi
1005                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1006                         if test "$cf_result" != yes; then
1007                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1008                         fi
1009                 fi
1010         done
1012         if test "$cf_result" != yes; then
1013                 if test "${with_openssl-no}" != "no"; then
1014                         AC_MSG_ERROR([OpenSSL not found])
1015                 fi
1016                 EL_RESTORE_FLAGS
1017         else
1018                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1019                 chosen_ssl_library="OpenSSL"
1021                 CFLAGS="$CFLAGS_X"
1022                 AC_SUBST(OPENSSL_CFLAGS)
1023         fi
1026 AC_MSG_RESULT($cf_result)
1028 # ---- GNU TLS
1030 # GnuTLS 2.2.0 changed libgnutls-openssl from GPLv2+
1031 # to GPLv3+.  Don't link that with the GPLv2 ELinks.
1032 # ELinks will use its internal MD5 code instead.
1033 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1035 if test "$with_gnutls" = no; then
1036         AC_MSG_CHECKING([[for GNUTLS]])
1037         AC_MSG_RESULT([[explicitly disabled]])
1039 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "GNUTLS"; then
1040         AC_MSG_CHECKING([[for GNUTLS]])
1041         AC_MSG_RESULT([[not used, because $chosen_ssl_library was chosen]])
1043 else
1044         cf_result=no
1045         AC_MSG_CHECKING([[for GNUTLS (1.2 or later) in pkg-config]])
1046         if pkg-config --atleast-version=1.2 gnutls; then
1047                 GNUTLS_CFLAGS=`pkg-config --cflags gnutls`
1048                 GNUTLS_LIBS=`pkg-config --libs gnutls`
1049                 AC_MSG_RESULT([[yes: $GNUTLS_CFLAGS $GNUTLS_LIBS]])
1051                 EL_SAVE_FLAGS
1052                 LIBS="$GNUTLS_LIBS $LIBS"
1053                 CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
1054                 CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
1056                 # Verify if it's really usable.  gnutls_session was
1057                 # renamed to gnutls_session_t before GNU TLS 1.2.0
1058                 # (on 2004-06-13); ELinks now requires this.
1059                 AC_MSG_CHECKING([[whether GNUTLS can be linked with]])
1060                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]],
1061                                                 [[gnutls_session_t dummy;
1062                                                   gnutls_check_version(NULL)]])],
1063                                [cf_result=yes],
1064                                [cf_result=no])
1065                 AC_MSG_RESULT([[$cf_result]])
1067                 if test "$cf_result" = yes; then
1068                         # According to gnutls/NEWS, the function was originally
1069                         # added as gnutls_set_default_priority2 in GNUTLS 2.1.4
1070                         # (released 2007-10-27) and then renamed to
1071                         # gnutls_priority_set_direct in GNUTLS 2.1.7 (released
1072                         # 2007-11-29).
1073                         AC_CHECK_FUNCS([gnutls_priority_set_direct])
1074                 fi
1076                 EL_RESTORE_FLAGS
1077         else
1078                 AC_MSG_RESULT([[$cf_result]])
1079         fi
1081         if test "$cf_result" = yes; then
1082                 EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1083                 chosen_ssl_library="GNUTLS"
1085                 LIBS="$GNUTLS_LIBS $LIBS"
1086                 AC_SUBST(GNUTLS_CFLAGS)
1088         elif test "${with_gnutls-no}" != "no"; then
1089                 AC_MSG_ERROR([[GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.]])
1090         fi
1093 # Final SSL setup
1095 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1096 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1097 AC_SUBST(CONFIG_OPENSSL)
1098 AC_SUBST(CONFIG_GNUTLS)
1100 #endif
1102 AC_MSG_CHECKING([whether to be or not to be])
1103 AC_MSG_RESULT([needs to be determined experimentally])
1105 # ===================================================================
1106 # Check for IPv6 support and related functions.
1107 # ===================================================================
1109 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1110 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1111 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1113 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1114 if test "$HAVE_GETADDRINFO" != yes; then
1115         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1116         if test "$HAVE_GETADDRINFO" = yes; then
1117                 LIBS="$LIBS -linet6"
1118         fi
1122 # ===================================================================
1123 # Checking for X11 (window title restoring).
1124 # ===================================================================
1126 AC_PATH_X
1127 if test x"$no_x" != xyes; then
1128         EL_SAVE_FLAGS
1129         if test -n "$x_includes"; then
1130                 X_CFLAGS="-I$x_includes"
1131                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1132                 CFLAGS="$CFLAGS $X_CFLAGS"
1133         fi
1134         if test -n "$x_libraries"; then
1135                 LDFLAGS="$LDFLAGS -L$x_libraries"
1136         fi
1137         LIBS="-lX11 $LIBS"
1138         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1139         EL_RESTORE_FLAGS
1140         if test "$cf_result" = yes; then
1141                 if test -n "$x_libraries"; then
1142                         LDFLAGS="$LDFLAGS -L$x_libraries"
1143                 fi
1144                 LIBS="-lX11 $LIBS"
1145                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1146                 AC_SUBST(X_CFLAGS)
1147         fi
1151 # ===================================================================
1152 # Backtraces displaying support.
1153 # ===================================================================
1155 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1156 # possible checks for other system-specific means go here
1159 # ===================================================================
1160 # Gettext grey zone. Beware.
1161 # ===================================================================
1163 ALL_LINGUAS="af be bg ca cs da de el es et fi fr gl hr hu id is it lt nl nb pl pt pt_BR ro ru sk sr sv tr uk"
1165 AM_GNU_GETTEXT
1167 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1168 dnl # f33r d4 l33t... I hope it's portable. :)
1169 dnl cf_result=$((48#z - 48#a + 1));
1170 dnl AC_MSG_RESULT($cf_result)
1173 # ===================================================================
1174 # Compile-time features control
1175 # ===================================================================
1177 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1178               [  --disable-cookies       disable cookie support])
1180 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1181               [  --disable-formhist      disable form history support])
1183 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1184               [  --disable-globhist      disable global history support])
1187 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1188               [  --disable-mailcap       disable mailcap support])
1190 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1191               [  --disable-mimetypes     disable mimetypes files support])
1194 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1195               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1196               [IPv6],
1197               [  --disable-ipv6          disable IPv6 support])
1199 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1200               [  --enable-bittorrent     enable BitTorrent protocol support])
1202 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1203               [  --disable-data          disable data protocol support])
1205 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1206               [  --disable-uri-rewrite   disable URI rewrite support])
1208 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1209               [  --enable-cgi            enable local CGI support])
1211 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1212               [  --enable-finger         enable finger protocol support])
1214 # ===================================================================
1215 # FSP protocol
1216 # ===================================================================
1217 EL_SAVE_FLAGS
1219 if test "x${enable_fsp}" != xno; then
1220         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1222         if test "$HAVE_FSPLIB" = yes; then
1223                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1224                 if test "$HAVE_FSPLIB" = yes; then
1225                         LIBS="$LIBS -lfsplib"
1226                 else
1227                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1228                         if test "$HAVE_FSPLIB" = yes; then
1229                                 LIBS="$LIBS -lfsp"
1230                         fi
1231                 fi
1232         fi
1235 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1236               [  --enable-fsp            enable FSP protocol support])
1238 if test "x$CONFIG_FSP" = xno; then
1239         EL_RESTORE_FLAGS
1242 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1243               [  --disable-ftp           disable ftp protocol support])
1245 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1246               [  --enable-gopher         enable gopher protocol support])
1248 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1249               [  --enable-nntp           enable nntp protocol support])
1251 # ===================================================================
1252 # SMB protocol support.
1253 # ===================================================================
1254 EL_SAVE_FLAGS
1256 if test "x${enable_smb}" != xno; then
1257         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1259         if test "$HAVE_SMBCLIENT" = yes; then
1260                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1261                 if test "$HAVE_SMBCLIENT" = yes; then
1262                         LIBS="$LIBS -lsmbclient"
1263                 fi
1264         fi
1267 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1268               [  --enable-smb            enable Samba protocol support])
1270 if test "x$CONFIG_SMB" = xno; then
1271         EL_RESTORE_FLAGS
1275 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1276               [  --disable-mouse         disable mouse support])
1278 # GPM mouse is Linux specific, so ...
1279 CONFIG_SYSMOUSE=yes
1280 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1281               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1282               [BSD sysmouse],
1283               [  --disable-sysmouse      disable BSD sysmouse support])
1285 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1286               [  --enable-88-colors      enable 88 color support])
1288 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1289               [  --enable-256-colors     enable 256 color support])
1291 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1292               [  --enable-true-color     enable true color support])
1294 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1295               [  --enable-exmode         enable exmode (CLI) interface])
1297 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1298               [  --disable-leds          disable LEDs support])
1300 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1301               [  --disable-marks         disable document marks support])
1304 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1305               [  --disable-css           disable Cascading Style Sheet support])
1307 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1308               [  --enable-html-highlight HTML highlighting using DOM engine])
1310 # Everything in the tree already uses CONFIG_DOM
1311 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1312 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1314 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1315               [  --disable-backtrace     disable backtrace support])
1317 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1318               [  --enable-no-root        enable prevention of usage by root])
1321 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1322               [  --enable-debug          enable leak debug and internal error checking])
1324 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1325               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1327 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1328               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1330 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1331               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1333 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1334               [  --disable-utf-8         disable UTF-8 support])
1337 AC_ARG_ENABLE(weehoofooboomookerchoo,
1338               [
1339     Also check out the features.conf file for more information about features!
1340               ],
1341               [AC_MSG_ERROR(Are you strange, or what?)])
1344 # ===================================================================
1345 # Decide whether to use TRE
1346 # ===================================================================
1348 # This must be done after the CONFIG_UTF8 check above.
1349 # The first part of the TRE check is separate, to get
1350 # the configure --help output in a sensible order.
1352 # After this section, nothing else must be added to the
1353 # beginning of $LIBS.
1355 if test "$tre_log" = "available"; then
1356         if test "$CONFIG_UTF8" = "yes"; then
1357                 # When CONFIG_UTF8 and CONFIG_TRE are both defined,
1358                 # src/viewer/text/search.c makes a string of
1359                 # unicode_val_T and gives it to regwexec(), which
1360                 # expects a string of wchar_t.  If the unicode_val_T
1361                 # and wchar_t types are too different, this won't
1362                 # work, so try to detect that and disable regexp
1363                 # operations entirely in that case.
1364                 #
1365                 # Currently, this code only compares the sizes of the
1366                 # types.  src/intl/charsets.h defines unicode_val_T as
1367                 # uint32_t, so we check whether wchar_t has exactly 32
1368                 # bits.  But don't use AC_CHECK_SIZEOF for this, because
1369                 # there doesn't seem to be a documented way to get the
1370                 # result of that for use in the configure script.
1371                 #
1372                 # C99 says the implementation can define
1373                 # __STDC_ISO_10646__ if wchar_t values match ISO 10646
1374                 # (or Unicode) numbers in all locales.  Do not check
1375                 # that macro here, because it is too restrictive: it
1376                 # should be enough for ELinks if the values match in
1377                 # the locales where ELinks is actually run.
1378                 AC_MSG_CHECKING([[whether wchar_t is exactly 32-bit]])
1379                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1380 #include <limits.h>
1381 #include <stddef.h>
1382 int dummy[(sizeof(wchar_t) * CHAR_BIT == 32) ? 1 : -1];]], [])],
1383                         [AC_MSG_RESULT([[yes]])
1384                          tre_log="TRE"],
1385                         [AC_MSG_RESULT([[no]])
1386                          tre_log="no (unsuitable wchar_t)"])
1387         else
1388                 # If UTF-8 is not used, then wchar_t doesn't matter.
1389                 tre_log="TRE"
1390         fi
1393 if test "$tre_log" = "TRE"; then
1394         AC_DEFINE([CONFIG_TRE], [1],
1395                 [Define as 1 to use the TRE library for regular expression searching.  This requires the <tre/regex.h> header file.  If you define CONFIG_UTF8 too, then wchar_t must be exactly 32-bit so that it matches unicode_val_T.])
1396         # TRE_CFLAGS will be used only where needed.
1397         #
1398         # Bug 1081: If both TRE and libc define the regfree function,
1399         # ELinks needs to use the version defined by TRE because
1400         # that's the one compatible with regex_t initialized by the
1401         # regwcomp function of TRE.  Therefore put $TRE_LIBS at the
1402         # very beginning of $LIBS so that the linker hopefully finds
1403         # regfree there before it examines libc.  In particular,
1404         # $PERL_LIBS appears to often include "-lc".
1405         #
1406         # This scheme still risks a crash if ELinks is linked with
1407         # some static library that uses GNU <regex.h> extensions that
1408         # TRE does not implement.  For example, the library might call
1409         # re_compile_pattern, which is found in GNU libc, and then
1410         # regfree, which is found in TRE and probably crashes with the
1411         # GNU-initialized regex_t.  Ways to avoid such crashes:
1412         #
1413         # - Change TRE so it defines only tre_... functions and does
1414         #   not attempt to override the POSIX names by default.
1415         #
1416         # - Change ELinks to access TRE only via dlopen and dlsym.
1417         #   The problem then is how to find the correct file name.
1418         #   There might be libtre.so.4 and libtre.so.5 with different
1419         #   ABI.  How can this configure script detect which of them
1420         #   matches the <tre/regex.h> in the include path?
1421         #
1422         # - Replace the static library with a shared library.  At
1423         #   least on GNU/Linux, when the shared library is built, the
1424         #   linker should note that e.g. regfree is defined in libc
1425         #   and has the GLIBC_2.0 version there, and write that
1426         #   version string to the shared library as well; because TRE
1427         #   does not provide regfree with that version, any regfree
1428         #   calls at run time should then get resolved to libc.
1429         LIBS="$TRE_LIBS $LIBS"
1430 else
1431         TRE_LIBS=
1432         TRE_CFLAGS=
1434 AC_SUBST(TRE_CFLAGS)
1435 AC_SUBST(TRE_LIBS)
1436 EL_LOG_CONFIG([CONFIG_TRE], [[Regexp searching]], [[$tre_log]])
1439 # ===================================================================
1440 # Further LDFLAGS tweaks
1441 # ===================================================================
1443 # == EMX hack
1445 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1446 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1449 # Check for -rdynamic
1451 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
1452 # the executable to its dynamic symbol table.  ELinks uses this for
1453 # two purposes:
1455 # 1. If ELinks detects a bug, it can try to display a backtrace by
1456 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
1457 #    manual states users of GNU ld must pass -rdynamic to make the
1458 #    symbols available to the program.
1460 # 2. It would eventually be nice to dynamically load shared
1461 #    libraries as plugins (bug 73).  The plugins must be able to
1462 #    call ELinks functions.  This can be implemented either by
1463 #    registering all callable functions in ELinks-specific data
1464 #    structures, or by letting the dynamic linker handle them.
1465 #    The latter way requires something equivalent to -rdynamic.
1467 # Because backtraces are not needed for correct operation, and bug
1468 # 73 is not yet being fixed, the configure script and makefiles
1469 # should not complain to the user if they find that -rdynamic does
1470 # not work.  Besides, it was reported at elinks-users on 2006-09-12
1471 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
1472 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
1473 # -rdynamic but does something equivalent automatically.  (This was
1474 # tested with "nm -D elinks | grep redraw_from_window".)
1476 # With Sun Studio 11 on Solaris 9, we get "cc: Warning: illegal option
1477 # -dynamic"; then, cc proceeds anyway, but the option can prevent the
1478 # linker from finding the libraries listed in -l operands.  So this
1479 # -rdynamic check needs to happen after the libraries have already
1480 # been added to $LDFLAGS.
1481 AC_MSG_CHECKING([for -rdynamic])
1482 LDFLAGS_X="$LDFLAGS"
1483 LDFLAGS="-rdynamic $LDFLAGS"
1484 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
1485 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
1486 AC_MSG_RESULT($have_rdynamic)
1488 # ===================================================================
1489 # Export directory paths
1490 # ===================================================================
1492 # Set up the ``entry points'' if they were not supplied by builder
1493 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1494 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1496 # Create CONFDIR #define for config.h
1498 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1499 # it's autoconf fault to force us to do such hacks ;p.
1500 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1501   # sysconfdir is set to its default value... fine, let's append /elinks/
1502   # XXX: We can't modify listing of the default in ./configure --help :-(
1503   sysconfdir_n=`eval echo "$sysconfdir"`
1504   sysconfdir=$sysconfdir_n
1505   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1506         sysconfdir="$sysconfdir/elinks"
1509 CONFDIR=$sysconfdir
1510 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1511 AC_SUBST(CONFDIR)
1513 # Create LOCALEDIR #define for config.h
1514 LOCALEDIR=`eval echo "$datadir/locale"`
1515 while echo "$LOCALEDIR" | grep "\\$"
1517         LOCALEDIR=`eval echo "$LOCALEDIR"`
1518 done > /dev/null 2> /dev/null
1519 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1520 AC_SUBST(LOCALEDIR)
1522 # Create LIBDIR #define for config.h
1523 LIBDIR=`eval echo "$libdir"`
1524 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1525 AC_SUBST(LIBDIR)
1527 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1528 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1531 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1532 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1533         #error not tcc
1534         #endif ]])],[cf_result=yes],[cf_result=no])
1536 if test "$cf_result" = "yes"; then
1537         AC_DEFINE([HAVE_ALLOCA])
1538         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1539                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1540                 override the alloca macro defined in <stddef.h> of TCC.
1541                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1542                 it has already been included, and does not redefine alloca.
1543                 This might not work in future glibc versions though, because
1544                 the names of the #include guard macros are not documented.
1545                 The incompatibility has been reported to the tinycc-devel
1546                 mailing list on 2008-07-14.  If a future version of TCC provides
1547                 an <alloca.h> of its own, this hack won't be needed.])
1549 # ===================================================================
1550 # A little fine tuning of gcc specific options (continued)
1551 # ===================================================================
1553 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1554   if test "$CONFIG_DEBUG" = "yes"; then
1555     # We want to see all warnings and live with none (in debug mode).
1556     CFLAGS="$CFLAGS -Werror"
1557   fi
1559   case "`$CC -dumpversion`" in
1560     3.0|3.1|3.2)
1561       # These should be ok using -Werror
1562       ;;
1563     3.*)
1564       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1565       # "dereferencing type-punned pointer will break strict-aliasing rules"
1566       # warnings. Disable them by not doing any strict-aliasing. The
1567       # alternative is just too ugly. Thanks gcc guys!! ;)
1568       CFLAGS="$CFLAGS -fno-strict-aliasing"
1569       ;;
1570     4.*)
1571       # Do not show warnings related to (char * | unsigned char *) type
1572       # difference.
1573       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1574       ;;
1575     *)
1576       # These should be ok using -Werror
1577       ;;
1578   esac
1580   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1581   # warning: the address of `builtin_modules' will always evaluate as `true'
1582   # This hits the object_lock and foreach_module macros in particular.
1583   # It would be okay to put something in the macros to avoid the warning,
1584   # but currently this seems to require defining parallel macros that skip
1585   # the NULL check, and that's too ugly.  So we instead disable the warning.
1586   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1587   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1588   for warning_flag in -Wno-address -Wno-always-true; do
1589     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1590     EL_SAVE_FLAGS
1591     CFLAGS="$CFLAGS $warning_flag"
1592     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1593       [AC_MSG_RESULT([yes])
1594        break],
1595       [AC_MSG_RESULT([no])])
1596     EL_RESTORE_FLAGS
1597   done
1599   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1600   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1601   # "warning: assuming signed overflow does not occur when assuming
1602   # that (X + c) > X is always true", which may be an incorrect
1603   # optimization (although allowed by the standard), and breaks the
1604   # build with -Werror.
1605   #
1606   # All of the following tests included -S -Wall -Wextra:
1607   #
1608   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1609   # * gcc-4.0 -O0: OK, compares the values
1610   # * gcc-4.0 -O2: assumes no overflow, does not warn
1611   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1612   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1613   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1614   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1615   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1616   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1617   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1618   #
1619   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1620   # * gcc-4.1 -O0: assumes no overflow, does not warn
1621   # * gcc-4.1 -O2: assumes no overflow, does not warn
1622   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1623   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1624   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1625   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1626   # * gcc-4.1 -O2 -ftrapv: compares the values
1627   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1628   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1629   #
1630   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1631   # * gcc-4.2 -O0: OK, compares the values
1632   # * gcc-4.2 -O2: assumes no overflow, warns about it
1633   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1634   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1635   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1636   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1637   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1638   # * gcc-4.2 -O2 -ftrapv: compares the values
1639   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1640   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1641   #
1642   # Apparently, -ftrapv does not work reliably at all.
1643   for overflow_flag in -fno-strict-overflow -fwrapv; do
1644     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1645     EL_SAVE_FLAGS
1646     CFLAGS="$CFLAGS $overflow_flag"
1647     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1648       [AC_MSG_RESULT([yes])
1649        break],
1650       [AC_MSG_RESULT([no])])
1651     EL_RESTORE_FLAGS
1652   done
1655 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1656 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1657 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1658 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1660 # ===================================================================
1661 # Colored make output
1662 # ===================================================================
1664 if test $(`which tput` colors 2> /dev/null || echo 0) -ge 4; then
1665         MAKE_COLOR=1
1666         AC_SUBST(MAKE_COLOR)
1669 # ===================================================================
1670 # Generated files
1671 # ===================================================================
1673 AC_CONFIG_FILES([ \
1674  Makefile.config \
1675  contrib/elinks.spec \
1676  contrib/lua/hooks.lua \
1677  contrib/conv/w3m2links.awk \
1678  doc/Doxyfile \
1679  doc/man/man1/elinks.1 \
1680  src/intl/gettext/ref-add.sed \
1681  src/intl/gettext/ref-del.sed
1683 AC_OUTPUT
1685 abs_srcdir="$(cd "$srcdir" && pwd)"
1686 # builddir is always absolute!
1687 if test "$abs_srcdir" != "$builddir"; then
1688         # Bootstrap the Makefile creation
1689         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1690         "$MAKE" "SRC=$abs_srcdir" init
1692         # Make cg-status ignore this build directory
1693         echo "*" > "$builddir/.gitignore"
1696 # ===================================================================
1697 # Configuration summary
1698 # ===================================================================
1700 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1701 cat features.log