Autoupdated configure.in and config/m4/*.m4. Obsolete macros removed.
[elinks.git] / configure.in
blob146642334cfbb611fde6b4a8cb33b38a1cfbbd32
1 dnl Process this file with autoconf to produce a configure script.
3 dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
4 dnl Autoconf 2.59 is installed in the computer that generates our daily
5 dnl snapshots, so we need to be compatible with that.
6 AC_PREREQ(2.59)
7 AC_INIT
8 AC_CONFIG_SRCDIR([src/main/main.c])
9 AC_CONFIG_AUX_DIR(config)
11 PACKAGE=elinks
12 VERSION=0.12.GIT
13 AC_SUBST(PACKAGE)
14 AC_SUBST(VERSION)
15 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
16 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
17 AC_CONFIG_HEADERS(config.h)
19 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
20 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
21 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
23 MAKE=
25 for make in gnumake gmake make false; do
26         if test "x$MAKE" = x; then
27                 AC_PATH_PROGS(MAKE, "$make")
28         fi
29 done
31 builddir="`pwd`"
33 # Cleanup if we are configuring with a previous build in the tree
34 if test -e Makefile.config; then
35         AC_MSG_CHECKING([for previous build to clean])
36         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
37         AC_MSG_RESULT(done)
40 dnl ===================================================================
41 dnl Load feature configuration file and start logging features.
42 dnl ===================================================================
44 features="features.conf"
45 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
46 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
47 echo "Feature summary:" > features.log
49 dnl ===================================================================
50 dnl Checks for programs.
51 dnl ===================================================================
53 AC_PROG_CC
54 AC_PROG_AWK
55 AC_PATH_PROGS(AWK, "$AWK")
56 AC_PROG_RANLIB
57 AC_PROG_INSTALL
59 AC_PATH_PROGS(CG_COMMIT_ID, "cg-commit-id")
60 AC_PATH_PROGS(SPARSE, "sparse")
62 CONFIG_ASCIIDOC="no"
63 CONFIG_POD2HTML="no"
64 CONFIG_XMLTO="no"
65 CONFIG_JW="no"
67 if test "x$CONFIG_DOC" != xno; then
68         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
69         if test "x$ASCIIDOC" != "x"; then
70                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
71                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
72                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
74                 echo > config.asciidoc-unsafe.txt
75                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
76                         ASCIIDOC_FLAGS=--unsafe
77                 fi
78                 rm config.asciidoc-unsafe.*
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
100 AC_SUBST(ASCIIDOC_FLAGS)
101 AC_SUBST(CONFIG_ASCIIDOC)
102 AC_SUBST(CONFIG_POD2HTML)
103 AC_SUBST(CONFIG_XMLTO)
104 AC_SUBST(CONFIG_JW)
106 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
107 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
108 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
110 dnl gcc specific options (to be continued at the bottom of configure)
111 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
112   dnl We want to see all warnings and live with none.
113   dnl We can't set up -Werror here as there may be some warnings in test
114   dnl suite of configure, and we don't want to fail them.
115   CFLAGS="$CFLAGS -Wall"
118 dnl ===================================================================
119 dnl Checks for special OSes.
120 dnl ===================================================================
122 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
123 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
125         AC_MSG_CHECKING([for $2])
127         for flag in $3; do
128                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
129 kill me!
130 #endif ]])],[$1=yes],[$1=no])
131                 if test "[$]$1" = yes; then
132                         EL_CONFIG([$1], [$2])
133                         break
134                 fi
135         done
137         AC_MSG_RESULT([$]$1)
140 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
141 AC_SUBST(CONFIG_OS_BEOS)
143 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
144 AC_SUBST(CONFIG_OS_RISCOS)
146 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
147 AC_SUBST(CONFIG_OS_WIN32)
149 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
150 AC_SUBST(CONFIG_OS_OS2)
151 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
153 AC_MSG_CHECKING([for UNIX])
154 dnl FIXME: some depend kind of mechanism
155 if test "$CONFIG_OS_BEOS" = no && \
156    test "$CONFIG_OS_RISCOS" = no && \
157    test "$CONFIG_OS_WIN32" = no && \
158    test "$CONFIG_OS_OS2" = no; then
159         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
160 else
161         CONFIG_OS_UNIX=no
163 AC_MSG_RESULT($CONFIG_OS_UNIX)
164 AC_SUBST(CONFIG_OS_UNIX)
166 dnl ===================================================================
167 dnl Checks for header files.
168 dnl ===================================================================
170 AC_HEADER_DIRENT
171 AC_HEADER_STDC
172 AC_HEADER_SYS_WAIT
173 AC_HEADER_TIME
175 AC_CHECK_HEADERS(wctype.h)
176 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
177 AC_CHECK_HEADERS(sigaction.h)
178 AC_CHECK_HEADERS(arpa/inet.h)
179 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
180 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
181 AC_CHECK_HEADERS(ifaddrs.h)
182 AC_CHECK_HEADERS(sys/cygwin.h io.h)
183 AC_CHECK_HEADERS(sys/fmutex.h)
184 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
185 AC_CHECK_HEADERS(sys/resource.h)
186 AC_CHECK_HEADERS(sys/select.h)
187 AC_CHECK_HEADERS(sys/signal.h)
188 AC_CHECK_HEADERS(sys/socket.h)
189 AC_CHECK_HEADERS(sys/time.h)
190 AC_CHECK_HEADERS(sys/utsname.h)
191 AC_CHECK_HEADERS(stdint.h inttypes.h)
192 AC_CHECK_HEADERS(locale.h pwd.h)
193 AC_CHECK_HEADERS(termios.h)
196 AC_CHECK_HEADERS(sys/un.h,
197         [CONFIG_INTERLINK=yes
198          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
199         [CONFIG_INTERLINK=no])
200 AC_SUBST(CONFIG_INTERLINK)
202 dnl ===================================================================
203 dnl Checks for typedefs, structures, and compiler characteristics.
204 dnl ===================================================================
206 AC_STRUCT_TM
207 AC_C_CONST
208 AC_C_INLINE
209 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
211 AC_SYS_LARGEFILE
212 AC_TYPE_SIZE_T
213 AC_TYPE_OFF_T
214 EL_CHECK_TYPE(ssize_t, int)
215 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
216 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
217 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
218 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
219 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
221 AC_CHECK_SIZEOF(char, 1)
222 AC_CHECK_SIZEOF(short, 2)
223 AC_CHECK_SIZEOF(int, 4)
224 AC_CHECK_SIZEOF(long, 4)
225 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
226 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
228 dnl Check for variadic macros
229 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
230                 [#include <stdio.h>
231                  #define a(b,c...) printf(b,##c)],
232                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
234 dnl Check for -rdynamic
236 dnl gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
237 dnl the executable to its dynamic symbol table.  ELinks uses this for
238 dnl two purposes:
240 dnl 1. If ELinks detects a bug, it can try to display a backtrace by
241 dnl    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
242 dnl    manual states users of GNU ld must pass -rdynamic to make the
243 dnl    symbols available to the program.
245 dnl 2. It would eventually be nice to dynamically load shared
246 dnl    libraries as plugins (bug 73).  The plugins must be able to
247 dnl    call ELinks functions.  This can be implemented either by
248 dnl    registering all callable functions in ELinks-specific data
249 dnl    structures, or by letting the dynamic linker handle them.
250 dnl    The latter way requires something equivalent to -rdynamic.
252 dnl Because backtraces are not needed for correct operation, and bug
253 dnl 73 is not yet being fixed, the configure script and makefiles
254 dnl should not complain to the user if they find that -rdynamic does
255 dnl not work.  Besides, it was reported at elinks-users on 2006-09-12
256 dnl that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
257 dnl Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
258 dnl -rdynamic but does something equivalent automatically.  (This was
259 dnl tested with "nm -D elinks | grep redraw_from_window".)
261 dnl FIXME: This check doesn't work. Something to do with the compiler
262 dnl happily ignoring it and stderr not being checked for error messages.
263 AC_MSG_CHECKING([for -rdynamic])
264 LDFLAGS_X="$LDFLAGS"
265 LDFLAGS="$LDFLAGS -rdynamic"
266 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
267 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
268 AC_MSG_RESULT($have_rdynamic)
270 dnl ===================================================================
271 dnl Check for POSIX <regex.h>
272 dnl ===================================================================
274 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
276 dnl ===================================================================
277 dnl Checks for library functions.
278 dnl ===================================================================
280 AC_PROG_GCC_TRADITIONAL
281 AC_FUNC_MEMCMP
282 AC_FUNC_MMAP
283 AC_FUNC_STRFTIME
284 AC_CHECK_FUNCS(atoll cfmakeraw gethostbyaddr herror strerror)
285 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
286 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
287 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
288 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
289 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
290 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
291 AC_CHECK_FUNCS(gettimeofday clock_gettime)
293 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
295 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
296 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
297 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
299 dnl These aren't probably needed now, as they are commented in links.h.
300 dnl I've no idea about their historical background, but I keep them here
301 dnl just in the case they will help later. --pasky
302 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
303 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
304 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
305 AC_CHECK_FUNCS(kill, HAVE_KILL=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 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
367 dnl ===================================================================
368 dnl Checks for libraries.
369 dnl ===================================================================
371 dnl Replace `main' with a function in -lsocket:
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 dnl ===================================================================
393 dnl Checks for packaging specific options.
394 dnl ===================================================================
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 dnl ===================================================================
402 dnl Checks for a libraries, optional even if installed.
403 dnl ===================================================================
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         $1=yes
456         WITHVAL_$1=
458         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
459         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
461         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
463         EL_LOG_CONFIG([$1], [$2], [])
466 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
467         [  --without-gpm           disable gpm (mouse) support])
469 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
470         [  --without-zlib          disable zlib support])
472 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
473         [  --without-bzlib         disable bzlib support])
475 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
476         [  --without-idn           disable international domain names support])
478 if test "x{with_gc}" != xno; then
479         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
480                 [  --with-gc               enable Boehm's garbage collector])
483 EL_ARG_ENABLE(CONFIG_LZMA, lzma, [lzma],
484               [  --enable-lzma           enable lzma encoding support])
486 dnl ===================================================================
487 dnl Check for GSSAPI, optional even if installed.
488 dnl ===================================================================
490 enable_gssapi="no";
492 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
493             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
495 AC_MSG_CHECKING([for GSSAPI])
497 if test "$enable_gssapi" = "yes"; then
498         AC_MSG_RESULT(yes)
499         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
500         GSSAPI_LIBS=`krb5-config --libs gssapi`
501         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
502         LIBS="$GSSAPI_LIBS $LIBS"
503         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
504 else
505         AC_MSG_RESULT(no)
508 AC_SUBST(CONFIG_GSSAPI)
510 dnl ===================================================================
511 dnl Bookmark and XBEL support
512 dnl ===================================================================
514 EL_SAVE_FLAGS
516 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
517               [  --disable-bookmarks     disable bookmark support])
519 # Check whether --enable-xbel or --disable-xbel was given.
520 if test "x${enable_xbel}" != xno; then
521         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
523         if test "$HAVE_LIBEXPAT" = yes; then
524                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
525                 if test "$HAVE_LIBEXPAT" = yes; then
526                         LIBS="$LIBS -lexpat"
527                 fi
528         fi
532 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
533               [XBEL bookmarks],
534               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
536 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
537         EL_RESTORE_FLAGS
540 dnl ===================================================================
541 dnl Checks for BSD sysmouse
542 dnl ===================================================================
544 HAVE_SYSMOUSE_HEADER="no"
546 # Either of these header files provides the (same) sysmouse interface
547 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
549 dnl ===================================================================
550 dnl Checks for OS/2
551 dnl ===================================================================
553 if test "$CONFIG_OS_OS2" = yes; then
554         EL_CONFIG_OS_OS2
557 dnl ===================================================================
558 dnl Checks for Win32
559 dnl ===================================================================
561 if test "$CONFIG_OS_WIN32" = yes; then
562         EL_CONFIG_OS_WIN32
565 dnl ===================================================================
566 dnl Check for SEE (Simple Ecmascript Engine)
567 dnl ===================================================================
568 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
569             [ if test "x$withval" != xno; then enable_see=yes; fi ])
571 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
572 # SEE_FLAGS but I really don't want to require people to have Guile in order
573 # to compile CVS. Also, the macro seems to be really stupid regarding searching
574 # for Guile in $PATH etc. --pasky
576 CONFIG_ECMASCRIPT_SEE=no
578 if test "$enable_see" = "yes"; then
579         if test -d "$withval"; then
580                 SEE_PATH="$withval:$PATH"
581         else
582                 SEE_PATH="$PATH"
583         fi
585         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
586         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
587         if test "$SEE_CONFIG" != no; then
588                 EL_SAVE_FLAGS
589                 SEE_LIBS="`$SEE_CONFIG --libs`"
590                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
591                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
592                 LIBS="$SEE_LIBS $LIBS_X"
593                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
594                         #error SEE too old
595                         #endif
596                 ]])],[cf_result=yes],[cf_result=no])
597                 EL_RESTORE_FLAGS
598                 if test "$cf_result" = yes; then
599                         LIBS="$SEE_LIBS $LIBS"
600                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
601                         AC_SUBST(SEE_CFLAGS)
602                 fi
603                 AC_MSG_RESULT($cf_result)
604         else
605                 if test -n "$withval" && test "x$withval" != xno; then
606                         AC_MSG_ERROR([SEE not found])
607                 else
608                         AC_MSG_WARN([SEE support disabled])
609                 fi
610         fi
613 dnl ===================================================================
614 dnl Check for SpiderMonkey, optional even if installed.
615 dnl ===================================================================
617 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
618             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
619 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
621 EL_SAVE_FLAGS
622 cf_result=no
624 if test -z "$disable_spidermonkey"; then
625         if test ! -d "$withval"; then
626                 withval="";
627         fi
628         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
629                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
630                         for spidermonkeylib in js smjs mozjs; do
631                                 if test "$cf_result" = no &&
632                                    test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then
633                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
635                                         if test ! -z "$spidermonkeydir"; then
636                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
637                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
638                                         fi
640                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
641                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
642                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
644                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
645                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
646                                 fi
647                         done
648                 done
649         done
652 AC_MSG_RESULT($cf_result)
653 CONFIG_SPIDERMONKEY="$cf_result"
654 EL_RESTORE_FLAGS
656 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
657    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
658         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
659 else
660         CONFIG_ECMASCRIPT_SMJS=no
663 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
664 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
665 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
668 dnl ===================================================================
669 dnl Optional Spidermonkey-based ECMAScript browser scripting
670 dnl ===================================================================
672 AC_ARG_ENABLE(sm-scripting,
673               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
674               [if test "$enableval" != no; then enableval="yes"; fi
675                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
677 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
678    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
679         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
680 else
681         CONFIG_SCRIPTING_SPIDERMONKEY=no
684 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
685    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
686         LIBS="$LIBS $SPIDERMONKEY_LIBS"
687         AC_SUBST(SPIDERMONKEY_LIBS)
688         AC_SUBST(SPIDERMONKEY_CFLAGS)
689         AC_SUBST(CONFIG_SPIDERMONKEY)
692 dnl ===================================================================
693 dnl Check for Guile, optional even if installed.
694 dnl ===================================================================
696 enable_guile="no";
698 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
699             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
701 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
702 # GUILE_FLAGS but I really don't want to require people to have Guile in order
703 # to compile CVS. Also, the macro seems to be really stupid regarding searching
704 # for Guile in $PATH etc. --pasky
706 AC_MSG_CHECKING([for Guile])
708 if test "$enable_guile" = "yes"; then
709         AC_MSG_RESULT(yes);
710         ## Based on the GUILE_FLAGS macro.
712         if test -d "$withval"; then
713                 GUILE_PATH="$withval:$PATH"
714         else
715                 GUILE_PATH="$PATH"
716         fi
718         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
720         ## First, let's just see if we can find Guile at all.
721         if test "$GUILE_CONFIG" != no; then
722                 cf_result="yes";
724                 GUILE_LIBS="`guile-config link`"
725                 GUILE_CFLAGS="`guile-config compile`"
726                 LIBS="$GUILE_LIBS $LIBS"
727                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
728                 AC_SUBST(GUILE_CFLAGS)
729                 cat <<EOF
730 ***********************************************************************
731 The Guile support is incomplete and not so well integrated to ELinks
732 yet. That means, e.g., that you have no Guile console and there might
733 not be all the necessary hooks. Also, the Guile interface is not too
734 well tested (success stories heartily welcomed!).  See
735 src/scripting/guile/README for further details and hints.
736 ***********************************************************************
738         else
739                 if test -n "$withval" && test "x$withval" != xno; then
740                         AC_MSG_ERROR([Guile not found])
741                 else
742                         AC_MSG_WARN([Guile support disabled])
743                 fi
744         fi
745 else
746         AC_MSG_RESULT(no);
749 dnl ===================================================================
750 dnl Check for Perl
751 dnl ===================================================================
752 enable_perl="no";
754 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
755             [
756 if test "$withval" = yes; then
757         # FIXME: If withval is a valid directory append it to PATH
758         # so that you can specify one of several perl installations.
759         withval="";
760         enable_perl=yes;
762             ])
764 AC_MSG_CHECKING([for Perl])
766 cf_result=no
768 EL_SAVE_FLAGS
770 if test "$enable_perl" = "yes"; then
771         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
772         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
773         LIBS="$PERL_LIBS $LIBS"
774         CFLAGS="$PERL_CFLAGS $CFLAGS"
775         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
776         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
777 #include <EXTERN.h>
778 #include <perl.h>
779 #include <perlapi.h>
780 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
783 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
785 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
786 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
787 #include <EXTERN.h>
788 #include <perl.h>
789 extern PerlInterpreter *my_perl;
790 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
791 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
792                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
793 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
795 if test "$cf_result" != "yes"; then
796         EL_RESTORE_FLAGS
797 else
798         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
800         CFLAGS="$CFLAGS_X"
801         CPPFLAGS="$CPPFLAGS_X"
802         AC_SUBST(PERL_LIBS)
803         AC_SUBST(PERL_CFLAGS)
806 dnl ===================================================================
807 dnl Check for Python
808 dnl ===================================================================
809 enable_python="no";
811 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
812             [ if test "x$withval" != xno; then enable_python=yes; fi ])
814 EL_SAVE_FLAGS
815 cf_result=no
817 AC_MSG_CHECKING([for Python])
819 if test "$enable_python" = "yes"; then
820         AC_MSG_RESULT(yes);
822         if test -d "$withval"; then
823                 PYTHON_PATH="$withval:$PATH"
824         else
825                 PYTHON_PATH="$PATH"
826         fi
828         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
830         if test "$PYTHON" != no; then
831                 cf_result="yes";
833                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
834                 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"))'`"
835                 LIBS="$PYTHON_LIBS $LIBS"
836                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
837                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
839                 if test "$cf_result" != "yes"; then
840                         EL_RESTORE_FLAGS
841                 else
842                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
843                         AC_SUBST(PYTHON_LIBS)
844                         AC_SUBST(PYTHON_CFLAGS)
845                         CPPFLAGS="$CPPFLAGS_X"
846                         cat <<EOF
847 ***********************************************************************
848 The Python support is incomplete and not so well integrated to ELinks
849 yet. That means, e.g., that you have no Python console and there might
850 not be all the necessary hooks. Also, the Python interface is not too
851 well tested (success stories heartily welcomed!).
852 ***********************************************************************
854                 fi
855         else
856                 if test -n "$withval" && test "x$withval" != xno; then
857                         AC_MSG_ERROR([Python not found])
858                 else
859                         AC_MSG_WARN([Python support disabled])
860                 fi
861         fi
862 else
863         AC_MSG_RESULT(no);
867 dnl ===================================================================
868 dnl Check for Lua, optional even if installed.
869 dnl ===================================================================
871 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
872 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
874 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
875             [if test "$withval" = no; then disable_lua=yes; fi])
876 AC_MSG_CHECKING([for Lua])
878 EL_SAVE_FLAGS
879 cf_result=no
881 if test -z "$disable_lua"; then
882         if test ! -d "$withval"; then
883                 withval="";
884         fi
885         for luadir in "$withval" "" /usr /usr/local; do
886                 for suffix in "" 50 51; do
887                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
888                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
889                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
891                                 if test ! -z "$luadir"; then
892                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
893                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
894                                 fi
896                                 LIBS="$LUA_LIBS $LIBS_X"
897                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
898                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
900                                 # Check that it is a compatible Lua version
901                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
902                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
903                                                 luaopen_base(L);
904                                                 luaopen_table(L);
905                                                 luaopen_io(L);
906                                                 luaopen_string(L);
907                                                 luaopen_math(L);
908                                                 lua_pushboolean(L, 1);
909                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
910                         fi
911                 done
912         done
915 AC_MSG_RESULT($cf_result)
917 if test "$cf_result" != yes; then
918         EL_RESTORE_FLAGS
919 else
920         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
921         AC_CHECK_HEADERS(lauxlib.h)
923         CFLAGS="$CFLAGS_X"
924         CPPFLAGS="$CPPFLAGS_X"
925         AC_SUBST(LUA_LIBS)
926         AC_SUBST(LUA_CFLAGS)
930 dnl ===================================================================
931 dnl Check for Ruby, optional even if installed.
932 dnl ===================================================================
934 EL_CONFIG_SCRIPTING_RUBY
936 dnl ===================================================================
937 dnl Setup global scripting
938 dnl ===================================================================
940 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])
941 AC_SUBST(CONFIG_SCRIPTING_GUILE)
942 AC_SUBST(CONFIG_SCRIPTING_LUA)
943 AC_SUBST(CONFIG_SCRIPTING_PERL)
944 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
945 AC_SUBST(CONFIG_SCRIPTING_RUBY)
946 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
947 AC_SUBST(CONFIG_SCRIPTING)
950 dnl ===================================================================
951 dnl Check for SSL support.
952 dnl ===================================================================
954 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
955 dnl is enabled, we won't try to use OpenSSL anymore.
957 dnl For wiping SSL hooks..
958 #ifdef CONFIG_SSL
960 disable_openssl=""
961 disable_gnutls=""
962 enable_gnutls=""
964 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
965             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
966 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
967             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
968 gnutls_withval="$withval"
970 if test "$enable_gnutls" = yes; then
971         disable_openssl=yes;
974 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
975             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
976 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
977 openssl_withval="$withval"
979 dnl ---- OpenSSL
981 AC_MSG_CHECKING([for OpenSSL])
983 EL_SAVE_FLAGS
984 cf_result="no"
986 if test "$disable_openssl" = yes; then
987         cf_result="not used"
988 else
989         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
990                          /usr/lib/openssl /usr/local/ssl \
991                          /usr/local/www /usr/lib/ssl /usr/local \
992                          /usr/pkg /opt /opt/openssl; do
993                 if test "$cf_result" = no; then
994                         if test -d "$ssldir"; then
995                                 OPENSSL_CFLAGS="-I$ssldir/include"
996                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
997                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
998                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
999 #                               # FIXME: This created serious portability problems. --pasky
1000 #                               if test "$CC" == "gcc"; then
1001 #                                       # I'm not sure about compatibility here. --pasky
1002 #                                       LIBS="$LIBS -R$ssldir/lib"
1003 #                               fi
1004                         else
1005                                 LIBS="-lssl -lcrypto $LIBS_X"
1006                         fi
1007                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1008                         if test "$cf_result" != yes; then
1009                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1010                         fi
1011                 fi
1012         done
1014         if test "$cf_result" != yes; then
1015                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1016                         AC_MSG_ERROR([OpenSSL not found])
1017                 fi
1018                 EL_RESTORE_FLAGS
1019         else
1020                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1022                 CFLAGS="$CFLAGS_X"
1023                 AC_SUBST(OPENSSL_CFLAGS)
1024         fi
1027 AC_MSG_RESULT($cf_result)
1029 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1030 dnl ---- GNU TLS
1031 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1032 dnl it looks ugly then.
1034 if test "$cf_result" = yes; then
1035         cf_result="not used"
1037 else
1038         EL_SAVE_FLAGS
1039         cf_result="no"
1041         if test -z "$disable_gnutls"; then
1042                 # Sure, we maybe _could_ use their macro, but how to ensure
1043                 # that the ./configure script won't fail if the macro won't be
1044                 # found..? :( --pasky
1046                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1048                 if test -d "$gnutls_withval"; then
1049                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1050                 fi
1052                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1054                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1055                         cf_result=no
1056                 else
1057                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1058                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1060                         LIBS="$GNUTLS_LIBS $LIBS_X"
1061                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1062                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1064                         # Verify if it's really usable.  gnutls_session was
1065                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1066                         # (on 2004-06-13); ELinks now requires this.
1067                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[gnutls_session_t dummy;
1068                                      gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no])
1069                 fi
1071                 if test "$cf_result" = yes; then
1072                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1074                         CFLAGS="$CFLAGS_X"
1075                         AC_SUBST(GNUTLS_CFLAGS)
1077                         # Verify if the MD5 compatibility layer is usable.
1078                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1079                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1080                                                   [GNU TLS OpenSSL compatibility],
1081                                                   gnutls/openssl.h, gnutls-openssl,
1082                                                   MD5_Init)
1083                 else
1084                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1085                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1086                         fi
1087                         EL_RESTORE_FLAGS
1088                 fi
1089         fi
1092 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1093 AC_MSG_RESULT($cf_result)
1095 dnl Final SSL setup
1097 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1098 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1099 AC_SUBST(CONFIG_OPENSSL)
1100 AC_SUBST(CONFIG_GNUTLS)
1102 #endif
1104 AC_MSG_CHECKING([whether to be or not to be])
1105 AC_MSG_RESULT([needs to be determined experimentally])
1107 dnl ===================================================================
1108 dnl Check for IPv6 support and related functions.
1109 dnl ===================================================================
1111 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1112 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1113 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1115 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1116 if test "$HAVE_GETADDRINFO" != yes; then
1117         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1118         if test "$HAVE_GETADDRINFO" = yes; then
1119                 LIBS="$LIBS -linet6"
1120         fi
1124 dnl ===================================================================
1125 dnl Checking for X11 (window title restoring).
1126 dnl ===================================================================
1128 AC_PATH_X
1129 if test x"$no_x" != xyes; then
1130         EL_SAVE_FLAGS
1131         if test -n "$x_includes"; then
1132                 X_CFLAGS="-I$x_includes"
1133                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1134                 CFLAGS="$CFLAGS $X_CFLAGS"
1135         fi
1136         if test -n "$x_libraries"; then
1137                 LDFLAGS="$LDFLAGS -L$x_libraries"
1138         fi
1139         LIBS="-lX11 $LIBS"
1140         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1141         EL_RESTORE_FLAGS
1142         if test "$cf_result" = yes; then
1143                 if test -n "$x_libraries"; then
1144                         LDFLAGS="$LDFLAGS -L$x_libraries"
1145                 fi
1146                 LIBS="-lX11 $LIBS"
1147                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1148                 AC_SUBST(X_CFLAGS)
1149         fi
1153 dnl ===================================================================
1154 dnl Backtraces displaying support.
1155 dnl ===================================================================
1157 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1158 # possible checks for other system-specific means go here
1161 dnl ===================================================================
1162 dnl Gettext grey zone. Beware.
1163 dnl ===================================================================
1165 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"
1167 AM_GNU_GETTEXT
1169 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1170 dnl # f33r d4 l33t... I hope it's portable. :)
1171 dnl cf_result=$((48#z - 48#a + 1));
1172 dnl AC_MSG_RESULT($cf_result)
1175 dnl ===================================================================
1176 dnl Compile-time features control
1177 dnl ===================================================================
1179 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1180               [  --disable-cookies       disable cookie support])
1182 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1183               [  --disable-formhist      disable form history support])
1185 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1186               [  --disable-globhist      disable global history support])
1189 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1190               [  --disable-mailcap       disable mailcap support])
1192 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1193               [  --disable-mimetypes     disable mimetypes files support])
1196 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1197               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1198               [IPv6],
1199               [  --disable-ipv6          disable IPv6 support])
1201 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1202               [  --enable-bittorrent     enable BitTorrent protocol support])
1204 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1205               [  --disable-data          disable data protocol support])
1207 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1208               [  --disable-uri-rewrite   disable URI rewrite support])
1210 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1211               [  --enable-cgi            enable local CGI support])
1213 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1214               [  --enable-finger         enable finger protocol support])
1216 dnl ===================================================================
1217 dnl FSP protocol
1218 dnl ===================================================================
1219 EL_SAVE_FLAGS
1221 if test "x${enable_fsp}" != xno; then
1222         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1224         if test "$HAVE_FSPLIB" = yes; then
1225                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1226                 if test "$HAVE_FSPLIB" = yes; then
1227                         LIBS="$LIBS -lfsplib"
1228                 else
1229                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1230                         if test "$HAVE_FSPLIB" = yes; then
1231                                 LIBS="$LIBS -lfsp"
1232                         fi
1233                 fi
1234         fi
1237 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1238               [  --enable-fsp            enable FSP protocol support])
1240 if test "x$CONFIG_FSP" = xno; then
1241         EL_RESTORE_FLAGS
1244 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1245               [  --disable-ftp           disable ftp protocol support])
1247 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1248               [  --enable-gopher         enable gopher protocol support])
1250 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1251               [  --enable-nntp           enable nntp protocol support])
1253 dnl ===================================================================
1254 dnl SMB protocol support.
1255 dnl ===================================================================
1256 EL_SAVE_FLAGS
1258 if test "x${enable_smb}" != xno; then
1259         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1261         if test "$HAVE_SMBCLIENT" = yes; then
1262                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1263                 if test "$HAVE_SMBCLIENT" = yes; then
1264                         LIBS="$LIBS -lsmbclient"
1265                 fi
1266         fi
1269 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1270               [  --enable-smb            enable Samba protocol support])
1272 if test "x$CONFIG_SMB" = xno; then
1273         EL_RESTORE_FLAGS
1277 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1278               [  --disable-mouse         disable mouse support])
1280 # GPM mouse is Linux specific, so ...
1281 CONFIG_SYSMOUSE=yes
1282 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1283               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1284               [BSD sysmouse],
1285               [  --disable-sysmouse      disable BSD sysmouse support])
1287 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1288               [  --enable-88-colors      enable 88 color support])
1290 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1291               [  --enable-256-colors     enable 256 color support])
1293 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1294               [  --enable-true-color     enable true color support])
1296 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1297               [  --enable-exmode         enable exmode (CLI) interface])
1299 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1300               [  --disable-leds          disable LEDs support])
1302 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1303               [  --disable-marks         disable document marks support])
1306 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1307               [  --disable-css           disable Cascading Style Sheet support])
1309 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1310               [  --enable-html-highlight HTML highlighting using DOM engine])
1312 dnl Everything in the tree already uses CONFIG_DOM
1313 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1314 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1316 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1317               [  --disable-backtrace     disable backtrace support])
1319 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1320               [  --enable-no-root        enable prevention of usage by root])
1323 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1324               [  --enable-debug          enable leak debug and internal error checking])
1326 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1327               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1329 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1330               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1332 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1333               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1335 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1336               [  --enable-utf-8          enable UTF-8 support])
1339 AC_ARG_ENABLE(weehoofooboomookerchoo,
1340               [
1341     Also check out the features.conf file for more information about features!
1342               ],
1343               [AC_MSG_ERROR(Are you strange, or what?)])
1346 dnl == EMX hack
1348 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1349 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1352 dnl ===================================================================
1353 dnl Export directory paths
1354 dnl ===================================================================
1356 # Set up the ``entry points'' if they were not supplied by builder
1357 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1358 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1360 # Create CONFDIR #define for config.h
1362 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1363 # it's autoconf fault to force us to do such hacks ;p.
1364 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1365   # sysconfdir is set to its default value... fine, let's append /elinks/
1366   # XXX: We can't modify listing of the default in ./configure --help :-(
1367   sysconfdir_n=`eval echo "$sysconfdir"`
1368   sysconfdir=$sysconfdir_n
1369   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1370         sysconfdir="$sysconfdir/elinks"
1373 CONFDIR=$sysconfdir
1374 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1375 AC_SUBST(CONFDIR)
1377 # Create LOCALEDIR #define for config.h
1378 LOCALEDIR=`eval echo "$datadir/locale"`
1379 while echo "$LOCALEDIR" | grep "\\$"
1381         LOCALEDIR=`eval echo "$LOCALEDIR"`
1382 done > /dev/null 2> /dev/null
1383 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1384 AC_SUBST(LOCALEDIR)
1386 # Create LIBDIR #define for config.h
1387 LIBDIR=`eval echo "$libdir"`
1388 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1389 AC_SUBST(LIBDIR)
1391 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1392 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1394 dnl ===================================================================
1395 dnl A little fine tuning of gcc specific options (continued)
1396 dnl ===================================================================
1398 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1399   if test "$CONFIG_DEBUG" = "yes"; then
1400     dnl We want to see all warnings and live with none (in debug mode).
1401     CFLAGS="$CFLAGS -Werror"
1402   fi
1404   case "`$CC -dumpversion`" in
1405     3.0|3.1|3.2)
1406       # These should be ok using -Werror
1407       ;;
1408     3.*)
1409       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1410       # "dereferencing type-punned pointer will break strict-aliasing rules"
1411       # warnings. Disable them by not doing any strict-aliasing. The
1412       # alternative is just too ugly. Thanks gcc guys!! ;)
1413       CFLAGS="$CFLAGS -fno-strict-aliasing"
1414       ;;
1415     4.*)
1416       # Do not show warnings related to (char * | unsigned char *) type
1417       # difference.
1418       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1419       ;;
1420     *)
1421       # These should be ok using -Werror
1422       ;;
1423   esac
1425   # GCC 4.2 snapshots warn that comparisons like &object != NULL
1426   # always return true.  Some macros in ELinks check whether pointer
1427   # arguments are NULL, and giving them addresses of named objects
1428   # triggers the warning.  These warnings have not revealed any real
1429   # bugs, so shut them up instead of complicating the code.  GCC 4.1
1430   # does not recognize -Wno-always-true and exits with code 1 if it is
1431   # given.
1432   AC_MSG_CHECKING([whether $CC accepts -Wno-always-true])
1433   EL_SAVE_FLAGS
1434   CFLAGS="$CFLAGS -Wno-always-true"
1435   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[AC_MSG_RESULT([yes])],[EL_RESTORE_FLAGS
1436      AC_MSG_RESULT([no])])
1439 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1440 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1441 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1442 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1444 dnl ===================================================================
1445 dnl Colored make output
1446 dnl ===================================================================
1448 if test $(`which tput` colors) -ge 4; then
1449         MAKE_COLOR=1
1450         AC_SUBST(MAKE_COLOR)
1453 dnl ===================================================================
1454 dnl Generated files
1455 dnl ===================================================================
1457 AC_CONFIG_FILES([ \
1458  Makefile.config \
1459  contrib/elinks.spec \
1460  contrib/lua/hooks.lua \
1461  contrib/conv/w3m2links.awk \
1462  doc/man/man1/elinks.1 \
1463  src/intl/gettext/ref-add.sed \
1464  src/intl/gettext/ref-del.sed
1466 AC_OUTPUT
1468 abs_srcdir="$(cd "$srcdir" && pwd)"
1469 # builddir is always absolute!
1470 if test "$abs_srcdir" != "$builddir"; then
1471         # Bootstrap the Makefile creation
1472         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1473         "$MAKE" "SRC=$abs_srcdir" init
1475         # Make cg-status ignore this build directory
1476         echo "*" > "$builddir/.gitignore"
1479 dnl ===================================================================
1480 dnl Configuration summary
1481 dnl ===================================================================
1483 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1484 cat features.log