Bug 960: Redefine LOADMSGCAT_USE_MMAP instead of HAVE_MMAP.
[elinks/kon.git] / configure.in
blob00b71cd779b2b49cc64d513bb13fc6889d5dce56
1 dnl Process this file with autoconf to produce a configure script.
3 dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
4 dnl Autoconf 2.59 is installed in the computer that generates our daily
5 dnl snapshots, so we need to be compatible with that.
6 AC_PREREQ(2.59)
7 AC_INIT(src/main/main.c)
8 AC_CONFIG_AUX_DIR(config)
10 PACKAGE=elinks
11 VERSION=0.12.GIT
12 AC_SUBST(PACKAGE)
13 AC_SUBST(VERSION)
14 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
15 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
16 AC_CONFIG_HEADERS(config.h)
18 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
19 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
20 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
22 MAKE=
24 for make in gnumake gmake make false; do
25         if test "x$MAKE" = x; then
26                 AC_PATH_PROGS(MAKE, "$make")
27         fi
28 done
30 builddir="`pwd`"
32 # Cleanup if we are configuring with a previous build in the tree
33 if test -e Makefile.config; then
34         AC_MSG_CHECKING([for previous build to clean])
35         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
36         AC_MSG_RESULT(done)
39 dnl ===================================================================
40 dnl Load feature configuration file and start logging features.
41 dnl ===================================================================
43 features="features.conf"
44 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
45 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
46 echo "Feature summary:" > features.log
48 dnl ===================================================================
49 dnl Checks for programs.
50 dnl ===================================================================
52 AC_PROG_CC
53 AC_PROG_AWK
54 AC_PATH_PROGS(AWK, "$AWK")
55 AC_PROG_RANLIB
56 AC_PROG_INSTALL
58 AC_PATH_PROGS(CG_COMMIT_ID, "cg-commit-id")
59 AC_PATH_PROGS(SPARSE, "sparse")
61 CONFIG_ASCIIDOC="no"
62 CONFIG_POD2HTML="no"
63 CONFIG_XMLTO="no"
64 CONFIG_JW="no"
66 if test "x$CONFIG_DOC" != xno; then
67         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
68         if test "x$ASCIIDOC" != "x"; then
69                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
70                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
71                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
73                 echo > config.asciidoc-unsafe.txt
74                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
75                         ASCIIDOC_FLAGS=--unsafe
76                 fi
77                 rm config.asciidoc-unsafe.*
78         fi
80         AC_PATH_PROGS(XMLTO, "xmlto")
81         if test "x$XMLTO" != "x"; then
82                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
83                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
84                 EL_CONFIG(MAN_XMLTO, [man (groff)])
85         fi
87         AC_PATH_PROGS(JW, "jw")
88         if test "x$JW" != "x"; then
89                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
90                 EL_CONFIG(MANUAL_JW, [PDF])
91         fi
93         AC_PATH_PROGS(POD2HTML, "pod2html")
94         if test "x$POD2HTML" != "x"; then
95                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
96         fi
99 AC_SUBST(ASCIIDOC_FLAGS)
100 AC_SUBST(CONFIG_ASCIIDOC)
101 AC_SUBST(CONFIG_POD2HTML)
102 AC_SUBST(CONFIG_XMLTO)
103 AC_SUBST(CONFIG_JW)
105 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
106 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
107 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
109 dnl gcc specific options (to be continued at the bottom of configure)
110 if test "x$ac_cv_prog_gcc" = "xyes"; then
111   dnl We want to see all warnings and live with none.
112   dnl We can't set up -Werror here as there may be some warnings in test
113   dnl suite of configure, and we don't want to fail them.
114   CFLAGS="$CFLAGS -Wall"
117 dnl ===================================================================
118 dnl Checks for special OSes.
119 dnl ===================================================================
121 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
122 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
124         AC_MSG_CHECKING([for $2])
126         for flag in $3; do
127                 AC_TRY_COMPILE(, [#ifndef $flag
128 kill me!
129 #endif ], $1=yes, $1=no)
130                 if test "[$]$1" = yes; then
131                         EL_CONFIG([$1], [$2])
132                         break
133                 fi
134         done
136         AC_MSG_RESULT([$]$1)
139 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
140 AC_SUBST(CONFIG_OS_BEOS)
142 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
143 AC_SUBST(CONFIG_OS_RISCOS)
145 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
146 AC_SUBST(CONFIG_OS_WIN32)
148 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
149 AC_SUBST(CONFIG_OS_OS2)
150 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
152 AC_MSG_CHECKING([for UNIX])
153 dnl FIXME: some depend kind of mechanism
154 if test "$CONFIG_OS_BEOS" = no && \
155    test "$CONFIG_OS_RISCOS" = no && \
156    test "$CONFIG_OS_WIN32" = no && \
157    test "$CONFIG_OS_OS2" = no; then
158         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
159 else
160         CONFIG_OS_UNIX=no
162 AC_MSG_RESULT($CONFIG_OS_UNIX)
163 AC_SUBST(CONFIG_OS_UNIX)
165 dnl ===================================================================
166 dnl Checks for header files.
167 dnl ===================================================================
169 AC_HEADER_DIRENT
170 AC_HEADER_STDC
171 AC_HEADER_SYS_WAIT
172 AC_HEADER_TIME
174 AC_CHECK_HEADERS(wctype.h)
175 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
176 AC_CHECK_HEADERS(sigaction.h)
177 AC_CHECK_HEADERS(arpa/inet.h)
178 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
179 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
180 AC_CHECK_HEADERS(ifaddrs.h)
181 AC_CHECK_HEADERS(sys/cygwin.h io.h)
182 AC_CHECK_HEADERS(sys/fmutex.h)
183 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
184 AC_CHECK_HEADERS(sys/resource.h)
185 AC_CHECK_HEADERS(sys/select.h)
186 AC_CHECK_HEADERS(sys/signal.h)
187 AC_CHECK_HEADERS(sys/socket.h)
188 AC_CHECK_HEADERS(sys/time.h)
189 AC_CHECK_HEADERS(sys/utsname.h)
190 AC_CHECK_HEADERS(stdint.h inttypes.h)
191 AC_CHECK_HEADERS(locale.h pwd.h)
192 AC_CHECK_HEADERS(termios.h)
195 AC_CHECK_HEADERS(sys/un.h,
196         [CONFIG_INTERLINK=yes
197          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
198         [CONFIG_INTERLINK=no])
199 AC_SUBST(CONFIG_INTERLINK)
201 dnl ===================================================================
202 dnl Checks for typedefs, structures, and compiler characteristics.
203 dnl ===================================================================
205 AC_STRUCT_TM
206 AC_C_CONST
207 AC_C_INLINE
208 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
210 AC_SYS_LARGEFILE
211 AC_TYPE_SIZE_T
212 AC_TYPE_OFF_T
213 EL_CHECK_TYPE(ssize_t, int)
214 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
215 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
216 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
217 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
218 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
220 AC_CHECK_SIZEOF(char, 1)
221 AC_CHECK_SIZEOF(short, 2)
222 AC_CHECK_SIZEOF(int, 4)
223 AC_CHECK_SIZEOF(long, 4)
224 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
225 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
227 dnl Check for variadic macros
228 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
229                 [#include <stdio.h>
230                  #define a(b,c...) printf(b,##c)],
231                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
233 dnl Check for -rdynamic
235 dnl gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
236 dnl the executable to its dynamic symbol table.  ELinks uses this for
237 dnl two purposes:
239 dnl 1. If ELinks detects a bug, it can try to display a backtrace by
240 dnl    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
241 dnl    manual states users of GNU ld must pass -rdynamic to make the
242 dnl    symbols available to the program.
244 dnl 2. It would eventually be nice to dynamically load shared
245 dnl    libraries as plugins (bug 73).  The plugins must be able to
246 dnl    call ELinks functions.  This can be implemented either by
247 dnl    registering all callable functions in ELinks-specific data
248 dnl    structures, or by letting the dynamic linker handle them.
249 dnl    The latter way requires something equivalent to -rdynamic.
251 dnl Because backtraces are not needed for correct operation, and bug
252 dnl 73 is not yet being fixed, the configure script and makefiles
253 dnl should not complain to the user if they find that -rdynamic does
254 dnl not work.  Besides, it was reported at elinks-users on 2006-09-12
255 dnl that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
256 dnl Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
257 dnl -rdynamic but does something equivalent automatically.  (This was
258 dnl tested with "nm -D elinks | grep redraw_from_window".)
260 dnl FIXME: This check doesn't work. Something to do with the compiler
261 dnl happily ignoring it and stderr not being checked for error messages.
262 AC_MSG_CHECKING([for -rdynamic])
263 LDFLAGS_X="$LDFLAGS"
264 LDFLAGS="$LDFLAGS -rdynamic"
265 AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no)
266 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
267 AC_MSG_RESULT($have_rdynamic)
269 dnl ===================================================================
270 dnl Check for POSIX <regex.h>
271 dnl ===================================================================
273 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
275 dnl ===================================================================
276 dnl Checks for library functions.
277 dnl ===================================================================
279 AC_PROG_GCC_TRADITIONAL
280 AC_FUNC_MEMCMP
281 AC_FUNC_MMAP
282 AC_FUNC_STRFTIME
283 AC_CHECK_FUNCS(atoll cfmakeraw gethostbyaddr herror strerror)
284 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
285 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
286 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
287 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
288 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
289 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
290 AC_CHECK_FUNCS(gettimeofday clock_gettime)
292 AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path)
294 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
295 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
296 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
298 dnl These aren't probably needed now, as they are commented in links.h.
299 dnl I've no idea about their historical background, but I keep them here
300 dnl just in the case they will help later. --pasky
301 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
302 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
303 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
304 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
306 if test x"$HAVE_RAISE" = x; then
307         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
308                 AC_ERROR([Unable to emulate raise()])
309         fi
312 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
313 AC_TRY_LINK([#include <stdarg.h>
314 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
315 el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)])
316 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
317         EL_DEFINE(HAVE_VA_COPY, __va_copy)
320 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
321 AC_TRY_LINK([#include <unistd.h>
322 ], [int page_size = sysconf(_SC_PAGE_SIZE);],
323 el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)])
324 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
325         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
328 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
329 AC_TRY_RUN([
330 #include <stdio.h>
331 #include <stdarg.h>
332 #include <stdlib.h>
333 #include <string.h>
335 char buf[8];
337 int bar(char *buf, const char *format, va_list ap)
339        return vsnprintf(buf, 0, format, ap);
342 void foo(const char *format, ...) {
343        va_list ap;
344        int len;
346        va_start(ap, format);
347        len = bar(buf, format, ap);
348        va_end(ap);
349        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
351        va_start(ap, format);
352        len = bar(buf, format, ap);
353        va_end(ap);
354        if ((len != 6) && (len != 7)) exit(1);
356        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
358        exit(0);
360 main() { foo("hello\n"); }
362 el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)])
363 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
364         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
367 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
369 dnl ===================================================================
370 dnl Checks for libraries.
371 dnl ===================================================================
373 dnl Replace `main' with a function in -lsocket:
374 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
375 if test "$cf_result" = no; then
376         AC_CHECK_LIB(socket, socket)
379 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
380 if test "$cf_result" = no; then
381         AC_CHECK_LIB(socket, setsockopt)
384 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
385 if test "$cf_result" = no; then
386         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
387         if test "$cf_result" = no; then
388                 AC_CHECK_LIB(nsl, gethostbyname)
389         else
390                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
391         fi
394 dnl ===================================================================
395 dnl Checks for packaging specific options.
396 dnl ===================================================================
398 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
399             [ if test "$withval" != no && test "$withval" != yes; then
400                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
401               fi ])
403 dnl ===================================================================
404 dnl Checks for a libraries, optional even if installed.
405 dnl ===================================================================
407 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
408 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
410         AC_MSG_CHECKING([for $2 support])
412         if test "[$]$1" != no; then
413                 AC_MSG_RESULT(yes)
414                 EL_SAVE_FLAGS
415                 if test -n "$withval" && test -d "$withval"; then
416                         # Be a little more careful when setting
417                         # include and lib directories. This way
418                         # $withval will work when includes are
419                         # there but the library is in the common
420                         # /usr/lib ... Does the right thing when
421                         # looking for gc on Debian.
422                         if test -d "$withval/include"; then
423                                 CFLAGS="$CFLAGS -I$withval/include"
424                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
425                         else
426                                 CFLAGS="$CFLAGS -I$withval"
427                                 CPPFLAGS="$CPPFLAGS -I$withval"
428                         fi
429                         if test -d "$withval/lib"; then
430                                 LDFLAGS="$LDFLAGS -L$withval/lib"
431                         fi
432                 fi
434                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
435                 if test "[$]$1" = yes; then
436                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
437                 fi
439                 if test "[$]$1" = yes; then
440                         EL_CONFIG([$1], [$2])
441                         LIBS="$LIBS -l$4"
442                 else
443                         if test -n "[$]WITHVAL_$1" &&
444                            test "[$]WITHVAL_$1" != xno; then
445                                 AC_MSG_ERROR([$2 not found])
446                         fi
447                         EL_RESTORE_FLAGS
448                 fi
449         else
450                 AC_MSG_RESULT(disabled)
451         fi
454 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
455 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
457         $1=yes
458         WITHVAL_$1=
460         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
461         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
463         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
465         EL_LOG_CONFIG([$1], [$2], [])
468 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
469         [  --without-gpm           disable gpm (mouse) support])
471 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
472         [  --without-zlib          disable zlib support])
474 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
475         [  --without-bzlib         disable bzlib support])
477 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
478         [  --without-idn           disable international domain names support])
480 if test "x{with_gc}" != xno; then
481         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
482                 [  --with-gc               enable Boehm's garbage collector])
485 EL_ARG_ENABLE(CONFIG_LZMA, lzma, [lzma],
486               [  --enable-lzma           enable lzma encoding support])
488 dnl ===================================================================
489 dnl Check for GSSAPI, optional even if installed.
490 dnl ===================================================================
492 enable_gssapi="no";
494 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
495             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
497 AC_MSG_CHECKING([for GSSAPI])
499 if test "$enable_gssapi" = "yes"; then
500         AC_MSG_RESULT(yes)
501         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
502         GSSAPI_LIBS=`krb5-config --libs gssapi`
503         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
504         LIBS="$GSSAPI_LIBS $LIBS"
505         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
506 else
507         AC_MSG_RESULT(no)
510 AC_SUBST(CONFIG_GSSAPI)
512 dnl ===================================================================
513 dnl Bookmark and XBEL support
514 dnl ===================================================================
516 EL_SAVE_FLAGS
518 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
519               [  --disable-bookmarks     disable bookmark support])
521 # Check whether --enable-xbel or --disable-xbel was given.
522 if test "x${enable_xbel}" != xno; then
523         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
525         if test "$HAVE_LIBEXPAT" = yes; then
526                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
527                 if test "$HAVE_LIBEXPAT" = yes; then
528                         LIBS="$LIBS -lexpat"
529                 fi
530         fi
534 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
535               [XBEL bookmarks],
536               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
538 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
539         EL_RESTORE_FLAGS
542 dnl ===================================================================
543 dnl Checks for BSD sysmouse
544 dnl ===================================================================
546 HAVE_SYSMOUSE_HEADER="no"
548 # Either of these header files provides the (same) sysmouse interface
549 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
551 dnl ===================================================================
552 dnl Checks for OS/2
553 dnl ===================================================================
555 if test "$CONFIG_OS_OS2" = yes; then
556         EL_CONFIG_OS_OS2
559 dnl ===================================================================
560 dnl Checks for Win32
561 dnl ===================================================================
563 if test "$CONFIG_OS_WIN32" = yes; then
564         EL_CONFIG_OS_WIN32
567 dnl ===================================================================
568 dnl Check for SEE (Simple Ecmascript Engine)
569 dnl ===================================================================
570 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
571             [ if test "x$withval" != xno; then enable_see=yes; fi ])
573 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
574 # SEE_FLAGS but I really don't want to require people to have Guile in order
575 # to compile CVS. Also, the macro seems to be really stupid regarding searching
576 # for Guile in $PATH etc. --pasky
578 CONFIG_ECMASCRIPT_SEE=no
580 if test "$enable_see" = "yes"; then
581         if test -d "$withval"; then
582                 SEE_PATH="$withval:$PATH"
583         else
584                 SEE_PATH="$PATH"
585         fi
587         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
588         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
589         if test "$SEE_CONFIG" != no; then
590                 EL_SAVE_FLAGS
591                 SEE_LIBS="`$SEE_CONFIG --libs`"
592                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
593                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
594                 LIBS="$SEE_LIBS $LIBS_X"
595                 AC_TRY_LINK([#include <see/see.h>],[#if SEE_VERSION_API_MAJOR < 2
596                         #error SEE too old
597                         #endif
598                 ], cf_result=yes, cf_result=no)
599                 EL_RESTORE_FLAGS
600                 if test "$cf_result" = yes; then
601                         LIBS="$SEE_LIBS $LIBS"
602                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
603                         AC_SUBST(SEE_CFLAGS)
604                 fi
605                 AC_MSG_RESULT($cf_result)
606         else
607                 if test -n "$withval" && test "x$withval" != xno; then
608                         AC_MSG_ERROR([SEE not found])
609                 else
610                         AC_MSG_WARN([SEE support disabled])
611                 fi
612         fi
615 dnl ===================================================================
616 dnl Check for SpiderMonkey, optional even if installed.
617 dnl ===================================================================
619 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
620             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
621 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
623 EL_SAVE_FLAGS
624 cf_result=no
626 if test -z "$disable_spidermonkey"; then
627         if test ! -d "$withval"; then
628                 withval="";
629         fi
630         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
631                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
632                         for spidermonkeylib in js smjs mozjs; do
633                                 if test "$cf_result" = no; then
634                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
636                                         if test ! -z "$spidermonkeydir"; then
637                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
638                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
639                                         fi
641                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
642                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
643                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
645                                         AC_TRY_LINK([#define XP_UNIX
646                                                      #include <jsapi.h>],
647                                                      [JS_GetReservedSlot(NULL, NULL, 0, NULL)],
648                                                      cf_result=yes, cf_result=no)
649                                 fi
650                         done
651                 done
652         done
655 AC_MSG_RESULT($cf_result)
656 CONFIG_SPIDERMONKEY="$cf_result"
657 EL_RESTORE_FLAGS
659 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
660    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
661         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
662 else
663         CONFIG_ECMASCRIPT_SMJS=no
666 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
667 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
668 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
671 dnl ===================================================================
672 dnl Optional Spidermonkey-based ECMAScript browser scripting
673 dnl ===================================================================
675 AC_ARG_ENABLE(sm-scripting,
676               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
677               [if test "$enableval" != no; then enableval="yes"; fi
678                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
680 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
681    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
682         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
683 else
684         CONFIG_SCRIPTING_SPIDERMONKEY=no
687 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
688    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
689         LIBS="$LIBS $SPIDERMONKEY_LIBS"
690         AC_SUBST(SPIDERMONKEY_LIBS)
691         AC_SUBST(SPIDERMONKEY_CFLAGS)
692         AC_SUBST(CONFIG_SPIDERMONKEY)
695 dnl ===================================================================
696 dnl Check for Guile, optional even if installed.
697 dnl ===================================================================
699 enable_guile="no";
701 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
702             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
704 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
705 # GUILE_FLAGS but I really don't want to require people to have Guile in order
706 # to compile CVS. Also, the macro seems to be really stupid regarding searching
707 # for Guile in $PATH etc. --pasky
709 AC_MSG_CHECKING([for Guile])
711 if test "$enable_guile" = "yes"; then
712         AC_MSG_RESULT(yes);
713         ## Based on the GUILE_FLAGS macro.
715         if test -d "$withval"; then
716                 GUILE_PATH="$withval:$PATH"
717         else
718                 GUILE_PATH="$PATH"
719         fi
721         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
723         ## First, let's just see if we can find Guile at all.
724         if test "$GUILE_CONFIG" != no; then
725                 cf_result="yes";
727                 GUILE_LIBS="`guile-config link`"
728                 GUILE_CFLAGS="`guile-config compile`"
729                 LIBS="$GUILE_LIBS $LIBS"
730                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
731                 AC_SUBST(GUILE_CFLAGS)
732                 cat <<EOF
733 ***********************************************************************
734 The Guile support is incomplete and not so well integrated to ELinks
735 yet. That means, e.g., that you have no Guile console and there might
736 not be all the necessary hooks. Also, the Guile interface is not too
737 well tested (success stories heartily welcomed!).  See
738 src/scripting/guile/README for further details and hints.
739 ***********************************************************************
741         else
742                 if test -n "$withval" && test "x$withval" != xno; then
743                         AC_MSG_ERROR([Guile not found])
744                 else
745                         AC_MSG_WARN([Guile support disabled])
746                 fi
747         fi
748 else
749         AC_MSG_RESULT(no);
752 dnl ===================================================================
753 dnl Check for Perl
754 dnl ===================================================================
755 enable_perl="no";
757 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
758             [
759 if test "$withval" = yes; then
760         # FIXME: If withval is a valid directory append it to PATH
761         # so that you can specify one of several perl installations.
762         withval="";
763         enable_perl=yes;
765             ])
767 AC_MSG_CHECKING([for Perl])
769 cf_result=no
771 EL_SAVE_FLAGS
773 if test "$enable_perl" = "yes"; then
774         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
775         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
776         LIBS="$PERL_LIBS $LIBS"
777         CFLAGS="$PERL_CFLAGS $CFLAGS"
778         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
779         AC_TRY_LINK([
780 #include <EXTERN.h>
781 #include <perl.h>
782 #include <perlapi.h>
784                     [PerlInterpreter *my_perl = perl_alloc();],
785                     cf_result=yes, cf_result=no)
788 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
790 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
791 AC_TRY_COMPILE([
792 #include <EXTERN.h>
793 #include <perl.h>
794 extern PerlInterpreter *my_perl;
796         [dSP; (void) POPpx;],
797         [AC_MSG_RESULT([yes])
798 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
799                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
800 no longer needs an "n_a" variable like it did in 5.8.7])],
801         [AC_MSG_RESULT([no])])
803 if test "$cf_result" != "yes"; then
804         EL_RESTORE_FLAGS
805 else
806         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
808         CFLAGS="$CFLAGS_X"
809         CPPFLAGS="$CPPFLAGS_X"
810         AC_SUBST(PERL_LIBS)
811         AC_SUBST(PERL_CFLAGS)
814 dnl ===================================================================
815 dnl Check for Python
816 dnl ===================================================================
817 enable_python="no";
819 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
820             [ if test "x$withval" != xno; then enable_python=yes; fi ])
822 EL_SAVE_FLAGS
823 cf_result=no
825 AC_MSG_CHECKING([for Python])
827 if test "$enable_python" = "yes"; then
828         AC_MSG_RESULT(yes);
830         if test -d "$withval"; then
831                 PYTHON_PATH="$withval:$PATH"
832         else
833                 PYTHON_PATH="$PATH"
834         fi
836         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
838         if test "$PYTHON" != no; then
839                 cf_result="yes";
841                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
842                 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"))'`"
843                 LIBS="$PYTHON_LIBS $LIBS"
844                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
845                 AC_TRY_LINK([#include <Python.h>],
846                     [Py_Initialize();],
847                     cf_result=yes, cf_result=no)
849                 if test "$cf_result" != "yes"; then
850                         EL_RESTORE_FLAGS
851                 else
852                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
853                         AC_SUBST(PYTHON_LIBS)
854                         AC_SUBST(PYTHON_CFLAGS)
855                         CPPFLAGS="$CPPFLAGS_X"
856                         cat <<EOF
857 ***********************************************************************
858 The Python support is incomplete and not so well integrated to ELinks
859 yet. That means, e.g., that you have no Python console and there might
860 not be all the necessary hooks. Also, the Python interface is not too
861 well tested (success stories heartily welcomed!).
862 ***********************************************************************
864                 fi
865         else
866                 if test -n "$withval" && test "x$withval" != xno; then
867                         AC_MSG_ERROR([Python not found])
868                 else
869                         AC_MSG_WARN([Python support disabled])
870                 fi
871         fi
872 else
873         AC_MSG_RESULT(no);
877 dnl ===================================================================
878 dnl Check for Lua, optional even if installed.
879 dnl ===================================================================
881 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
882 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
884 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
885             [if test "$withval" = no; then disable_lua=yes; fi])
886 AC_MSG_CHECKING([for Lua])
888 EL_SAVE_FLAGS
889 cf_result=no
891 if test -z "$disable_lua"; then
892         if test ! -d "$withval"; then
893                 withval="";
894         fi
895         for luadir in "$withval" "" /usr /usr/local; do
896                 for suffix in "" 50 51; do
897                         if test "$cf_result" = no; then
898                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
900                                 if test ! -z "$luadir"; then
901                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
902                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
903                                 fi
905                                 LIBS="$LUA_LIBS $LIBS_X"
906                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
907                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
909                                 # Check that it is a compatible Lua version
910                                 AC_TRY_LINK([   #include <lua.h>
911                                                 #include <lualib.h>],
912                                             [   lua_State *L = lua_open();
913                                                 luaopen_base(L);
914                                                 luaopen_table(L);
915                                                 luaopen_io(L);
916                                                 luaopen_string(L);
917                                                 luaopen_math(L);
918                                                 lua_pushboolean(L, 1);
919                                                 lua_close(L);],
920                                             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 dnl ===================================================================
942 dnl Check for Ruby, optional even if installed.
943 dnl ===================================================================
945 EL_CONFIG_SCRIPTING_RUBY
947 dnl ===================================================================
948 dnl Setup global scripting
949 dnl ===================================================================
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 dnl ===================================================================
962 dnl Check for SSL support.
963 dnl ===================================================================
965 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
966 dnl is enabled, we won't try to use OpenSSL anymore.
968 dnl 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 dnl ---- 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_TRY_LINK([#include <openssl/ssl.h>],
1019                                     [OpenSSL_add_all_algorithms()],
1020                                     cf_result=yes, cf_result=no)
1021                         if test "$cf_result" != yes; then
1022                                 AC_TRY_LINK([#include <openssl/ssl.h>],
1023                                             [SSLeay_add_ssl_algorithms()],
1024                                             cf_result=yes, cf_result=no)
1025                         fi
1026                 fi
1027         done
1029         if test "$cf_result" != yes; then
1030                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1031                         AC_MSG_ERROR([OpenSSL not found])
1032                 fi
1033                 EL_RESTORE_FLAGS
1034         else
1035                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1037                 CFLAGS="$CFLAGS_X"
1038                 AC_SUBST(OPENSSL_CFLAGS)
1039         fi
1042 AC_MSG_RESULT($cf_result)
1044 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1045 dnl ---- GNU TLS
1046 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1047 dnl it looks ugly then.
1049 if test "$cf_result" = yes; then
1050         cf_result="not used"
1052 else
1053         EL_SAVE_FLAGS
1054         cf_result="no"
1056         if test -z "$disable_gnutls"; then
1057                 # Sure, we maybe _could_ use their macro, but how to ensure
1058                 # that the ./configure script won't fail if the macro won't be
1059                 # found..? :( --pasky
1061                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1063                 if test -d "$gnutls_withval"; then
1064                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1065                 fi
1067                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1069                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1070                         cf_result=no
1071                 else
1072                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1073                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1075                         LIBS="$GNUTLS_LIBS $LIBS_X"
1076                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1077                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1079                         # Verify if it's really usable.  gnutls_session was
1080                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1081                         # (on 2004-06-13); ELinks now requires this.
1082                         AC_TRY_LINK([#include <gnutls/gnutls.h>],
1083                                     [gnutls_session_t dummy;
1084                                      gnutls_check_version(NULL)],
1085                                     cf_result=yes, cf_result=no)
1086                 fi
1088                 if test "$cf_result" = yes; then
1089                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1091                         CFLAGS="$CFLAGS_X"
1092                         AC_SUBST(GNUTLS_CFLAGS)
1094                         # Verify if the MD5 compatibility layer is usable.
1095                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1096                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1097                                                   [GNU TLS OpenSSL compatibility],
1098                                                   gnutls/openssl.h, gnutls-openssl,
1099                                                   MD5_Init)
1100                 else
1101                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1102                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1103                         fi
1104                         EL_RESTORE_FLAGS
1105                 fi
1106         fi
1109 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1110 AC_MSG_RESULT($cf_result)
1112 dnl Final SSL setup
1114 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1115 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1116 AC_SUBST(CONFIG_OPENSSL)
1117 AC_SUBST(CONFIG_GNUTLS)
1119 #endif
1121 AC_MSG_CHECKING([whether to be or not to be])
1122 AC_MSG_RESULT([needs to be determined experimentally])
1124 dnl ===================================================================
1125 dnl Check for IPv6 support and related functions.
1126 dnl ===================================================================
1128 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1129 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1130 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1132 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1133 if test "$HAVE_GETADDRINFO" != yes; then
1134         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1135         if test "$HAVE_GETADDRINFO" = yes; then
1136                 LIBS="$LIBS -linet6"
1137         fi
1141 dnl ===================================================================
1142 dnl Checking for X11 (window title restoring).
1143 dnl ===================================================================
1145 AC_PATH_X
1146 if test x"$no_x" != xyes; then
1147         if test -n "$x_includes"; then
1148                 X_CFLAGS="-I$x_includes"
1149         fi
1150         if test -n "$x_libraries"; then
1151                 LDFLAGS="$LDFLAGS -L$x_libraries"
1152         fi
1153         LIBS="-lX11 $LIBS"
1154         EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1155         AC_SUBST(X_CFLAGS)
1159 dnl ===================================================================
1160 dnl Backtraces displaying support.
1161 dnl ===================================================================
1163 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1164 # possible checks for other system-specific means go here
1167 dnl ===================================================================
1168 dnl Gettext grey zone. Beware.
1169 dnl ===================================================================
1171 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"
1173 AM_GNU_GETTEXT
1175 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1176 dnl # f33r d4 l33t... I hope it's portable. :)
1177 dnl cf_result=$((48#z - 48#a + 1));
1178 dnl AC_MSG_RESULT($cf_result)
1181 dnl ===================================================================
1182 dnl Compile-time features control
1183 dnl ===================================================================
1185 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1186               [  --disable-cookies       disable cookie support])
1188 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1189               [  --disable-formhist      disable form history support])
1191 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1192               [  --disable-globhist      disable global history support])
1195 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1196               [  --disable-mailcap       disable mailcap support])
1198 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1199               [  --disable-mimetypes     disable mimetypes files support])
1202 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1203               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1204               [IPv6],
1205               [  --disable-ipv6          disable IPv6 support])
1207 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1208               [  --enable-bittorrent     enable BitTorrent protocol support])
1210 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1211               [  --disable-data          disable data protocol support])
1213 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1214               [  --disable-uri-rewrite   disable URI rewrite support])
1216 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1217               [  --enable-cgi            enable local CGI support])
1219 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1220               [  --enable-finger         enable finger protocol support])
1222 dnl ===================================================================
1223 dnl FSP protocol
1224 dnl ===================================================================
1225 EL_SAVE_FLAGS
1227 if test "x${enable_fsp}" != xno; then
1228         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1230         if test "$HAVE_FSPLIB" = yes; then
1231                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1232                 if test "$HAVE_FSPLIB" = yes; then
1233                         LIBS="$LIBS -lfsplib"
1234                 else
1235                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1236                         if test "$HAVE_FSPLIB" = yes; then
1237                                 LIBS="$LIBS -lfsp"
1238                         fi
1239                 fi
1240         fi
1243 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1244               [  --enable-fsp            enable FSP protocol support])
1246 if test "x$CONFIG_FSP" = xno; then
1247         EL_RESTORE_FLAGS
1250 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1251               [  --disable-ftp           disable ftp protocol support])
1253 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1254               [  --enable-gopher         enable gopher protocol support])
1256 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1257               [  --enable-nntp           enable nntp protocol support])
1259 dnl ===================================================================
1260 dnl SMB protocol support.
1261 dnl ===================================================================
1262 EL_SAVE_FLAGS
1264 if test "x${enable_smb}" != xno; then
1265         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1267         if test "$HAVE_SMBCLIENT" = yes; then
1268                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1269                 if test "$HAVE_SMBCLIENT" = yes; then
1270                         LIBS="$LIBS -lsmbclient"
1271                 fi
1272         fi
1275 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1276               [  --enable-smb            enable Samba protocol support])
1278 if test "x$CONFIG_SMB" = xno; then
1279         EL_RESTORE_FLAGS
1283 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1284               [  --disable-mouse         disable mouse support])
1286 # GPM mouse is Linux specific, so ...
1287 CONFIG_SYSMOUSE=yes
1288 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1289               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1290               [BSD sysmouse],
1291               [  --disable-sysmouse      disable BSD sysmouse support])
1293 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1294               [  --enable-88-colors      enable 88 color support])
1296 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1297               [  --enable-256-colors     enable 256 color support])
1299 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1300               [  --enable-true-color     enable true color support])
1302 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1303               [  --enable-exmode         enable exmode (CLI) interface])
1305 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1306               [  --disable-leds          disable LEDs support])
1308 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1309               [  --disable-marks         disable document marks support])
1312 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1313               [  --disable-css           disable Cascading Style Sheet support])
1315 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1316               [  --enable-html-highlight HTML highlighting using DOM engine])
1318 dnl Everything in the tree already uses CONFIG_DOM
1319 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1320 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1322 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1323               [  --disable-backtrace     disable backtrace support])
1325 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1326               [  --enable-no-root        enable prevention of usage by root])
1329 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1330               [  --enable-debug          enable leak debug and internal error checking])
1332 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1333               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1335 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1336               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1338 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1339               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1341 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1342               [  --enable-utf-8          enable UTF-8 support])
1345 AC_ARG_ENABLE(weehoofooboomookerchoo,
1346               [
1347     Also check out the features.conf file for more information about features!
1348               ],
1349               [AC_MSG_ERROR(Are you strange, or what?)])
1352 dnl == EMX hack
1354 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1355 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1358 dnl ===================================================================
1359 dnl Export directory paths
1360 dnl ===================================================================
1362 # Set up the ``entry points'' if they were not supplied by builder
1363 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1364 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1366 # Create CONFDIR #define for config.h
1368 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1369 # it's autoconf fault to force us to do such hacks ;p.
1370 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1371   # sysconfdir is set to its default value... fine, let's append /elinks/
1372   # XXX: We can't modify listing of the default in ./configure --help :-(
1373   sysconfdir_n=`eval echo "$sysconfdir"`
1374   sysconfdir=$sysconfdir_n
1375   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1376         sysconfdir="$sysconfdir/elinks"
1379 CONFDIR=$sysconfdir
1380 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1381 AC_SUBST(CONFDIR)
1383 # Create LOCALEDIR #define for config.h
1384 LOCALEDIR=`eval echo "$datadir/locale"`
1385 while echo "$LOCALEDIR" | grep "\\$"
1387         LOCALEDIR=`eval echo "$LOCALEDIR"`
1388 done > /dev/null 2> /dev/null
1389 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1390 AC_SUBST(LOCALEDIR)
1392 # Create LIBDIR #define for config.h
1393 LIBDIR=`eval echo "$libdir"`
1394 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1395 AC_SUBST(LIBDIR)
1397 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1398 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1400 dnl ===================================================================
1401 dnl A little fine tuning of gcc specific options (continued)
1402 dnl ===================================================================
1404 if test "x$ac_cv_prog_gcc" = "xyes"; then
1405   if test "$CONFIG_DEBUG" = "yes"; then
1406     dnl We want to see all warnings and live with none (in debug mode).
1407     CFLAGS="$CFLAGS -Werror"
1408   fi
1410   case "`$CC -dumpversion`" in
1411     3.0|3.1|3.2)
1412       # These should be ok using -Werror
1413       ;;
1414     3.*)
1415       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1416       # "dereferencing type-punned pointer will break strict-aliasing rules"
1417       # warnings. Disable them by not doing any strict-aliasing. The
1418       # alternative is just too ugly. Thanks gcc guys!! ;)
1419       CFLAGS="$CFLAGS -fno-strict-aliasing"
1420       ;;
1421     4.*)
1422       # Do not show warnings related to (char * | unsigned char *) type
1423       # difference.
1424       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1425       ;;
1426     *)
1427       # These should be ok using -Werror
1428       ;;
1429   esac
1431   # GCC 4.2 snapshots warn that comparisons like &object != NULL
1432   # always return true.  Some macros in ELinks check whether pointer
1433   # arguments are NULL, and giving them addresses of named objects
1434   # triggers the warning.  These warnings have not revealed any real
1435   # bugs, so shut them up instead of complicating the code.  GCC 4.1
1436   # does not recognize -Wno-always-true and exits with code 1 if it is
1437   # given.
1438   AC_MSG_CHECKING([whether $CC accepts -Wno-always-true])
1439   EL_SAVE_FLAGS
1440   CFLAGS="$CFLAGS -Wno-always-true"
1441   AC_TRY_COMPILE([], [],
1442     [AC_MSG_RESULT([yes])],
1443     [EL_RESTORE_FLAGS
1444      AC_MSG_RESULT([no])])
1447 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1448 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1449 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1450 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1452 dnl ===================================================================
1453 dnl Colored make output
1454 dnl ===================================================================
1456 if test $(`which tput` colors) -ge 4; then
1457         MAKE_COLOR=1
1458         AC_SUBST(MAKE_COLOR)
1461 dnl ===================================================================
1462 dnl Generated files
1463 dnl ===================================================================
1465 AC_OUTPUT([ \
1466  Makefile.config \
1467  contrib/elinks.spec \
1468  contrib/lua/hooks.lua \
1469  contrib/conv/w3m2links.awk \
1470  doc/man/man1/elinks.1 \
1471  src/intl/gettext/ref-add.sed \
1472  src/intl/gettext/ref-del.sed
1475 abs_srcdir="$(cd "$srcdir" && pwd)"
1476 # builddir is always absolute!
1477 if test "$abs_srcdir" != "$builddir"; then
1478         # Bootstrap the Makefile creation
1479         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1480         "$MAKE" "SRC=$abs_srcdir" init
1482         # Make cg-status ignore this build directory
1483         echo "*" > "$builddir/.gitignore"
1486 dnl ===================================================================
1487 dnl Configuration summary
1488 dnl ===================================================================
1490 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1491 cat features.log