pl.po: Previous commit was wrong.
[elinks.git] / configure.in
blobd32ca56a7564c5ab2dd4d276d337b4fbe7fe95bf
1 dnl Process this file with autoconf to produce a configure script.
3 dnl There are two types of comments in this file.
4 dnl Comments that refer to Autoconf macros begin with "dnl", and m4
5 dnl discards them.  Other comments begin with "#", and they get copied
6 dnl to the configure script, hopefully making it easier to read.
8 dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
9 dnl Autoconf 2.59 is installed in the computer that generates our nightly
10 dnl snapshots, so we need to be compatible with that.
11 AC_PREREQ(2.59)
12 AC_INIT
13 AC_CONFIG_SRCDIR([src/main/main.c])
14 AC_CONFIG_AUX_DIR(config)
16 PACKAGE=elinks
17 VERSION=0.12.GIT
18 AC_SUBST(PACKAGE)
19 AC_SUBST(VERSION)
20 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
21 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
22 AC_CONFIG_HEADERS(config.h)
24 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
25 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
26 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
28 MAKE=
30 for make in gnumake gmake make false; do
31         if test "x$MAKE" = x; then
32                 AC_PATH_PROGS(MAKE, "$make")
33         fi
34 done
36 builddir="`pwd`"
38 # Cleanup if we are configuring with a previous build in the tree
39 if test -e Makefile.config; then
40         AC_MSG_CHECKING([for previous build to clean])
41         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
42         AC_MSG_RESULT(done)
45 # ===================================================================
46 # Load feature configuration file and start logging features.
47 # ===================================================================
49 features="features.conf"
50 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
51 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
52 echo "Feature summary:" > features.log
54 # ===================================================================
55 # Checks for programs.
56 # ===================================================================
58 AC_PROG_CC
59 AC_PROG_AWK
60 AC_PATH_PROGS(AWK, "$AWK")
61 AC_PROG_RANLIB
62 AC_PROG_INSTALL
64 AC_PATH_PROGS(GIT, "git")
65 AC_PATH_PROGS(SPARSE, "sparse")
67 CONFIG_ASCIIDOC="no"
68 CONFIG_POD2HTML="no"
69 CONFIG_XMLTO="no"
70 CONFIG_JW="no"
72 if test "x$CONFIG_DOC" != xno; then
73         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
74         if test "x$ASCIIDOC" != "x"; then
75                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
76                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
77                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
79                 echo > config.asciidoc-unsafe.txt
80                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
81                         ASCIIDOC_FLAGS=--unsafe
82                 fi
83                 rm config.asciidoc-unsafe.*
84         fi
86         AC_PATH_PROGS(XMLTO, "xmlto")
87         if test "x$XMLTO" != "x"; then
88                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
89                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
90                 EL_CONFIG(MAN_XMLTO, [man (groff)])
91         fi
93         AC_PATH_PROGS(JW, "jw")
94         if test "x$JW" != "x"; then
95                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
96                 EL_CONFIG(MANUAL_JW, [PDF])
97         fi
99         AC_PATH_PROGS(POD2HTML, "pod2html")
100         if test "x$POD2HTML" != "x"; then
101                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
102         fi
104         AC_PATH_PROGS(DOXYGEN, "doxygen")
105         if test "x$DOXYGEN" != "x"; then
106                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
107                 api_srcdir="$(cd "$srcdir" && pwd)/src"
108                 AC_SUBST(api_srcdir)
109         fi
112 AC_SUBST(ASCIIDOC_FLAGS)
113 AC_SUBST(CONFIG_ASCIIDOC)
114 AC_SUBST(CONFIG_DOXYGEN)
115 AC_SUBST(CONFIG_POD2HTML)
116 AC_SUBST(CONFIG_XMLTO)
117 AC_SUBST(CONFIG_JW)
119 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
120 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
121 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
122 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
124 # gcc specific options (to be continued at the bottom of configure)
125 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
126   # We want to see all warnings and live with none.
127   # We can't set up -Werror here as there may be some warnings in test
128   # suite of configure, and we don't want to fail them.
129   CFLAGS="$CFLAGS -Wall"
132 # ===================================================================
133 # Checks for special OSes.
134 # ===================================================================
136 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
137 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
139         AC_MSG_CHECKING([for $2])
141         for flag in $3; do
142                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
143 kill me!
144 #endif ]])],[$1=yes],[$1=no])
145                 if test "[$]$1" = yes; then
146                         EL_CONFIG([$1], [$2])
147                         break
148                 fi
149         done
151         AC_MSG_RESULT([$]$1)
154 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
155 AC_SUBST(CONFIG_OS_BEOS)
157 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
158 AC_SUBST(CONFIG_OS_RISCOS)
160 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
161 AC_SUBST(CONFIG_OS_WIN32)
163 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
164 AC_SUBST(CONFIG_OS_OS2)
165 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
167 AC_MSG_CHECKING([for UNIX])
168 dnl FIXME: some depend kind of mechanism
169 if test "$CONFIG_OS_BEOS" = no && \
170    test "$CONFIG_OS_RISCOS" = no && \
171    test "$CONFIG_OS_WIN32" = no && \
172    test "$CONFIG_OS_OS2" = no; then
173         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
174 else
175         CONFIG_OS_UNIX=no
177 AC_MSG_RESULT($CONFIG_OS_UNIX)
178 AC_SUBST(CONFIG_OS_UNIX)
180 # ===================================================================
181 # Checks for header files.
182 # ===================================================================
184 AC_HEADER_DIRENT
185 AC_HEADER_STDC
186 AC_HEADER_SYS_WAIT
187 AC_HEADER_TIME
189 AC_CHECK_HEADERS(wctype.h)
190 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
191 AC_CHECK_HEADERS(sigaction.h)
192 AC_CHECK_HEADERS(arpa/inet.h)
193 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
194 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
195 AC_CHECK_HEADERS(ifaddrs.h)
196 AC_CHECK_HEADERS(sys/cygwin.h io.h)
197 AC_CHECK_HEADERS(sys/fmutex.h)
198 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
199 AC_CHECK_HEADERS(sys/resource.h)
200 AC_CHECK_HEADERS(sys/select.h)
201 AC_CHECK_HEADERS(sys/signal.h)
202 AC_CHECK_HEADERS(sys/socket.h)
203 AC_CHECK_HEADERS(sys/time.h)
204 AC_CHECK_HEADERS(sys/utsname.h)
205 AC_CHECK_HEADERS(stdint.h inttypes.h)
206 AC_CHECK_HEADERS(locale.h pwd.h)
207 AC_CHECK_HEADERS(termios.h)
210 AC_CHECK_HEADERS(sys/un.h,
211         [CONFIG_INTERLINK=yes
212          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
213         [CONFIG_INTERLINK=no])
214 AC_SUBST(CONFIG_INTERLINK)
216 # ===================================================================
217 # Checks for typedefs, structures, and compiler characteristics.
218 # ===================================================================
220 AC_STRUCT_TM
221 AC_C_CONST
222 AC_C_INLINE
223 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
225 AC_SYS_LARGEFILE
226 AC_TYPE_SIZE_T
227 AC_TYPE_OFF_T
228 EL_CHECK_TYPE(ssize_t, int)
229 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
230 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
231 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
232 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
233 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
235 AC_CHECK_SIZEOF(char, 1)
236 AC_CHECK_SIZEOF(short, 2)
237 AC_CHECK_SIZEOF(int, 4)
238 AC_CHECK_SIZEOF(long, 4)
239 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
240 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
242 # Check for variadic macros
243 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
244                 [#include <stdio.h>
245                  #define a(b,c...) printf(b,##c)],
246                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
248 # Check for -rdynamic
250 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
251 # the executable to its dynamic symbol table.  ELinks uses this for
252 # two purposes:
254 # 1. If ELinks detects a bug, it can try to display a backtrace by
255 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
256 #    manual states users of GNU ld must pass -rdynamic to make the
257 #    symbols available to the program.
259 # 2. It would eventually be nice to dynamically load shared
260 #    libraries as plugins (bug 73).  The plugins must be able to
261 #    call ELinks functions.  This can be implemented either by
262 #    registering all callable functions in ELinks-specific data
263 #    structures, or by letting the dynamic linker handle them.
264 #    The latter way requires something equivalent to -rdynamic.
266 # Because backtraces are not needed for correct operation, and bug
267 # 73 is not yet being fixed, the configure script and makefiles
268 # should not complain to the user if they find that -rdynamic does
269 # not work.  Besides, it was reported at elinks-users on 2006-09-12
270 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
271 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
272 # -rdynamic but does something equivalent automatically.  (This was
273 # tested with "nm -D elinks | grep redraw_from_window".)
275 # FIXME: This check doesn't work. Something to do with the compiler
276 # happily ignoring it and stderr not being checked for error messages.
277 AC_MSG_CHECKING([for -rdynamic])
278 LDFLAGS_X="$LDFLAGS"
279 LDFLAGS="$LDFLAGS -rdynamic"
280 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
281 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
282 AC_MSG_RESULT($have_rdynamic)
284 # ===================================================================
285 # Check for POSIX <regex.h>
286 # ===================================================================
288 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
290 # ===================================================================
291 # Checks for library functions.
292 # ===================================================================
294 AC_PROG_GCC_TRADITIONAL
295 AC_FUNC_MEMCMP
296 AC_FUNC_MMAP
297 AC_FUNC_STRFTIME
298 AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
299 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
300 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
301 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
302 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
303 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
304 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
305 AC_CHECK_FUNCS(gettimeofday clock_gettime)
307 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
309 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
310 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
311 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
313 # These aren't probably needed now, as they are commented in links.h.
314 # I've no idea about their historical background, but I keep them here
315 # just in the case they will help later. --pasky
316 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
317 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
318 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
319 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
321 if test x"$HAVE_RAISE" = x; then
322         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
323                 AC_MSG_ERROR([Unable to emulate raise()])
324         fi
327 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
328 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
329 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
330 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
331         EL_DEFINE(HAVE_VA_COPY, __va_copy)
334 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
335 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
336 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
337 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
338         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
341 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
342 AC_RUN_IFELSE([AC_LANG_SOURCE([[
343 #include <stdio.h>
344 #include <stdarg.h>
345 #include <stdlib.h>
346 #include <string.h>
348 char buf[8];
350 int bar(char *buf, const char *format, va_list ap)
352        return vsnprintf(buf, 0, format, ap);
355 void foo(const char *format, ...) {
356        va_list ap;
357        int len;
359        va_start(ap, format);
360        len = bar(buf, format, ap);
361        va_end(ap);
362        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
364        va_start(ap, format);
365        len = bar(buf, format, ap);
366        va_end(ap);
367        if ((len != 6) && (len != 7)) exit(1);
369        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
371        exit(0);
373 main() { foo("hello\n"); }
374 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
375 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
376         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
379 # OpenSSL and Lua frequently need dlopen
380 AC_CHECK_LIB(dl, dlopen)
382 # ===================================================================
383 # Checks for libraries.
384 # ===================================================================
386 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
387 if test "$cf_result" = no; then
388         AC_CHECK_LIB(socket, socket)
391 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
392 if test "$cf_result" = no; then
393         AC_CHECK_LIB(socket, setsockopt)
396 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
397 if test "$cf_result" = no; then
398         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
399         if test "$cf_result" = no; then
400                 AC_CHECK_LIB(nsl, gethostbyname)
401         else
402                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
403         fi
406 # ===================================================================
407 # Checks for packaging specific options.
408 # ===================================================================
410 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
411             [ if test "$withval" != no && test "$withval" != yes; then
412                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
413               fi ])
415 # ===================================================================
416 # Checks for a libraries, optional even if installed.
417 # ===================================================================
419 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
420 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
422         AC_MSG_CHECKING([for $2 support])
424         if test "[$]$1" != no; then
425                 AC_MSG_RESULT(yes)
426                 EL_SAVE_FLAGS
427                 if test -n "$withval" && test -d "$withval"; then
428                         # Be a little more careful when setting
429                         # include and lib directories. This way
430                         # $withval will work when includes are
431                         # there but the library is in the common
432                         # /usr/lib ... Does the right thing when
433                         # looking for gc on Debian.
434                         if test -d "$withval/include"; then
435                                 CFLAGS="$CFLAGS -I$withval/include"
436                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
437                         else
438                                 CFLAGS="$CFLAGS -I$withval"
439                                 CPPFLAGS="$CPPFLAGS -I$withval"
440                         fi
441                         if test -d "$withval/lib"; then
442                                 LDFLAGS="$LDFLAGS -L$withval/lib"
443                         fi
444                 fi
446                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
447                 if test "[$]$1" = yes; then
448                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
449                 fi
451                 if test "[$]$1" = yes; then
452                         EL_CONFIG([$1], [$2])
453                         LIBS="$LIBS -l$4"
454                 else
455                         if test -n "[$]WITHVAL_$1" &&
456                            test "[$]WITHVAL_$1" != xno; then
457                                 AC_MSG_ERROR([$2 not found])
458                         fi
459                         EL_RESTORE_FLAGS
460                 fi
461         else
462                 AC_MSG_RESULT(disabled)
463         fi
466 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
467 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
469         $1=yes
470         WITHVAL_$1=
472         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
473         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
475         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
477         EL_LOG_CONFIG([$1], [$2], [])
480 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
481         [  --without-gpm           disable gpm (mouse) support])
483 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
484 # enable automatic decoding of both zlib and gzip headers.  This
485 # feature was added in zlib 1.2.0.2; earlier versions return an error.
486 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
487 # that, even though ELinks does not actually call gzclearerr.
488 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
489         [  --without-zlib          disable zlib support])
491 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
492         [  --without-bzlib         disable bzlib support])
494 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
495         [  --without-idn           disable international domain names support])
497 if test "x{with_gc}" != xno; then
498         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
499                 [  --with-gc               enable Boehm's garbage collector])
502 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
503         [  --without-lzma          disable lzma encoding support])
505 # ===================================================================
506 # Check for GSSAPI, optional even if installed.
507 # ===================================================================
509 enable_gssapi="no";
511 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
512             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
514 AC_MSG_CHECKING([for GSSAPI])
516 if test "$enable_gssapi" = "yes"; then
517         AC_MSG_RESULT(yes)
518         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
519         GSSAPI_LIBS=`krb5-config --libs gssapi`
520         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
521         LIBS="$GSSAPI_LIBS $LIBS"
522         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
523 else
524         AC_MSG_RESULT(no)
527 AC_SUBST(CONFIG_GSSAPI)
529 # ===================================================================
530 # Bookmark and XBEL support
531 # ===================================================================
533 EL_SAVE_FLAGS
535 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
536               [  --disable-bookmarks     disable bookmark support])
538 # Check whether --enable-xbel or --disable-xbel was given.
539 if test "x${enable_xbel}" != xno; then
540         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
542         if test "$HAVE_LIBEXPAT" = yes; then
543                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
544                 if test "$HAVE_LIBEXPAT" = yes; then
545                         LIBS="$LIBS -lexpat"
546                 fi
547         fi
551 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
552               [XBEL bookmarks],
553               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
555 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
556         EL_RESTORE_FLAGS
559 # ===================================================================
560 # Checks for BSD sysmouse
561 # ===================================================================
563 HAVE_SYSMOUSE_HEADER="no"
565 # Either of these header files provides the (same) sysmouse interface
566 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
568 # ===================================================================
569 # Checks for OS/2
570 # ===================================================================
572 if test "$CONFIG_OS_OS2" = yes; then
573         EL_CONFIG_OS_OS2
576 # ===================================================================
577 # Checks for Win32
578 # ===================================================================
580 if test "$CONFIG_OS_WIN32" = yes; then
581         EL_CONFIG_OS_WIN32
584 # ===================================================================
585 # Check for SEE (Simple Ecmascript Engine)
586 # ===================================================================
587 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
588             [ if test "x$withval" != xno; then enable_see=yes; fi ])
590 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
591 # SEE_FLAGS but I really don't want to require people to have Guile in order
592 # to compile CVS. Also, the macro seems to be really stupid regarding searching
593 # for Guile in $PATH etc. --pasky
595 CONFIG_ECMASCRIPT_SEE=no
597 if test "$enable_see" = "yes"; then
598         if test -d "$withval"; then
599                 SEE_PATH="$withval:$PATH"
600         else
601                 SEE_PATH="$PATH"
602         fi
604         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
605         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
606         if test "$SEE_CONFIG" != no; then
607                 EL_SAVE_FLAGS
608                 SEE_LIBS="`$SEE_CONFIG --libs`"
609                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
610                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
611                 LIBS="$SEE_LIBS $LIBS_X"
612                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
613                         #error SEE too old
614                         #endif
615                 ]])],[cf_result=yes],[cf_result=no])
616                 EL_RESTORE_FLAGS
617                 if test "$cf_result" = yes; then
618                         LIBS="$SEE_LIBS $LIBS"
619                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
620                         AC_SUBST(SEE_CFLAGS)
621                 fi
622                 AC_MSG_RESULT($cf_result)
623         else
624                 if test -n "$withval" && test "x$withval" != xno; then
625                         AC_MSG_ERROR([SEE not found])
626                 else
627                         AC_MSG_WARN([SEE support disabled])
628                 fi
629         fi
632 # ===================================================================
633 # Check for SpiderMonkey, optional even if installed.
634 # ===================================================================
636 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
637             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
638 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
640 EL_SAVE_FLAGS
641 cf_result=no
643 if test -z "$disable_spidermonkey"; then
644         if test ! -d "$withval"; then
645                 withval="";
646         fi
647         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
648                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
649                         for spidermonkeylib in js smjs mozjs; do
650                                 if test "$cf_result" = no &&
651                                    test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then
652                                         SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
653                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
655                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
656                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
657                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
659                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
660                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
661                                 fi
662                         done
663                 done
664         done
667 AC_MSG_RESULT($cf_result)
668 CONFIG_SPIDERMONKEY="$cf_result"
669 EL_RESTORE_FLAGS
671 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
672    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
673         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
674 else
675         CONFIG_ECMASCRIPT_SMJS=no
678 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
679 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
680 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
683 # ===================================================================
684 # Optional Spidermonkey-based ECMAScript browser scripting
685 # ===================================================================
687 AC_ARG_ENABLE(sm-scripting,
688               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
689               [if test "$enableval" != no; then enableval="yes"; fi
690                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
692 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
693    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
694         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
695 else
696         CONFIG_SCRIPTING_SPIDERMONKEY=no
699 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
700    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
701         LIBS="$LIBS $SPIDERMONKEY_LIBS"
702         AC_SUBST(SPIDERMONKEY_LIBS)
703         AC_SUBST(SPIDERMONKEY_CFLAGS)
704         AC_SUBST(CONFIG_SPIDERMONKEY)
707 # ===================================================================
708 # Check for Guile, optional even if installed.
709 # ===================================================================
711 enable_guile="no";
713 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
714             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
716 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
717 # GUILE_FLAGS but I really don't want to require people to have Guile in order
718 # to compile CVS. Also, the macro seems to be really stupid regarding searching
719 # for Guile in $PATH etc. --pasky
721 AC_MSG_CHECKING([for Guile])
723 if test "$enable_guile" = "yes"; then
724         AC_MSG_RESULT(yes);
725         ## Based on the GUILE_FLAGS macro.
727         if test -d "$withval"; then
728                 GUILE_PATH="$withval:$PATH"
729         else
730                 GUILE_PATH="$PATH"
731         fi
733         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
735         ## First, let's just see if we can find Guile at all.
736         if test "$GUILE_CONFIG" != no; then
737                 cf_result="yes";
739                 GUILE_LIBS="`guile-config link`"
740                 GUILE_CFLAGS="`guile-config compile`"
741                 LIBS="$GUILE_LIBS $LIBS"
742                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
743                 AC_SUBST(GUILE_CFLAGS)
744                 cat <<EOF
745 ***********************************************************************
746 The Guile support is incomplete and not so well integrated to ELinks
747 yet. That means, e.g., that you have no Guile console and there might
748 not be all the necessary hooks. Also, the Guile interface is not too
749 well tested (success stories heartily welcomed!).  See
750 src/scripting/guile/README for further details and hints.
751 ***********************************************************************
753         else
754                 if test -n "$withval" && test "x$withval" != xno; then
755                         AC_MSG_ERROR([Guile not found])
756                 else
757                         AC_MSG_WARN([Guile support disabled])
758                 fi
759         fi
760 else
761         AC_MSG_RESULT(no);
764 # ===================================================================
765 # Check for Perl
766 # ===================================================================
767 enable_perl="no";
769 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
770             [
771 if test "$withval" = yes; then
772         # FIXME: If withval is a valid directory append it to PATH
773         # so that you can specify one of several perl installations.
774         withval="";
775         enable_perl=yes;
777             ])
779 AC_MSG_CHECKING([for Perl])
781 cf_result=no
783 EL_SAVE_FLAGS
785 if test "$enable_perl" = "yes"; then
786         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
787         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
788         LIBS="$PERL_LIBS $LIBS"
789         CFLAGS="$PERL_CFLAGS $CFLAGS"
790         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
791         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
792 #include <EXTERN.h>
793 #include <perl.h>
794 #include <perlapi.h>
795 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
798 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
800 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
801 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
802 #include <EXTERN.h>
803 #include <perl.h>
804 extern PerlInterpreter *my_perl;
805 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
806 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
807                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
808 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
810 if test "$cf_result" != "yes"; then
811         EL_RESTORE_FLAGS
812 else
813         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
815         CFLAGS="$CFLAGS_X"
816         CPPFLAGS="$CPPFLAGS_X"
817         AC_SUBST(PERL_LIBS)
818         AC_SUBST(PERL_CFLAGS)
821 # ===================================================================
822 # Check for Python
823 # ===================================================================
824 enable_python="no";
826 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
827             [ if test "x$withval" != xno; then enable_python=yes; fi ])
829 EL_SAVE_FLAGS
830 cf_result=no
832 AC_MSG_CHECKING([for Python])
834 if test "$enable_python" = "yes"; then
835         AC_MSG_RESULT(yes);
837         if test -d "$withval"; then
838                 PYTHON_PATH="$withval:$PATH"
839         else
840                 PYTHON_PATH="$PATH"
841         fi
843         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
845         if test "$PYTHON" != no; then
846                 cf_result="yes";
848                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
849                 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"))'`"
850                 LIBS="$PYTHON_LIBS $LIBS"
851                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
852                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
854                 if test "$cf_result" != "yes"; then
855                         EL_RESTORE_FLAGS
856                 else
857                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
858                         AC_SUBST(PYTHON_LIBS)
859                         AC_SUBST(PYTHON_CFLAGS)
860                         CPPFLAGS="$CPPFLAGS_X"
861                         cat <<EOF
862 ***********************************************************************
863 The Python support is incomplete and not so well integrated to ELinks
864 yet. That means, e.g., that you have no Python console and there might
865 not be all the necessary hooks. Also, the Python interface is not too
866 well tested (success stories heartily welcomed!).
867 ***********************************************************************
869                 fi
870         else
871                 if test -n "$withval" && test "x$withval" != xno; then
872                         AC_MSG_ERROR([Python not found])
873                 else
874                         AC_MSG_WARN([Python support disabled])
875                 fi
876         fi
877 else
878         AC_MSG_RESULT(no);
882 # ===================================================================
883 # Check for Lua, optional even if installed.
884 # ===================================================================
886 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
887 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
889 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
890             [if test "$withval" = no; then disable_lua=yes; fi])
891 AC_MSG_CHECKING([for Lua])
893 EL_SAVE_FLAGS
894 cf_result=no
896 if test -z "$disable_lua"; then
897         if test ! -d "$withval"; then
898                 withval="";
899         fi
900         for luadir in "$withval" "" /usr /usr/local; do
901                 for suffix in "" 50; do
902                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
903                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
904                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
905                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
907                                 LIBS="$LUA_LIBS $LIBS_X"
908                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
909                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
911                                 # Check that it is a compatible Lua version
912                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
913                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
914                                                 luaopen_base(L);
915                                                 luaopen_table(L);
916                                                 luaopen_io(L);
917                                                 luaopen_string(L);
918                                                 luaopen_math(L);
919                                                 lua_pushboolean(L, 1);
920                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
921                         fi
922                 done
923         done
926 AC_MSG_RESULT($cf_result)
928 if test "$cf_result" != yes; then
929         EL_RESTORE_FLAGS
930 else
931         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
932         AC_CHECK_HEADERS(lauxlib.h)
934         CFLAGS="$CFLAGS_X"
935         CPPFLAGS="$CPPFLAGS_X"
936         AC_SUBST(LUA_LIBS)
937         AC_SUBST(LUA_CFLAGS)
941 # ===================================================================
942 # Check for Ruby, optional even if installed.
943 # ===================================================================
945 EL_CONFIG_SCRIPTING_RUBY
947 # ===================================================================
948 # Setup global scripting
949 # ===================================================================
951 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])
952 AC_SUBST(CONFIG_SCRIPTING_GUILE)
953 AC_SUBST(CONFIG_SCRIPTING_LUA)
954 AC_SUBST(CONFIG_SCRIPTING_PERL)
955 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
956 AC_SUBST(CONFIG_SCRIPTING_RUBY)
957 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
958 AC_SUBST(CONFIG_SCRIPTING)
961 # ===================================================================
962 # Check for SSL support.
963 # ===================================================================
965 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
966 # is enabled, we won't try to use OpenSSL anymore.
968 # For wiping SSL hooks..
969 #ifdef CONFIG_SSL
971 disable_openssl=""
972 disable_gnutls=""
973 enable_gnutls=""
975 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
976             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
977 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
978             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
979 gnutls_withval="$withval"
981 if test "$enable_gnutls" = yes; then
982         disable_openssl=yes;
985 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
986             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
987 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
988 openssl_withval="$withval"
990 # ---- OpenSSL
992 AC_MSG_CHECKING([for OpenSSL])
994 EL_SAVE_FLAGS
995 cf_result="no"
997 if test "$disable_openssl" = yes; then
998         cf_result="not used"
999 else
1000         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
1001                          /usr/lib/openssl /usr/local/ssl \
1002                          /usr/local/www /usr/lib/ssl /usr/local \
1003                          /usr/pkg /opt /opt/openssl; do
1004                 if test "$cf_result" = no; then
1005                         if test -d "$ssldir"; then
1006                                 OPENSSL_CFLAGS="-I$ssldir/include"
1007                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1008                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1009                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1010 #                               # FIXME: This created serious portability problems. --pasky
1011 #                               if test "$CC" == "gcc"; then
1012 #                                       # I'm not sure about compatibility here. --pasky
1013 #                                       LIBS="$LIBS -R$ssldir/lib"
1014 #                               fi
1015                         else
1016                                 LIBS="-lssl -lcrypto $LIBS_X"
1017                         fi
1018                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1019                         if test "$cf_result" != yes; then
1020                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1021                         fi
1022                 fi
1023         done
1025         if test "$cf_result" != yes; then
1026                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1027                         AC_MSG_ERROR([OpenSSL not found])
1028                 fi
1029                 EL_RESTORE_FLAGS
1030         else
1031                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1033                 CFLAGS="$CFLAGS_X"
1034                 AC_SUBST(OPENSSL_CFLAGS)
1035         fi
1038 AC_MSG_RESULT($cf_result)
1040 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1041 # ---- GNU TLS
1042 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1043 dnl it looks ugly then.
1045 if test "$cf_result" = yes; then
1046         cf_result="not used"
1048 else
1049         EL_SAVE_FLAGS
1050         cf_result="no"
1052         if test -z "$disable_gnutls"; then
1053                 # Sure, we maybe _could_ use their macro, but how to ensure
1054                 # that the ./configure script won't fail if the macro won't be
1055                 # found..? :( --pasky
1057                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1059                 if test -d "$gnutls_withval"; then
1060                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1061                 fi
1063                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1065                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1066                         cf_result=no
1067                 else
1068                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1069                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1071                         LIBS="$GNUTLS_LIBS $LIBS_X"
1072                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1073                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1075                         # Verify if it's really usable.  gnutls_session was
1076                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1077                         # (on 2004-06-13); ELinks now requires this.
1078                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[gnutls_session_t dummy;
1079                                      gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no])
1080                 fi
1082                 if test "$cf_result" = yes; then
1083                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1085                         CFLAGS="$CFLAGS_X"
1086                         AC_SUBST(GNUTLS_CFLAGS)
1088                         # Verify if the MD5 compatibility layer is usable.
1089                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1090                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1091                                                   [GNU TLS OpenSSL compatibility],
1092                                                   gnutls/openssl.h, gnutls-openssl,
1093                                                   MD5_Init)
1094                 else
1095                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1096                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1097                         fi
1098                         EL_RESTORE_FLAGS
1099                 fi
1100         fi
1103 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1104 AC_MSG_RESULT($cf_result)
1106 # Final SSL setup
1108 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1109 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1110 AC_SUBST(CONFIG_OPENSSL)
1111 AC_SUBST(CONFIG_GNUTLS)
1113 #endif
1115 AC_MSG_CHECKING([whether to be or not to be])
1116 AC_MSG_RESULT([needs to be determined experimentally])
1118 # ===================================================================
1119 # Check for IPv6 support and related functions.
1120 # ===================================================================
1122 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1123 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1124 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1126 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1127 if test "$HAVE_GETADDRINFO" != yes; then
1128         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1129         if test "$HAVE_GETADDRINFO" = yes; then
1130                 LIBS="$LIBS -linet6"
1131         fi
1135 # ===================================================================
1136 # Checking for X11 (window title restoring).
1137 # ===================================================================
1139 AC_PATH_X
1140 if test x"$no_x" != xyes; then
1141         EL_SAVE_FLAGS
1142         if test -n "$x_includes"; then
1143                 X_CFLAGS="-I$x_includes"
1144                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1145                 CFLAGS="$CFLAGS $X_CFLAGS"
1146         fi
1147         if test -n "$x_libraries"; then
1148                 LDFLAGS="$LDFLAGS -L$x_libraries"
1149         fi
1150         LIBS="-lX11 $LIBS"
1151         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1152         EL_RESTORE_FLAGS
1153         if test "$cf_result" = yes; then
1154                 if test -n "$x_libraries"; then
1155                         LDFLAGS="$LDFLAGS -L$x_libraries"
1156                 fi
1157                 LIBS="-lX11 $LIBS"
1158                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1159                 AC_SUBST(X_CFLAGS)
1160         fi
1164 # ===================================================================
1165 # Backtraces displaying support.
1166 # ===================================================================
1168 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1169 # possible checks for other system-specific means go here
1172 # ===================================================================
1173 # Gettext grey zone. Beware.
1174 # ===================================================================
1176 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"
1178 AM_GNU_GETTEXT
1180 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1181 dnl # f33r d4 l33t... I hope it's portable. :)
1182 dnl cf_result=$((48#z - 48#a + 1));
1183 dnl AC_MSG_RESULT($cf_result)
1186 # ===================================================================
1187 # Compile-time features control
1188 # ===================================================================
1190 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1191               [  --disable-cookies       disable cookie support])
1193 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1194               [  --disable-formhist      disable form history support])
1196 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1197               [  --disable-globhist      disable global history support])
1200 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1201               [  --disable-mailcap       disable mailcap support])
1203 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1204               [  --disable-mimetypes     disable mimetypes files support])
1207 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1208               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1209               [IPv6],
1210               [  --disable-ipv6          disable IPv6 support])
1212 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1213               [  --enable-bittorrent     enable BitTorrent protocol support])
1215 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1216               [  --disable-data          disable data protocol support])
1218 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1219               [  --disable-uri-rewrite   disable URI rewrite support])
1221 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1222               [  --enable-cgi            enable local CGI support])
1224 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1225               [  --enable-finger         enable finger protocol support])
1227 # ===================================================================
1228 # FSP protocol
1229 # ===================================================================
1230 EL_SAVE_FLAGS
1232 if test "x${enable_fsp}" != xno; then
1233         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1235         if test "$HAVE_FSPLIB" = yes; then
1236                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1237                 if test "$HAVE_FSPLIB" = yes; then
1238                         LIBS="$LIBS -lfsplib"
1239                 else
1240                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1241                         if test "$HAVE_FSPLIB" = yes; then
1242                                 LIBS="$LIBS -lfsp"
1243                         fi
1244                 fi
1245         fi
1248 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1249               [  --enable-fsp            enable FSP protocol support])
1251 if test "x$CONFIG_FSP" = xno; then
1252         EL_RESTORE_FLAGS
1255 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1256               [  --disable-ftp           disable ftp protocol support])
1258 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1259               [  --enable-gopher         enable gopher protocol support])
1261 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1262               [  --enable-nntp           enable nntp protocol support])
1264 # ===================================================================
1265 # SMB protocol support.
1266 # ===================================================================
1267 EL_SAVE_FLAGS
1269 if test "x${enable_smb}" != xno; then
1270         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1272         if test "$HAVE_SMBCLIENT" = yes; then
1273                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1274                 if test "$HAVE_SMBCLIENT" = yes; then
1275                         LIBS="$LIBS -lsmbclient"
1276                 fi
1277         fi
1280 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1281               [  --enable-smb            enable Samba protocol support])
1283 if test "x$CONFIG_SMB" = xno; then
1284         EL_RESTORE_FLAGS
1288 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1289               [  --disable-mouse         disable mouse support])
1291 # GPM mouse is Linux specific, so ...
1292 CONFIG_SYSMOUSE=yes
1293 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1294               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1295               [BSD sysmouse],
1296               [  --disable-sysmouse      disable BSD sysmouse support])
1298 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1299               [  --enable-88-colors      enable 88 color support])
1301 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1302               [  --enable-256-colors     enable 256 color support])
1304 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1305               [  --enable-true-color     enable true color support])
1307 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1308               [  --enable-exmode         enable exmode (CLI) interface])
1310 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1311               [  --disable-leds          disable LEDs support])
1313 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1314               [  --disable-marks         disable document marks support])
1317 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1318               [  --disable-css           disable Cascading Style Sheet support])
1320 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1321               [  --enable-html-highlight HTML highlighting using DOM engine])
1323 # Everything in the tree already uses CONFIG_DOM
1324 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1325 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1327 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1328               [  --disable-backtrace     disable backtrace support])
1330 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1331               [  --enable-no-root        enable prevention of usage by root])
1334 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1335               [  --enable-debug          enable leak debug and internal error checking])
1337 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1338               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1340 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1341               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1343 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1344               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1346 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1347               [  --disable-utf-8         disable UTF-8 support])
1350 AC_ARG_ENABLE(weehoofooboomookerchoo,
1351               [
1352     Also check out the features.conf file for more information about features!
1353               ],
1354               [AC_MSG_ERROR(Are you strange, or what?)])
1357 # == EMX hack
1359 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1360 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1363 # ===================================================================
1364 # Export directory paths
1365 # ===================================================================
1367 # Set up the ``entry points'' if they were not supplied by builder
1368 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1369 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1371 # Create CONFDIR #define for config.h
1373 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1374 # it's autoconf fault to force us to do such hacks ;p.
1375 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1376   # sysconfdir is set to its default value... fine, let's append /elinks/
1377   # XXX: We can't modify listing of the default in ./configure --help :-(
1378   sysconfdir_n=`eval echo "$sysconfdir"`
1379   sysconfdir=$sysconfdir_n
1380   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1381         sysconfdir="$sysconfdir/elinks"
1384 CONFDIR=$sysconfdir
1385 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1386 AC_SUBST(CONFDIR)
1388 # Create LOCALEDIR #define for config.h
1389 LOCALEDIR=`eval echo "$datadir/locale"`
1390 while echo "$LOCALEDIR" | grep "\\$"
1392         LOCALEDIR=`eval echo "$LOCALEDIR"`
1393 done > /dev/null 2> /dev/null
1394 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1395 AC_SUBST(LOCALEDIR)
1397 # Create LIBDIR #define for config.h
1398 LIBDIR=`eval echo "$libdir"`
1399 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1400 AC_SUBST(LIBDIR)
1402 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1403 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1405 # ===================================================================
1406 # A little fine tuning of gcc specific options (continued)
1407 # ===================================================================
1409 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1410   if test "$CONFIG_DEBUG" = "yes"; then
1411     # We want to see all warnings and live with none (in debug mode).
1412     CFLAGS="$CFLAGS -Werror"
1413   fi
1415   case "`$CC -dumpversion`" in
1416     3.0|3.1|3.2)
1417       # These should be ok using -Werror
1418       ;;
1419     3.*)
1420       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1421       # "dereferencing type-punned pointer will break strict-aliasing rules"
1422       # warnings. Disable them by not doing any strict-aliasing. The
1423       # alternative is just too ugly. Thanks gcc guys!! ;)
1424       CFLAGS="$CFLAGS -fno-strict-aliasing"
1425       ;;
1426     4.*)
1427       # Do not show warnings related to (char * | unsigned char *) type
1428       # difference.
1429       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1430       ;;
1431     *)
1432       # These should be ok using -Werror
1433       ;;
1434   esac
1436   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1437   # warning: the address of `builtin_modules' will always evaluate as `true'
1438   # This hits the object_lock and foreach_module macros in particular.
1439   # It would be okay to put something in the macros to avoid the warning,
1440   # but currently this seems to require defining parallel macros that skip
1441   # the NULL check, and that's too ugly.  So we instead disable the warning.
1442   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1443   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1444   for warning_flag in -Wno-address -Wno-always-true; do
1445     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1446     EL_SAVE_FLAGS
1447     CFLAGS="$CFLAGS $warning_flag"
1448     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1449       [AC_MSG_RESULT([yes])
1450        break],
1451       [AC_MSG_RESULT([no])])
1452     EL_RESTORE_FLAGS
1453   done
1456 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1457 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1458 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1459 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1461 # ===================================================================
1462 # Colored make output
1463 # ===================================================================
1465 if test $(`which tput` colors) -ge 4; then
1466         MAKE_COLOR=1
1467         AC_SUBST(MAKE_COLOR)
1470 # ===================================================================
1471 # Generated files
1472 # ===================================================================
1474 AC_CONFIG_FILES([ \
1475  Makefile.config \
1476  contrib/elinks.spec \
1477  contrib/lua/hooks.lua \
1478  contrib/conv/w3m2links.awk \
1479  doc/Doxyfile \
1480  doc/man/man1/elinks.1 \
1481  src/intl/gettext/ref-add.sed \
1482  src/intl/gettext/ref-del.sed
1484 AC_OUTPUT
1486 abs_srcdir="$(cd "$srcdir" && pwd)"
1487 # builddir is always absolute!
1488 if test "$abs_srcdir" != "$builddir"; then
1489         # Bootstrap the Makefile creation
1490         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1491         "$MAKE" "SRC=$abs_srcdir" init
1493         # Make cg-status ignore this build directory
1494         echo "*" > "$builddir/.gitignore"
1497 # ===================================================================
1498 # Configuration summary
1499 # ===================================================================
1501 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1502 cat features.log