move-link-prev-line: Really fixed.
[elinks.git] / configure.in
blobbccc2a475a545091f247d26bb2f8c9984b615853
1 dnl Process this file with autoconf to produce a configure script.
3 dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
4 dnl Autoconf 2.59 is installed in the computer that generates our nightly
5 dnl snapshots, so we need to be compatible with that.
6 AC_PREREQ(2.59)
7 AC_INIT
8 AC_CONFIG_SRCDIR([src/main/main.c])
9 AC_CONFIG_AUX_DIR(config)
11 PACKAGE=elinks
12 VERSION=0.13.GIT
13 AC_SUBST(PACKAGE)
14 AC_SUBST(VERSION)
15 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
16 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
17 AC_CONFIG_HEADERS(config.h)
19 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
20 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
21 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
23 MAKE=
25 for make in gnumake gmake make false; do
26         if test "x$MAKE" = x; then
27                 AC_PATH_PROGS(MAKE, "$make")
28         fi
29 done
31 builddir="`pwd`"
33 # Cleanup if we are configuring with a previous build in the tree
34 if test -e Makefile.config; then
35         AC_MSG_CHECKING([for previous build to clean])
36         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
37         AC_MSG_RESULT(done)
40 dnl ===================================================================
41 dnl Load feature configuration file and start logging features.
42 dnl ===================================================================
44 features="features.conf"
45 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
46 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
47 echo "Feature summary:" > features.log
49 dnl ===================================================================
50 dnl Checks for programs.
51 dnl ===================================================================
53 AC_PROG_CC
54 AC_PROG_AWK
55 AC_PATH_PROGS(AWK, "$AWK")
56 AC_PROG_RANLIB
57 AC_PROG_INSTALL
59 AC_PATH_PROGS(CG_COMMIT_ID, "cg-commit-id")
60 AC_PATH_PROGS(SPARSE, "sparse")
62 CONFIG_ASCIIDOC="no"
63 CONFIG_POD2HTML="no"
64 CONFIG_XMLTO="no"
65 CONFIG_JW="no"
67 if test "x$CONFIG_DOC" != xno; then
68         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
69         if test "x$ASCIIDOC" != "x"; then
70                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
71                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
72                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
74                 echo > config.asciidoc-unsafe.txt
75                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
76                         ASCIIDOC_FLAGS=--unsafe
77                 fi
78                 rm config.asciidoc-unsafe.*
79         fi
81         AC_PATH_PROGS(XMLTO, "xmlto")
82         if test "x$XMLTO" != "x"; then
83                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
84                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
85                 EL_CONFIG(MAN_XMLTO, [man (groff)])
86         fi
88         AC_PATH_PROGS(JW, "jw")
89         if test "x$JW" != "x"; then
90                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
91                 EL_CONFIG(MANUAL_JW, [PDF])
92         fi
94         AC_PATH_PROGS(POD2HTML, "pod2html")
95         if test "x$POD2HTML" != "x"; then
96                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
97         fi
99         AC_PATH_PROGS(DOXYGEN, "doxygen")
100         if test "x$DOXYGEN" != "x"; then
101                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
102                 api_srcdir="$(cd "$srcdir" && pwd)/src"
103                 AC_SUBST(api_srcdir)
104         fi
107 AC_SUBST(ASCIIDOC_FLAGS)
108 AC_SUBST(CONFIG_ASCIIDOC)
109 AC_SUBST(CONFIG_DOXYGEN)
110 AC_SUBST(CONFIG_POD2HTML)
111 AC_SUBST(CONFIG_XMLTO)
112 AC_SUBST(CONFIG_JW)
114 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
115 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
116 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
117 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
119 dnl gcc specific options (to be continued at the bottom of configure)
120 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
121   dnl We want to see all warnings and live with none.
122   dnl We can't set up -Werror here as there may be some warnings in test
123   dnl suite of configure, and we don't want to fail them.
124   CFLAGS="$CFLAGS -Wall"
127 dnl ===================================================================
128 dnl Checks for special OSes.
129 dnl ===================================================================
131 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
132 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
134         AC_MSG_CHECKING([for $2])
136         for flag in $3; do
137                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
138 kill me!
139 #endif ]])],[$1=yes],[$1=no])
140                 if test "[$]$1" = yes; then
141                         EL_CONFIG([$1], [$2])
142                         break
143                 fi
144         done
146         AC_MSG_RESULT([$]$1)
149 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
150 AC_SUBST(CONFIG_OS_BEOS)
152 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
153 AC_SUBST(CONFIG_OS_RISCOS)
155 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
156 AC_SUBST(CONFIG_OS_WIN32)
158 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
159 AC_SUBST(CONFIG_OS_OS2)
160 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
162 AC_MSG_CHECKING([for UNIX])
163 dnl FIXME: some depend kind of mechanism
164 if test "$CONFIG_OS_BEOS" = no && \
165    test "$CONFIG_OS_RISCOS" = no && \
166    test "$CONFIG_OS_WIN32" = no && \
167    test "$CONFIG_OS_OS2" = no; then
168         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
169 else
170         CONFIG_OS_UNIX=no
172 AC_MSG_RESULT($CONFIG_OS_UNIX)
173 AC_SUBST(CONFIG_OS_UNIX)
175 dnl ===================================================================
176 dnl Checks for header files.
177 dnl ===================================================================
179 AC_HEADER_DIRENT
180 AC_HEADER_STDC
181 AC_HEADER_SYS_WAIT
182 AC_HEADER_TIME
184 AC_CHECK_HEADERS(wctype.h)
185 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
186 AC_CHECK_HEADERS(sigaction.h)
187 AC_CHECK_HEADERS(arpa/inet.h)
188 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
189 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
190 AC_CHECK_HEADERS(ifaddrs.h)
191 AC_CHECK_HEADERS(sys/cygwin.h io.h)
192 AC_CHECK_HEADERS(sys/fmutex.h)
193 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
194 AC_CHECK_HEADERS(sys/resource.h)
195 AC_CHECK_HEADERS(sys/select.h)
196 AC_CHECK_HEADERS(sys/signal.h)
197 AC_CHECK_HEADERS(sys/socket.h)
198 AC_CHECK_HEADERS(sys/time.h)
199 AC_CHECK_HEADERS(sys/utsname.h)
200 AC_CHECK_HEADERS(stdint.h inttypes.h)
201 AC_CHECK_HEADERS(locale.h pwd.h)
202 AC_CHECK_HEADERS(termios.h)
205 AC_CHECK_HEADERS(sys/un.h,
206         [CONFIG_INTERLINK=yes
207          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
208         [CONFIG_INTERLINK=no])
209 AC_SUBST(CONFIG_INTERLINK)
211 dnl ===================================================================
212 dnl Checks for typedefs, structures, and compiler characteristics.
213 dnl ===================================================================
215 AC_STRUCT_TM
216 AC_C_CONST
217 AC_C_INLINE
218 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
220 AC_SYS_LARGEFILE
221 AC_TYPE_SIZE_T
222 AC_TYPE_OFF_T
223 EL_CHECK_TYPE(ssize_t, int)
224 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
225 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
226 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
227 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
228 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
230 AC_CHECK_SIZEOF(char, 1)
231 AC_CHECK_SIZEOF(short, 2)
232 AC_CHECK_SIZEOF(int, 4)
233 AC_CHECK_SIZEOF(long, 4)
234 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
235 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
237 dnl Check for variadic macros
238 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
239                 [#include <stdio.h>
240                  #define a(b,c...) printf(b,##c)],
241                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
243 dnl Check for -rdynamic
245 dnl gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
246 dnl the executable to its dynamic symbol table.  ELinks uses this for
247 dnl two purposes:
249 dnl 1. If ELinks detects a bug, it can try to display a backtrace by
250 dnl    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
251 dnl    manual states users of GNU ld must pass -rdynamic to make the
252 dnl    symbols available to the program.
254 dnl 2. It would eventually be nice to dynamically load shared
255 dnl    libraries as plugins (bug 73).  The plugins must be able to
256 dnl    call ELinks functions.  This can be implemented either by
257 dnl    registering all callable functions in ELinks-specific data
258 dnl    structures, or by letting the dynamic linker handle them.
259 dnl    The latter way requires something equivalent to -rdynamic.
261 dnl Because backtraces are not needed for correct operation, and bug
262 dnl 73 is not yet being fixed, the configure script and makefiles
263 dnl should not complain to the user if they find that -rdynamic does
264 dnl not work.  Besides, it was reported at elinks-users on 2006-09-12
265 dnl that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
266 dnl Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
267 dnl -rdynamic but does something equivalent automatically.  (This was
268 dnl tested with "nm -D elinks | grep redraw_from_window".)
270 dnl FIXME: This check doesn't work. Something to do with the compiler
271 dnl happily ignoring it and stderr not being checked for error messages.
272 AC_MSG_CHECKING([for -rdynamic])
273 LDFLAGS_X="$LDFLAGS"
274 LDFLAGS="$LDFLAGS -rdynamic"
275 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
276 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
277 AC_MSG_RESULT($have_rdynamic)
279 dnl ===================================================================
280 dnl Check for POSIX <regex.h>
281 dnl ===================================================================
283 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
285 dnl ===================================================================
286 dnl Checks for library functions.
287 dnl ===================================================================
289 AC_PROG_GCC_TRADITIONAL
290 AC_FUNC_MEMCMP
291 AC_FUNC_MMAP
292 AC_FUNC_STRFTIME
293 AC_CHECK_FUNCS(atoll cfmakeraw gethostbyaddr herror strerror)
294 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
295 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
296 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
297 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
298 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
299 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
300 AC_CHECK_FUNCS(gettimeofday clock_gettime)
302 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
304 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
305 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
306 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
308 dnl These aren't probably needed now, as they are commented in links.h.
309 dnl I've no idea about their historical background, but I keep them here
310 dnl just in the case they will help later. --pasky
311 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
312 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
313 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
314 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
316 if test x"$HAVE_RAISE" = x; then
317         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
318                 AC_MSG_ERROR([Unable to emulate raise()])
319         fi
322 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
323 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
324 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
325 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
326         EL_DEFINE(HAVE_VA_COPY, __va_copy)
329 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
330 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
331 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
332 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
333         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
336 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
337 AC_RUN_IFELSE([AC_LANG_SOURCE([[
338 #include <stdio.h>
339 #include <stdarg.h>
340 #include <stdlib.h>
341 #include <string.h>
343 char buf[8];
345 int bar(char *buf, const char *format, va_list ap)
347        return vsnprintf(buf, 0, format, ap);
350 void foo(const char *format, ...) {
351        va_list ap;
352        int len;
354        va_start(ap, format);
355        len = bar(buf, format, ap);
356        va_end(ap);
357        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
359        va_start(ap, format);
360        len = bar(buf, format, ap);
361        va_end(ap);
362        if ((len != 6) && (len != 7)) exit(1);
364        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
366        exit(0);
368 main() { foo("hello\n"); }
369 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
370 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
371         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
374 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
376 dnl ===================================================================
377 dnl Checks for libraries.
378 dnl ===================================================================
380 dnl Replace `main' with a function in -lsocket:
381 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
382 if test "$cf_result" = no; then
383         AC_CHECK_LIB(socket, socket)
386 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
387 if test "$cf_result" = no; then
388         AC_CHECK_LIB(socket, setsockopt)
391 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
392 if test "$cf_result" = no; then
393         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
394         if test "$cf_result" = no; then
395                 AC_CHECK_LIB(nsl, gethostbyname)
396         else
397                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
398         fi
401 dnl ===================================================================
402 dnl Checks for packaging specific options.
403 dnl ===================================================================
405 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
406             [ if test "$withval" != no && test "$withval" != yes; then
407                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
408               fi ])
410 dnl ===================================================================
411 dnl Checks for a libraries, optional even if installed.
412 dnl ===================================================================
414 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
415 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
417         AC_MSG_CHECKING([for $2 support])
419         if test "[$]$1" != no; then
420                 AC_MSG_RESULT(yes)
421                 EL_SAVE_FLAGS
422                 if test -n "$withval" && test -d "$withval"; then
423                         # Be a little more careful when setting
424                         # include and lib directories. This way
425                         # $withval will work when includes are
426                         # there but the library is in the common
427                         # /usr/lib ... Does the right thing when
428                         # looking for gc on Debian.
429                         if test -d "$withval/include"; then
430                                 CFLAGS="$CFLAGS -I$withval/include"
431                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
432                         else
433                                 CFLAGS="$CFLAGS -I$withval"
434                                 CPPFLAGS="$CPPFLAGS -I$withval"
435                         fi
436                         if test -d "$withval/lib"; then
437                                 LDFLAGS="$LDFLAGS -L$withval/lib"
438                         fi
439                 fi
441                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
442                 if test "[$]$1" = yes; then
443                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
444                 fi
446                 if test "[$]$1" = yes; then
447                         EL_CONFIG([$1], [$2])
448                         LIBS="$LIBS -l$4"
449                 else
450                         if test -n "[$]WITHVAL_$1" &&
451                            test "[$]WITHVAL_$1" != xno; then
452                                 AC_MSG_ERROR([$2 not found])
453                         fi
454                         EL_RESTORE_FLAGS
455                 fi
456         else
457                 AC_MSG_RESULT(disabled)
458         fi
461 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
462 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
464         $1=yes
465         WITHVAL_$1=
467         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
468         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
470         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
472         EL_LOG_CONFIG([$1], [$2], [])
475 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
476         [  --without-gpm           disable gpm (mouse) support])
478 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
479         [  --without-zlib          disable zlib support])
481 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
482         [  --without-bzlib         disable bzlib support])
484 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
485         [  --without-idn           disable international domain names support])
487 if test "x{with_gc}" != xno; then
488         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
489                 [  --with-gc               enable Boehm's garbage collector])
492 EL_ARG_ENABLE(CONFIG_LZMA, lzma, [lzma],
493               [  --enable-lzma           enable lzma encoding support])
495 dnl ===================================================================
496 dnl Check for GSSAPI, optional even if installed.
497 dnl ===================================================================
499 enable_gssapi="no";
501 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
502             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
504 AC_MSG_CHECKING([for GSSAPI])
506 if test "$enable_gssapi" = "yes"; then
507         AC_MSG_RESULT(yes)
508         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
509         GSSAPI_LIBS=`krb5-config --libs gssapi`
510         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
511         LIBS="$GSSAPI_LIBS $LIBS"
512         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
513 else
514         AC_MSG_RESULT(no)
517 AC_SUBST(CONFIG_GSSAPI)
519 dnl ===================================================================
520 dnl Bookmark and XBEL support
521 dnl ===================================================================
523 EL_SAVE_FLAGS
525 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
526               [  --disable-bookmarks     disable bookmark support])
528 # Check whether --enable-xbel or --disable-xbel was given.
529 if test "x${enable_xbel}" != xno; then
530         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
532         if test "$HAVE_LIBEXPAT" = yes; then
533                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
534                 if test "$HAVE_LIBEXPAT" = yes; then
535                         LIBS="$LIBS -lexpat"
536                 fi
537         fi
541 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
542               [XBEL bookmarks],
543               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
545 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
546         EL_RESTORE_FLAGS
549 dnl ===================================================================
550 dnl Checks for BSD sysmouse
551 dnl ===================================================================
553 HAVE_SYSMOUSE_HEADER="no"
555 # Either of these header files provides the (same) sysmouse interface
556 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
558 dnl ===================================================================
559 dnl Checks for OS/2
560 dnl ===================================================================
562 if test "$CONFIG_OS_OS2" = yes; then
563         EL_CONFIG_OS_OS2
566 dnl ===================================================================
567 dnl Checks for Win32
568 dnl ===================================================================
570 if test "$CONFIG_OS_WIN32" = yes; then
571         EL_CONFIG_OS_WIN32
574 dnl ===================================================================
575 dnl Check for SEE (Simple Ecmascript Engine)
576 dnl ===================================================================
577 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
578             [ if test "x$withval" != xno; then enable_see=yes; fi ])
580 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
581 # SEE_FLAGS but I really don't want to require people to have Guile in order
582 # to compile CVS. Also, the macro seems to be really stupid regarding searching
583 # for Guile in $PATH etc. --pasky
585 CONFIG_ECMASCRIPT_SEE=no
587 if test "$enable_see" = "yes"; then
588         if test -d "$withval"; then
589                 SEE_PATH="$withval:$PATH"
590         else
591                 SEE_PATH="$PATH"
592         fi
594         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
595         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
596         if test "$SEE_CONFIG" != no; then
597                 EL_SAVE_FLAGS
598                 SEE_LIBS="`$SEE_CONFIG --libs`"
599                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
600                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
601                 LIBS="$SEE_LIBS $LIBS_X"
602                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
603                         #error SEE too old
604                         #endif
605                 ]])],[cf_result=yes],[cf_result=no])
606                 EL_RESTORE_FLAGS
607                 if test "$cf_result" = yes; then
608                         LIBS="$SEE_LIBS $LIBS"
609                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
610                         AC_SUBST(SEE_CFLAGS)
611                 fi
612                 AC_MSG_RESULT($cf_result)
613         else
614                 if test -n "$withval" && test "x$withval" != xno; then
615                         AC_MSG_ERROR([SEE not found])
616                 else
617                         AC_MSG_WARN([SEE support disabled])
618                 fi
619         fi
622 dnl ===================================================================
623 dnl Check for SpiderMonkey, optional even if installed.
624 dnl ===================================================================
626 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
627             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
628 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
630 EL_SAVE_FLAGS
631 cf_result=no
633 if test -z "$disable_spidermonkey"; then
634         if test ! -d "$withval"; then
635                 withval="";
636         fi
637         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
638                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
639                         for spidermonkeylib in js smjs mozjs; do
640                                 if test "$cf_result" = no &&
641                                    test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then
642                                         SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
643                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
645                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
646                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
647                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
649                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
650                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
651                                 fi
652                         done
653                 done
654         done
657 AC_MSG_RESULT($cf_result)
658 CONFIG_SPIDERMONKEY="$cf_result"
659 EL_RESTORE_FLAGS
661 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
662    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
663         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
664 else
665         CONFIG_ECMASCRIPT_SMJS=no
668 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
669 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
670 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
673 dnl ===================================================================
674 dnl Optional Spidermonkey-based ECMAScript browser scripting
675 dnl ===================================================================
677 AC_ARG_ENABLE(sm-scripting,
678               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
679               [if test "$enableval" != no; then enableval="yes"; fi
680                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
682 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
683    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
684         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
685 else
686         CONFIG_SCRIPTING_SPIDERMONKEY=no
689 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
690    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
691         LIBS="$LIBS $SPIDERMONKEY_LIBS"
692         AC_SUBST(SPIDERMONKEY_LIBS)
693         AC_SUBST(SPIDERMONKEY_CFLAGS)
694         AC_SUBST(CONFIG_SPIDERMONKEY)
697 dnl ===================================================================
698 dnl Check for Guile, optional even if installed.
699 dnl ===================================================================
701 enable_guile="no";
703 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
704             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
706 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
707 # GUILE_FLAGS but I really don't want to require people to have Guile in order
708 # to compile CVS. Also, the macro seems to be really stupid regarding searching
709 # for Guile in $PATH etc. --pasky
711 AC_MSG_CHECKING([for Guile])
713 if test "$enable_guile" = "yes"; then
714         AC_MSG_RESULT(yes);
715         ## Based on the GUILE_FLAGS macro.
717         if test -d "$withval"; then
718                 GUILE_PATH="$withval:$PATH"
719         else
720                 GUILE_PATH="$PATH"
721         fi
723         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
725         ## First, let's just see if we can find Guile at all.
726         if test "$GUILE_CONFIG" != no; then
727                 cf_result="yes";
729                 GUILE_LIBS="`guile-config link`"
730                 GUILE_CFLAGS="`guile-config compile`"
731                 LIBS="$GUILE_LIBS $LIBS"
732                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
733                 AC_SUBST(GUILE_CFLAGS)
734                 cat <<EOF
735 ***********************************************************************
736 The Guile support is incomplete and not so well integrated to ELinks
737 yet. That means, e.g., that you have no Guile console and there might
738 not be all the necessary hooks. Also, the Guile interface is not too
739 well tested (success stories heartily welcomed!).  See
740 src/scripting/guile/README for further details and hints.
741 ***********************************************************************
743         else
744                 if test -n "$withval" && test "x$withval" != xno; then
745                         AC_MSG_ERROR([Guile not found])
746                 else
747                         AC_MSG_WARN([Guile support disabled])
748                 fi
749         fi
750 else
751         AC_MSG_RESULT(no);
754 dnl ===================================================================
755 dnl Check for Perl
756 dnl ===================================================================
757 enable_perl="no";
759 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
760             [
761 if test "$withval" = yes; then
762         # FIXME: If withval is a valid directory append it to PATH
763         # so that you can specify one of several perl installations.
764         withval="";
765         enable_perl=yes;
767             ])
769 AC_MSG_CHECKING([for Perl])
771 cf_result=no
773 EL_SAVE_FLAGS
775 if test "$enable_perl" = "yes"; then
776         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
777         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
778         LIBS="$PERL_LIBS $LIBS"
779         CFLAGS="$PERL_CFLAGS $CFLAGS"
780         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
781         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
782 #include <EXTERN.h>
783 #include <perl.h>
784 #include <perlapi.h>
785 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[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_COMPILE_IFELSE([AC_LANG_PROGRAM([[
792 #include <EXTERN.h>
793 #include <perl.h>
794 extern PerlInterpreter *my_perl;
795 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
796 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
797                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
798 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
800 if test "$cf_result" != "yes"; then
801         EL_RESTORE_FLAGS
802 else
803         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
805         CFLAGS="$CFLAGS_X"
806         CPPFLAGS="$CPPFLAGS_X"
807         AC_SUBST(PERL_LIBS)
808         AC_SUBST(PERL_CFLAGS)
811 dnl ===================================================================
812 dnl Check for Python
813 dnl ===================================================================
814 enable_python="no";
816 AC_ARG_WITH(python, [  --with-python=[DIR]     enable Python support],
817             [ if test "x$withval" != xno; then enable_python=yes; fi ])
819 EL_SAVE_FLAGS
820 cf_result=no
822 AC_MSG_CHECKING([for Python])
824 if test "$enable_python" = "yes"; then
825         AC_MSG_RESULT(yes);
827         if test -d "$withval"; then
828                 PYTHON_PATH="$withval:$PATH"
829         else
830                 PYTHON_PATH="$PATH"
831         fi
833         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
835         if test "$PYTHON" != no; then
836                 cf_result="yes";
838                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
839                 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"))'`"
840                 LIBS="$PYTHON_LIBS $LIBS"
841                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
842                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
844                 if test "$cf_result" != "yes"; then
845                         EL_RESTORE_FLAGS
846                 else
847                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
848                         AC_SUBST(PYTHON_LIBS)
849                         AC_SUBST(PYTHON_CFLAGS)
850                         CPPFLAGS="$CPPFLAGS_X"
851                         cat <<EOF
852 ***********************************************************************
853 The Python support is incomplete and not so well integrated to ELinks
854 yet. That means, e.g., that you have no Python console and there might
855 not be all the necessary hooks. Also, the Python interface is not too
856 well tested (success stories heartily welcomed!).
857 ***********************************************************************
859                 fi
860         else
861                 if test -n "$withval" && test "x$withval" != xno; then
862                         AC_MSG_ERROR([Python not found])
863                 else
864                         AC_MSG_WARN([Python support disabled])
865                 fi
866         fi
867 else
868         AC_MSG_RESULT(no);
872 dnl ===================================================================
873 dnl Check for Lua, optional even if installed.
874 dnl ===================================================================
876 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
877 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
879 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
880             [if test "$withval" = no; then disable_lua=yes; fi])
881 AC_MSG_CHECKING([for Lua])
883 EL_SAVE_FLAGS
884 cf_result=no
886 if test -z "$disable_lua"; then
887         if test ! -d "$withval"; then
888                 withval="";
889         fi
890         for luadir in "$withval" "" /usr /usr/local; do
891                 for suffix in "" 50 51; do
892                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
893                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
894                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
895                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
897                                 LIBS="$LUA_LIBS $LIBS_X"
898                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
899                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
901                                 # Check that it is a compatible Lua version
902                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
903                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
904                                                 luaopen_base(L);
905                                                 luaopen_table(L);
906                                                 luaopen_io(L);
907                                                 luaopen_string(L);
908                                                 luaopen_math(L);
909                                                 lua_pushboolean(L, 1);
910                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
911                         fi
912                 done
913         done
916 AC_MSG_RESULT($cf_result)
918 if test "$cf_result" != yes; then
919         EL_RESTORE_FLAGS
920 else
921         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
922         AC_CHECK_HEADERS(lauxlib.h)
924         CFLAGS="$CFLAGS_X"
925         CPPFLAGS="$CPPFLAGS_X"
926         AC_SUBST(LUA_LIBS)
927         AC_SUBST(LUA_CFLAGS)
931 dnl ===================================================================
932 dnl Check for Ruby, optional even if installed.
933 dnl ===================================================================
935 EL_CONFIG_SCRIPTING_RUBY
937 dnl ===================================================================
938 dnl Setup global scripting
939 dnl ===================================================================
941 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])
942 AC_SUBST(CONFIG_SCRIPTING_GUILE)
943 AC_SUBST(CONFIG_SCRIPTING_LUA)
944 AC_SUBST(CONFIG_SCRIPTING_PERL)
945 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
946 AC_SUBST(CONFIG_SCRIPTING_RUBY)
947 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
948 AC_SUBST(CONFIG_SCRIPTING)
951 dnl ===================================================================
952 dnl Check for SSL support.
953 dnl ===================================================================
955 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
956 dnl is enabled, we won't try to use OpenSSL anymore.
958 dnl For wiping SSL hooks..
959 #ifdef CONFIG_SSL
961 disable_openssl=""
962 disable_gnutls=""
963 enable_gnutls=""
965 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
966             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
967 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
968             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
969 gnutls_withval="$withval"
971 if test "$enable_gnutls" = yes; then
972         disable_openssl=yes;
975 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
976             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
977 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
978 openssl_withval="$withval"
980 dnl ---- OpenSSL
982 AC_MSG_CHECKING([for OpenSSL])
984 EL_SAVE_FLAGS
985 cf_result="no"
987 if test "$disable_openssl" = yes; then
988         cf_result="not used"
989 else
990         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
991                          /usr/lib/openssl /usr/local/ssl \
992                          /usr/local/www /usr/lib/ssl /usr/local \
993                          /usr/pkg /opt /opt/openssl; do
994                 if test "$cf_result" = no; then
995                         if test -d "$ssldir"; then
996                                 OPENSSL_CFLAGS="-I$ssldir/include"
997                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
998                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
999                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1000 #                               # FIXME: This created serious portability problems. --pasky
1001 #                               if test "$CC" == "gcc"; then
1002 #                                       # I'm not sure about compatibility here. --pasky
1003 #                                       LIBS="$LIBS -R$ssldir/lib"
1004 #                               fi
1005                         else
1006                                 LIBS="-lssl -lcrypto $LIBS_X"
1007                         fi
1008                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1009                         if test "$cf_result" != yes; then
1010                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1011                         fi
1012                 fi
1013         done
1015         if test "$cf_result" != yes; then
1016                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1017                         AC_MSG_ERROR([OpenSSL not found])
1018                 fi
1019                 EL_RESTORE_FLAGS
1020         else
1021                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1023                 CFLAGS="$CFLAGS_X"
1024                 AC_SUBST(OPENSSL_CFLAGS)
1025         fi
1028 AC_MSG_RESULT($cf_result)
1030 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1031 dnl ---- GNU TLS
1032 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1033 dnl it looks ugly then.
1035 if test "$cf_result" = yes; then
1036         cf_result="not used"
1038 else
1039         EL_SAVE_FLAGS
1040         cf_result="no"
1042         if test -z "$disable_gnutls"; then
1043                 # Sure, we maybe _could_ use their macro, but how to ensure
1044                 # that the ./configure script won't fail if the macro won't be
1045                 # found..? :( --pasky
1047                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1049                 if test -d "$gnutls_withval"; then
1050                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1051                 fi
1053                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1055                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1056                         cf_result=no
1057                 else
1058                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1059                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1061                         LIBS="$GNUTLS_LIBS $LIBS_X"
1062                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1063                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1065                         # Verify if it's really usable.  gnutls_session was
1066                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1067                         # (on 2004-06-13); ELinks now requires this.
1068                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[gnutls_session_t dummy;
1069                                      gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no])
1070                 fi
1072                 if test "$cf_result" = yes; then
1073                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1075                         CFLAGS="$CFLAGS_X"
1076                         AC_SUBST(GNUTLS_CFLAGS)
1078                         # Verify if the MD5 compatibility layer is usable.
1079                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1080                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1081                                                   [GNU TLS OpenSSL compatibility],
1082                                                   gnutls/openssl.h, gnutls-openssl,
1083                                                   MD5_Init)
1084                 else
1085                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1086                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1087                         fi
1088                         EL_RESTORE_FLAGS
1089                 fi
1090         fi
1093 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1094 AC_MSG_RESULT($cf_result)
1096 dnl Final SSL setup
1098 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1099 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1100 AC_SUBST(CONFIG_OPENSSL)
1101 AC_SUBST(CONFIG_GNUTLS)
1103 #endif
1105 AC_MSG_CHECKING([whether to be or not to be])
1106 AC_MSG_RESULT([needs to be determined experimentally])
1108 dnl ===================================================================
1109 dnl Check for IPv6 support and related functions.
1110 dnl ===================================================================
1112 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1113 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1114 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1116 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1117 if test "$HAVE_GETADDRINFO" != yes; then
1118         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1119         if test "$HAVE_GETADDRINFO" = yes; then
1120                 LIBS="$LIBS -linet6"
1121         fi
1125 dnl ===================================================================
1126 dnl Checking for X11 (window title restoring).
1127 dnl ===================================================================
1129 AC_PATH_X
1130 if test x"$no_x" != xyes; then
1131         EL_SAVE_FLAGS
1132         if test -n "$x_includes"; then
1133                 X_CFLAGS="-I$x_includes"
1134                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1135                 CFLAGS="$CFLAGS $X_CFLAGS"
1136         fi
1137         if test -n "$x_libraries"; then
1138                 LDFLAGS="$LDFLAGS -L$x_libraries"
1139         fi
1140         LIBS="-lX11 $LIBS"
1141         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1142         EL_RESTORE_FLAGS
1143         if test "$cf_result" = yes; then
1144                 if test -n "$x_libraries"; then
1145                         LDFLAGS="$LDFLAGS -L$x_libraries"
1146                 fi
1147                 LIBS="-lX11 $LIBS"
1148                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1149                 AC_SUBST(X_CFLAGS)
1150         fi
1154 dnl ===================================================================
1155 dnl Backtraces displaying support.
1156 dnl ===================================================================
1158 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1159 # possible checks for other system-specific means go here
1162 dnl ===================================================================
1163 dnl Gettext grey zone. Beware.
1164 dnl ===================================================================
1166 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"
1168 AM_GNU_GETTEXT
1170 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1171 dnl # f33r d4 l33t... I hope it's portable. :)
1172 dnl cf_result=$((48#z - 48#a + 1));
1173 dnl AC_MSG_RESULT($cf_result)
1176 dnl ===================================================================
1177 dnl Compile-time features control
1178 dnl ===================================================================
1180 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1181               [  --disable-cookies       disable cookie support])
1183 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1184               [  --disable-formhist      disable form history support])
1186 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1187               [  --disable-globhist      disable global history support])
1190 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1191               [  --disable-mailcap       disable mailcap support])
1193 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1194               [  --disable-mimetypes     disable mimetypes files support])
1197 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1198               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1199               [IPv6],
1200               [  --disable-ipv6          disable IPv6 support])
1202 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1203               [  --enable-bittorrent     enable BitTorrent protocol support])
1205 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1206               [  --disable-data          disable data protocol support])
1208 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1209               [  --disable-uri-rewrite   disable URI rewrite support])
1211 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1212               [  --enable-cgi            enable local CGI support])
1214 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1215               [  --enable-finger         enable finger protocol support])
1217 dnl ===================================================================
1218 dnl FSP protocol
1219 dnl ===================================================================
1220 EL_SAVE_FLAGS
1222 if test "x${enable_fsp}" != xno; then
1223         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1225         if test "$HAVE_FSPLIB" = yes; then
1226                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1227                 if test "$HAVE_FSPLIB" = yes; then
1228                         LIBS="$LIBS -lfsplib"
1229                 else
1230                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1231                         if test "$HAVE_FSPLIB" = yes; then
1232                                 LIBS="$LIBS -lfsp"
1233                         fi
1234                 fi
1235         fi
1238 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1239               [  --enable-fsp            enable FSP protocol support])
1241 if test "x$CONFIG_FSP" = xno; then
1242         EL_RESTORE_FLAGS
1245 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1246               [  --disable-ftp           disable ftp protocol support])
1248 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1249               [  --enable-gopher         enable gopher protocol support])
1251 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1252               [  --enable-nntp           enable nntp protocol support])
1254 dnl ===================================================================
1255 dnl SMB protocol support.
1256 dnl ===================================================================
1257 EL_SAVE_FLAGS
1259 if test "x${enable_smb}" != xno; then
1260         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1262         if test "$HAVE_SMBCLIENT" = yes; then
1263                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1264                 if test "$HAVE_SMBCLIENT" = yes; then
1265                         LIBS="$LIBS -lsmbclient"
1266                 fi
1267         fi
1270 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1271               [  --enable-smb            enable Samba protocol support])
1273 if test "x$CONFIG_SMB" = xno; then
1274         EL_RESTORE_FLAGS
1278 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1279               [  --disable-mouse         disable mouse support])
1281 # GPM mouse is Linux specific, so ...
1282 CONFIG_SYSMOUSE=yes
1283 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1284               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1285               [BSD sysmouse],
1286               [  --disable-sysmouse      disable BSD sysmouse support])
1288 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1289               [  --enable-88-colors      enable 88 color support])
1291 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1292               [  --enable-256-colors     enable 256 color support])
1294 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1295               [  --enable-true-color     enable true color support])
1297 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1298               [  --enable-exmode         enable exmode (CLI) interface])
1300 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1301               [  --disable-leds          disable LEDs support])
1303 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1304               [  --disable-marks         disable document marks support])
1307 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1308               [  --disable-css           disable Cascading Style Sheet support])
1310 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1311               [  --enable-html-highlight HTML highlighting using DOM engine])
1313 dnl Everything in the tree already uses CONFIG_DOM
1314 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1315 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1317 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1318               [  --disable-backtrace     disable backtrace support])
1320 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1321               [  --enable-no-root        enable prevention of usage by root])
1324 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1325               [  --enable-debug          enable leak debug and internal error checking])
1327 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1328               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1330 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1331               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1333 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1334               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1336 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1337               [  --enable-utf-8          enable UTF-8 support])
1340 AC_ARG_ENABLE(weehoofooboomookerchoo,
1341               [
1342     Also check out the features.conf file for more information about features!
1343               ],
1344               [AC_MSG_ERROR(Are you strange, or what?)])
1347 dnl == EMX hack
1349 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1350 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1353 dnl ===================================================================
1354 dnl Export directory paths
1355 dnl ===================================================================
1357 # Set up the ``entry points'' if they were not supplied by builder
1358 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1359 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1361 # Create CONFDIR #define for config.h
1363 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1364 # it's autoconf fault to force us to do such hacks ;p.
1365 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1366   # sysconfdir is set to its default value... fine, let's append /elinks/
1367   # XXX: We can't modify listing of the default in ./configure --help :-(
1368   sysconfdir_n=`eval echo "$sysconfdir"`
1369   sysconfdir=$sysconfdir_n
1370   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1371         sysconfdir="$sysconfdir/elinks"
1374 CONFDIR=$sysconfdir
1375 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1376 AC_SUBST(CONFDIR)
1378 # Create LOCALEDIR #define for config.h
1379 LOCALEDIR=`eval echo "$datadir/locale"`
1380 while echo "$LOCALEDIR" | grep "\\$"
1382         LOCALEDIR=`eval echo "$LOCALEDIR"`
1383 done > /dev/null 2> /dev/null
1384 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1385 AC_SUBST(LOCALEDIR)
1387 # Create LIBDIR #define for config.h
1388 LIBDIR=`eval echo "$libdir"`
1389 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1390 AC_SUBST(LIBDIR)
1392 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1393 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1395 dnl ===================================================================
1396 dnl A little fine tuning of gcc specific options (continued)
1397 dnl ===================================================================
1399 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1400   if test "$CONFIG_DEBUG" = "yes"; then
1401     dnl We want to see all warnings and live with none (in debug mode).
1402     CFLAGS="$CFLAGS -Werror"
1403   fi
1405   case "`$CC -dumpversion`" in
1406     3.0|3.1|3.2)
1407       # These should be ok using -Werror
1408       ;;
1409     3.*)
1410       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1411       # "dereferencing type-punned pointer will break strict-aliasing rules"
1412       # warnings. Disable them by not doing any strict-aliasing. The
1413       # alternative is just too ugly. Thanks gcc guys!! ;)
1414       CFLAGS="$CFLAGS -fno-strict-aliasing"
1415       ;;
1416     4.*)
1417       # Do not show warnings related to (char * | unsigned char *) type
1418       # difference.
1419       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1420       ;;
1421     *)
1422       # These should be ok using -Werror
1423       ;;
1424   esac
1426   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1427   # warning: the address of `builtin_modules' will always evaluate as `true'
1428   # This hits the object_lock and foreach_module macros in particular.
1429   # It would be okay to put something in the macros to avoid the warning,
1430   # but currently this seems to require defining parallel macros that skip
1431   # the NULL check, and that's too ugly.  So we instead disable the warning.
1432   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1433   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1434   for warning_flag in -Wno-address -Wno-always-true; do
1435     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1436     EL_SAVE_FLAGS
1437     CFLAGS="$CFLAGS $warning_flag"
1438     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1439       [AC_MSG_RESULT([yes])
1440        break],
1441       [AC_MSG_RESULT([no])])
1442     EL_RESTORE_FLAGS
1443   done
1446 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1447 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1448 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1449 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1451 dnl ===================================================================
1452 dnl Colored make output
1453 dnl ===================================================================
1455 if test $(`which tput` colors) -ge 4; then
1456         MAKE_COLOR=1
1457         AC_SUBST(MAKE_COLOR)
1460 dnl ===================================================================
1461 dnl Generated files
1462 dnl ===================================================================
1464 AC_CONFIG_FILES([ \
1465  Makefile.config \
1466  contrib/elinks.spec \
1467  contrib/lua/hooks.lua \
1468  contrib/conv/w3m2links.awk \
1469  doc/Doxyfile \
1470  doc/man/man1/elinks.1 \
1471  src/intl/gettext/ref-add.sed \
1472  src/intl/gettext/ref-del.sed
1474 AC_OUTPUT
1476 abs_srcdir="$(cd "$srcdir" && pwd)"
1477 # builddir is always absolute!
1478 if test "$abs_srcdir" != "$builddir"; then
1479         # Bootstrap the Makefile creation
1480         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1481         "$MAKE" "SRC=$abs_srcdir" init
1483         # Make cg-status ignore this build directory
1484         echo "*" > "$builddir/.gitignore"
1487 dnl ===================================================================
1488 dnl Configuration summary
1489 dnl ===================================================================
1491 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1492 cat features.log