Compilation fix on Mingw32.
[elinks.git] / configure.in
blob3d8790c4b13fdadc7f715d447ff57d40ec446728
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.13.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(wchar.h 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)
286 AC_CHECK_FUNCS(setitimer, HAVE_SETITIMER=yes)
288 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
290 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
291 AC_CHECK_FUNCS(unsetenv)
292 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
293 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
295 AC_CHECK_FUNCS(wcwidth, HAVE_WCWIDTH=yes)
297 # These aren't probably needed now, as they are commented in links.h.
298 # I've no idea about their historical background, but I keep them here
299 # just in the case they will help later. --pasky
300 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
301 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
302 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
303 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
305 AC_CHECK_FUNCS(fpathconf, HAVE_FPATHCONF=yes)
307 if test x"$HAVE_RAISE" = x; then
308         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
309                 AC_MSG_ERROR([Unable to emulate raise()])
310         fi
313 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
314 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
315 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
316 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
317         EL_DEFINE(HAVE_VA_COPY, __va_copy)
320 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
321 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
322 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
323 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
324         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
327 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
328 AC_RUN_IFELSE([AC_LANG_SOURCE([[
329 #include <stdio.h>
330 #include <stdarg.h>
331 #include <stdlib.h>
332 #include <string.h>
334 char buf[8];
336 int bar(char *buf, const char *format, va_list ap)
338        return vsnprintf(buf, 0, format, ap);
341 void foo(const char *format, ...) {
342        va_list ap;
343        int len;
345        va_start(ap, format);
346        len = bar(buf, format, ap);
347        va_end(ap);
348        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
350        va_start(ap, format);
351        len = bar(buf, format, ap);
352        va_end(ap);
353        if ((len != 6) && (len != 7)) exit(1);
355        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
357        exit(0);
359 main() { foo("hello\n"); }
360 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
361 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
362         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
365 # OpenSSL and Lua frequently need dlopen
366 AC_CHECK_LIB(dl, dlopen)
368 # ===================================================================
369 # Checks for libraries.
370 # ===================================================================
372 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
373 if test "$cf_result" = no; then
374         AC_CHECK_LIB(socket, socket)
377 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
378 if test "$cf_result" = no; then
379         AC_CHECK_LIB(socket, setsockopt)
382 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
383 if test "$cf_result" = no; then
384         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
385         if test "$cf_result" = no; then
386                 AC_CHECK_LIB(nsl, gethostbyname)
387         else
388                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
389         fi
392 # ===================================================================
393 # Checks for packaging specific options.
394 # ===================================================================
396 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
397             [ if test "$withval" != no && test "$withval" != yes; then
398                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
399               fi ])
401 # ===================================================================
402 # Checks for a libraries, optional even if installed.
403 # ===================================================================
405 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
406 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
408         AC_MSG_CHECKING([for $2 support])
410         if test "[$]$1" != no; then
411                 AC_MSG_RESULT(yes)
412                 EL_SAVE_FLAGS
413                 if test -n "$withval" && test -d "$withval"; then
414                         # Be a little more careful when setting
415                         # include and lib directories. This way
416                         # $withval will work when includes are
417                         # there but the library is in the common
418                         # /usr/lib ... Does the right thing when
419                         # looking for gc on Debian.
420                         if test -d "$withval/include"; then
421                                 CFLAGS="$CFLAGS -I$withval/include"
422                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
423                         else
424                                 CFLAGS="$CFLAGS -I$withval"
425                                 CPPFLAGS="$CPPFLAGS -I$withval"
426                         fi
427                         if test -d "$withval/lib"; then
428                                 LDFLAGS="$LDFLAGS -L$withval/lib"
429                         fi
430                 fi
432                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
433                 if test "[$]$1" = yes; then
434                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
435                 fi
437                 if test "[$]$1" = yes; then
438                         EL_CONFIG([$1], [$2])
439                         LIBS="$LIBS -l$4"
440                 else
441                         if test -n "[$]WITHVAL_$1" &&
442                            test "[$]WITHVAL_$1" != xno; then
443                                 AC_MSG_ERROR([$2 not found])
444                         fi
445                         EL_RESTORE_FLAGS
446                 fi
447         else
448                 AC_MSG_RESULT(disabled)
449         fi
452 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
453 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
455         if test "x[$]$1" != xno; then $1=yes; fi
456         WITHVAL_$1=
458         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
459         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
460         if test "x[$]WITHVAL_$1" = xyes; then $1=yes; fi
462         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
464         EL_LOG_CONFIG([$1], [$2], [])
467 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
468         [  --without-gpm           disable gpm (mouse) support])
470 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
471 # enable automatic decoding of both zlib and gzip headers.  This
472 # feature was added in zlib 1.2.0.2; earlier versions return an error.
473 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
474 # that, even though ELinks does not actually call gzclearerr.
475 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
476         [  --without-zlib          disable zlib support])
478 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
479         [  --without-bzlib         disable bzlib support])
481 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
482         [  --without-idn           disable international domain names support])
484 if test "x${with_gc}" != xno; then
485         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
486                 [  --with-gc               enable Boehm's garbage collector])
489 # LZMA disabled by default, because of little usability and compilation problems
490 # with new xz
491 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
492         [  --with-lzma             enable lzma encoding support])
494 # ===================================================================
495 # Check for GSSAPI, optional even if installed.
496 # ===================================================================
498 enable_gssapi="no";
500 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
501             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
503 AC_MSG_CHECKING([for GSSAPI])
505 if test "$enable_gssapi" = "yes"; then
506         AC_MSG_RESULT(yes)
507         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
508         GSSAPI_LIBS=`krb5-config --libs gssapi`
509         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
510         LIBS="$GSSAPI_LIBS $LIBS"
511         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
512 else
513         AC_MSG_RESULT(no)
516 AC_SUBST(CONFIG_GSSAPI)
518 # ===================================================================
519 # Bookmark and XBEL support
520 # ===================================================================
522 EL_SAVE_FLAGS
524 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
525               [  --disable-bookmarks     disable bookmark support])
527 # Check whether --enable-xbel or --disable-xbel was given.
528 if test "x${enable_xbel}" != xno; then
529         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
531         if test "$HAVE_LIBEXPAT" = yes; then
532                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
533                 if test "$HAVE_LIBEXPAT" = yes; then
534                         LIBS="$LIBS -lexpat"
535                 fi
536         fi
540 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
541               [XBEL bookmarks],
542               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
544 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
545         EL_RESTORE_FLAGS
548 # ===================================================================
549 # Checks for BSD sysmouse
550 # ===================================================================
552 HAVE_SYSMOUSE_HEADER="no"
554 # Either of these header files provides the (same) sysmouse interface
555 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
557 # ===================================================================
558 # Checks for OS/2
559 # ===================================================================
561 if test "$CONFIG_OS_OS2" = yes; then
562         EL_CONFIG_OS_OS2
565 # ===================================================================
566 # Checks for Win32
567 # ===================================================================
569 if test "$CONFIG_OS_WIN32" = yes; then
570         EL_CONFIG_OS_WIN32
573 # ===================================================================
574 # Check for SEE (Simple Ecmascript Engine)
575 # ===================================================================
576 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
577             [ if test "x$withval" != xno; then enable_see=yes; fi ])
579 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
580 # GUILE_FLAGS but I really don't want to require people to have Guile in order
581 # to compile CVS. Also, the macro seems to be really stupid regarding searching
582 # for Guile in $PATH etc. --pasky
584 CONFIG_ECMASCRIPT_SEE=no
586 if test "$enable_see" = "yes"; then
587         if test -d "$withval"; then
588                 SEE_PATH="$withval:$PATH"
589         else
590                 SEE_PATH="$PATH"
591         fi
593         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
594         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
595         if test "$SEE_CONFIG" != no; then
596                 EL_SAVE_FLAGS
597                 SEE_LIBS="`$SEE_CONFIG --libs`"
598                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
599                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
600                 LIBS="$SEE_LIBS $LIBS_X"
601                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
602                         #error SEE too old
603                         #endif
604                 ]])],[cf_result=yes],[cf_result=no])
605                 EL_RESTORE_FLAGS
606                 if test "$cf_result" = yes; then
607                         LIBS="$SEE_LIBS $LIBS"
608                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
609                         AC_SUBST(SEE_CFLAGS)
610                 fi
611                 AC_MSG_RESULT($cf_result)
612         else
613                 if test -n "$withval" && test "x$withval" != xno; then
614                         AC_MSG_ERROR([SEE not found])
615                 else
616                         AC_MSG_WARN([SEE support disabled])
617                 fi
618         fi
621 # ===================================================================
622 # Check for SpiderMonkey, optional even if installed.
623 # ===================================================================
625 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
626             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
627 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
629 EL_SAVE_FLAGS
630 cf_result=no
632 if test -z "$disable_spidermonkey"; then
633         if test ! -d "$withval"; then
634                 withval="";
635         fi
636         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
637                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
638                         for spidermonkeylib in js smjs mozjs; do
639                                 if test "$cf_result" = no; then
640                                         SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
641                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
643                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
644                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
645                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
647                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
648                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
649                                 fi
650                         done
651                 done
652         done
655 AC_MSG_RESULT($cf_result)
656 CONFIG_SPIDERMONKEY="$cf_result"
657 if test "$cf_result" = "yes"; then
658         AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]])
659         AC_CHECK_FUNCS(JS_SetBranchCallback)
660         AC_CHECK_FUNCS(JS_TriggerOperationCallback, HAVE_JS_TRIGGEROPERATIONCALLBACK=yes)
662 EL_RESTORE_FLAGS
664 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
665    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
666         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
667 else
668         CONFIG_ECMASCRIPT_SMJS=no
671 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
672 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
673 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
675 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
676    test "x$HAVE_JS_TRIGGEROPERATIONCALLBACK" = xyes &&
677    test "x$HAVE_SETITIMER" = xyes; then
678         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT, [ECMAScript heartbeat support])
679 else
680         CONFIG_ECMASCRIPT_SMJS_HEARTBEAT=no
682 AC_SUBST(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
685 # ===================================================================
686 # Optional Spidermonkey-based ECMAScript browser scripting
687 # ===================================================================
689 AC_ARG_ENABLE(sm-scripting,
690               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
691               [if test "$enableval" != no; then enableval="yes"; fi
692                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
694 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
695    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
696         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
697 else
698         CONFIG_SCRIPTING_SPIDERMONKEY=no
701 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
702    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
703         LIBS="$LIBS $SPIDERMONKEY_LIBS"
704         AC_SUBST(SPIDERMONKEY_LIBS)
705         AC_SUBST(SPIDERMONKEY_CFLAGS)
706         AC_SUBST(CONFIG_SPIDERMONKEY)
709 # ===================================================================
710 # Check for Guile, optional even if installed.
711 # ===================================================================
713 enable_guile="no";
715 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
716             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
718 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
719 # GUILE_FLAGS but I really don't want to require people to have Guile in order
720 # to compile CVS. Also, the macro seems to be really stupid regarding searching
721 # for Guile in $PATH etc. --pasky
723 AC_MSG_CHECKING([for Guile])
725 if test "$enable_guile" = "yes"; then
726         AC_MSG_RESULT(yes);
727         ## Based on the GUILE_FLAGS macro.
729         if test -d "$withval"; then
730                 GUILE_PATH="$withval:$PATH"
731         else
732                 GUILE_PATH="$PATH"
733         fi
735         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
737         ## First, let's just see if we can find Guile at all.
738         if test "$GUILE_CONFIG" != no; then
739                 cf_result="yes";
741                 GUILE_LIBS="`guile-config link`"
742                 GUILE_CFLAGS="`guile-config compile`"
743                 LIBS="$GUILE_LIBS $LIBS"
744                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
745                 AC_SUBST(GUILE_CFLAGS)
746                 cat <<EOF
747 ***********************************************************************
748 The Guile support is incomplete and not so well integrated to ELinks
749 yet. That means, e.g., that you have no Guile console and there might
750 not be all the necessary hooks. Also, the Guile interface is not too
751 well tested (success stories heartily welcomed!).  See
752 src/scripting/guile/README for further details and hints.
753 ***********************************************************************
755         else
756                 if test -n "$withval" && test "x$withval" != xno; then
757                         AC_MSG_ERROR([Guile not found])
758                 else
759                         AC_MSG_WARN([Guile support disabled])
760                 fi
761         fi
762 else
763         AC_MSG_RESULT(no);
766 # ===================================================================
767 # Check for Perl
768 # ===================================================================
769 enable_perl="no";
771 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
772             [
773 if test "$withval" = yes; then
774         # FIXME: If withval is a valid directory append it to PATH
775         # so that you can specify one of several perl installations.
776         withval="";
777         enable_perl=yes;
779             ])
781 AC_MSG_CHECKING([for Perl])
783 cf_result=no
785 EL_SAVE_FLAGS
787 if test "$enable_perl" = "yes"; then
788         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
789         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
790         LIBS="$PERL_LIBS $LIBS"
791         CFLAGS="$PERL_CFLAGS $CFLAGS"
792         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
793         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
794 #include <EXTERN.h>
795 #include <perl.h>
796 #include <perlapi.h>
797 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
800 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
802 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
803 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
804 #include <EXTERN.h>
805 #include <perl.h>
806 extern PerlInterpreter *my_perl;
807 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
808 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
809                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
810 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
812 if test "$cf_result" != "yes"; then
813         EL_RESTORE_FLAGS
814 else
815         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
817         CFLAGS="$CFLAGS_X"
818         CPPFLAGS="$CPPFLAGS_X"
819         AC_SUBST(PERL_LIBS)
820         AC_SUBST(PERL_CFLAGS)
823 # ===================================================================
824 # Check for Python
825 # ===================================================================
826 enable_python="no";
828 AC_ARG_WITH(python, [[  --with-python[=DIR]     enable Python support]],
829             [ if test "x$withval" != xno; then enable_python=yes; fi ])
831 EL_SAVE_FLAGS
832 cf_result=no
834 AC_MSG_CHECKING([for Python])
836 if test "$enable_python" = "yes"; then
837         AC_MSG_RESULT(yes);
839         if test -d "$withval"; then
840                 PYTHON_PATH="$withval:$PATH"
841         else
842                 PYTHON_PATH="$PATH"
843         fi
845         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
847         if test "$PYTHON" != no; then
848                 cf_result="yes";
850                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
851                 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"))'`"
852                 LIBS="$PYTHON_LIBS $LIBS"
853                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
854                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
856                 if test "$cf_result" != "yes"; then
857                         EL_RESTORE_FLAGS
858                 else
859                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
860                         AC_SUBST(PYTHON_LIBS)
861                         AC_SUBST(PYTHON_CFLAGS)
862                         CPPFLAGS="$CPPFLAGS_X"
863                         cat <<EOF
864 ***********************************************************************
865 The Python support is incomplete and not so well integrated to ELinks
866 yet. That means, e.g., that you have no Python console and there might
867 not be all the necessary hooks. Also, the Python interface is not too
868 well tested (success stories heartily welcomed!).
869 ***********************************************************************
871                 fi
872         else
873                 if test -n "$withval" && test "x$withval" != xno; then
874                         AC_MSG_ERROR([Python not found])
875                 else
876                         AC_MSG_WARN([Python support disabled])
877                 fi
878         fi
879 else
880         AC_MSG_RESULT(no);
884 # ===================================================================
885 # Check for Lua, optional even if installed.
886 # ===================================================================
888 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
889 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
891 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
892             [if test "$withval" = no; then disable_lua=yes; fi])
893 AC_MSG_CHECKING([for Lua])
895 EL_SAVE_FLAGS
896 cf_result=no
898 if test -z "$disable_lua"; then
899         if test ! -d "$withval"; then
900                 withval="";
901         fi
902         for luadir in "$withval" "" /usr /usr/local; do
903                 for suffix in "" 50; do
904                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
905                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
906                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
907                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
909                                 LIBS="$LUA_LIBS $LIBS_X"
910                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
911                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
913                                 # Check that it is a compatible Lua version
914                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
915                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
916                                                 luaopen_base(L);
917                                                 luaopen_table(L);
918                                                 luaopen_io(L);
919                                                 luaopen_string(L);
920                                                 luaopen_math(L);
921                                                 lua_pushboolean(L, 1);
922                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
923                         fi
924                 done
925         done
928 AC_MSG_RESULT($cf_result)
930 if test "$cf_result" != yes; then
931         EL_RESTORE_FLAGS
932 else
933         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
934         AC_CHECK_HEADERS(lauxlib.h)
936         CFLAGS="$CFLAGS_X"
937         CPPFLAGS="$CPPFLAGS_X"
938         AC_SUBST(LUA_LIBS)
939         AC_SUBST(LUA_CFLAGS)
942 # ===================================================================
943 # Check for TRE library
944 # ===================================================================
946 # This section only checks that --without-tre is not given and the
947 # library seems to work, and sets TRE_CFLAGS, TRE_LIBS, and
948 # tre_log.  It does not define CONFIG_TRE, and always resets
949 # LIBS and CFLAGS back to their original values.
951 # After any --enable-utf-8 and --disable-utf-8 options have been
952 # handled, a separate section decides whether to actually use TRE.
954 # tre version 0.8.0 or higher is required which have the "tre_" prefix
955 # for functions.
957 AC_ARG_WITH([[tre]], [[  --without-tre           disable TRE regex search support]])
958 if test "$with_tre" = no; then
959         AC_MSG_CHECKING([[for TRE]])
960         AC_MSG_RESULT([[disabled]])
961         tre_log="no (explicitly disabled)"
962 else
963         AC_MSG_CHECKING([[for TRE in pkg-config]])
964         if pkg-config tre; then
965                 TRE_CFLAGS=`pkg-config --cflags tre`
966                 TRE_LIBS=`pkg-config --libs tre`
967                 AC_MSG_RESULT([[yes]])
968         else
969                 # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
970                 # "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
971                 # so we look for the library even if pkg-config doesn't know about it.
972                 TRE_CFLAGS=
973                 TRE_LIBS=-ltre
974                 AC_MSG_RESULT([[no, but let's try defaults]])
975         fi
977         AC_MSG_CHECKING([[for TRE header and library]])
978         EL_SAVE_FLAGS
979         CFLAGS="$TRE_CFLAGS $CFLAGS"
980         LIBS="$TRE_LIBS $LIBS" # must be first, because of regfree conflict
981         AC_TRY_LINK([#include <tre/tre.h>],
982                     [regex_t re;
983                      regmatch_t match[1];
984                      tre_regwcomp(&re, L"zap", REG_ICASE);
985                      tre_regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
986                     [AC_MSG_RESULT([[yes]])
987                      tre_log="available"],
988                     [AC_MSG_RESULT([[no]])
989                      tre_log="no (TRE not found)"])
990         EL_RESTORE_FLAGS
993 # ===================================================================
994 # Check for Ruby, optional even if installed.
995 # ===================================================================
997 EL_CONFIG_SCRIPTING_RUBY
999 # ===================================================================
1000 # Setup global scripting
1001 # ===================================================================
1003 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])
1004 AC_SUBST(CONFIG_SCRIPTING_GUILE)
1005 AC_SUBST(CONFIG_SCRIPTING_LUA)
1006 AC_SUBST(CONFIG_SCRIPTING_PERL)
1007 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
1008 AC_SUBST(CONFIG_SCRIPTING_RUBY)
1009 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
1010 AC_SUBST(CONFIG_SCRIPTING)
1013 # ===================================================================
1014 # Check for SSL support.
1015 # ===================================================================
1017 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
1018 # is enabled, we won't try to use OpenSSL anymore.
1020 # For wiping SSL hooks..
1021 #ifdef CONFIG_SSL
1023 chosen_ssl_library=""
1025 AC_ARG_WITH(gnutls, [[  --without-gnutls        disable GNUTLS SSL support]])
1026 AC_ARG_WITH(gnutls, [[  --with-gnutls           enable GNUTLS SSL support]],
1027             [case "$with_gnutls" in
1028                 "no")   : ;;
1029                 "yes")  chosen_ssl_library="GNUTLS" ;;
1030                 *)      chosen_ssl_library="GNUTLS"
1031                         AC_MSG_WARN([[Support for --with-gnutls=DIR has been removed.
1032 You may have to set the PKG_CONFIG_PATH environment variable instead.]]) ;;
1033              esac])
1035 AC_ARG_WITH(openssl, [[  --without-openssl       disable OpenSSL support]])
1036 AC_ARG_WITH(openssl, [[  --with-openssl[=DIR]    enable OpenSSL support (default)]],
1037             [case "$with_openssl" in
1038                 "no")   : ;;
1039                 *)      chosen_ssl_library="OpenSSL" ;;
1040              esac])
1042 AC_ARG_WITH(nss_compat_ossl, [[  --with-nss_compat_ossl[=DIR]
1043                           NSS compatibility SSL libraries/include files]],
1044             [case "$with_nss_compat_ossl" in
1045                 "no")   : ;;
1046                 *)      chosen_ssl_library="nss_compat_ossl" ;;
1047              esac])
1049 # ---- nss_compat_ossl
1051 if test "$with_nss_compat_ossl" = no; then
1052         # explicitly disabled
1053         :
1054 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "nss_compat_ossl"; then
1055         # not used, because $chosen_ssl_library was chosen
1056         :
1057 elif test -z "${with_nss_compat_ossl+set}"; then
1058         # SSL_library_init() in nss_compat_ossl 0.9.2 calls exit(1)
1059         # with no error message if there is no certificate database.
1060         # https://bugzilla.redhat.com/show_bug.cgi?id=463437
1061         # So ELinks uses nss_compat_ossl only if explicitly requested.
1062         :
1063 else
1064         EL_SAVE_FLAGS
1065         if test "$with_nss_compat_ossl" = yes; then
1066                 if pkg-config nss; then
1067                         CFLAGS="$CFLAGS_X `pkg-config --cflags nss`"
1068                         LIBS="$LIBS_X `pkg-config --libs nss`"
1069                 else
1070                         with_nss_compat_ossl=no
1071                 fi
1072         else
1073                 # Without pkg-config, we'll kludge in some defaults
1074                 CFLAGS="$CFLAGS_X -I$with_nss_compat_ossl/include -I/usr/include/nss3 -I/usr/include/nspr4"
1075                 LIBS="$LIBS_X -L$with_nss_compat_ossl/lib -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
1076         fi
1077         AC_CHECK_HEADERS(nss_compat_ossl/nss_compat_ossl.h,, [with_nss_compat_ossl=no], [#define NSS_COMPAT_OSSL_H])
1078         AC_CHECK_LIB(nss_compat_ossl, X509_free,, [with_nss_compat_ossl=no])
1080         if test "$with_nss_compat_ossl" = "no"; then
1081                 EL_RESTORE_FLAGS
1082         else
1083                 LIBS="$LIBS -lnss_compat_ossl"
1084                 EL_CONFIG(CONFIG_NSS_COMPAT_OSSL, [nss_compat_ossl])
1085                 chosen_ssl_library="nss_compat_ossl"
1086         fi
1089 # ---- OpenSSL
1091 AC_MSG_CHECKING([for OpenSSL])
1093 EL_SAVE_FLAGS
1095 if test "$with_openssl" = no; then
1096         cf_result="explicitly disabled"
1098 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "OpenSSL"; then
1099         cf_result="not used, because $chosen_ssl_library was chosen"
1101 else
1102         cf_result=no
1103         for ssldir in "$with_openssl" "" /usr /usr/local/openssl \
1104                          /usr/lib/openssl /usr/local/ssl \
1105                          /usr/local/www /usr/lib/ssl /usr/local \
1106                          /usr/pkg /opt /opt/openssl; do
1107                 if test "$cf_result" = no; then
1108                         if test -d "$ssldir"; then
1109                                 OPENSSL_CFLAGS="-I$ssldir/include"
1110                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1111                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1112                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1113 #                               # FIXME: This created serious portability problems. --pasky
1114 #                               if test "$CC" == "gcc"; then
1115 #                                       # I'm not sure about compatibility here. --pasky
1116 #                                       LIBS="$LIBS -R$ssldir/lib"
1117 #                               fi
1118                         else
1119                                 LIBS="-lssl -lcrypto $LIBS_X"
1120                         fi
1121                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1122                         if test "$cf_result" != yes; then
1123                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1124                         fi
1125                 fi
1126         done
1128         if test "$cf_result" != yes; then
1129                 if test "${with_openssl-no}" != "no"; then
1130                         AC_MSG_ERROR([OpenSSL not found])
1131                 fi
1132                 EL_RESTORE_FLAGS
1133         else
1134                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1135                 chosen_ssl_library="OpenSSL"
1137                 CFLAGS="$CFLAGS_X"
1138                 AC_SUBST(OPENSSL_CFLAGS)
1139         fi
1142 AC_MSG_RESULT($cf_result)
1144 # ---- GNU TLS
1146 # GnuTLS 2.2.0 changed libgnutls-openssl from GPLv2+
1147 # to GPLv3+.  Don't link that with the GPLv2 ELinks.
1148 # ELinks will use its internal MD5 code instead.
1149 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1151 if test "$with_gnutls" = no; then
1152         AC_MSG_CHECKING([[for GNUTLS]])
1153         AC_MSG_RESULT([[explicitly disabled]])
1155 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "GNUTLS"; then
1156         AC_MSG_CHECKING([[for GNUTLS]])
1157         AC_MSG_RESULT([[not used, because $chosen_ssl_library was chosen]])
1159 else
1160         cf_result=no
1161         AC_MSG_CHECKING([[for GNUTLS (1.2 or later) in pkg-config]])
1162         if pkg-config --atleast-version=1.2 gnutls; then
1163                 GNUTLS_CFLAGS=`pkg-config --cflags gnutls`
1164                 GNUTLS_LIBS=`pkg-config --libs gnutls`
1165                 AC_MSG_RESULT([[yes: $GNUTLS_CFLAGS $GNUTLS_LIBS]])
1167                 EL_SAVE_FLAGS
1168                 LIBS="$GNUTLS_LIBS $LIBS"
1169                 CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
1170                 CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
1172                 # Verify if it's really usable.  gnutls_session was
1173                 # renamed to gnutls_session_t before GNU TLS 1.2.0
1174                 # (on 2004-06-13); ELinks now requires this.
1175                 AC_MSG_CHECKING([[whether GNUTLS can be linked with]])
1176                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]],
1177                                                 [[gnutls_session_t dummy;
1178                                                   gnutls_check_version(NULL)]])],
1179                                [cf_result=yes],
1180                                [cf_result=no])
1181                 AC_MSG_RESULT([[$cf_result]])
1183                 if test "$cf_result" = yes; then
1184                         # According to gnutls/NEWS, the function was originally
1185                         # added as gnutls_set_default_priority2 in GNUTLS 2.1.4
1186                         # (released 2007-10-27) and then renamed to
1187                         # gnutls_priority_set_direct in GNUTLS 2.1.7 (released
1188                         # 2007-11-29).
1189                         AC_CHECK_FUNCS([gnutls_priority_set_direct])
1190                 fi
1192                 EL_RESTORE_FLAGS
1193         else
1194                 AC_MSG_RESULT([[$cf_result]])
1195         fi
1197         if test "$cf_result" = yes; then
1198                 EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1199                 chosen_ssl_library="GNUTLS"
1201                 LIBS="$GNUTLS_LIBS $LIBS"
1202                 AC_SUBST(GNUTLS_CFLAGS)
1204         elif test "${with_gnutls-no}" != "no"; then
1205                 AC_MSG_ERROR([[GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.]])
1206         fi
1209 # Final SSL setup
1211 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS CONFIG_NSS_COMPAT_OSSL], [SSL])
1212 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1213 AC_SUBST(CONFIG_OPENSSL)
1214 AC_SUBST(CONFIG_GNUTLS)
1215 AC_SUBST(CONFIG_NSS_COMPAT_OSSL)
1217 #endif
1219 AC_MSG_CHECKING([whether to be or not to be])
1220 AC_MSG_RESULT([needs to be determined experimentally])
1222 # ===================================================================
1223 # Check for IPv6 support and related functions.
1224 # ===================================================================
1226 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1227 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1228 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1230 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1231 if test "$HAVE_GETADDRINFO" != yes; then
1232         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1233         if test "$HAVE_GETADDRINFO" = yes; then
1234                 LIBS="$LIBS -linet6"
1235         fi
1239 # ===================================================================
1240 # Checking for X11 (window title restoring).
1241 # ===================================================================
1243 AC_PATH_X
1244 if test x"$no_x" != xyes; then
1245         EL_SAVE_FLAGS
1246         if test -n "$x_includes"; then
1247                 X_CFLAGS="-I$x_includes"
1248                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1249                 CFLAGS="$CFLAGS $X_CFLAGS"
1250         fi
1251         if test -n "$x_libraries"; then
1252                 LDFLAGS="$LDFLAGS -L$x_libraries"
1253         fi
1254         LIBS="-lX11 $LIBS"
1255         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1256         EL_RESTORE_FLAGS
1257         if test "$cf_result" = yes; then
1258                 if test -n "$x_libraries"; then
1259                         LDFLAGS="$LDFLAGS -L$x_libraries"
1260                 fi
1261                 LIBS="-lX11 $LIBS"
1262                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1263                 AC_SUBST(X_CFLAGS)
1264         fi
1268 # ===================================================================
1269 # Backtraces displaying support.
1270 # ===================================================================
1272 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1273 # possible checks for other system-specific means go here
1276 # ===================================================================
1277 # Gettext grey zone. Beware.
1278 # ===================================================================
1280 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"
1282 AM_GNU_GETTEXT
1284 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1285 dnl # f33r d4 l33t... I hope it's portable. :)
1286 dnl cf_result=$((48#z - 48#a + 1));
1287 dnl AC_MSG_RESULT($cf_result)
1290 # ===================================================================
1291 # Compile-time features control
1292 # ===================================================================
1294 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1295               [  --disable-cookies       disable cookie support])
1297 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1298               [  --disable-formhist      disable form history support])
1300 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1301               [  --disable-globhist      disable global history support])
1304 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1305               [  --disable-mailcap       disable mailcap support])
1307 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1308               [  --disable-mimetypes     disable mimetypes files support])
1311 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1312               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1313               [IPv6],
1314               [  --disable-ipv6          disable IPv6 support])
1316 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1317               [  --enable-bittorrent     enable BitTorrent protocol support])
1319 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1320               [  --disable-data          disable data protocol support])
1322 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1323               [  --disable-uri-rewrite   disable URI rewrite support])
1325 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1326               [  --enable-cgi            enable local CGI support])
1328 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1329               [  --enable-finger         enable finger protocol support])
1331 # ===================================================================
1332 # FSP protocol
1333 # ===================================================================
1334 EL_SAVE_FLAGS
1336 if test "x${enable_fsp}" != xno; then
1337         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1339         if test "$HAVE_FSPLIB" = yes; then
1340                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1341                 if test "$HAVE_FSPLIB" = yes; then
1342                         LIBS="$LIBS -lfsplib"
1343                 else
1344                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1345                         if test "$HAVE_FSPLIB" = yes; then
1346                                 LIBS="$LIBS -lfsp"
1347                         fi
1348                 fi
1349         fi
1352 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1353               [  --enable-fsp            enable FSP protocol support])
1355 if test "x$CONFIG_FSP" = xno; then
1356         EL_RESTORE_FLAGS
1359 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1360               [  --disable-ftp           disable ftp protocol support])
1362 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1363               [  --enable-gopher         enable gopher protocol support])
1365 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1366               [  --enable-nntp           enable nntp protocol support])
1368 # ===================================================================
1369 # SMB protocol support.
1370 # ===================================================================
1371 EL_SAVE_FLAGS
1373 if test "x${enable_smb}" != xno; then
1374         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1376         if test "$HAVE_SMBCLIENT" = yes; then
1377                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1378                 if test "$HAVE_SMBCLIENT" = yes; then
1379                         LIBS="$LIBS -lsmbclient"
1380                 fi
1381         fi
1384 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1385               [  --enable-smb            enable Samba protocol support])
1387 if test "x$CONFIG_SMB" = xno; then
1388         EL_RESTORE_FLAGS
1392 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1393               [  --disable-mouse         disable mouse support])
1395 # GPM mouse is Linux specific, so ...
1396 CONFIG_SYSMOUSE=yes
1397 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1398               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1399               [BSD sysmouse],
1400               [  --disable-sysmouse      disable BSD sysmouse support])
1402 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1403               [  --enable-88-colors      enable 88 color support])
1405 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1406               [  --enable-256-colors     enable 256 color support])
1408 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1409               [  --enable-true-color     enable true color support])
1411 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1412               [  --enable-exmode         enable exmode (CLI) interface])
1414 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1415               [  --disable-leds          disable LEDs support])
1417 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1418               [  --disable-marks         disable document marks support])
1421 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1422               [  --disable-css           disable Cascading Style Sheet support])
1424 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1425               [  --enable-html-highlight HTML highlighting using DOM engine])
1427 # Everything in the tree already uses CONFIG_DOM
1428 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1429 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1431 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1432               [  --disable-backtrace     disable backtrace support])
1434 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1435               [  --enable-no-root        enable prevention of usage by root])
1438 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1439               [  --enable-debug          enable leak debug and internal error checking])
1441 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1442               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1444 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1445               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1447 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1448               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1450 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1451               [  --disable-utf-8         disable UTF-8 support])
1453 EL_ARG_DEPEND(CONFIG_COMBINE, combining, [CONFIG_UTF8:yes HAVE_WCWIDTH:yes], [Combining characters],
1454               [  --enable-combining      support Unicode combining characters (experimental)])
1457 AC_ARG_ENABLE(weehoofooboomookerchoo,
1458               [
1459     Also check out the features.conf file for more information about features!
1460               ],
1461               [AC_MSG_ERROR(Are you strange, or what?)])
1464 # ===================================================================
1465 # Decide whether to use TRE
1466 # ===================================================================
1468 # This must be done after the CONFIG_UTF8 check above.
1469 # The first part of the TRE check is separate, to get
1470 # the configure --help output in a sensible order.
1472 # After this section, nothing else must be added to the
1473 # beginning of $LIBS.
1475 if test "$tre_log" = "available"; then
1476         if test "$CONFIG_UTF8" = "yes"; then
1477                 # When CONFIG_UTF8 and CONFIG_TRE are both defined,
1478                 # src/viewer/text/search.c makes a string of
1479                 # unicode_val_T and gives it to regwexec(), which
1480                 # expects a string of wchar_t.  If the unicode_val_T
1481                 # and wchar_t types are too different, this won't
1482                 # work, so try to detect that and disable regexp
1483                 # operations entirely in that case.
1484                 #
1485                 # Currently, this code only compares the sizes of the
1486                 # types.  src/intl/charsets.h defines unicode_val_T as
1487                 # uint32_t, so we check whether wchar_t has exactly 32
1488                 # bits.  But don't use AC_CHECK_SIZEOF for this, because
1489                 # there doesn't seem to be a documented way to get the
1490                 # result of that for use in the configure script.
1491                 #
1492                 # C99 says the implementation can define
1493                 # __STDC_ISO_10646__ if wchar_t values match ISO 10646
1494                 # (or Unicode) numbers in all locales.  Do not check
1495                 # that macro here, because it is too restrictive: it
1496                 # should be enough for ELinks if the values match in
1497                 # the locales where ELinks is actually run.
1498                 AC_MSG_CHECKING([[whether wchar_t is exactly 32-bit]])
1499                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1500 #include <limits.h>
1501 #include <stddef.h>
1502 int dummy[(sizeof(wchar_t) * CHAR_BIT == 32) ? 1 : -1];]], [])],
1503                         [AC_MSG_RESULT([[yes]])
1504                          tre_log="TRE"],
1505                         [AC_MSG_RESULT([[no]])
1506                          tre_log="no (unsuitable wchar_t)"])
1507         else
1508                 # If UTF-8 is not used, then wchar_t doesn't matter.
1509                 tre_log="TRE"
1510         fi
1513 if test "$tre_log" = "TRE"; then
1514         AC_DEFINE([CONFIG_TRE], [1],
1515                 [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.])
1516         # TRE_CFLAGS will be used only where needed.
1517         #
1518         # Bug 1081: If both TRE and libc define the regfree function,
1519         # ELinks needs to use the version defined by TRE because
1520         # that's the one compatible with regex_t initialized by the
1521         # regwcomp function of TRE.  Therefore put $TRE_LIBS at the
1522         # very beginning of $LIBS so that the linker hopefully finds
1523         # regfree there before it examines libc.  In particular,
1524         # $PERL_LIBS appears to often include "-lc".
1525         #
1526         # This scheme still risks a crash if ELinks is linked with
1527         # some static library that uses GNU <regex.h> extensions that
1528         # TRE does not implement.  For example, the library might call
1529         # re_compile_pattern, which is found in GNU libc, and then
1530         # regfree, which is found in TRE and probably crashes with the
1531         # GNU-initialized regex_t.  Ways to avoid such crashes:
1532         #
1533         # - Change TRE so it defines only tre_... functions and does
1534         #   not attempt to override the POSIX names by default.
1535         #
1536         # - Change ELinks to access TRE only via dlopen and dlsym.
1537         #   The problem then is how to find the correct file name.
1538         #   There might be libtre.so.4 and libtre.so.5 with different
1539         #   ABI.  How can this configure script detect which of them
1540         #   matches the <tre/regex.h> in the include path?
1541         #
1542         # - Replace the static library with a shared library.  At
1543         #   least on GNU/Linux, when the shared library is built, the
1544         #   linker should note that e.g. regfree is defined in libc
1545         #   and has the GLIBC_2.0 version there, and write that
1546         #   version string to the shared library as well; because TRE
1547         #   does not provide regfree with that version, any regfree
1548         #   calls at run time should then get resolved to libc.
1549         LIBS="$TRE_LIBS $LIBS"
1550 else
1551         TRE_LIBS=
1552         TRE_CFLAGS=
1554 AC_SUBST(TRE_CFLAGS)
1555 AC_SUBST(TRE_LIBS)
1556 EL_LOG_CONFIG([CONFIG_TRE], [[Regexp searching]], [[$tre_log]])
1559 # ===================================================================
1560 # Further LDFLAGS tweaks
1561 # ===================================================================
1563 # == EMX hack
1565 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1566 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1569 # Check for -rdynamic
1571 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
1572 # the executable to its dynamic symbol table.  ELinks uses this for
1573 # two purposes:
1575 # 1. If ELinks detects a bug, it can try to display a backtrace by
1576 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
1577 #    manual states users of GNU ld must pass -rdynamic to make the
1578 #    symbols available to the program.
1580 # 2. It would eventually be nice to dynamically load shared
1581 #    libraries as plugins (bug 73).  The plugins must be able to
1582 #    call ELinks functions.  This can be implemented either by
1583 #    registering all callable functions in ELinks-specific data
1584 #    structures, or by letting the dynamic linker handle them.
1585 #    The latter way requires something equivalent to -rdynamic.
1587 # Because backtraces are not needed for correct operation, and bug
1588 # 73 is not yet being fixed, the configure script and makefiles
1589 # should not complain to the user if they find that -rdynamic does
1590 # not work.  Besides, it was reported at elinks-users on 2006-09-12
1591 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
1592 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
1593 # -rdynamic but does something equivalent automatically.  (This was
1594 # tested with "nm -D elinks | grep redraw_from_window".)
1596 # With Sun Studio 11 on Solaris 9, we get "cc: Warning: illegal option
1597 # -dynamic"; then, cc proceeds anyway, but the option can prevent the
1598 # linker from finding the libraries listed in -l operands.  So this
1599 # -rdynamic check needs to happen after the libraries have already
1600 # been added to $LDFLAGS.
1601 AC_MSG_CHECKING([for -rdynamic])
1602 LDFLAGS_X="$LDFLAGS"
1603 LDFLAGS="-rdynamic $LDFLAGS"
1604 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
1605 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
1606 AC_MSG_RESULT($have_rdynamic)
1608 # ===================================================================
1609 # Export directory paths
1610 # ===================================================================
1612 # Set up the ``entry points'' if they were not supplied by builder
1613 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1614 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1616 # Create CONFDIR #define for config.h
1618 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1619 # it's autoconf fault to force us to do such hacks ;p.
1620 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1621   # sysconfdir is set to its default value... fine, let's append /elinks/
1622   # XXX: We can't modify listing of the default in ./configure --help :-(
1623   sysconfdir_n=`eval echo "$sysconfdir"`
1624   sysconfdir=$sysconfdir_n
1625   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1626         sysconfdir="$sysconfdir/elinks"
1629 CONFDIR=$sysconfdir
1630 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1631 AC_SUBST(CONFDIR)
1633 # Create LOCALEDIR #define for config.h
1634 LOCALEDIR=`eval echo "$datadir/locale"`
1635 while echo "$LOCALEDIR" | grep "\\$"
1637         LOCALEDIR=`eval echo "$LOCALEDIR"`
1638 done > /dev/null 2> /dev/null
1639 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1640 AC_SUBST(LOCALEDIR)
1642 # Create LIBDIR #define for config.h
1643 LIBDIR=`eval echo "$libdir"`
1644 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1645 AC_SUBST(LIBDIR)
1647 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1648 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1651 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1652 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1653         #error not tcc
1654         #endif ]])],[cf_result=yes],[cf_result=no])
1656 if test "$cf_result" = "yes"; then
1657         AC_DEFINE([HAVE_ALLOCA])
1658         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1659                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1660                 override the alloca macro defined in <stddef.h> of TCC.
1661                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1662                 it has already been included, and does not redefine alloca.
1663                 This might not work in future glibc versions though, because
1664                 the names of the #include guard macros are not documented.
1665                 The incompatibility has been reported to the tinycc-devel
1666                 mailing list on 2008-07-14.  If a future version of TCC provides
1667                 an <alloca.h> of its own, this hack won't be needed.])
1669 # ===================================================================
1670 # A little fine tuning of gcc specific options (continued)
1671 # ===================================================================
1673 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1674   if test "$CONFIG_DEBUG" = "yes"; then
1675     # We want to see all warnings and live with none (in debug mode).
1676     CFLAGS="$CFLAGS -Werror"
1677   fi
1679   case "`$CC -dumpversion`" in
1680     3.0|3.1|3.2)
1681       # These should be ok using -Werror
1682       ;;
1683     3.*)
1684       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1685       # "dereferencing type-punned pointer will break strict-aliasing rules"
1686       # warnings. Disable them by not doing any strict-aliasing. The
1687       # alternative is just too ugly. Thanks gcc guys!! ;)
1688       CFLAGS="$CFLAGS -fno-strict-aliasing"
1689       ;;
1690     4.*)
1691       # Do not show warnings related to (char * | unsigned char *) type
1692       # difference.
1693       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1694       ;;
1695     *)
1696       # These should be ok using -Werror
1697       ;;
1698   esac
1700   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1701   # warning: the address of `builtin_modules' will always evaluate as `true'
1702   # This hits the object_lock and foreach_module macros in particular.
1703   # It would be okay to put something in the macros to avoid the warning,
1704   # but currently this seems to require defining parallel macros that skip
1705   # the NULL check, and that's too ugly.  So we instead disable the warning.
1706   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1707   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1708   for warning_flag in -Wno-address -Wno-always-true; do
1709     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1710     EL_SAVE_FLAGS
1711     CFLAGS="$CFLAGS $warning_flag"
1712     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1713       [AC_MSG_RESULT([yes])
1714        break],
1715       [AC_MSG_RESULT([no])])
1716     EL_RESTORE_FLAGS
1717   done
1719   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1720   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1721   # "warning: assuming signed overflow does not occur when assuming
1722   # that (X + c) > X is always true", which may be an incorrect
1723   # optimization (although allowed by the standard), and breaks the
1724   # build with -Werror.
1725   #
1726   # All of the following tests included -S -Wall -Wextra:
1727   #
1728   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1729   # * gcc-4.0 -O0: OK, compares the values
1730   # * gcc-4.0 -O2: assumes no overflow, does not warn
1731   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1732   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1733   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1734   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1735   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1736   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1737   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1738   #
1739   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1740   # * gcc-4.1 -O0: assumes no overflow, does not warn
1741   # * gcc-4.1 -O2: assumes no overflow, does not warn
1742   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1743   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1744   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1745   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1746   # * gcc-4.1 -O2 -ftrapv: compares the values
1747   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1748   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1749   #
1750   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1751   # * gcc-4.2 -O0: OK, compares the values
1752   # * gcc-4.2 -O2: assumes no overflow, warns about it
1753   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1754   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1755   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1756   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1757   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1758   # * gcc-4.2 -O2 -ftrapv: compares the values
1759   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1760   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1761   #
1762   # Apparently, -ftrapv does not work reliably at all.
1763   for overflow_flag in -fno-strict-overflow -fwrapv; do
1764     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1765     EL_SAVE_FLAGS
1766     CFLAGS="$CFLAGS $overflow_flag"
1767     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1768       [AC_MSG_RESULT([yes])
1769        break],
1770       [AC_MSG_RESULT([no])])
1771     EL_RESTORE_FLAGS
1772   done
1775 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1776 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1777 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1778 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1780 # ===================================================================
1781 # Colored make output
1782 # ===================================================================
1784 if test $(`which tput` colors) -ge 4; then
1785         MAKE_COLOR=1
1786         AC_SUBST(MAKE_COLOR)
1789 # ===================================================================
1790 # Generated files
1791 # ===================================================================
1793 AC_CONFIG_FILES([ \
1794  Makefile.config \
1795  contrib/elinks.spec \
1796  contrib/lua/hooks.lua \
1797  contrib/conv/w3m2links.awk \
1798  doc/Doxyfile \
1799  doc/man/man1/elinks.1 \
1800  src/intl/gettext/ref-add.sed \
1801  src/intl/gettext/ref-del.sed
1803 AC_OUTPUT
1805 abs_srcdir="$(cd "$srcdir" && pwd)"
1806 # builddir is always absolute!
1807 if test "$abs_srcdir" != "$builddir"; then
1808         # Bootstrap the Makefile creation
1809         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1810         "$MAKE" "SRC=$abs_srcdir" init
1812         # Make cg-status ignore this build directory
1813         echo "*" > "$builddir/.gitignore"
1816 # ===================================================================
1817 # Configuration summary
1818 # ===================================================================
1820 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1821 cat features.log