POST method of CGI did not work. It works now.
[elinks.git] / configure.in
blobcc5bd2aa18f7e7069bd683a726599628c617848b
1 dnl Process this file with autoconf to produce a configure script.
3 AC_PREREQ(2.13)
4 AC_INIT(src/main/main.c)
5 AC_CONFIG_AUX_DIR(config)
7 PACKAGE=elinks
8 VERSION=0.12.GIT
9 AC_SUBST(PACKAGE)
10 AC_SUBST(VERSION)
11 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
12 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
13 AC_CONFIG_HEADERS(config.h)
15 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
16 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
17 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
19 MAKE=
21 for make in gnumake gmake make false; do
22         if test "x$MAKE" = x; then
23                 AC_PATH_PROGS(MAKE, "$make")
24         fi
25 done
27 builddir="`pwd`"
29 # Cleanup if we are configuring with a previous build in the tree
30 if test -e Makefile.config; then
31         AC_MSG_CHECKING([for previous build to clean])
32         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
33         AC_MSG_RESULT(done)
36 dnl ===================================================================
37 dnl Load feature configuration file and start logging features.
38 dnl ===================================================================
40 features="features.conf"
41 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
42 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
43 echo "Feature summary:" > features.log
45 dnl ===================================================================
46 dnl Checks for programs.
47 dnl ===================================================================
49 AC_PROG_CC
50 AC_PROG_AWK
51 AC_PATH_PROGS(AWK, "$AWK")
52 AC_PROG_RANLIB
53 AC_PROG_INSTALL
55 AC_PATH_PROGS(CG_COMMIT_ID, "cg-commit-id")
56 AC_PATH_PROGS(SPARSE, "sparse")
58 CONFIG_ASCIIDOC="no"
59 CONFIG_POD2HTML="no"
60 CONFIG_XMLTO="no"
61 CONFIG_JW="no"
63 if test "x$CONFIG_DOC" != xno; then
64         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
65         if test "x$ASCIIDOC" != "x"; then
66                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
67                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
68                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
70                 echo > config.asciidoc-unsafe.txt
71                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
72                         ASCIIDOC_FLAGS=--unsafe
73                 fi
74                 rm config.asciidoc-unsafe.*
75         fi
77         AC_PATH_PROGS(XMLTO, "xmlto")
78         if test "x$XMLTO" != "x"; then
79                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
80                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
81                 EL_CONFIG(MAN_XMLTO, [man (groff)])
82         fi
84         AC_PATH_PROGS(JW, "jw")
85         if test "x$JW" != "x"; then
86                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
87                 EL_CONFIG(MANUAL_JW, [PDF])
88         fi
90         AC_PATH_PROGS(POD2HTML, "pod2html")
91         if test "x$POD2HTML" != "x"; then
92                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
93         fi
96 AC_PATH_PROGS(FESTIVAL, "festival", [/usr/bin/festival])
97 AC_SUBST(FESTIVAL)
98 AC_DEFINE_UNQUOTED(FESTIVAL, "$FESTIVAL", [Festival])
99 AC_PATH_PROGS(FLITE, "flite", [/usr/bin/flite])
100 AC_SUBST(FLITE)
101 AC_DEFINE_UNQUOTED(FLITE, "$FLITE", [Flite])
102 AC_SUBST(ASCIIDOC_FLAGS)
103 AC_SUBST(CONFIG_ASCIIDOC)
104 AC_SUBST(CONFIG_POD2HTML)
105 AC_SUBST(CONFIG_XMLTO)
106 AC_SUBST(CONFIG_JW)
108 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
109 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
110 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
112 dnl gcc specific options (to be continued at the bottom of configure)
113 if test "x$ac_cv_prog_gcc" = "xyes"; then
114   dnl We want to see all warnings and live with none.
115   dnl We can't set up -Werror here as there may be some warnings in test
116   dnl suite of configure, and we don't want to fail them.
117   CFLAGS="$CFLAGS -Wall"
120 dnl ===================================================================
121 dnl Checks for special OSes.
122 dnl ===================================================================
124 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
125 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
127         AC_MSG_CHECKING([for $2])
129         for flag in $3; do
130                 AC_TRY_COMPILE(, [#ifndef $flag
131 kill me!
132 #endif ], $1=yes, $1=no)
133                 if test "[$]$1" = yes; then
134                         EL_CONFIG([$1], [$2])
135                         break
136                 fi
137         done
139         AC_MSG_RESULT([$]$1)
142 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
143 AC_SUBST(CONFIG_OS_BEOS)
145 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
146 AC_SUBST(CONFIG_OS_RISCOS)
148 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
149 AC_SUBST(CONFIG_OS_WIN32)
151 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
152 AC_SUBST(CONFIG_OS_OS2)
153 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
155 AC_MSG_CHECKING([for UNIX])
156 dnl FIXME: some depend kind of mechanism
157 if test "$CONFIG_OS_BEOS" = no && \
158    test "$CONFIG_OS_RISCOS" = no && \
159    test "$CONFIG_OS_WIN32" = no && \
160    test "$CONFIG_OS_OS2" = no; then
161         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
162 else
163         CONFIG_OS_UNIX=no
165 AC_MSG_RESULT($CONFIG_OS_UNIX)
166 AC_SUBST(CONFIG_OS_UNIX)
168 dnl ===================================================================
169 dnl Checks for header files.
170 dnl ===================================================================
172 AC_HEADER_DIRENT
173 AC_HEADER_STDC
174 AC_HEADER_SYS_WAIT
175 AC_HEADER_TIME
177 AC_CHECK_HEADERS(wctype.h)
178 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
179 AC_CHECK_HEADERS(sigaction.h)
180 AC_CHECK_HEADERS(arpa/inet.h)
181 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
182 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
183 AC_CHECK_HEADERS(ifaddrs.h)
184 AC_CHECK_HEADERS(sys/cygwin.h io.h)
185 AC_CHECK_HEADERS(sys/fmutex.h)
186 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
187 AC_CHECK_HEADERS(sys/resource.h)
188 AC_CHECK_HEADERS(sys/select.h)
189 AC_CHECK_HEADERS(sys/signal.h)
190 AC_CHECK_HEADERS(sys/socket.h)
191 AC_CHECK_HEADERS(sys/time.h)
192 AC_CHECK_HEADERS(sys/utsname.h)
193 AC_CHECK_HEADERS(stdint.h inttypes.h)
194 AC_CHECK_HEADERS(locale.h pwd.h)
195 AC_CHECK_HEADERS(termios.h)
197 AC_CHECK_HEADERS(sys/epoll.h, [HAVE_SYS_EPOLL_H=yes])
199 AC_CHECK_HEADERS(sys/un.h,
200         [CONFIG_INTERLINK=yes
201          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
202         [CONFIG_INTERLINK=no])
203 AC_SUBST(CONFIG_INTERLINK)
205 dnl ===================================================================
206 dnl Checks for typedefs, structures, and compiler characteristics.
207 dnl ===================================================================
209 AC_STRUCT_TM
210 AC_C_CONST
211 AC_C_INLINE
212 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
214 AC_SYS_LARGEFILE
215 AC_TYPE_SIZE_T
216 AC_TYPE_OFF_T
217 EL_CHECK_TYPE(ssize_t, int)
218 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
219 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
220 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
221 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
222 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
224 AC_CHECK_SIZEOF(char, 1)
225 AC_CHECK_SIZEOF(short, 2)
226 AC_CHECK_SIZEOF(int, 4)
227 AC_CHECK_SIZEOF(long, 4)
228 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
229 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
231 dnl Check for variadic macros
232 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
233                 [#include <stdio.h>
234                  #define a(b,c...) printf(b,##c)],
235                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
237 dnl Check for -rdynamic
239 dnl gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
240 dnl the executable to its dynamic symbol table.  ELinks uses this for
241 dnl two purposes:
243 dnl 1. If ELinks detects a bug, it can try to display a backtrace by
244 dnl    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
245 dnl    manual states users of GNU ld must pass -rdynamic to make the
246 dnl    symbols available to the program.
248 dnl 2. It would eventually be nice to dynamically load shared
249 dnl    libraries as plugins (bug 73).  The plugins must be able to
250 dnl    call ELinks functions.  This can be implemented either by
251 dnl    registering all callable functions in ELinks-specific data
252 dnl    structures, or by letting the dynamic linker handle them.
253 dnl    The latter way requires something equivalent to -rdynamic.
255 dnl Because backtraces are not needed for correct operation, and bug
256 dnl 73 is not yet being fixed, the configure script and makefiles
257 dnl should not complain to the user if they find that -rdynamic does
258 dnl not work.  Besides, it was reported at elinks-users on 2006-09-12
259 dnl that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
260 dnl Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
261 dnl -rdynamic but does something equivalent automatically.  (This was
262 dnl tested with "nm -D elinks | grep redraw_from_window".)
264 dnl FIXME: This check doesn't work. Something to do with the compiler
265 dnl happily ignoring it and stderr not being checked for error messages.
266 AC_MSG_CHECKING([for -rdynamic])
267 LDFLAGS_X="$LDFLAGS"
268 LDFLAGS="$LDFLAGS -rdynamic"
269 AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no)
270 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
271 AC_MSG_RESULT($have_rdynamic)
273 dnl ===================================================================
274 dnl Check for POSIX <regex.h>
275 dnl ===================================================================
277 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
279 dnl ===================================================================
280 dnl Checks for library functions.
281 dnl ===================================================================
283 AC_PROG_GCC_TRADITIONAL
284 AC_FUNC_MEMCMP
285 AC_FUNC_MMAP
286 AC_FUNC_STRFTIME
287 AC_CHECK_FUNCS(atoll cfmakeraw gethostbyaddr herror strerror)
288 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
289 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
290 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
291 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
292 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
293 AC_CHECK_FUNCS(fflush fork fsync fseeko ftello sigaction)
294 AC_CHECK_FUNCS(gettimeofday clock_gettime)
296 AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path)
298 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
299 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
300 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
301 AC_CHECK_FUNCS(epoll_ctl, HAVE_EPOLL_CTL=yes)
303 dnl These aren't probably needed now, as they are commented in links.h.
304 dnl I've no idea about their historical background, but I keep them here
305 dnl just in the case they will help later. --pasky
306 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
307 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
308 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
309 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
311 if test x"$HAVE_RAISE" = x; then
312         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
313                 AC_ERROR([Unable to emulate raise()])
314         fi
317 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
318 AC_TRY_LINK([#include <stdarg.h>
319 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
320 el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)])
321 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
322         EL_DEFINE(HAVE_VA_COPY, __va_copy)
325 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
326 AC_TRY_LINK([#include <unistd.h>
327 ], [int page_size = sysconf(_SC_PAGE_SIZE);],
328 el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)])
329 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
330         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
333 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
334 AC_TRY_RUN([
335 #include <stdio.h>
336 #include <stdarg.h>
337 #include <stdlib.h>
338 #include <string.h>
340 char buf[8];
342 int bar(char *buf, const char *format, va_list ap)
344        return vsnprintf(buf, 0, format, ap);
347 void foo(const char *format, ...) {
348        va_list ap;
349        int len;
351        va_start(ap, format);
352        len = bar(buf, format, ap);
353        va_end(ap);
354        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
356        va_start(ap, format);
357        len = bar(buf, format, ap);
358        va_end(ap);
359        if ((len != 6) && (len != 7)) exit(1);
361        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
363        exit(0);
365 main() { foo("hello\n"); }
367 el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)])
368 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
369         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
372 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
374 dnl ===================================================================
375 dnl Checks for libraries.
376 dnl ===================================================================
378 dnl Replace `main' with a function in -lsocket:
379 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
380 if test "$cf_result" = no; then
381         AC_CHECK_LIB(socket, socket)
384 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
385 if test "$cf_result" = no; then
386         AC_CHECK_LIB(socket, setsockopt)
389 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
390 if test "$cf_result" = no; then
391         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
392         if test "$cf_result" = no; then
393                 AC_CHECK_LIB(nsl, gethostbyname)
394         else
395                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
396         fi
399 dnl ===================================================================
400 dnl Checks for packaging specific options.
401 dnl ===================================================================
403 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
404             [ if test "$withval" != no && test "$withval" != yes; then
405                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
406               fi ])
408 dnl ===================================================================
409 dnl Checks for a libraries, optional even if installed.
410 dnl ===================================================================
412 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
413 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
415         AC_MSG_CHECKING([for $2 support])
417         if test "[$]$1" != no; then
418                 AC_MSG_RESULT(yes)
419                 EL_SAVE_FLAGS
420                 if test -n "$withval" && test -d "$withval"; then
421                         # Be a little more careful when setting
422                         # include and lib directories. This way
423                         # $withval will work when includes are
424                         # there but the library is in the common
425                         # /usr/lib ... Does the right thing when
426                         # looking for gc on Debian.
427                         if test -d "$withval/include"; then
428                                 CFLAGS="$CFLAGS -I$withval/include"
429                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
430                         else
431                                 CFLAGS="$CFLAGS -I$withval"
432                                 CPPFLAGS="$CPPFLAGS -I$withval"
433                         fi
434                         if test -d "$withval/lib"; then
435                                 LDFLAGS="$LDFLAGS -L$withval/lib"
436                         fi
437                 fi
439                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
440                 if test "[$]$1" = yes; then
441                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
442                 fi
444                 if test "[$]$1" = yes; then
445                         EL_CONFIG([$1], [$2])
446                         LIBS="$LIBS -l$4"
447                 else
448                         if test -n "[$]WITHVAL_$1" &&
449                            test "[$]WITHVAL_$1" != xno; then
450                                 AC_MSG_ERROR([$2 not found])
451                         fi
452                         EL_RESTORE_FLAGS
453                 fi
454         else
455                 AC_MSG_RESULT(disabled)
456         fi
459 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
460 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
462         $1=yes
463         WITHVAL_$1=
465         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
466         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
468         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
470         EL_LOG_CONFIG([$1], [$2], [])
473 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
474         [  --without-gpm           disable gpm (mouse) support])
476 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzdopen,
477         [  --without-zlib          disable zlib support])
479 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
480         [  --without-bzlib         disable bzlib support])
482 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
483         [  --without-idn           disable international domain names support])
485 if test "x{with_gc}" != xno; then
486         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
487                 [  --with-gc               enable Boehm's garbage collector])
490 EL_ARG_ENABLE(CONFIG_LZMA, lzma, [lzma],
491               [  --enable-lzma           enable lzma encoding support])
493 dnl ===================================================================
494 dnl Check for GSSAPI, optional even if installed.
495 dnl ===================================================================
497 enable_gssapi="no";
499 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
500             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
502 AC_MSG_CHECKING([for GSSAPI])
504 if test "$enable_gssapi" = "yes"; then
505         AC_MSG_RESULT(yes)
506         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
507         GSSAPI_LIBS=`krb5-config --libs gssapi`
508         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
509         LIBS="$GSSAPI_LIBS $LIBS"
510         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
511 else
512         AC_MSG_RESULT(no)
515 AC_SUBST(CONFIG_GSSAPI)
517 dnl ===================================================================
518 dnl Bookmark and XBEL support
519 dnl ===================================================================
521 EL_SAVE_FLAGS
523 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
524               [  --disable-bookmarks     disable bookmark support])
526 # Check whether --enable-xbel or --disable-xbel was given.
527 if test "x${enable_xbel}" != xno; then
528         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
530         if test "$HAVE_LIBEXPAT" = yes; then
531                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
532                 if test "$HAVE_LIBEXPAT" = yes; then
533                         LIBS="$LIBS -lexpat"
534                 fi
535         fi
539 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
540               [XBEL bookmarks],
541               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
543 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
544         EL_RESTORE_FLAGS
547 dnl ===================================================================
548 dnl Checks for BSD sysmouse
549 dnl ===================================================================
551 HAVE_SYSMOUSE_HEADER="no"
553 # Either of these header files provides the (same) sysmouse interface
554 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
556 dnl ===================================================================
557 dnl Checks for OS/2
558 dnl ===================================================================
560 if test "$CONFIG_OS_OS2" = yes; then
561         EL_CONFIG_OS_OS2
564 dnl ===================================================================
565 dnl Checks for Win32
566 dnl ===================================================================
568 if test "$CONFIG_OS_WIN32" = yes; then
569         EL_CONFIG_OS_WIN32
572 dnl ===================================================================
573 dnl Check for SEE (Simple Ecmascript Engine)
574 dnl ===================================================================
575 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
576             [ if test "x$withval" != xno; then enable_see=yes; fi ])
578 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
579 # SEE_FLAGS but I really don't want to require people to have Guile in order
580 # to compile CVS. Also, the macro seems to be really stupid regarding searching
581 # for Guile in $PATH etc. --pasky
583 AC_MSG_CHECKING([for SEE])
585 CONFIG_ECMASCRIPT_SEE=no
587 if test "$enable_see" = "yes"; then
588         AC_MSG_RESULT(yes);
589         ## Based on the SEE_FLAGS macro.
591         if test -d "$withval"; then
592                 SEE_PATH="$withval:$PATH"
593         else
594                 SEE_PATH="$PATH"
595         fi
597         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
599         ## First, let's just see if we can find Guile at all.
600         if test "$SEE_CONFIG" != no; then
601                 cf_result="yes";
603                 SEE_LIBS="`$SEE_CONFIG --libs`"
604                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
605                 LIBS="$SEE_LIBS $LIBS"
606                 EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
607                 AC_SUBST(SEE_CFLAGS)
608         else
609                 if test -n "$withval" && test "x$withval" != xno; then
610                         AC_MSG_ERROR([SEE not found])
611                 else
612                         AC_MSG_WARN([SEE support disabled])
613                 fi
614         fi
615 else
616         AC_MSG_RESULT(no);
620 dnl ===================================================================
621 dnl Check for SpiderMonkey, optional even if installed.
622 dnl ===================================================================
624 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
625             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
626 AC_MSG_CHECKING([for SpiderMonkey])
628 EL_SAVE_FLAGS
629 cf_result=no
631 if test -z "$disable_spidermonkey"; then
632         if test ! -d "$withval"; then
633                 withval="";
634         fi
635         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
636                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
637                         for spidermonkeylib in js smjs mozjs; do
638                                 if test "$cf_result" = no; then
639                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
641                                         if test ! -z "$spidermonkeydir"; then
642                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
643                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
644                                         fi
646                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
647                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
648                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
650                                         AC_TRY_LINK([#define XP_UNIX
651                                                      #include <jsapi.h>],
652                                                      [JS_GetImplementationVersion()],
653                                                      cf_result=yes, cf_result=no)
654                                 fi
655                         done
656                 done
657         done
660 AC_MSG_RESULT($cf_result)
661 CONFIG_SPIDERMONKEY="$cf_result"
662 EL_RESTORE_FLAGS
664 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
665    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
666         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
667 else
668         CONFIG_ECMASCRIPT_SMJS=no
671 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
672 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
673 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
676 dnl ===================================================================
677 dnl Optional Spidermonkey-based ECMAScript browser scripting
678 dnl ===================================================================
680 AC_ARG_ENABLE(sm-scripting,
681               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
682               [if test "$enableval" != no; then enableval="yes"; fi
683                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
685 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
686    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
687         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
688 else
689         CONFIG_SCRIPTING_SPIDERMONKEY=no
692 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
693    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
694         LIBS="$LIBS $SPIDERMONKEY_LIBS"
695         AC_SUBST(SPIDERMONKEY_LIBS)
696         AC_SUBST(SPIDERMONKEY_CFLAGS)
697         AC_SUBST(CONFIG_SPIDERMONKEY)
700 dnl ===================================================================
701 dnl Check for Guile, optional even if installed.
702 dnl ===================================================================
704 enable_guile="no";
706 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
707             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
709 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
710 # GUILE_FLAGS but I really don't want to require people to have Guile in order
711 # to compile CVS. Also, the macro seems to be really stupid regarding searching
712 # for Guile in $PATH etc. --pasky
714 AC_MSG_CHECKING([for Guile])
716 if test "$enable_guile" = "yes"; then
717         AC_MSG_RESULT(yes);
718         ## Based on the GUILE_FLAGS macro.
720         if test -d "$withval"; then
721                 GUILE_PATH="$withval:$PATH"
722         else
723                 GUILE_PATH="$PATH"
724         fi
726         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
728         ## First, let's just see if we can find Guile at all.
729         if test "$GUILE_CONFIG" != no; then
730                 cf_result="yes";
732                 GUILE_LIBS="`guile-config link`"
733                 GUILE_CFLAGS="`guile-config compile`"
734                 LIBS="$GUILE_LIBS $LIBS"
735                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
736                 AC_SUBST(GUILE_CFLAGS)
737                 cat <<EOF
738 ***********************************************************************
739 The Guile support is incomplete and not so well integrated to ELinks
740 yet. That means, e.g., that you have no Guile console and there might
741 not be all the necessary hooks. Also, the Guile interface is not too
742 well tested (success stories heartily welcomed!).  See
743 src/scripting/guile/README for further details and hints.
744 ***********************************************************************
746         else
747                 if test -n "$withval" && test "x$withval" != xno; then
748                         AC_MSG_ERROR([Guile not found])
749                 else
750                         AC_MSG_WARN([Guile support disabled])
751                 fi
752         fi
753 else
754         AC_MSG_RESULT(no);
757 dnl ===================================================================
758 dnl Check for Perl
759 dnl ===================================================================
760 enable_perl="no";
762 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
763             [
764 if test "$withval" = yes; then
765         # FIXME: If withval is a valid directory append it to PATH
766         # so that you can specify one of several perl installations.
767         withval="";
768         enable_perl=yes;
770             ])
772 AC_MSG_CHECKING([for Perl])
774 cf_result=no
776 EL_SAVE_FLAGS
778 if test "$enable_perl" = "yes"; then
779         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
780         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
781         LIBS="$PERL_LIBS $LIBS"
782         CFLAGS="$PERL_CFLAGS $CFLAGS"
783         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
784         AC_TRY_LINK([
785 #include <EXTERN.h>
786 #include <perl.h>
787 #include <perlapi.h>
789                     [PerlInterpreter *my_perl = perl_alloc();],
790                     cf_result=yes, cf_result=no)
793 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
795 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
796 AC_TRY_COMPILE([
797 #include <EXTERN.h>
798 #include <perl.h>
799 extern PerlInterpreter *my_perl;
801         [dSP; (void) POPpx;],
802         [AC_MSG_RESULT([yes])
803 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
804                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
805 no longer needs an "n_a" variable like it did in 5.8.7])],
806         [AC_MSG_RESULT([no])])
808 if test "$cf_result" != "yes"; then
809         EL_RESTORE_FLAGS
810 else
811         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
813         CFLAGS="$CFLAGS_X"
814         CPPFLAGS="$CPPFLAGS_X"
815         AC_SUBST(PERL_LIBS)
816         AC_SUBST(PERL_CFLAGS)
819 dnl ===================================================================
820 dnl Check for Python
821 dnl ===================================================================
822 enable_python="no";
824 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
825             [ if test "x$withval" != xno; then enable_python=yes; fi ])
827 EL_SAVE_FLAGS
828 cf_result=no
830 AC_MSG_CHECKING([for Python])
832 if test "$enable_python" = "yes"; then
833         AC_MSG_RESULT(yes);
835         if test -d "$withval"; then
836                 PYTHON_PATH="$withval:$PATH"
837         else
838                 PYTHON_PATH="$PATH"
839         fi
841         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
843         if test "$PYTHON" != no; then
844                 cf_result="yes";
846                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
847                 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"))'`"
848                 LIBS="$PYTHON_LIBS $LIBS"
849                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
850                 AC_TRY_LINK([#include <Python.h>],
851                     [Py_Initialize();],
852                     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 dnl ===================================================================
883 dnl Check for Lua, optional even if installed.
884 dnl ===================================================================
886 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
887 dnl 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 51; do
902                         if test "$cf_result" = no; then
903                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
905                                 if test ! -z "$luadir"; then
906                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
907                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
908                                 fi
910                                 LIBS="$LUA_LIBS $LIBS_X"
911                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
912                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
914                                 # Check that it is a compatible Lua version
915                                 AC_TRY_LINK([   #include <lua.h>
916                                                 #include <lualib.h>],
917                                             [   lua_State *L = lua_open();
918                                                 luaopen_base(L);
919                                                 luaopen_table(L);
920                                                 luaopen_io(L);
921                                                 luaopen_string(L);
922                                                 luaopen_math(L);
923                                                 lua_pushboolean(L, 1);
924                                                 lua_close(L);],
925                                             cf_result=yes, cf_result=no)
926                         fi
927                 done
928         done
931 AC_MSG_RESULT($cf_result)
933 if test "$cf_result" != yes; then
934         EL_RESTORE_FLAGS
935 else
936         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
937         AC_CHECK_HEADERS(lauxlib.h)
939         CFLAGS="$CFLAGS_X"
940         CPPFLAGS="$CPPFLAGS_X"
941         AC_SUBST(LUA_LIBS)
942         AC_SUBST(LUA_CFLAGS)
946 dnl ===================================================================
947 dnl Check for Ruby, optional even if installed.
948 dnl ===================================================================
950 EL_CONFIG_SCRIPTING_RUBY
952 dnl ===================================================================
953 dnl Setup global scripting
954 dnl ===================================================================
956 EL_CONFIG_DEPENDS(CONFIG_SCRIPTING, [CONFIG_SCRIPTING_GUILE CONFIG_SCRIPTING_LUA CONFIG_SCRIPTING_PERL CONFIG_SCRIPTING_PYTHON CONFIG_SCRIPTING_RUBY CONFIG_SCRIPTING_SPIDERMONKEY], [Browser scripting])
957 AC_SUBST(CONFIG_SCRIPTING_GUILE)
958 AC_SUBST(CONFIG_SCRIPTING_LUA)
959 AC_SUBST(CONFIG_SCRIPTING_PERL)
960 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
961 AC_SUBST(CONFIG_SCRIPTING_RUBY)
962 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
963 AC_SUBST(CONFIG_SCRIPTING)
966 dnl ===================================================================
967 dnl Check for SSL support.
968 dnl ===================================================================
970 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
971 dnl is enabled, we won't try to use OpenSSL anymore.
973 dnl For wiping SSL hooks..
974 #ifdef CONFIG_SSL
976 disable_openssl=""
977 disable_gnutls=""
978 enable_gnutls=""
980 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
981             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
982 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
983             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
984 gnutls_withval="$withval"
986 if test "$enable_gnutls" = yes; then
987         disable_openssl=yes;
990 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
991             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
992 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
993 openssl_withval="$withval"
995 dnl ---- OpenSSL
997 AC_MSG_CHECKING([for OpenSSL])
999 EL_SAVE_FLAGS
1000 cf_result="no"
1002 if test "$disable_openssl" = yes; then
1003         cf_result="not used"
1004 else
1005         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
1006                          /usr/lib/openssl /usr/local/ssl \
1007                          /usr/local/www /usr/lib/ssl /usr/local \
1008                          /usr/pkg /opt /opt/openssl; do
1009                 if test "$cf_result" = no; then
1010                         if test -d "$ssldir"; then
1011                                 OPENSSL_CFLAGS="-I$ssldir/include"
1012                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1013                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1014                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1015 #                               # FIXME: This created serious portability problems. --pasky
1016 #                               if test "$CC" == "gcc"; then
1017 #                                       # I'm not sure about compatibility here. --pasky
1018 #                                       LIBS="$LIBS -R$ssldir/lib"
1019 #                               fi
1020                         else
1021                                 LIBS="-lssl -lcrypto $LIBS_X"
1022                         fi
1023                         AC_TRY_LINK([#include <openssl/ssl.h>],
1024                                     [OpenSSL_add_all_algorithms()],
1025                                     cf_result=yes, cf_result=no)
1026                         if test "$cf_result" != yes; then
1027                                 AC_TRY_LINK([#include <openssl/ssl.h>],
1028                                             [SSLeay_add_ssl_algorithms()],
1029                                             cf_result=yes, cf_result=no)
1030                         fi
1031                 fi
1032         done
1034         if test "$cf_result" != yes; then
1035                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1036                         AC_MSG_ERROR([OpenSSL not found])
1037                 fi
1038                 EL_RESTORE_FLAGS
1039         else
1040                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1042                 CFLAGS="$CFLAGS_X"
1043                 AC_SUBST(OPENSSL_CFLAGS)
1044         fi
1047 AC_MSG_RESULT($cf_result)
1049 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1050 dnl ---- GNU TLS
1051 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1052 dnl it looks ugly then.
1054 if test "$cf_result" = yes; then
1055         cf_result="not used"
1057 else
1058         EL_SAVE_FLAGS
1059         cf_result="no"
1061         if test -z "$disable_gnutls"; then
1062                 # Sure, we maybe _could_ use their macro, but how to ensure
1063                 # that the ./configure script won't fail if the macro won't be
1064                 # found..? :( --pasky
1066                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1068                 if test -d "$gnutls_withval"; then
1069                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1070                 fi
1072                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1074                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1075                         cf_result=no
1076                 else
1077                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1078                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1080                         LIBS="$GNUTLS_LIBS $LIBS_X"
1081                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1082                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1084                         # Verify if it's really usable.  gnutls_session was
1085                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1086                         # (on 2004-06-13); ELinks now requires this.
1087                         AC_TRY_LINK([#include <gnutls/gnutls.h>],
1088                                     [gnutls_session_t dummy;
1089                                      gnutls_check_version(NULL)],
1090                                     cf_result=yes, cf_result=no)
1091                 fi
1093                 if test "$cf_result" = yes; then
1094                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1096                         CFLAGS="$CFLAGS_X"
1097                         AC_SUBST(GNUTLS_CFLAGS)
1099                         # Verify if the MD5 compatibility layer is usable.
1100                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1101                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1102                                                   [GNU TLS OpenSSL compatibility],
1103                                                   gnutls/openssl.h, gnutls-openssl,
1104                                                   MD5_Init)
1105                 else
1106                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1107                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1108                         fi
1109                         EL_RESTORE_FLAGS
1110                 fi
1111         fi
1114 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1115 AC_MSG_RESULT($cf_result)
1117 dnl Final SSL setup
1119 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1120 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1121 AC_SUBST(CONFIG_OPENSSL)
1122 AC_SUBST(CONFIG_GNUTLS)
1124 #endif
1126 AC_MSG_CHECKING([whether to be or not to be])
1127 AC_MSG_RESULT([needs to be determined experimentally])
1129 dnl ===================================================================
1130 dnl Check for IPv6 support and related functions.
1131 dnl ===================================================================
1133 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1134 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1135 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1137 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1138 if test "$HAVE_GETADDRINFO" != yes; then
1139         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1140         if test "$HAVE_GETADDRINFO" = yes; then
1141                 LIBS="$LIBS -linet6"
1142         fi
1146 dnl ===================================================================
1147 dnl Checking for X11 (window title restoring).
1148 dnl ===================================================================
1150 AC_PATH_X
1151 if test x"$no_x" != xyes; then
1152         if test -n "$x_includes"; then
1153                 X_CFLAGS="-I$x_includes"
1154         fi
1155         if test -n "$x_libraries"; then
1156                 LDFLAGS="$LDFLAGS -L$x_libraries"
1157         fi
1158         LIBS="-lX11 $LIBS"
1159         EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1160         AC_SUBST(X_CFLAGS)
1164 dnl ===================================================================
1165 dnl Backtraces displaying support.
1166 dnl ===================================================================
1168 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1169 # possible checks for other system-specific means go here
1172 dnl ===================================================================
1173 dnl Gettext grey zone. Beware.
1174 dnl ===================================================================
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 dnl ===================================================================
1187 dnl Compile-time features control
1188 dnl ===================================================================
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 dnl ===================================================================
1228 dnl FSP protocol
1229 dnl ===================================================================
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 dnl ===================================================================
1265 dnl SMB protocol support.
1266 dnl ===================================================================
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 dnl Everything in the tree already uses CONFIG_DOM
1324 dnl 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               [  --enable-utf-8          enable UTF-8 support])
1349 EL_ARG_DEPEND(CONFIG_EPOLL, epoll, [HAVE_SYS_EPOLL_H:yes HAVE_EPOLL_CTL:yes], [epoll],
1350               [  --enable-epoll          enable epoll])
1352 EL_LOG_CONFIG(FESTIVAL, [festival], [])
1353 EL_LOG_CONFIG(FLITE, [flite], [])
1355 AC_ARG_ENABLE(weehoofooboomookerchoo,
1356               [
1357     Also check out the features.conf file for more information about features!
1358               ],
1359               [AC_MSG_ERROR(Are you strange, or what?)])
1362 dnl == EMX hack
1364 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1365 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1368 dnl ===================================================================
1369 dnl Export directory paths
1370 dnl ===================================================================
1372 # Set up the ``entry points'' if they were not supplied by builder
1373 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1374 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1376 # Create CONFDIR #define for config.h
1378 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1379 # it's autoconf fault to force us to do such hacks ;p.
1380 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1381   # sysconfdir is set to its default value... fine, let's append /elinks/
1382   # XXX: We can't modify listing of the default in ./configure --help :-(
1383   sysconfdir_n=`eval echo "$sysconfdir"`
1384   sysconfdir=$sysconfdir_n
1385   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1386         sysconfdir="$sysconfdir/elinks"
1389 CONFDIR=$sysconfdir
1390 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1391 AC_SUBST(CONFDIR)
1393 # Create LOCALEDIR #define for config.h
1394 LOCALEDIR=`eval echo "$datadir/locale"`
1395 while echo "$LOCALEDIR" | grep "\\$"
1397         LOCALEDIR=`eval echo "$LOCALEDIR"`
1398 done > /dev/null 2> /dev/null
1399 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1400 AC_SUBST(LOCALEDIR)
1402 # Create LIBDIR #define for config.h
1403 LIBDIR=`eval echo "$libdir"`
1404 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1405 AC_SUBST(LIBDIR)
1407 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1408 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1410 dnl ===================================================================
1411 dnl A little fine tuning of gcc specific options (continued)
1412 dnl ===================================================================
1414 if test "x$ac_cv_prog_gcc" = "xyes"; then
1415   if test "$CONFIG_DEBUG" = "yes"; then
1416     dnl We want to see all warnings and live with none (in debug mode).
1417     CFLAGS="$CFLAGS -Werror"
1418   fi
1420   case "`$CC -dumpversion`" in
1421     3.0|3.1|3.2)
1422       # These should be ok using -Werror
1423       ;;
1424     3.*)
1425       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1426       # "dereferencing type-punned pointer will break strict-aliasing rules"
1427       # warnings. Disable them by not doing any strict-aliasing. The
1428       # alternative is just too ugly. Thanks gcc guys!! ;)
1429       CFLAGS="$CFLAGS -fno-strict-aliasing"
1430       ;;
1431     4.*)
1432       # Do not show warnings related to (char * | unsigned char *) type
1433       # difference. Do not show "always evaluate as true".
1434       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1435       ;;
1436     *)
1437       # These should be ok using -Werror
1438       ;;
1439   esac
1441   # GCC 4.2 snapshots warn that comparisons like &object != NULL
1442   # always return true.  Some macros in ELinks check whether pointer
1443   # arguments are NULL, and giving them addresses of named objects
1444   # triggers the warning.  These warnings have not revealed any real
1445   # bugs, so shut them up instead of complicating the code.  GCC 4.1
1446   # does not recognize -Wno-always-true and exits with code 1 if it is
1447   # given.
1448   AC_MSG_CHECKING([whether $CC accepts -Wno-always-true])
1449   EL_SAVE_FLAGS
1450   CFLAGS="$CFLAGS -Wno-always-true"
1451   AC_TRY_COMPILE([], [],
1452     [AC_MSG_RESULT([yes])],
1453     [EL_RESTORE_FLAGS
1454      AC_MSG_RESULT([no])])
1457 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1458 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1459 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1460 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1462 dnl ===================================================================
1463 dnl Colored make output
1464 dnl ===================================================================
1466 if test $(`which tput` colors) -ge 4; then
1467         MAKE_COLOR=1
1468         AC_SUBST(MAKE_COLOR)
1471 dnl ===================================================================
1472 dnl Generated files
1473 dnl ===================================================================
1475 AC_OUTPUT([ \
1476  Makefile.config \
1477  contrib/elinks.spec \
1478  contrib/lua/hooks.lua \
1479  contrib/conv/w3m2links.awk \
1480  doc/man/man1/elinks.1 \
1481  src/intl/gettext/ref-add.sed \
1482  src/intl/gettext/ref-del.sed
1485 abs_srcdir="$(cd "$srcdir" && pwd)"
1486 # builddir is always absolute!
1487 if test "$abs_srcdir" != "$builddir"; then
1488         # Bootstrap the Makefile creation
1489         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1490         "$MAKE" "SRC=$abs_srcdir" init
1492         # Make cg-status ignore this build directory
1493         echo "*" > "$builddir/.gitignore"
1496 dnl ===================================================================
1497 dnl Configuration summary
1498 dnl ===================================================================
1500 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1501 cat features.log