const in css_appliers[]
[elinks.git] / configure.in
blobfa120eec8bec3004e18c08beef0262c22c03f3ad
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 nightly
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$spidermonkeydir/lib -l$spidermonkeylib"
634                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
636                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
637                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
638                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
640                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
641                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
642                                 fi
643                         done
644                 done
645         done
648 AC_MSG_RESULT($cf_result)
649 CONFIG_SPIDERMONKEY="$cf_result"
650 EL_RESTORE_FLAGS
652 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
653    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
654         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
655 else
656         CONFIG_ECMASCRIPT_SMJS=no
659 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
660 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
661 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
664 dnl ===================================================================
665 dnl Optional Spidermonkey-based ECMAScript browser scripting
666 dnl ===================================================================
668 AC_ARG_ENABLE(sm-scripting,
669               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
670               [if test "$enableval" != no; then enableval="yes"; fi
671                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
673 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
674    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
675         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
676 else
677         CONFIG_SCRIPTING_SPIDERMONKEY=no
680 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
681    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
682         LIBS="$LIBS $SPIDERMONKEY_LIBS"
683         AC_SUBST(SPIDERMONKEY_LIBS)
684         AC_SUBST(SPIDERMONKEY_CFLAGS)
685         AC_SUBST(CONFIG_SPIDERMONKEY)
688 dnl ===================================================================
689 dnl Check for Guile, optional even if installed.
690 dnl ===================================================================
692 enable_guile="no";
694 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
695             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
697 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
698 # GUILE_FLAGS but I really don't want to require people to have Guile in order
699 # to compile CVS. Also, the macro seems to be really stupid regarding searching
700 # for Guile in $PATH etc. --pasky
702 AC_MSG_CHECKING([for Guile])
704 if test "$enable_guile" = "yes"; then
705         AC_MSG_RESULT(yes);
706         ## Based on the GUILE_FLAGS macro.
708         if test -d "$withval"; then
709                 GUILE_PATH="$withval:$PATH"
710         else
711                 GUILE_PATH="$PATH"
712         fi
714         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
716         ## First, let's just see if we can find Guile at all.
717         if test "$GUILE_CONFIG" != no; then
718                 cf_result="yes";
720                 GUILE_LIBS="`guile-config link`"
721                 GUILE_CFLAGS="`guile-config compile`"
722                 LIBS="$GUILE_LIBS $LIBS"
723                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
724                 AC_SUBST(GUILE_CFLAGS)
725                 cat <<EOF
726 ***********************************************************************
727 The Guile support is incomplete and not so well integrated to ELinks
728 yet. That means, e.g., that you have no Guile console and there might
729 not be all the necessary hooks. Also, the Guile interface is not too
730 well tested (success stories heartily welcomed!).  See
731 src/scripting/guile/README for further details and hints.
732 ***********************************************************************
734         else
735                 if test -n "$withval" && test "x$withval" != xno; then
736                         AC_MSG_ERROR([Guile not found])
737                 else
738                         AC_MSG_WARN([Guile support disabled])
739                 fi
740         fi
741 else
742         AC_MSG_RESULT(no);
745 dnl ===================================================================
746 dnl Check for Perl
747 dnl ===================================================================
748 enable_perl="no";
750 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
751             [
752 if test "$withval" = yes; then
753         # FIXME: If withval is a valid directory append it to PATH
754         # so that you can specify one of several perl installations.
755         withval="";
756         enable_perl=yes;
758             ])
760 AC_MSG_CHECKING([for Perl])
762 cf_result=no
764 EL_SAVE_FLAGS
766 if test "$enable_perl" = "yes"; then
767         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
768         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
769         LIBS="$PERL_LIBS $LIBS"
770         CFLAGS="$PERL_CFLAGS $CFLAGS"
771         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
772         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
773 #include <EXTERN.h>
774 #include <perl.h>
775 #include <perlapi.h>
776 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
779 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
781 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
782 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
783 #include <EXTERN.h>
784 #include <perl.h>
785 extern PerlInterpreter *my_perl;
786 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
787 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
788                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
789 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
791 if test "$cf_result" != "yes"; then
792         EL_RESTORE_FLAGS
793 else
794         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
796         CFLAGS="$CFLAGS_X"
797         CPPFLAGS="$CPPFLAGS_X"
798         AC_SUBST(PERL_LIBS)
799         AC_SUBST(PERL_CFLAGS)
802 dnl ===================================================================
803 dnl Check for Python
804 dnl ===================================================================
805 enable_python="no";
807 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
808             [ if test "x$withval" != xno; then enable_python=yes; fi ])
810 EL_SAVE_FLAGS
811 cf_result=no
813 AC_MSG_CHECKING([for Python])
815 if test "$enable_python" = "yes"; then
816         AC_MSG_RESULT(yes);
818         if test -d "$withval"; then
819                 PYTHON_PATH="$withval:$PATH"
820         else
821                 PYTHON_PATH="$PATH"
822         fi
824         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
826         if test "$PYTHON" != no; then
827                 cf_result="yes";
829                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
830                 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"))'`"
831                 LIBS="$PYTHON_LIBS $LIBS"
832                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
833                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
835                 if test "$cf_result" != "yes"; then
836                         EL_RESTORE_FLAGS
837                 else
838                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
839                         AC_SUBST(PYTHON_LIBS)
840                         AC_SUBST(PYTHON_CFLAGS)
841                         CPPFLAGS="$CPPFLAGS_X"
842                         cat <<EOF
843 ***********************************************************************
844 The Python support is incomplete and not so well integrated to ELinks
845 yet. That means, e.g., that you have no Python console and there might
846 not be all the necessary hooks. Also, the Python interface is not too
847 well tested (success stories heartily welcomed!).
848 ***********************************************************************
850                 fi
851         else
852                 if test -n "$withval" && test "x$withval" != xno; then
853                         AC_MSG_ERROR([Python not found])
854                 else
855                         AC_MSG_WARN([Python support disabled])
856                 fi
857         fi
858 else
859         AC_MSG_RESULT(no);
863 dnl ===================================================================
864 dnl Check for Lua, optional even if installed.
865 dnl ===================================================================
867 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
868 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
870 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
871             [if test "$withval" = no; then disable_lua=yes; fi])
872 AC_MSG_CHECKING([for Lua])
874 EL_SAVE_FLAGS
875 cf_result=no
877 if test -z "$disable_lua"; then
878         if test ! -d "$withval"; then
879                 withval="";
880         fi
881         for luadir in "$withval" "" /usr /usr/local; do
882                 for suffix in "" 50 51; do
883                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
884                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
885                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
886                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
888                                 LIBS="$LUA_LIBS $LIBS_X"
889                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
890                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
892                                 # Check that it is a compatible Lua version
893                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
894                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
895                                                 luaopen_base(L);
896                                                 luaopen_table(L);
897                                                 luaopen_io(L);
898                                                 luaopen_string(L);
899                                                 luaopen_math(L);
900                                                 lua_pushboolean(L, 1);
901                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
902                         fi
903                 done
904         done
907 AC_MSG_RESULT($cf_result)
909 if test "$cf_result" != yes; then
910         EL_RESTORE_FLAGS
911 else
912         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
913         AC_CHECK_HEADERS(lauxlib.h)
915         CFLAGS="$CFLAGS_X"
916         CPPFLAGS="$CPPFLAGS_X"
917         AC_SUBST(LUA_LIBS)
918         AC_SUBST(LUA_CFLAGS)
922 dnl ===================================================================
923 dnl Check for Ruby, optional even if installed.
924 dnl ===================================================================
926 EL_CONFIG_SCRIPTING_RUBY
928 dnl ===================================================================
929 dnl Setup global scripting
930 dnl ===================================================================
932 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])
933 AC_SUBST(CONFIG_SCRIPTING_GUILE)
934 AC_SUBST(CONFIG_SCRIPTING_LUA)
935 AC_SUBST(CONFIG_SCRIPTING_PERL)
936 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
937 AC_SUBST(CONFIG_SCRIPTING_RUBY)
938 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
939 AC_SUBST(CONFIG_SCRIPTING)
942 dnl ===================================================================
943 dnl Check for SSL support.
944 dnl ===================================================================
946 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
947 dnl is enabled, we won't try to use OpenSSL anymore.
949 dnl For wiping SSL hooks..
950 #ifdef CONFIG_SSL
952 disable_openssl=""
953 disable_gnutls=""
954 enable_gnutls=""
956 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
957             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
958 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
959             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
960 gnutls_withval="$withval"
962 if test "$enable_gnutls" = yes; then
963         disable_openssl=yes;
966 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
967             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
968 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
969 openssl_withval="$withval"
971 dnl ---- OpenSSL
973 AC_MSG_CHECKING([for OpenSSL])
975 EL_SAVE_FLAGS
976 cf_result="no"
978 if test "$disable_openssl" = yes; then
979         cf_result="not used"
980 else
981         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
982                          /usr/lib/openssl /usr/local/ssl \
983                          /usr/local/www /usr/lib/ssl /usr/local \
984                          /usr/pkg /opt /opt/openssl; do
985                 if test "$cf_result" = no; then
986                         if test -d "$ssldir"; then
987                                 OPENSSL_CFLAGS="-I$ssldir/include"
988                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
989                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
990                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
991 #                               # FIXME: This created serious portability problems. --pasky
992 #                               if test "$CC" == "gcc"; then
993 #                                       # I'm not sure about compatibility here. --pasky
994 #                                       LIBS="$LIBS -R$ssldir/lib"
995 #                               fi
996                         else
997                                 LIBS="-lssl -lcrypto $LIBS_X"
998                         fi
999                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1000                         if test "$cf_result" != yes; then
1001                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1002                         fi
1003                 fi
1004         done
1006         if test "$cf_result" != yes; then
1007                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1008                         AC_MSG_ERROR([OpenSSL not found])
1009                 fi
1010                 EL_RESTORE_FLAGS
1011         else
1012                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1014                 CFLAGS="$CFLAGS_X"
1015                 AC_SUBST(OPENSSL_CFLAGS)
1016         fi
1019 AC_MSG_RESULT($cf_result)
1021 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1022 dnl ---- GNU TLS
1023 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1024 dnl it looks ugly then.
1026 if test "$cf_result" = yes; then
1027         cf_result="not used"
1029 else
1030         EL_SAVE_FLAGS
1031         cf_result="no"
1033         if test -z "$disable_gnutls"; then
1034                 # Sure, we maybe _could_ use their macro, but how to ensure
1035                 # that the ./configure script won't fail if the macro won't be
1036                 # found..? :( --pasky
1038                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1040                 if test -d "$gnutls_withval"; then
1041                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1042                 fi
1044                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1046                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1047                         cf_result=no
1048                 else
1049                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1050                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1052                         LIBS="$GNUTLS_LIBS $LIBS_X"
1053                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1054                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1056                         # Verify if it's really usable.  gnutls_session was
1057                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1058                         # (on 2004-06-13); ELinks now requires this.
1059                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[gnutls_session_t dummy;
1060                                      gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no])
1061                 fi
1063                 if test "$cf_result" = yes; then
1064                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1066                         CFLAGS="$CFLAGS_X"
1067                         AC_SUBST(GNUTLS_CFLAGS)
1069                         # Verify if the MD5 compatibility layer is usable.
1070                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1071                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1072                                                   [GNU TLS OpenSSL compatibility],
1073                                                   gnutls/openssl.h, gnutls-openssl,
1074                                                   MD5_Init)
1075                 else
1076                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1077                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1078                         fi
1079                         EL_RESTORE_FLAGS
1080                 fi
1081         fi
1084 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1085 AC_MSG_RESULT($cf_result)
1087 dnl Final SSL setup
1089 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1090 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1091 AC_SUBST(CONFIG_OPENSSL)
1092 AC_SUBST(CONFIG_GNUTLS)
1094 #endif
1096 AC_MSG_CHECKING([whether to be or not to be])
1097 AC_MSG_RESULT([needs to be determined experimentally])
1099 dnl ===================================================================
1100 dnl Check for IPv6 support and related functions.
1101 dnl ===================================================================
1103 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1104 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1105 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1107 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1108 if test "$HAVE_GETADDRINFO" != yes; then
1109         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1110         if test "$HAVE_GETADDRINFO" = yes; then
1111                 LIBS="$LIBS -linet6"
1112         fi
1116 dnl ===================================================================
1117 dnl Checking for X11 (window title restoring).
1118 dnl ===================================================================
1120 AC_PATH_X
1121 if test x"$no_x" != xyes; then
1122         EL_SAVE_FLAGS
1123         if test -n "$x_includes"; then
1124                 X_CFLAGS="-I$x_includes"
1125                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1126                 CFLAGS="$CFLAGS $X_CFLAGS"
1127         fi
1128         if test -n "$x_libraries"; then
1129                 LDFLAGS="$LDFLAGS -L$x_libraries"
1130         fi
1131         LIBS="-lX11 $LIBS"
1132         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1133         EL_RESTORE_FLAGS
1134         if test "$cf_result" = yes; then
1135                 if test -n "$x_libraries"; then
1136                         LDFLAGS="$LDFLAGS -L$x_libraries"
1137                 fi
1138                 LIBS="-lX11 $LIBS"
1139                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1140                 AC_SUBST(X_CFLAGS)
1141         fi
1145 dnl ===================================================================
1146 dnl Backtraces displaying support.
1147 dnl ===================================================================
1149 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1150 # possible checks for other system-specific means go here
1153 dnl ===================================================================
1154 dnl Gettext grey zone. Beware.
1155 dnl ===================================================================
1157 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"
1159 AM_GNU_GETTEXT
1161 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1162 dnl # f33r d4 l33t... I hope it's portable. :)
1163 dnl cf_result=$((48#z - 48#a + 1));
1164 dnl AC_MSG_RESULT($cf_result)
1167 dnl ===================================================================
1168 dnl Compile-time features control
1169 dnl ===================================================================
1171 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1172               [  --disable-cookies       disable cookie support])
1174 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1175               [  --disable-formhist      disable form history support])
1177 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1178               [  --disable-globhist      disable global history support])
1181 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1182               [  --disable-mailcap       disable mailcap support])
1184 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1185               [  --disable-mimetypes     disable mimetypes files support])
1188 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1189               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1190               [IPv6],
1191               [  --disable-ipv6          disable IPv6 support])
1193 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1194               [  --enable-bittorrent     enable BitTorrent protocol support])
1196 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1197               [  --disable-data          disable data protocol support])
1199 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1200               [  --disable-uri-rewrite   disable URI rewrite support])
1202 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1203               [  --enable-cgi            enable local CGI support])
1205 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1206               [  --enable-finger         enable finger protocol support])
1208 dnl ===================================================================
1209 dnl FSP protocol
1210 dnl ===================================================================
1211 EL_SAVE_FLAGS
1213 if test "x${enable_fsp}" != xno; then
1214         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1216         if test "$HAVE_FSPLIB" = yes; then
1217                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1218                 if test "$HAVE_FSPLIB" = yes; then
1219                         LIBS="$LIBS -lfsplib"
1220                 else
1221                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1222                         if test "$HAVE_FSPLIB" = yes; then
1223                                 LIBS="$LIBS -lfsp"
1224                         fi
1225                 fi
1226         fi
1229 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1230               [  --enable-fsp            enable FSP protocol support])
1232 if test "x$CONFIG_FSP" = xno; then
1233         EL_RESTORE_FLAGS
1236 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1237               [  --disable-ftp           disable ftp protocol support])
1239 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1240               [  --enable-gopher         enable gopher protocol support])
1242 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1243               [  --enable-nntp           enable nntp protocol support])
1245 dnl ===================================================================
1246 dnl SMB protocol support.
1247 dnl ===================================================================
1248 EL_SAVE_FLAGS
1250 if test "x${enable_smb}" != xno; then
1251         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1253         if test "$HAVE_SMBCLIENT" = yes; then
1254                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1255                 if test "$HAVE_SMBCLIENT" = yes; then
1256                         LIBS="$LIBS -lsmbclient"
1257                 fi
1258         fi
1261 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1262               [  --enable-smb            enable Samba protocol support])
1264 if test "x$CONFIG_SMB" = xno; then
1265         EL_RESTORE_FLAGS
1269 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1270               [  --disable-mouse         disable mouse support])
1272 # GPM mouse is Linux specific, so ...
1273 CONFIG_SYSMOUSE=yes
1274 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1275               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1276               [BSD sysmouse],
1277               [  --disable-sysmouse      disable BSD sysmouse support])
1279 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1280               [  --enable-88-colors      enable 88 color support])
1282 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1283               [  --enable-256-colors     enable 256 color support])
1285 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1286               [  --enable-true-color     enable true color support])
1288 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1289               [  --enable-exmode         enable exmode (CLI) interface])
1291 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1292               [  --disable-leds          disable LEDs support])
1294 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1295               [  --disable-marks         disable document marks support])
1298 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1299               [  --disable-css           disable Cascading Style Sheet support])
1301 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1302               [  --enable-html-highlight HTML highlighting using DOM engine])
1304 dnl Everything in the tree already uses CONFIG_DOM
1305 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1306 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1308 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1309               [  --disable-backtrace     disable backtrace support])
1311 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1312               [  --enable-no-root        enable prevention of usage by root])
1315 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1316               [  --enable-debug          enable leak debug and internal error checking])
1318 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1319               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1321 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1322               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1324 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1325               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1327 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1328               [  --enable-utf-8          enable UTF-8 support])
1331 AC_ARG_ENABLE(weehoofooboomookerchoo,
1332               [
1333     Also check out the features.conf file for more information about features!
1334               ],
1335               [AC_MSG_ERROR(Are you strange, or what?)])
1338 dnl == EMX hack
1340 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1341 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1344 dnl ===================================================================
1345 dnl Export directory paths
1346 dnl ===================================================================
1348 # Set up the ``entry points'' if they were not supplied by builder
1349 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1350 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1352 # Create CONFDIR #define for config.h
1354 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1355 # it's autoconf fault to force us to do such hacks ;p.
1356 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1357   # sysconfdir is set to its default value... fine, let's append /elinks/
1358   # XXX: We can't modify listing of the default in ./configure --help :-(
1359   sysconfdir_n=`eval echo "$sysconfdir"`
1360   sysconfdir=$sysconfdir_n
1361   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1362         sysconfdir="$sysconfdir/elinks"
1365 CONFDIR=$sysconfdir
1366 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1367 AC_SUBST(CONFDIR)
1369 # Create LOCALEDIR #define for config.h
1370 LOCALEDIR=`eval echo "$datadir/locale"`
1371 while echo "$LOCALEDIR" | grep "\\$"
1373         LOCALEDIR=`eval echo "$LOCALEDIR"`
1374 done > /dev/null 2> /dev/null
1375 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1376 AC_SUBST(LOCALEDIR)
1378 # Create LIBDIR #define for config.h
1379 LIBDIR=`eval echo "$libdir"`
1380 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1381 AC_SUBST(LIBDIR)
1383 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1384 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1386 dnl ===================================================================
1387 dnl A little fine tuning of gcc specific options (continued)
1388 dnl ===================================================================
1390 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1391   if test "$CONFIG_DEBUG" = "yes"; then
1392     dnl We want to see all warnings and live with none (in debug mode).
1393     CFLAGS="$CFLAGS -Werror"
1394   fi
1396   case "`$CC -dumpversion`" in
1397     3.0|3.1|3.2)
1398       # These should be ok using -Werror
1399       ;;
1400     3.*)
1401       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1402       # "dereferencing type-punned pointer will break strict-aliasing rules"
1403       # warnings. Disable them by not doing any strict-aliasing. The
1404       # alternative is just too ugly. Thanks gcc guys!! ;)
1405       CFLAGS="$CFLAGS -fno-strict-aliasing"
1406       ;;
1407     4.*)
1408       # Do not show warnings related to (char * | unsigned char *) type
1409       # difference.
1410       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1411       ;;
1412     *)
1413       # These should be ok using -Werror
1414       ;;
1415   esac
1417   # GCC 4.2 snapshots warn that comparisons like &object != NULL
1418   # always return true.  Some macros in ELinks check whether pointer
1419   # arguments are NULL, and giving them addresses of named objects
1420   # triggers the warning.  These warnings have not revealed any real
1421   # bugs, so shut them up instead of complicating the code.  GCC 4.1
1422   # does not recognize -Wno-always-true and exits with code 1 if it is
1423   # given.
1424   AC_MSG_CHECKING([whether $CC accepts -Wno-always-true])
1425   EL_SAVE_FLAGS
1426   CFLAGS="$CFLAGS -Wno-always-true"
1427   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[AC_MSG_RESULT([yes])],[EL_RESTORE_FLAGS
1428      AC_MSG_RESULT([no])])
1431 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1432 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1433 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1434 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1436 dnl ===================================================================
1437 dnl Colored make output
1438 dnl ===================================================================
1440 if test $(`which tput` colors) -ge 4; then
1441         MAKE_COLOR=1
1442         AC_SUBST(MAKE_COLOR)
1445 dnl ===================================================================
1446 dnl Generated files
1447 dnl ===================================================================
1449 AC_CONFIG_FILES([ \
1450  Makefile.config \
1451  contrib/elinks.spec \
1452  contrib/lua/hooks.lua \
1453  contrib/conv/w3m2links.awk \
1454  doc/man/man1/elinks.1 \
1455  src/intl/gettext/ref-add.sed \
1456  src/intl/gettext/ref-del.sed
1458 AC_OUTPUT
1460 abs_srcdir="$(cd "$srcdir" && pwd)"
1461 # builddir is always absolute!
1462 if test "$abs_srcdir" != "$builddir"; then
1463         # Bootstrap the Makefile creation
1464         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1465         "$MAKE" "SRC=$abs_srcdir" init
1467         # Make cg-status ignore this build directory
1468         echo "*" > "$builddir/.gitignore"
1471 dnl ===================================================================
1472 dnl Configuration summary
1473 dnl ===================================================================
1475 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1476 cat features.log