When checking for <net/if.h>, #include <sys/socket.h> first.
[elinks.git] / configure.in
blob31acfea964ee624c28ab8c9825c3b468309415f5
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.59 is installed in the computer that generates our nightly
10 dnl snapshots, so we need to be compatible with that.
11 AC_PREREQ(2.59)
12 AC_INIT
13 AC_CONFIG_SRCDIR([src/main/main.c])
14 AC_CONFIG_AUX_DIR(config)
16 PACKAGE=elinks
17 VERSION=0.12pre1.GIT
18 AC_SUBST(PACKAGE)
19 AC_SUBST(VERSION)
20 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
21 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
22 AC_CONFIG_HEADERS(config.h)
24 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
25 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
26 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
28 MAKE=
30 for make in gnumake gmake make false; do
31         if test "x$MAKE" = x; then
32                 AC_PATH_PROGS(MAKE, "$make")
33         fi
34 done
36 builddir="`pwd`"
38 # Cleanup if we are configuring with a previous build in the tree
39 if test -e Makefile.config; then
40         AC_MSG_CHECKING([for previous build to clean])
41         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
42         AC_MSG_RESULT(done)
45 # ===================================================================
46 # Load feature configuration file and start logging features.
47 # ===================================================================
49 features="features.conf"
50 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
51 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
52 echo "Feature summary:" > features.log
54 # ===================================================================
55 # Checks for programs.
56 # ===================================================================
58 AC_PROG_CC
59 AC_PROG_AWK
60 AC_PATH_PROGS(AWK, "$AWK")
61 AC_PROG_RANLIB
62 AC_PROG_INSTALL
64 AC_PATH_PROGS(GIT, "git")
65 AC_PATH_PROGS(SPARSE, "sparse")
67 CONFIG_ASCIIDOC="no"
68 CONFIG_POD2HTML="no"
69 CONFIG_XMLTO="no"
70 CONFIG_JW="no"
72 if test "x$CONFIG_DOC" != xno; then
73         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
74         if test "x$ASCIIDOC" != "x"; then
75                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
76                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
77                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
79                 echo > config.asciidoc-unsafe.txt
80                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
81                         ASCIIDOC_FLAGS=--unsafe
82                 fi
83                 rm config.asciidoc-unsafe.*
84         fi
86         AC_PATH_PROGS(XMLTO, "xmlto")
87         if test "x$XMLTO" != "x"; then
88                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
89                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
90                 EL_CONFIG(MAN_XMLTO, [man (groff)])
91         fi
93         AC_PATH_PROGS(JW, "jw")
94         if test "x$JW" != "x"; then
95                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
96                 EL_CONFIG(MANUAL_JW, [PDF])
97         fi
99         AC_PATH_PROGS(POD2HTML, "pod2html")
100         if test "x$POD2HTML" != "x"; then
101                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
102         fi
104         AC_PATH_PROGS(DOXYGEN, "doxygen")
105         if test "x$DOXYGEN" != "x"; then
106                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
107                 api_srcdir="$(cd "$srcdir" && pwd)/src"
108                 AC_SUBST(api_srcdir)
109         fi
112 AC_SUBST(ASCIIDOC_FLAGS)
113 AC_SUBST(CONFIG_ASCIIDOC)
114 AC_SUBST(CONFIG_DOXYGEN)
115 AC_SUBST(CONFIG_POD2HTML)
116 AC_SUBST(CONFIG_XMLTO)
117 AC_SUBST(CONFIG_JW)
119 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
120 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
121 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
122 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
124 # gcc specific options (to be continued at the bottom of configure)
125 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
126   # We want to see all warnings and live with none.
127   # We can't set up -Werror here as there may be some warnings in test
128   # suite of configure, and we don't want to fail them.
129   CFLAGS="$CFLAGS -Wall"
132 # ===================================================================
133 # Checks for special OSes.
134 # ===================================================================
136 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
137 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
139         AC_MSG_CHECKING([for $2])
141         for flag in $3; do
142                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
143 kill me!
144 #endif ]])],[$1=yes],[$1=no])
145                 if test "[$]$1" = yes; then
146                         EL_CONFIG([$1], [$2])
147                         break
148                 fi
149         done
151         AC_MSG_RESULT([$]$1)
154 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
155 AC_SUBST(CONFIG_OS_BEOS)
157 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
158 AC_SUBST(CONFIG_OS_RISCOS)
160 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
161 AC_SUBST(CONFIG_OS_WIN32)
163 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
164 AC_SUBST(CONFIG_OS_OS2)
165 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
167 AC_MSG_CHECKING([for UNIX])
168 dnl FIXME: some depend kind of mechanism
169 if test "$CONFIG_OS_BEOS" = no && \
170    test "$CONFIG_OS_RISCOS" = no && \
171    test "$CONFIG_OS_WIN32" = no && \
172    test "$CONFIG_OS_OS2" = no; then
173         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
174 else
175         CONFIG_OS_UNIX=no
177 AC_MSG_RESULT($CONFIG_OS_UNIX)
178 AC_SUBST(CONFIG_OS_UNIX)
180 # ===================================================================
181 # Checks for header files.
182 # ===================================================================
184 AC_HEADER_DIRENT
185 AC_HEADER_STDC
186 AC_HEADER_SYS_WAIT
187 AC_HEADER_TIME
189 AC_CHECK_HEADERS(wctype.h)
190 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
191 AC_CHECK_HEADERS(sigaction.h)
192 AC_CHECK_HEADERS(arpa/inet.h)
193 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
194 AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/in6_var.h)
195 AC_CHECK_HEADERS(ifaddrs.h)
196 AC_CHECK_HEADERS(sys/cygwin.h io.h)
197 AC_CHECK_HEADERS(sys/fmutex.h)
198 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
199 AC_CHECK_HEADERS(sys/resource.h)
200 AC_CHECK_HEADERS(sys/select.h)
201 AC_CHECK_HEADERS(sys/signal.h)
202 AC_CHECK_HEADERS(sys/socket.h)
203 AC_CHECK_HEADERS(sys/time.h)
204 AC_CHECK_HEADERS(sys/utsname.h)
205 AC_CHECK_HEADERS([net/if.h], [], [],
206 [[#ifdef HAVE_SYS_SOCKET_H
207 # include <sys/socket.h> /* <net/if.h> on Mac OS X 10.5.4 needs this */
208 #endif
210 AC_CHECK_HEADERS(stdint.h inttypes.h)
211 AC_CHECK_HEADERS(locale.h pwd.h)
212 AC_CHECK_HEADERS(termios.h)
215 AC_CHECK_HEADERS(sys/un.h,
216         [CONFIG_INTERLINK=yes
217          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
218         [CONFIG_INTERLINK=no])
219 AC_SUBST(CONFIG_INTERLINK)
221 # ===================================================================
222 # Checks for typedefs, structures, and compiler characteristics.
223 # ===================================================================
225 AC_STRUCT_TM
226 AC_C_CONST
227 AC_C_INLINE
228 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
230 AC_SYS_LARGEFILE
231 AC_TYPE_SIZE_T
232 AC_TYPE_OFF_T
233 EL_CHECK_TYPE(ssize_t, int)
234 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
235 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
236 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
237 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
238 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
240 AC_CHECK_SIZEOF(char, 1)
241 AC_CHECK_SIZEOF(short, 2)
242 AC_CHECK_SIZEOF(int, 4)
243 AC_CHECK_SIZEOF(long, 4)
244 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
245 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
247 # Check for variadic macros
248 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
249                 [#include <stdio.h>
250                  #define a(b,c...) printf(b,##c)],
251                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
253 # Check for -rdynamic
255 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
256 # the executable to its dynamic symbol table.  ELinks uses this for
257 # two purposes:
259 # 1. If ELinks detects a bug, it can try to display a backtrace by
260 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
261 #    manual states users of GNU ld must pass -rdynamic to make the
262 #    symbols available to the program.
264 # 2. It would eventually be nice to dynamically load shared
265 #    libraries as plugins (bug 73).  The plugins must be able to
266 #    call ELinks functions.  This can be implemented either by
267 #    registering all callable functions in ELinks-specific data
268 #    structures, or by letting the dynamic linker handle them.
269 #    The latter way requires something equivalent to -rdynamic.
271 # Because backtraces are not needed for correct operation, and bug
272 # 73 is not yet being fixed, the configure script and makefiles
273 # should not complain to the user if they find that -rdynamic does
274 # not work.  Besides, it was reported at elinks-users on 2006-09-12
275 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
276 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
277 # -rdynamic but does something equivalent automatically.  (This was
278 # tested with "nm -D elinks | grep redraw_from_window".)
280 # FIXME: This check doesn't work. Something to do with the compiler
281 # happily ignoring it and stderr not being checked for error messages.
282 AC_MSG_CHECKING([for -rdynamic])
283 LDFLAGS_X="$LDFLAGS"
284 LDFLAGS="$LDFLAGS -rdynamic"
285 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
286 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
287 AC_MSG_RESULT($have_rdynamic)
289 # ===================================================================
290 # Check for POSIX <regex.h>
291 # ===================================================================
293 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
295 # ===================================================================
296 # Checks for library functions.
297 # ===================================================================
299 AC_PROG_GCC_TRADITIONAL
300 AC_FUNC_MEMCMP
301 AC_FUNC_MMAP
302 AC_FUNC_STRFTIME
303 AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
304 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
305 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
306 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
307 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
308 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
309 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
310 AC_CHECK_FUNCS(gettimeofday clock_gettime)
312 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
314 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
315 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
316 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
318 # These aren't probably needed now, as they are commented in links.h.
319 # I've no idea about their historical background, but I keep them here
320 # just in the case they will help later. --pasky
321 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
322 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
323 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
324 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
326 if test x"$HAVE_RAISE" = x; then
327         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
328                 AC_MSG_ERROR([Unable to emulate raise()])
329         fi
332 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
333 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
334 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
335 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
336         EL_DEFINE(HAVE_VA_COPY, __va_copy)
339 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
340 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
341 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
342 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
343         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
346 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
347 AC_RUN_IFELSE([AC_LANG_SOURCE([[
348 #include <stdio.h>
349 #include <stdarg.h>
350 #include <stdlib.h>
351 #include <string.h>
353 char buf[8];
355 int bar(char *buf, const char *format, va_list ap)
357        return vsnprintf(buf, 0, format, ap);
360 void foo(const char *format, ...) {
361        va_list ap;
362        int len;
364        va_start(ap, format);
365        len = bar(buf, format, ap);
366        va_end(ap);
367        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
369        va_start(ap, format);
370        len = bar(buf, format, ap);
371        va_end(ap);
372        if ((len != 6) && (len != 7)) exit(1);
374        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
376        exit(0);
378 main() { foo("hello\n"); }
379 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
380 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
381         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
384 # OpenSSL and Lua frequently need dlopen
385 AC_CHECK_LIB(dl, dlopen)
387 # ===================================================================
388 # Checks for libraries.
389 # ===================================================================
391 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
392 if test "$cf_result" = no; then
393         AC_CHECK_LIB(socket, socket)
396 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
397 if test "$cf_result" = no; then
398         AC_CHECK_LIB(socket, setsockopt)
401 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
402 if test "$cf_result" = no; then
403         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
404         if test "$cf_result" = no; then
405                 AC_CHECK_LIB(nsl, gethostbyname)
406         else
407                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
408         fi
411 # ===================================================================
412 # Checks for packaging specific options.
413 # ===================================================================
415 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
416             [ if test "$withval" != no && test "$withval" != yes; then
417                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
418               fi ])
420 # ===================================================================
421 # Checks for a libraries, optional even if installed.
422 # ===================================================================
424 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
425 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
427         AC_MSG_CHECKING([for $2 support])
429         if test "[$]$1" != no; then
430                 AC_MSG_RESULT(yes)
431                 EL_SAVE_FLAGS
432                 if test -n "$withval" && test -d "$withval"; then
433                         # Be a little more careful when setting
434                         # include and lib directories. This way
435                         # $withval will work when includes are
436                         # there but the library is in the common
437                         # /usr/lib ... Does the right thing when
438                         # looking for gc on Debian.
439                         if test -d "$withval/include"; then
440                                 CFLAGS="$CFLAGS -I$withval/include"
441                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
442                         else
443                                 CFLAGS="$CFLAGS -I$withval"
444                                 CPPFLAGS="$CPPFLAGS -I$withval"
445                         fi
446                         if test -d "$withval/lib"; then
447                                 LDFLAGS="$LDFLAGS -L$withval/lib"
448                         fi
449                 fi
451                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
452                 if test "[$]$1" = yes; then
453                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
454                 fi
456                 if test "[$]$1" = yes; then
457                         EL_CONFIG([$1], [$2])
458                         LIBS="$LIBS -l$4"
459                 else
460                         if test -n "[$]WITHVAL_$1" &&
461                            test "[$]WITHVAL_$1" != xno; then
462                                 AC_MSG_ERROR([$2 not found])
463                         fi
464                         EL_RESTORE_FLAGS
465                 fi
466         else
467                 AC_MSG_RESULT(disabled)
468         fi
471 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
472 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
474         $1=yes
475         WITHVAL_$1=
477         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
478         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
480         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
482         EL_LOG_CONFIG([$1], [$2], [])
485 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
486         [  --without-gpm           disable gpm (mouse) support])
488 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
489 # enable automatic decoding of both zlib and gzip headers.  This
490 # feature was added in zlib 1.2.0.2; earlier versions return an error.
491 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
492 # that, even though ELinks does not actually call gzclearerr.
493 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
494         [  --without-zlib          disable zlib support])
496 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
497         [  --without-bzlib         disable bzlib support])
499 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
500         [  --without-idn           disable international domain names support])
502 if test "x{with_gc}" != xno; then
503         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
504                 [  --with-gc               enable Boehm's garbage collector])
507 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
508         [  --without-lzma          disable lzma encoding support])
510 # ===================================================================
511 # Check for GSSAPI, optional even if installed.
512 # ===================================================================
514 enable_gssapi="no";
516 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
517             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
519 AC_MSG_CHECKING([for GSSAPI])
521 if test "$enable_gssapi" = "yes"; then
522         AC_MSG_RESULT(yes)
523         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
524         GSSAPI_LIBS=`krb5-config --libs gssapi`
525         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
526         LIBS="$GSSAPI_LIBS $LIBS"
527         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
528 else
529         AC_MSG_RESULT(no)
532 AC_SUBST(CONFIG_GSSAPI)
534 # ===================================================================
535 # Bookmark and XBEL support
536 # ===================================================================
538 EL_SAVE_FLAGS
540 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
541               [  --disable-bookmarks     disable bookmark support])
543 # Check whether --enable-xbel or --disable-xbel was given.
544 if test "x${enable_xbel}" != xno; then
545         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
547         if test "$HAVE_LIBEXPAT" = yes; then
548                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
549                 if test "$HAVE_LIBEXPAT" = yes; then
550                         LIBS="$LIBS -lexpat"
551                 fi
552         fi
556 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
557               [XBEL bookmarks],
558               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
560 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
561         EL_RESTORE_FLAGS
564 # ===================================================================
565 # Checks for BSD sysmouse
566 # ===================================================================
568 HAVE_SYSMOUSE_HEADER="no"
570 # Either of these header files provides the (same) sysmouse interface
571 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
573 # ===================================================================
574 # Checks for OS/2
575 # ===================================================================
577 if test "$CONFIG_OS_OS2" = yes; then
578         EL_CONFIG_OS_OS2
581 # ===================================================================
582 # Checks for Win32
583 # ===================================================================
585 if test "$CONFIG_OS_WIN32" = yes; then
586         EL_CONFIG_OS_WIN32
589 # ===================================================================
590 # Check for SEE (Simple Ecmascript Engine)
591 # ===================================================================
592 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
593             [ if test "x$withval" != xno; then enable_see=yes; fi ])
595 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
596 # SEE_FLAGS but I really don't want to require people to have Guile in order
597 # to compile CVS. Also, the macro seems to be really stupid regarding searching
598 # for Guile in $PATH etc. --pasky
600 CONFIG_ECMASCRIPT_SEE=no
602 if test "$enable_see" = "yes"; then
603         if test -d "$withval"; then
604                 SEE_PATH="$withval:$PATH"
605         else
606                 SEE_PATH="$PATH"
607         fi
609         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
610         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
611         if test "$SEE_CONFIG" != no; then
612                 EL_SAVE_FLAGS
613                 SEE_LIBS="`$SEE_CONFIG --libs`"
614                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
615                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
616                 LIBS="$SEE_LIBS $LIBS_X"
617                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
618                         #error SEE too old
619                         #endif
620                 ]])],[cf_result=yes],[cf_result=no])
621                 EL_RESTORE_FLAGS
622                 if test "$cf_result" = yes; then
623                         LIBS="$SEE_LIBS $LIBS"
624                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
625                         AC_SUBST(SEE_CFLAGS)
626                 fi
627                 AC_MSG_RESULT($cf_result)
628         else
629                 if test -n "$withval" && test "x$withval" != xno; then
630                         AC_MSG_ERROR([SEE not found])
631                 else
632                         AC_MSG_WARN([SEE support disabled])
633                 fi
634         fi
637 # ===================================================================
638 # Check for SpiderMonkey, optional even if installed.
639 # ===================================================================
641 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
642             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
643 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
645 EL_SAVE_FLAGS
646 cf_result=no
648 if test -z "$disable_spidermonkey"; then
649         if test ! -d "$withval"; then
650                 withval="";
651         fi
652         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
653                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
654                         for spidermonkeylib in js smjs mozjs; do
655                                 if test "$cf_result" = no &&
656                                    test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then
657                                         SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
658                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
660                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
661                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
662                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
664                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
665                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
666                                 fi
667                         done
668                 done
669         done
672 AC_MSG_RESULT($cf_result)
673 CONFIG_SPIDERMONKEY="$cf_result"
674 EL_RESTORE_FLAGS
676 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
677    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
678         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
679 else
680         CONFIG_ECMASCRIPT_SMJS=no
683 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
684 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
685 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
688 # ===================================================================
689 # Optional Spidermonkey-based ECMAScript browser scripting
690 # ===================================================================
692 AC_ARG_ENABLE(sm-scripting,
693               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
694               [if test "$enableval" != no; then enableval="yes"; fi
695                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
697 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
698    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
699         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
700 else
701         CONFIG_SCRIPTING_SPIDERMONKEY=no
704 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
705    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
706         LIBS="$LIBS $SPIDERMONKEY_LIBS"
707         AC_SUBST(SPIDERMONKEY_LIBS)
708         AC_SUBST(SPIDERMONKEY_CFLAGS)
709         AC_SUBST(CONFIG_SPIDERMONKEY)
712 # ===================================================================
713 # Check for Guile, optional even if installed.
714 # ===================================================================
716 enable_guile="no";
718 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
719             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
721 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
722 # GUILE_FLAGS but I really don't want to require people to have Guile in order
723 # to compile CVS. Also, the macro seems to be really stupid regarding searching
724 # for Guile in $PATH etc. --pasky
726 AC_MSG_CHECKING([for Guile])
728 if test "$enable_guile" = "yes"; then
729         AC_MSG_RESULT(yes);
730         ## Based on the GUILE_FLAGS macro.
732         if test -d "$withval"; then
733                 GUILE_PATH="$withval:$PATH"
734         else
735                 GUILE_PATH="$PATH"
736         fi
738         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
740         ## First, let's just see if we can find Guile at all.
741         if test "$GUILE_CONFIG" != no; then
742                 cf_result="yes";
744                 GUILE_LIBS="`guile-config link`"
745                 GUILE_CFLAGS="`guile-config compile`"
746                 LIBS="$GUILE_LIBS $LIBS"
747                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
748                 AC_SUBST(GUILE_CFLAGS)
749                 cat <<EOF
750 ***********************************************************************
751 The Guile support is incomplete and not so well integrated to ELinks
752 yet. That means, e.g., that you have no Guile console and there might
753 not be all the necessary hooks. Also, the Guile interface is not too
754 well tested (success stories heartily welcomed!).  See
755 src/scripting/guile/README for further details and hints.
756 ***********************************************************************
758         else
759                 if test -n "$withval" && test "x$withval" != xno; then
760                         AC_MSG_ERROR([Guile not found])
761                 else
762                         AC_MSG_WARN([Guile support disabled])
763                 fi
764         fi
765 else
766         AC_MSG_RESULT(no);
769 # ===================================================================
770 # Check for Perl
771 # ===================================================================
772 enable_perl="no";
774 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
775             [
776 if test "$withval" = yes; then
777         # FIXME: If withval is a valid directory append it to PATH
778         # so that you can specify one of several perl installations.
779         withval="";
780         enable_perl=yes;
782             ])
784 AC_MSG_CHECKING([for Perl])
786 cf_result=no
788 EL_SAVE_FLAGS
790 if test "$enable_perl" = "yes"; then
791         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
792         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
793         LIBS="$PERL_LIBS $LIBS"
794         CFLAGS="$PERL_CFLAGS $CFLAGS"
795         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
796         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
797 #include <EXTERN.h>
798 #include <perl.h>
799 #include <perlapi.h>
800 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
803 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
805 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
806 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
807 #include <EXTERN.h>
808 #include <perl.h>
809 extern PerlInterpreter *my_perl;
810 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
811 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
812                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
813 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
815 if test "$cf_result" != "yes"; then
816         EL_RESTORE_FLAGS
817 else
818         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
820         CFLAGS="$CFLAGS_X"
821         CPPFLAGS="$CPPFLAGS_X"
822         AC_SUBST(PERL_LIBS)
823         AC_SUBST(PERL_CFLAGS)
826 # ===================================================================
827 # Check for Python
828 # ===================================================================
829 enable_python="no";
831 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
832             [ if test "x$withval" != xno; then enable_python=yes; fi ])
834 EL_SAVE_FLAGS
835 cf_result=no
837 AC_MSG_CHECKING([for Python])
839 if test "$enable_python" = "yes"; then
840         AC_MSG_RESULT(yes);
842         if test -d "$withval"; then
843                 PYTHON_PATH="$withval:$PATH"
844         else
845                 PYTHON_PATH="$PATH"
846         fi
848         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
850         if test "$PYTHON" != no; then
851                 cf_result="yes";
853                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
854                 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"))'`"
855                 LIBS="$PYTHON_LIBS $LIBS"
856                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
857                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
859                 if test "$cf_result" != "yes"; then
860                         EL_RESTORE_FLAGS
861                 else
862                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
863                         AC_SUBST(PYTHON_LIBS)
864                         AC_SUBST(PYTHON_CFLAGS)
865                         CPPFLAGS="$CPPFLAGS_X"
866                         cat <<EOF
867 ***********************************************************************
868 The Python support is incomplete and not so well integrated to ELinks
869 yet. That means, e.g., that you have no Python console and there might
870 not be all the necessary hooks. Also, the Python interface is not too
871 well tested (success stories heartily welcomed!).
872 ***********************************************************************
874                 fi
875         else
876                 if test -n "$withval" && test "x$withval" != xno; then
877                         AC_MSG_ERROR([Python not found])
878                 else
879                         AC_MSG_WARN([Python support disabled])
880                 fi
881         fi
882 else
883         AC_MSG_RESULT(no);
887 # ===================================================================
888 # Check for Lua, optional even if installed.
889 # ===================================================================
891 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
892 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
894 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
895             [if test "$withval" = no; then disable_lua=yes; fi])
896 AC_MSG_CHECKING([for Lua])
898 EL_SAVE_FLAGS
899 cf_result=no
901 if test -z "$disable_lua"; then
902         if test ! -d "$withval"; then
903                 withval="";
904         fi
905         for luadir in "$withval" "" /usr /usr/local; do
906                 for suffix in "" 50; do
907                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
908                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
909                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
910                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
912                                 LIBS="$LUA_LIBS $LIBS_X"
913                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
914                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
916                                 # Check that it is a compatible Lua version
917                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
918                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
919                                                 luaopen_base(L);
920                                                 luaopen_table(L);
921                                                 luaopen_io(L);
922                                                 luaopen_string(L);
923                                                 luaopen_math(L);
924                                                 lua_pushboolean(L, 1);
925                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
926                         fi
927                 done
928         done
931 AC_MSG_RESULT($cf_result)
933 if test "$cf_result" != yes; then
934         EL_RESTORE_FLAGS
935 else
936         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
937         AC_CHECK_HEADERS(lauxlib.h)
939         CFLAGS="$CFLAGS_X"
940         CPPFLAGS="$CPPFLAGS_X"
941         AC_SUBST(LUA_LIBS)
942         AC_SUBST(LUA_CFLAGS)
946 # ===================================================================
947 # Check for Ruby, optional even if installed.
948 # ===================================================================
950 EL_CONFIG_SCRIPTING_RUBY
952 # ===================================================================
953 # Setup global scripting
954 # ===================================================================
956 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])
957 AC_SUBST(CONFIG_SCRIPTING_GUILE)
958 AC_SUBST(CONFIG_SCRIPTING_LUA)
959 AC_SUBST(CONFIG_SCRIPTING_PERL)
960 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
961 AC_SUBST(CONFIG_SCRIPTING_RUBY)
962 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
963 AC_SUBST(CONFIG_SCRIPTING)
966 # ===================================================================
967 # Check for SSL support.
968 # ===================================================================
970 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
971 # is enabled, we won't try to use OpenSSL anymore.
973 # For wiping SSL hooks..
974 #ifdef CONFIG_SSL
976 disable_openssl=""
977 disable_gnutls=""
978 enable_gnutls=""
980 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
981             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
982 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
983             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
984 gnutls_withval="$withval"
986 if test "$enable_gnutls" = yes; then
987         disable_openssl=yes;
990 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
991             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
992 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
993 openssl_withval="$withval"
995 # ---- OpenSSL
997 AC_MSG_CHECKING([for OpenSSL])
999 EL_SAVE_FLAGS
1000 cf_result="no"
1002 if test "$disable_openssl" = yes; then
1003         cf_result="not used"
1004 else
1005         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
1006                          /usr/lib/openssl /usr/local/ssl \
1007                          /usr/local/www /usr/lib/ssl /usr/local \
1008                          /usr/pkg /opt /opt/openssl; do
1009                 if test "$cf_result" = no; then
1010                         if test -d "$ssldir"; then
1011                                 OPENSSL_CFLAGS="-I$ssldir/include"
1012                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1013                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1014                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1015 #                               # FIXME: This created serious portability problems. --pasky
1016 #                               if test "$CC" == "gcc"; then
1017 #                                       # I'm not sure about compatibility here. --pasky
1018 #                                       LIBS="$LIBS -R$ssldir/lib"
1019 #                               fi
1020                         else
1021                                 LIBS="-lssl -lcrypto $LIBS_X"
1022                         fi
1023                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1024                         if test "$cf_result" != yes; then
1025                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1026                         fi
1027                 fi
1028         done
1030         if test "$cf_result" != yes; then
1031                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1032                         AC_MSG_ERROR([OpenSSL not found])
1033                 fi
1034                 EL_RESTORE_FLAGS
1035         else
1036                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1038                 CFLAGS="$CFLAGS_X"
1039                 AC_SUBST(OPENSSL_CFLAGS)
1040         fi
1043 AC_MSG_RESULT($cf_result)
1045 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1046 # ---- GNU TLS
1047 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1048 dnl it looks ugly then.
1050 if test "$cf_result" = yes; then
1051         cf_result="not used"
1053 else
1054         EL_SAVE_FLAGS
1055         cf_result="no"
1057         if test -z "$disable_gnutls"; then
1058                 # Sure, we maybe _could_ use their macro, but how to ensure
1059                 # that the ./configure script won't fail if the macro won't be
1060                 # found..? :( --pasky
1062                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1064                 if test -d "$gnutls_withval"; then
1065                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1066                 fi
1068                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1070                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1071                         cf_result=no
1072                 else
1073                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1074                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1076                         LIBS="$GNUTLS_LIBS $LIBS_X"
1077                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1078                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1080                         # Verify if it's really usable.  gnutls_session was
1081                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1082                         # (on 2004-06-13); ELinks now requires this.
1083                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[gnutls_session_t dummy;
1084                                      gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no])
1085                 fi
1087                 if test "$cf_result" = yes; then
1088                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1090                         CFLAGS="$CFLAGS_X"
1091                         AC_SUBST(GNUTLS_CFLAGS)
1093                         # Verify if the MD5 compatibility layer is usable.
1094                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1095                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1096                                                   [GNU TLS OpenSSL compatibility],
1097                                                   gnutls/openssl.h, gnutls-openssl,
1098                                                   MD5_Init)
1099                 else
1100                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1101                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1102                         fi
1103                         EL_RESTORE_FLAGS
1104                 fi
1105         fi
1108 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1109 AC_MSG_RESULT($cf_result)
1111 # Final SSL setup
1113 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1114 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1115 AC_SUBST(CONFIG_OPENSSL)
1116 AC_SUBST(CONFIG_GNUTLS)
1118 #endif
1120 AC_MSG_CHECKING([whether to be or not to be])
1121 AC_MSG_RESULT([needs to be determined experimentally])
1123 # ===================================================================
1124 # Check for IPv6 support and related functions.
1125 # ===================================================================
1127 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1128 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1129 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1131 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1132 if test "$HAVE_GETADDRINFO" != yes; then
1133         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1134         if test "$HAVE_GETADDRINFO" = yes; then
1135                 LIBS="$LIBS -linet6"
1136         fi
1140 # ===================================================================
1141 # Checking for X11 (window title restoring).
1142 # ===================================================================
1144 AC_PATH_X
1145 if test x"$no_x" != xyes; then
1146         EL_SAVE_FLAGS
1147         if test -n "$x_includes"; then
1148                 X_CFLAGS="-I$x_includes"
1149                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1150                 CFLAGS="$CFLAGS $X_CFLAGS"
1151         fi
1152         if test -n "$x_libraries"; then
1153                 LDFLAGS="$LDFLAGS -L$x_libraries"
1154         fi
1155         LIBS="-lX11 $LIBS"
1156         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1157         EL_RESTORE_FLAGS
1158         if test "$cf_result" = yes; then
1159                 if test -n "$x_libraries"; then
1160                         LDFLAGS="$LDFLAGS -L$x_libraries"
1161                 fi
1162                 LIBS="-lX11 $LIBS"
1163                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1164                 AC_SUBST(X_CFLAGS)
1165         fi
1169 # ===================================================================
1170 # Backtraces displaying support.
1171 # ===================================================================
1173 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1174 # possible checks for other system-specific means go here
1177 # ===================================================================
1178 # Gettext grey zone. Beware.
1179 # ===================================================================
1181 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"
1183 AM_GNU_GETTEXT
1185 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1186 dnl # f33r d4 l33t... I hope it's portable. :)
1187 dnl cf_result=$((48#z - 48#a + 1));
1188 dnl AC_MSG_RESULT($cf_result)
1191 # ===================================================================
1192 # Compile-time features control
1193 # ===================================================================
1195 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1196               [  --disable-cookies       disable cookie support])
1198 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1199               [  --disable-formhist      disable form history support])
1201 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1202               [  --disable-globhist      disable global history support])
1205 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1206               [  --disable-mailcap       disable mailcap support])
1208 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1209               [  --disable-mimetypes     disable mimetypes files support])
1212 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1213               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1214               [IPv6],
1215               [  --disable-ipv6          disable IPv6 support])
1217 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1218               [  --enable-bittorrent     enable BitTorrent protocol support])
1220 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1221               [  --disable-data          disable data protocol support])
1223 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1224               [  --disable-uri-rewrite   disable URI rewrite support])
1226 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1227               [  --enable-cgi            enable local CGI support])
1229 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1230               [  --enable-finger         enable finger protocol support])
1232 # ===================================================================
1233 # FSP protocol
1234 # ===================================================================
1235 EL_SAVE_FLAGS
1237 if test "x${enable_fsp}" != xno; then
1238         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1240         if test "$HAVE_FSPLIB" = yes; then
1241                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1242                 if test "$HAVE_FSPLIB" = yes; then
1243                         LIBS="$LIBS -lfsplib"
1244                 else
1245                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1246                         if test "$HAVE_FSPLIB" = yes; then
1247                                 LIBS="$LIBS -lfsp"
1248                         fi
1249                 fi
1250         fi
1253 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1254               [  --enable-fsp            enable FSP protocol support])
1256 if test "x$CONFIG_FSP" = xno; then
1257         EL_RESTORE_FLAGS
1260 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1261               [  --disable-ftp           disable ftp protocol support])
1263 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1264               [  --enable-gopher         enable gopher protocol support])
1266 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1267               [  --enable-nntp           enable nntp protocol support])
1269 # ===================================================================
1270 # SMB protocol support.
1271 # ===================================================================
1272 EL_SAVE_FLAGS
1274 if test "x${enable_smb}" != xno; then
1275         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1277         if test "$HAVE_SMBCLIENT" = yes; then
1278                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1279                 if test "$HAVE_SMBCLIENT" = yes; then
1280                         LIBS="$LIBS -lsmbclient"
1281                 fi
1282         fi
1285 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1286               [  --enable-smb            enable Samba protocol support])
1288 if test "x$CONFIG_SMB" = xno; then
1289         EL_RESTORE_FLAGS
1293 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1294               [  --disable-mouse         disable mouse support])
1296 # GPM mouse is Linux specific, so ...
1297 CONFIG_SYSMOUSE=yes
1298 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1299               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1300               [BSD sysmouse],
1301               [  --disable-sysmouse      disable BSD sysmouse support])
1303 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1304               [  --enable-88-colors      enable 88 color support])
1306 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1307               [  --enable-256-colors     enable 256 color support])
1309 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1310               [  --enable-true-color     enable true color support])
1312 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1313               [  --enable-exmode         enable exmode (CLI) interface])
1315 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1316               [  --disable-leds          disable LEDs support])
1318 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1319               [  --disable-marks         disable document marks support])
1322 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1323               [  --disable-css           disable Cascading Style Sheet support])
1325 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1326               [  --enable-html-highlight HTML highlighting using DOM engine])
1328 # Everything in the tree already uses CONFIG_DOM
1329 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1330 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1332 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1333               [  --disable-backtrace     disable backtrace support])
1335 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1336               [  --enable-no-root        enable prevention of usage by root])
1339 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1340               [  --enable-debug          enable leak debug and internal error checking])
1342 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1343               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1345 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1346               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1348 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1349               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1351 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1352               [  --disable-utf-8         disable UTF-8 support])
1355 AC_ARG_ENABLE(weehoofooboomookerchoo,
1356               [
1357     Also check out the features.conf file for more information about features!
1358               ],
1359               [AC_MSG_ERROR(Are you strange, or what?)])
1362 # == EMX hack
1364 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1365 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1368 # ===================================================================
1369 # Export directory paths
1370 # ===================================================================
1372 # Set up the ``entry points'' if they were not supplied by builder
1373 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1374 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1376 # Create CONFDIR #define for config.h
1378 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1379 # it's autoconf fault to force us to do such hacks ;p.
1380 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1381   # sysconfdir is set to its default value... fine, let's append /elinks/
1382   # XXX: We can't modify listing of the default in ./configure --help :-(
1383   sysconfdir_n=`eval echo "$sysconfdir"`
1384   sysconfdir=$sysconfdir_n
1385   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1386         sysconfdir="$sysconfdir/elinks"
1389 CONFDIR=$sysconfdir
1390 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1391 AC_SUBST(CONFDIR)
1393 # Create LOCALEDIR #define for config.h
1394 LOCALEDIR=`eval echo "$datadir/locale"`
1395 while echo "$LOCALEDIR" | grep "\\$"
1397         LOCALEDIR=`eval echo "$LOCALEDIR"`
1398 done > /dev/null 2> /dev/null
1399 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1400 AC_SUBST(LOCALEDIR)
1402 # Create LIBDIR #define for config.h
1403 LIBDIR=`eval echo "$libdir"`
1404 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1405 AC_SUBST(LIBDIR)
1407 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1408 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1411 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1412 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1413         #error not tcc
1414         #endif ]])],[cf_result=yes],[cf_result=no])
1416 if test "$cf_result" = "yes"; then
1417         AC_DEFINE([HAVE_ALLOCA])
1418         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1419                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1420                 override the alloca macro defined in <stddef.h> of TCC.
1421                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1422                 it has already been included, and does not redefine alloca.
1423                 This might not work in future glibc versions though, because
1424                 the names of the #include guard macros are not documented.
1425                 The incompatibility has been reported to the tinycc-devel
1426                 mailing list on 2008-07-14.  If a future version of TCC provides
1427                 an <alloca.h> of its own, this hack won't be needed.])
1429 # ===================================================================
1430 # A little fine tuning of gcc specific options (continued)
1431 # ===================================================================
1433 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1434   if test "$CONFIG_DEBUG" = "yes"; then
1435     # We want to see all warnings and live with none (in debug mode).
1436     CFLAGS="$CFLAGS -Werror"
1437   fi
1439   case "`$CC -dumpversion`" in
1440     3.0|3.1|3.2)
1441       # These should be ok using -Werror
1442       ;;
1443     3.*)
1444       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1445       # "dereferencing type-punned pointer will break strict-aliasing rules"
1446       # warnings. Disable them by not doing any strict-aliasing. The
1447       # alternative is just too ugly. Thanks gcc guys!! ;)
1448       CFLAGS="$CFLAGS -fno-strict-aliasing"
1449       ;;
1450     4.*)
1451       # Do not show warnings related to (char * | unsigned char *) type
1452       # difference.
1453       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1454       ;;
1455     *)
1456       # These should be ok using -Werror
1457       ;;
1458   esac
1460   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1461   # warning: the address of `builtin_modules' will always evaluate as `true'
1462   # This hits the object_lock and foreach_module macros in particular.
1463   # It would be okay to put something in the macros to avoid the warning,
1464   # but currently this seems to require defining parallel macros that skip
1465   # the NULL check, and that's too ugly.  So we instead disable the warning.
1466   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1467   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1468   for warning_flag in -Wno-address -Wno-always-true; do
1469     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1470     EL_SAVE_FLAGS
1471     CFLAGS="$CFLAGS $warning_flag"
1472     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1473       [AC_MSG_RESULT([yes])
1474        break],
1475       [AC_MSG_RESULT([no])])
1476     EL_RESTORE_FLAGS
1477   done
1479   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1480   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1481   # "warning: assuming signed overflow does not occur when assuming
1482   # that (X + c) > X is always true", which may be an incorrect
1483   # optimization (although allowed by the standard), and breaks the
1484   # build with -Werror.
1485   #
1486   # All of the following tests included -S -Wall -Wextra:
1487   #
1488   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1489   # * gcc-4.0 -O0: OK, compares the values
1490   # * gcc-4.0 -O2: assumes no overflow, does not warn
1491   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1492   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1493   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1494   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1495   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1496   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1497   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1498   #
1499   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1500   # * gcc-4.1 -O0: assumes no overflow, does not warn
1501   # * gcc-4.1 -O2: assumes no overflow, does not warn
1502   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1503   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1504   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1505   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1506   # * gcc-4.1 -O2 -ftrapv: compares the values
1507   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1508   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1509   #
1510   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1511   # * gcc-4.2 -O0: OK, compares the values
1512   # * gcc-4.2 -O2: assumes no overflow, warns about it
1513   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1514   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1515   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1516   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1517   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1518   # * gcc-4.2 -O2 -ftrapv: compares the values
1519   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1520   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1521   #
1522   # Apparently, -ftrapv does not work reliably at all.
1523   for overflow_flag in -fno-strict-overflow -fwrapv; do
1524     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1525     EL_SAVE_FLAGS
1526     CFLAGS="$CFLAGS $overflow_flag"
1527     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1528       [AC_MSG_RESULT([yes])
1529        break],
1530       [AC_MSG_RESULT([no])])
1531     EL_RESTORE_FLAGS
1532   done
1535 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1536 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1537 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1538 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1540 # ===================================================================
1541 # Colored make output
1542 # ===================================================================
1544 if test $(`which tput` colors) -ge 4; then
1545         MAKE_COLOR=1
1546         AC_SUBST(MAKE_COLOR)
1549 # ===================================================================
1550 # Generated files
1551 # ===================================================================
1553 AC_CONFIG_FILES([ \
1554  Makefile.config \
1555  contrib/elinks.spec \
1556  contrib/lua/hooks.lua \
1557  contrib/conv/w3m2links.awk \
1558  doc/Doxyfile \
1559  doc/man/man1/elinks.1 \
1560  src/intl/gettext/ref-add.sed \
1561  src/intl/gettext/ref-del.sed
1563 AC_OUTPUT
1565 abs_srcdir="$(cd "$srcdir" && pwd)"
1566 # builddir is always absolute!
1567 if test "$abs_srcdir" != "$builddir"; then
1568         # Bootstrap the Makefile creation
1569         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1570         "$MAKE" "SRC=$abs_srcdir" init
1572         # Make cg-status ignore this build directory
1573         echo "*" > "$builddir/.gitignore"
1576 # ===================================================================
1577 # Configuration summary
1578 # ===================================================================
1580 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1581 cat features.log