Merge branch 'elinks-0.12' into elinks-0.13
[elinks/witekfl.git] / configure.in
blob77133a9493a76389f381696ab96ce2c9d04261b4
1 dnl Process this file with autoconf to produce a configure script.
3 dnl There are two types of comments in this file.
4 dnl Comments that refer to Autoconf macros begin with "dnl", and m4
5 dnl discards them.  Other comments begin with "#", and they get copied
6 dnl to the configure script, hopefully making it easier to read.
8 dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
9 dnl Autoconf 2.59 is installed in the computer that generates our nightly
10 dnl snapshots, so we need to be compatible with that.
11 AC_PREREQ(2.59)
12 AC_INIT
13 AC_CONFIG_SRCDIR([src/main/main.c])
14 AC_CONFIG_AUX_DIR(config)
16 PACKAGE=elinks
17 VERSION=0.13.GIT
18 AC_SUBST(PACKAGE)
19 AC_SUBST(VERSION)
20 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
21 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
22 AC_CONFIG_HEADERS(config.h)
24 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
25 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
26 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
28 MAKE=
30 for make in gnumake gmake make false; do
31         if test "x$MAKE" = x; then
32                 AC_PATH_PROGS(MAKE, "$make")
33         fi
34 done
36 builddir="`pwd`"
38 # Cleanup if we are configuring with a previous build in the tree
39 if test -e Makefile.config; then
40         AC_MSG_CHECKING([for previous build to clean])
41         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
42         AC_MSG_RESULT(done)
45 # ===================================================================
46 # Load feature configuration file and start logging features.
47 # ===================================================================
49 features="features.conf"
50 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
51 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
52 echo "Feature summary:" > features.log
54 # ===================================================================
55 # Checks for programs.
56 # ===================================================================
58 AC_PROG_CC
59 AC_PROG_AWK
60 AC_PATH_PROGS(AWK, "$AWK")
61 AC_PROG_RANLIB
62 AC_PROG_INSTALL
64 AC_PATH_PROGS(GIT, "git")
65 AC_PATH_PROGS(SPARSE, "sparse")
67 CONFIG_ASCIIDOC="no"
68 CONFIG_POD2HTML="no"
69 CONFIG_XMLTO="no"
70 CONFIG_JW="no"
72 if test "x$CONFIG_DOC" != xno; then
73         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
74         if test "x$ASCIIDOC" != "x"; then
75                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
76                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
77                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
79                 echo > config.asciidoc-unsafe.txt
80                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
81                         ASCIIDOC_FLAGS=--unsafe
82                 fi
83                 rm config.asciidoc-unsafe.*
84         fi
86         AC_PATH_PROGS(XMLTO, "xmlto")
87         if test "x$XMLTO" != "x"; then
88                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
89                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
90                 EL_CONFIG(MAN_XMLTO, [man (groff)])
91         fi
93         AC_PATH_PROGS(JW, "jw")
94         if test "x$JW" != "x"; then
95                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
96                 EL_CONFIG(MANUAL_JW, [PDF])
97         fi
99         AC_PATH_PROGS(POD2HTML, "pod2html")
100         if test "x$POD2HTML" != "x"; then
101                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
102         fi
104         AC_PATH_PROGS(DOXYGEN, "doxygen")
105         if test "x$DOXYGEN" != "x"; then
106                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
107                 api_srcdir="$(cd "$srcdir" && pwd)/src"
108                 AC_SUBST(api_srcdir)
109         fi
112 AC_SUBST(ASCIIDOC_FLAGS)
113 AC_SUBST(CONFIG_ASCIIDOC)
114 AC_SUBST(CONFIG_DOXYGEN)
115 AC_SUBST(CONFIG_POD2HTML)
116 AC_SUBST(CONFIG_XMLTO)
117 AC_SUBST(CONFIG_JW)
119 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
120 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
121 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
122 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
124 # gcc specific options (to be continued at the bottom of configure)
125 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
126   # We want to see all warnings and live with none.
127   # We can't set up -Werror here as there may be some warnings in test
128   # suite of configure, and we don't want to fail them.
129   CFLAGS="$CFLAGS -Wall"
132 # ===================================================================
133 # Checks for special OSes.
134 # ===================================================================
136 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
137 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
139         AC_MSG_CHECKING([for $2])
141         for flag in $3; do
142                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
143 kill me!
144 #endif ]])],[$1=yes],[$1=no])
145                 if test "[$]$1" = yes; then
146                         EL_CONFIG([$1], [$2])
147                         break
148                 fi
149         done
151         AC_MSG_RESULT([$]$1)
154 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
155 AC_SUBST(CONFIG_OS_BEOS)
157 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
158 AC_SUBST(CONFIG_OS_RISCOS)
160 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
161 AC_SUBST(CONFIG_OS_WIN32)
163 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
164 AC_SUBST(CONFIG_OS_OS2)
165 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
167 AC_MSG_CHECKING([for UNIX])
168 dnl FIXME: some depend kind of mechanism
169 if test "$CONFIG_OS_BEOS" = no && \
170    test "$CONFIG_OS_RISCOS" = no && \
171    test "$CONFIG_OS_WIN32" = no && \
172    test "$CONFIG_OS_OS2" = no; then
173         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
174 else
175         CONFIG_OS_UNIX=no
177 AC_MSG_RESULT($CONFIG_OS_UNIX)
178 AC_SUBST(CONFIG_OS_UNIX)
180 # ===================================================================
181 # Checks for header files.
182 # ===================================================================
184 AC_HEADER_DIRENT
185 AC_HEADER_STDC
186 AC_HEADER_SYS_WAIT
187 AC_HEADER_TIME
189 AC_CHECK_HEADERS(wchar.h wctype.h)
190 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
191 AC_CHECK_HEADERS(sigaction.h)
192 AC_CHECK_HEADERS(arpa/inet.h)
193 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
194 AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/in6_var.h)
195 AC_CHECK_HEADERS(ifaddrs.h)
196 AC_CHECK_HEADERS(sys/cygwin.h io.h)
197 AC_CHECK_HEADERS(sys/fmutex.h)
198 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
199 AC_CHECK_HEADERS(sys/resource.h)
200 AC_CHECK_HEADERS(sys/select.h)
201 AC_CHECK_HEADERS(sys/signal.h)
202 AC_CHECK_HEADERS(sys/socket.h)
203 AC_CHECK_HEADERS(sys/time.h)
204 AC_CHECK_HEADERS(sys/utsname.h)
205 AC_CHECK_HEADERS([net/if.h], [], [],
206 [[#ifdef HAVE_SYS_SOCKET_H
207 # include <sys/socket.h> /* <net/if.h> on Mac OS X 10.5.4 needs this */
208 #endif
210 AC_CHECK_HEADERS(stdint.h inttypes.h)
211 AC_CHECK_HEADERS(locale.h pwd.h)
212 AC_CHECK_HEADERS(termios.h)
215 AC_CHECK_HEADERS(sys/un.h,
216         [CONFIG_INTERLINK=yes
217          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
218         [CONFIG_INTERLINK=no])
219 AC_SUBST(CONFIG_INTERLINK)
221 # ===================================================================
222 # Checks for typedefs, structures, and compiler characteristics.
223 # ===================================================================
225 AC_STRUCT_TM
226 AC_C_CONST
227 AC_C_INLINE
228 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
230 AC_SYS_LARGEFILE
231 AC_TYPE_SIZE_T
232 AC_TYPE_OFF_T
233 EL_CHECK_TYPE(ssize_t, int)
234 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
235 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
236 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
237 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
238 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
240 AC_CHECK_SIZEOF(char, 1)
241 AC_CHECK_SIZEOF(short, 2)
242 AC_CHECK_SIZEOF(int, 4)
243 AC_CHECK_SIZEOF(long, 4)
244 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
245 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
247 # Check for variadic macros
248 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
249                 [#include <stdio.h>
250                  #define a(b,c...) printf(b,##c)],
251                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
253 # ===================================================================
254 # Check for POSIX <regex.h>
255 # ===================================================================
257 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
259 # ===================================================================
260 # Checks for library functions.
261 # ===================================================================
263 AC_PROG_GCC_TRADITIONAL
264 AC_FUNC_MEMCMP
265 AC_FUNC_MMAP
266 AC_FUNC_STRFTIME
267 AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
268 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
269 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
270 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
271 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
272 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
273 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
274 AC_CHECK_FUNCS(gettimeofday clock_gettime)
276 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
278 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
279 AC_CHECK_FUNCS(unsetenv)
280 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
281 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
283 AC_CHECK_FUNCS(wcwidth, HAVE_WCWIDTH=yes)
285 # These aren't probably needed now, as they are commented in links.h.
286 # I've no idea about their historical background, but I keep them here
287 # just in the case they will help later. --pasky
288 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
289 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
290 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
291 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
293 if test x"$HAVE_RAISE" = x; then
294         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
295                 AC_MSG_ERROR([Unable to emulate raise()])
296         fi
299 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
300 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
301 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
302 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
303         EL_DEFINE(HAVE_VA_COPY, __va_copy)
306 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
307 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
308 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
309 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
310         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
313 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
314 AC_RUN_IFELSE([AC_LANG_SOURCE([[
315 #include <stdio.h>
316 #include <stdarg.h>
317 #include <stdlib.h>
318 #include <string.h>
320 char buf[8];
322 int bar(char *buf, const char *format, va_list ap)
324        return vsnprintf(buf, 0, format, ap);
327 void foo(const char *format, ...) {
328        va_list ap;
329        int len;
331        va_start(ap, format);
332        len = bar(buf, format, ap);
333        va_end(ap);
334        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
336        va_start(ap, format);
337        len = bar(buf, format, ap);
338        va_end(ap);
339        if ((len != 6) && (len != 7)) exit(1);
341        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
343        exit(0);
345 main() { foo("hello\n"); }
346 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
347 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
348         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
351 # OpenSSL and Lua frequently need dlopen
352 AC_CHECK_LIB(dl, dlopen)
354 # ===================================================================
355 # Checks for libraries.
356 # ===================================================================
358 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
359 if test "$cf_result" = no; then
360         AC_CHECK_LIB(socket, socket)
363 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
364 if test "$cf_result" = no; then
365         AC_CHECK_LIB(socket, setsockopt)
368 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
369 if test "$cf_result" = no; then
370         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
371         if test "$cf_result" = no; then
372                 AC_CHECK_LIB(nsl, gethostbyname)
373         else
374                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
375         fi
378 # ===================================================================
379 # Checks for packaging specific options.
380 # ===================================================================
382 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
383             [ if test "$withval" != no && test "$withval" != yes; then
384                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
385               fi ])
387 # ===================================================================
388 # Checks for a libraries, optional even if installed.
389 # ===================================================================
391 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
392 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
394         AC_MSG_CHECKING([for $2 support])
396         if test "[$]$1" != no; then
397                 AC_MSG_RESULT(yes)
398                 EL_SAVE_FLAGS
399                 if test -n "$withval" && test -d "$withval"; then
400                         # Be a little more careful when setting
401                         # include and lib directories. This way
402                         # $withval will work when includes are
403                         # there but the library is in the common
404                         # /usr/lib ... Does the right thing when
405                         # looking for gc on Debian.
406                         if test -d "$withval/include"; then
407                                 CFLAGS="$CFLAGS -I$withval/include"
408                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
409                         else
410                                 CFLAGS="$CFLAGS -I$withval"
411                                 CPPFLAGS="$CPPFLAGS -I$withval"
412                         fi
413                         if test -d "$withval/lib"; then
414                                 LDFLAGS="$LDFLAGS -L$withval/lib"
415                         fi
416                 fi
418                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
419                 if test "[$]$1" = yes; then
420                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
421                 fi
423                 if test "[$]$1" = yes; then
424                         EL_CONFIG([$1], [$2])
425                         LIBS="$LIBS -l$4"
426                 else
427                         if test -n "[$]WITHVAL_$1" &&
428                            test "[$]WITHVAL_$1" != xno; then
429                                 AC_MSG_ERROR([$2 not found])
430                         fi
431                         EL_RESTORE_FLAGS
432                 fi
433         else
434                 AC_MSG_RESULT(disabled)
435         fi
438 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
439 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
441         $1=yes
442         WITHVAL_$1=
444         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
445         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
447         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
449         EL_LOG_CONFIG([$1], [$2], [])
452 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
453         [  --without-gpm           disable gpm (mouse) support])
455 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
456 # enable automatic decoding of both zlib and gzip headers.  This
457 # feature was added in zlib 1.2.0.2; earlier versions return an error.
458 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
459 # that, even though ELinks does not actually call gzclearerr.
460 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
461         [  --without-zlib          disable zlib support])
463 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
464         [  --without-bzlib         disable bzlib support])
466 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
467         [  --without-idn           disable international domain names support])
469 if test "x{with_gc}" != xno; then
470         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
471                 [  --with-gc               enable Boehm's garbage collector])
474 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
475         [  --without-lzma          disable lzma encoding support])
477 # ===================================================================
478 # Check for GSSAPI, optional even if installed.
479 # ===================================================================
481 enable_gssapi="no";
483 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
484             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
486 AC_MSG_CHECKING([for GSSAPI])
488 if test "$enable_gssapi" = "yes"; then
489         AC_MSG_RESULT(yes)
490         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
491         GSSAPI_LIBS=`krb5-config --libs gssapi`
492         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
493         LIBS="$GSSAPI_LIBS $LIBS"
494         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
495 else
496         AC_MSG_RESULT(no)
499 AC_SUBST(CONFIG_GSSAPI)
501 # ===================================================================
502 # Bookmark and XBEL support
503 # ===================================================================
505 EL_SAVE_FLAGS
507 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
508               [  --disable-bookmarks     disable bookmark support])
510 # Check whether --enable-xbel or --disable-xbel was given.
511 if test "x${enable_xbel}" != xno; then
512         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
514         if test "$HAVE_LIBEXPAT" = yes; then
515                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
516                 if test "$HAVE_LIBEXPAT" = yes; then
517                         LIBS="$LIBS -lexpat"
518                 fi
519         fi
523 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
524               [XBEL bookmarks],
525               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
527 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
528         EL_RESTORE_FLAGS
531 # ===================================================================
532 # Checks for BSD sysmouse
533 # ===================================================================
535 HAVE_SYSMOUSE_HEADER="no"
537 # Either of these header files provides the (same) sysmouse interface
538 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
540 # ===================================================================
541 # Checks for OS/2
542 # ===================================================================
544 if test "$CONFIG_OS_OS2" = yes; then
545         EL_CONFIG_OS_OS2
548 # ===================================================================
549 # Checks for Win32
550 # ===================================================================
552 if test "$CONFIG_OS_WIN32" = yes; then
553         EL_CONFIG_OS_WIN32
556 # ===================================================================
557 # Check for SEE (Simple Ecmascript Engine)
558 # ===================================================================
559 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
560             [ if test "x$withval" != xno; then enable_see=yes; fi ])
562 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
563 # SEE_FLAGS but I really don't want to require people to have Guile in order
564 # to compile CVS. Also, the macro seems to be really stupid regarding searching
565 # for Guile in $PATH etc. --pasky
567 CONFIG_ECMASCRIPT_SEE=no
569 if test "$enable_see" = "yes"; then
570         if test -d "$withval"; then
571                 SEE_PATH="$withval:$PATH"
572         else
573                 SEE_PATH="$PATH"
574         fi
576         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
577         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
578         if test "$SEE_CONFIG" != no; then
579                 EL_SAVE_FLAGS
580                 SEE_LIBS="`$SEE_CONFIG --libs`"
581                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
582                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
583                 LIBS="$SEE_LIBS $LIBS_X"
584                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
585                         #error SEE too old
586                         #endif
587                 ]])],[cf_result=yes],[cf_result=no])
588                 EL_RESTORE_FLAGS
589                 if test "$cf_result" = yes; then
590                         LIBS="$SEE_LIBS $LIBS"
591                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
592                         AC_SUBST(SEE_CFLAGS)
593                 fi
594                 AC_MSG_RESULT($cf_result)
595         else
596                 if test -n "$withval" && test "x$withval" != xno; then
597                         AC_MSG_ERROR([SEE not found])
598                 else
599                         AC_MSG_WARN([SEE support disabled])
600                 fi
601         fi
604 # ===================================================================
605 # Check for SpiderMonkey, optional even if installed.
606 # ===================================================================
608 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
609             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
610 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
612 EL_SAVE_FLAGS
613 cf_result=no
615 if test -z "$disable_spidermonkey"; then
616         if test ! -d "$withval"; then
617                 withval="";
618         fi
619         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
620                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
621                         for spidermonkeylib in js smjs mozjs; do
622                                 if test "$cf_result" = no &&
623                                    test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then
624                                         SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
625                                         SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
627                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
628                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
629                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
631                                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
632                                                      #include <jsapi.h>]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no])
633                                 fi
634                         done
635                 done
636         done
639 AC_MSG_RESULT($cf_result)
640 CONFIG_SPIDERMONKEY="$cf_result"
641 EL_RESTORE_FLAGS
643 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
644    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
645         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
646 else
647         CONFIG_ECMASCRIPT_SMJS=no
650 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
651 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
652 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
655 # ===================================================================
656 # Optional Spidermonkey-based ECMAScript browser scripting
657 # ===================================================================
659 AC_ARG_ENABLE(sm-scripting,
660               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
661               [if test "$enableval" != no; then enableval="yes"; fi
662                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
664 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
665    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
666         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
667 else
668         CONFIG_SCRIPTING_SPIDERMONKEY=no
671 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
672    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
673         LIBS="$LIBS $SPIDERMONKEY_LIBS"
674         AC_SUBST(SPIDERMONKEY_LIBS)
675         AC_SUBST(SPIDERMONKEY_CFLAGS)
676         AC_SUBST(CONFIG_SPIDERMONKEY)
679 # ===================================================================
680 # Check for Guile, optional even if installed.
681 # ===================================================================
683 enable_guile="no";
685 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
686             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
688 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
689 # GUILE_FLAGS but I really don't want to require people to have Guile in order
690 # to compile CVS. Also, the macro seems to be really stupid regarding searching
691 # for Guile in $PATH etc. --pasky
693 AC_MSG_CHECKING([for Guile])
695 if test "$enable_guile" = "yes"; then
696         AC_MSG_RESULT(yes);
697         ## Based on the GUILE_FLAGS macro.
699         if test -d "$withval"; then
700                 GUILE_PATH="$withval:$PATH"
701         else
702                 GUILE_PATH="$PATH"
703         fi
705         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
707         ## First, let's just see if we can find Guile at all.
708         if test "$GUILE_CONFIG" != no; then
709                 cf_result="yes";
711                 GUILE_LIBS="`guile-config link`"
712                 GUILE_CFLAGS="`guile-config compile`"
713                 LIBS="$GUILE_LIBS $LIBS"
714                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
715                 AC_SUBST(GUILE_CFLAGS)
716                 cat <<EOF
717 ***********************************************************************
718 The Guile support is incomplete and not so well integrated to ELinks
719 yet. That means, e.g., that you have no Guile console and there might
720 not be all the necessary hooks. Also, the Guile interface is not too
721 well tested (success stories heartily welcomed!).  See
722 src/scripting/guile/README for further details and hints.
723 ***********************************************************************
725         else
726                 if test -n "$withval" && test "x$withval" != xno; then
727                         AC_MSG_ERROR([Guile not found])
728                 else
729                         AC_MSG_WARN([Guile support disabled])
730                 fi
731         fi
732 else
733         AC_MSG_RESULT(no);
736 # ===================================================================
737 # Check for Perl
738 # ===================================================================
739 enable_perl="no";
741 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
742             [
743 if test "$withval" = yes; then
744         # FIXME: If withval is a valid directory append it to PATH
745         # so that you can specify one of several perl installations.
746         withval="";
747         enable_perl=yes;
749             ])
751 AC_MSG_CHECKING([for Perl])
753 cf_result=no
755 EL_SAVE_FLAGS
757 if test "$enable_perl" = "yes"; then
758         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
759         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
760         LIBS="$PERL_LIBS $LIBS"
761         CFLAGS="$PERL_CFLAGS $CFLAGS"
762         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
763         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
764 #include <EXTERN.h>
765 #include <perl.h>
766 #include <perlapi.h>
767 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
770 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
772 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
773 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
774 #include <EXTERN.h>
775 #include <perl.h>
776 extern PerlInterpreter *my_perl;
777 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
778 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
779                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
780 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
782 if test "$cf_result" != "yes"; then
783         EL_RESTORE_FLAGS
784 else
785         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
787         CFLAGS="$CFLAGS_X"
788         CPPFLAGS="$CPPFLAGS_X"
789         AC_SUBST(PERL_LIBS)
790         AC_SUBST(PERL_CFLAGS)
793 # ===================================================================
794 # Check for Python
795 # ===================================================================
796 enable_python="no";
798 AC_ARG_WITH(python, [[  --with-python[=DIR]     enable Python support]],
799             [ if test "x$withval" != xno; then enable_python=yes; fi ])
801 EL_SAVE_FLAGS
802 cf_result=no
804 AC_MSG_CHECKING([for Python])
806 if test "$enable_python" = "yes"; then
807         AC_MSG_RESULT(yes);
809         if test -d "$withval"; then
810                 PYTHON_PATH="$withval:$PATH"
811         else
812                 PYTHON_PATH="$PATH"
813         fi
815         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
817         if test "$PYTHON" != no; then
818                 cf_result="yes";
820                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
821                 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"))'`"
822                 LIBS="$PYTHON_LIBS $LIBS"
823                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
824                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
826                 if test "$cf_result" != "yes"; then
827                         EL_RESTORE_FLAGS
828                 else
829                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
830                         AC_SUBST(PYTHON_LIBS)
831                         AC_SUBST(PYTHON_CFLAGS)
832                         CPPFLAGS="$CPPFLAGS_X"
833                         cat <<EOF
834 ***********************************************************************
835 The Python support is incomplete and not so well integrated to ELinks
836 yet. That means, e.g., that you have no Python console and there might
837 not be all the necessary hooks. Also, the Python interface is not too
838 well tested (success stories heartily welcomed!).
839 ***********************************************************************
841                 fi
842         else
843                 if test -n "$withval" && test "x$withval" != xno; then
844                         AC_MSG_ERROR([Python not found])
845                 else
846                         AC_MSG_WARN([Python support disabled])
847                 fi
848         fi
849 else
850         AC_MSG_RESULT(no);
854 # ===================================================================
855 # Check for Lua, optional even if installed.
856 # ===================================================================
858 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
859 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
861 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
862             [if test "$withval" = no; then disable_lua=yes; fi])
863 AC_MSG_CHECKING([for Lua])
865 EL_SAVE_FLAGS
866 cf_result=no
868 if test -z "$disable_lua"; then
869         if test ! -d "$withval"; then
870                 withval="";
871         fi
872         for luadir in "$withval" "" /usr /usr/local; do
873                 for suffix in "" 50; do
874                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
875                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
876                                 LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
877                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
879                                 LIBS="$LUA_LIBS $LIBS_X"
880                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
881                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
883                                 # Check that it is a compatible Lua version
884                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lua.h>
885                                                 #include <lualib.h>]], [[       lua_State *L = lua_open();
886                                                 luaopen_base(L);
887                                                 luaopen_table(L);
888                                                 luaopen_io(L);
889                                                 luaopen_string(L);
890                                                 luaopen_math(L);
891                                                 lua_pushboolean(L, 1);
892                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
893                         fi
894                 done
895         done
898 AC_MSG_RESULT($cf_result)
900 if test "$cf_result" != yes; then
901         EL_RESTORE_FLAGS
902 else
903         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
904         AC_CHECK_HEADERS(lauxlib.h)
906         CFLAGS="$CFLAGS_X"
907         CPPFLAGS="$CPPFLAGS_X"
908         AC_SUBST(LUA_LIBS)
909         AC_SUBST(LUA_CFLAGS)
913 # ===================================================================
914 # Check for Ruby, optional even if installed.
915 # ===================================================================
917 EL_CONFIG_SCRIPTING_RUBY
919 # ===================================================================
920 # Setup global scripting
921 # ===================================================================
923 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])
924 AC_SUBST(CONFIG_SCRIPTING_GUILE)
925 AC_SUBST(CONFIG_SCRIPTING_LUA)
926 AC_SUBST(CONFIG_SCRIPTING_PERL)
927 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
928 AC_SUBST(CONFIG_SCRIPTING_RUBY)
929 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
930 AC_SUBST(CONFIG_SCRIPTING)
933 # ===================================================================
934 # Check for SSL support.
935 # ===================================================================
937 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
938 # is enabled, we won't try to use OpenSSL anymore.
940 # For wiping SSL hooks..
941 #ifdef CONFIG_SSL
943 disable_openssl=""
944 disable_gnutls=""
945 enable_gnutls=""
947 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
948             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
949 AC_ARG_WITH(gnutls, [[  --with-gnutls[=DIR]     enable GNUTLS SSL support]],
950             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
951 gnutls_withval="$withval"
953 if test "$enable_gnutls" = yes; then
954         disable_openssl=yes;
957 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
958             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
959 AC_ARG_WITH(openssl, [[  --with-openssl[=DIR]    enable OpenSSL support (default)]])
960 openssl_withval="$withval"
962 # ---- OpenSSL
964 AC_MSG_CHECKING([for OpenSSL])
966 EL_SAVE_FLAGS
967 cf_result="no"
969 if test "$disable_openssl" = yes; then
970         cf_result="not used"
971 else
972         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
973                          /usr/lib/openssl /usr/local/ssl \
974                          /usr/local/www /usr/lib/ssl /usr/local \
975                          /usr/pkg /opt /opt/openssl; do
976                 if test "$cf_result" = no; then
977                         if test -d "$ssldir"; then
978                                 OPENSSL_CFLAGS="-I$ssldir/include"
979                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
980                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
981                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
982 #                               # FIXME: This created serious portability problems. --pasky
983 #                               if test "$CC" == "gcc"; then
984 #                                       # I'm not sure about compatibility here. --pasky
985 #                                       LIBS="$LIBS -R$ssldir/lib"
986 #                               fi
987                         else
988                                 LIBS="-lssl -lcrypto $LIBS_X"
989                         fi
990                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
991                         if test "$cf_result" != yes; then
992                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
993                         fi
994                 fi
995         done
997         if test "$cf_result" != yes; then
998                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
999                         AC_MSG_ERROR([OpenSSL not found])
1000                 fi
1001                 EL_RESTORE_FLAGS
1002         else
1003                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1005                 CFLAGS="$CFLAGS_X"
1006                 AC_SUBST(OPENSSL_CFLAGS)
1007         fi
1010 AC_MSG_RESULT($cf_result)
1012 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1013 # ---- GNU TLS
1014 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1015 dnl it looks ugly then.
1017 if test "$cf_result" = yes; then
1018         cf_result="not used"
1020 else
1021         EL_SAVE_FLAGS
1022         cf_result="no"
1024         if test -z "$disable_gnutls"; then
1025                 # Sure, we maybe _could_ use their macro, but how to ensure
1026                 # that the ./configure script won't fail if the macro won't be
1027                 # found..? :( --pasky
1029                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1031                 if test -d "$gnutls_withval"; then
1032                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1033                 fi
1035                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1037                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1038                         cf_result=no
1039                 else
1040                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1041                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1043                         LIBS="$GNUTLS_LIBS $LIBS_X"
1044                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1045                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1047                         # Verify if it's really usable.  gnutls_session was
1048                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1049                         # (on 2004-06-13); ELinks now requires this.
1050                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[gnutls_session_t dummy;
1051                                      gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no])
1052                 fi
1054                 if test "$cf_result" = yes; then
1055                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1057                         CFLAGS="$CFLAGS_X"
1058                         AC_SUBST(GNUTLS_CFLAGS)
1060                         # GnuTLS 2.2.0 changed libgnutls-openssl from GPLv2+
1061                         # to GPLv3+.  Don't link that with the GPLv2 ELinks.
1062                         # ELinks will use its internal MD5 code instead.
1063                         CONFIG_GNUTLS_OPENSSL_COMPAT=no
1064                 else
1065                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1066                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1067                         fi
1068                         EL_RESTORE_FLAGS
1069                 fi
1070         fi
1073 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1074 AC_MSG_RESULT($cf_result)
1076 # Final SSL setup
1078 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1079 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1080 AC_SUBST(CONFIG_OPENSSL)
1081 AC_SUBST(CONFIG_GNUTLS)
1083 #endif
1085 AC_MSG_CHECKING([whether to be or not to be])
1086 AC_MSG_RESULT([needs to be determined experimentally])
1088 # ===================================================================
1089 # Check for IPv6 support and related functions.
1090 # ===================================================================
1092 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1093 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1094 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1096 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1097 if test "$HAVE_GETADDRINFO" != yes; then
1098         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1099         if test "$HAVE_GETADDRINFO" = yes; then
1100                 LIBS="$LIBS -linet6"
1101         fi
1105 # ===================================================================
1106 # Checking for X11 (window title restoring).
1107 # ===================================================================
1109 AC_PATH_X
1110 if test x"$no_x" != xyes; then
1111         EL_SAVE_FLAGS
1112         if test -n "$x_includes"; then
1113                 X_CFLAGS="-I$x_includes"
1114                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1115                 CFLAGS="$CFLAGS $X_CFLAGS"
1116         fi
1117         if test -n "$x_libraries"; then
1118                 LDFLAGS="$LDFLAGS -L$x_libraries"
1119         fi
1120         LIBS="-lX11 $LIBS"
1121         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1122         EL_RESTORE_FLAGS
1123         if test "$cf_result" = yes; then
1124                 if test -n "$x_libraries"; then
1125                         LDFLAGS="$LDFLAGS -L$x_libraries"
1126                 fi
1127                 LIBS="-lX11 $LIBS"
1128                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1129                 AC_SUBST(X_CFLAGS)
1130         fi
1134 # ===================================================================
1135 # Backtraces displaying support.
1136 # ===================================================================
1138 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1139 # possible checks for other system-specific means go here
1142 # ===================================================================
1143 # Gettext grey zone. Beware.
1144 # ===================================================================
1146 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"
1148 AM_GNU_GETTEXT
1150 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1151 dnl # f33r d4 l33t... I hope it's portable. :)
1152 dnl cf_result=$((48#z - 48#a + 1));
1153 dnl AC_MSG_RESULT($cf_result)
1156 # ===================================================================
1157 # Compile-time features control
1158 # ===================================================================
1160 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1161               [  --disable-cookies       disable cookie support])
1163 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1164               [  --disable-formhist      disable form history support])
1166 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1167               [  --disable-globhist      disable global history support])
1170 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1171               [  --disable-mailcap       disable mailcap support])
1173 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1174               [  --disable-mimetypes     disable mimetypes files support])
1177 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1178               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1179               [IPv6],
1180               [  --disable-ipv6          disable IPv6 support])
1182 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1183               [  --enable-bittorrent     enable BitTorrent protocol support])
1185 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1186               [  --disable-data          disable data protocol support])
1188 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1189               [  --disable-uri-rewrite   disable URI rewrite support])
1191 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1192               [  --enable-cgi            enable local CGI support])
1194 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1195               [  --enable-finger         enable finger protocol support])
1197 # ===================================================================
1198 # FSP protocol
1199 # ===================================================================
1200 EL_SAVE_FLAGS
1202 if test "x${enable_fsp}" != xno; then
1203         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1205         if test "$HAVE_FSPLIB" = yes; then
1206                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1207                 if test "$HAVE_FSPLIB" = yes; then
1208                         LIBS="$LIBS -lfsplib"
1209                 else
1210                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1211                         if test "$HAVE_FSPLIB" = yes; then
1212                                 LIBS="$LIBS -lfsp"
1213                         fi
1214                 fi
1215         fi
1218 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1219               [  --enable-fsp            enable FSP protocol support])
1221 if test "x$CONFIG_FSP" = xno; then
1222         EL_RESTORE_FLAGS
1225 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1226               [  --disable-ftp           disable ftp protocol support])
1228 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1229               [  --enable-gopher         enable gopher protocol support])
1231 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1232               [  --enable-nntp           enable nntp protocol support])
1234 # ===================================================================
1235 # SMB protocol support.
1236 # ===================================================================
1237 EL_SAVE_FLAGS
1239 if test "x${enable_smb}" != xno; then
1240         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1242         if test "$HAVE_SMBCLIENT" = yes; then
1243                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1244                 if test "$HAVE_SMBCLIENT" = yes; then
1245                         LIBS="$LIBS -lsmbclient"
1246                 fi
1247         fi
1250 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1251               [  --enable-smb            enable Samba protocol support])
1253 if test "x$CONFIG_SMB" = xno; then
1254         EL_RESTORE_FLAGS
1258 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1259               [  --disable-mouse         disable mouse support])
1261 # GPM mouse is Linux specific, so ...
1262 CONFIG_SYSMOUSE=yes
1263 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1264               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1265               [BSD sysmouse],
1266               [  --disable-sysmouse      disable BSD sysmouse support])
1268 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1269               [  --enable-88-colors      enable 88 color support])
1271 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1272               [  --enable-256-colors     enable 256 color support])
1274 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1275               [  --enable-true-color     enable true color support])
1277 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1278               [  --enable-exmode         enable exmode (CLI) interface])
1280 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1281               [  --disable-leds          disable LEDs support])
1283 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1284               [  --disable-marks         disable document marks support])
1287 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1288               [  --disable-css           disable Cascading Style Sheet support])
1290 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1291               [  --enable-html-highlight HTML highlighting using DOM engine])
1293 # Everything in the tree already uses CONFIG_DOM
1294 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1295 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1297 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1298               [  --disable-backtrace     disable backtrace support])
1300 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1301               [  --enable-no-root        enable prevention of usage by root])
1304 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1305               [  --enable-debug          enable leak debug and internal error checking])
1307 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1308               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1310 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1311               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1313 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1314               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1316 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1317               [  --disable-utf-8         disable UTF-8 support])
1319 EL_ARG_DEPEND(CONFIG_COMBINE, combining, [CONFIG_UTF8:yes HAVE_WCWIDTH:yes], [Combining characters],
1320               [  --enable-combining      support Unicode combining characters (experimental)])
1323 AC_ARG_ENABLE(weehoofooboomookerchoo,
1324               [
1325     Also check out the features.conf file for more information about features!
1326               ],
1327               [AC_MSG_ERROR(Are you strange, or what?)])
1330 # ===================================================================
1331 # Further LDFLAGS tweaks
1332 # ===================================================================
1334 # == EMX hack
1336 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1337 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1340 # Check for -rdynamic
1342 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
1343 # the executable to its dynamic symbol table.  ELinks uses this for
1344 # two purposes:
1346 # 1. If ELinks detects a bug, it can try to display a backtrace by
1347 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
1348 #    manual states users of GNU ld must pass -rdynamic to make the
1349 #    symbols available to the program.
1351 # 2. It would eventually be nice to dynamically load shared
1352 #    libraries as plugins (bug 73).  The plugins must be able to
1353 #    call ELinks functions.  This can be implemented either by
1354 #    registering all callable functions in ELinks-specific data
1355 #    structures, or by letting the dynamic linker handle them.
1356 #    The latter way requires something equivalent to -rdynamic.
1358 # Because backtraces are not needed for correct operation, and bug
1359 # 73 is not yet being fixed, the configure script and makefiles
1360 # should not complain to the user if they find that -rdynamic does
1361 # not work.  Besides, it was reported at elinks-users on 2006-09-12
1362 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
1363 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
1364 # -rdynamic but does something equivalent automatically.  (This was
1365 # tested with "nm -D elinks | grep redraw_from_window".)
1367 # With Sun Studio 11 on Solaris 9, we get "cc: Warning: illegal option
1368 # -dynamic"; then, cc proceeds anyway, but the option can prevent the
1369 # linker from finding the libraries listed in -l operands.  So this
1370 # -rdynamic check needs to happen after the libraries have already
1371 # been added to $LDFLAGS.
1372 AC_MSG_CHECKING([for -rdynamic])
1373 LDFLAGS_X="$LDFLAGS"
1374 LDFLAGS="-rdynamic $LDFLAGS"
1375 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
1376 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
1377 AC_MSG_RESULT($have_rdynamic)
1379 # ===================================================================
1380 # Export directory paths
1381 # ===================================================================
1383 # Set up the ``entry points'' if they were not supplied by builder
1384 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1385 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1387 # Create CONFDIR #define for config.h
1389 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1390 # it's autoconf fault to force us to do such hacks ;p.
1391 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1392   # sysconfdir is set to its default value... fine, let's append /elinks/
1393   # XXX: We can't modify listing of the default in ./configure --help :-(
1394   sysconfdir_n=`eval echo "$sysconfdir"`
1395   sysconfdir=$sysconfdir_n
1396   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1397         sysconfdir="$sysconfdir/elinks"
1400 CONFDIR=$sysconfdir
1401 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1402 AC_SUBST(CONFDIR)
1404 # Create LOCALEDIR #define for config.h
1405 LOCALEDIR=`eval echo "$datadir/locale"`
1406 while echo "$LOCALEDIR" | grep "\\$"
1408         LOCALEDIR=`eval echo "$LOCALEDIR"`
1409 done > /dev/null 2> /dev/null
1410 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1411 AC_SUBST(LOCALEDIR)
1413 # Create LIBDIR #define for config.h
1414 LIBDIR=`eval echo "$libdir"`
1415 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1416 AC_SUBST(LIBDIR)
1418 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1419 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1422 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1423 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1424         #error not tcc
1425         #endif ]])],[cf_result=yes],[cf_result=no])
1427 if test "$cf_result" = "yes"; then
1428         AC_DEFINE([HAVE_ALLOCA])
1429         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1430                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1431                 override the alloca macro defined in <stddef.h> of TCC.
1432                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1433                 it has already been included, and does not redefine alloca.
1434                 This might not work in future glibc versions though, because
1435                 the names of the #include guard macros are not documented.
1436                 The incompatibility has been reported to the tinycc-devel
1437                 mailing list on 2008-07-14.  If a future version of TCC provides
1438                 an <alloca.h> of its own, this hack won't be needed.])
1440 # ===================================================================
1441 # A little fine tuning of gcc specific options (continued)
1442 # ===================================================================
1444 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1445   if test "$CONFIG_DEBUG" = "yes"; then
1446     # We want to see all warnings and live with none (in debug mode).
1447     CFLAGS="$CFLAGS -Werror"
1448   fi
1450   case "`$CC -dumpversion`" in
1451     3.0|3.1|3.2)
1452       # These should be ok using -Werror
1453       ;;
1454     3.*)
1455       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1456       # "dereferencing type-punned pointer will break strict-aliasing rules"
1457       # warnings. Disable them by not doing any strict-aliasing. The
1458       # alternative is just too ugly. Thanks gcc guys!! ;)
1459       CFLAGS="$CFLAGS -fno-strict-aliasing"
1460       ;;
1461     4.*)
1462       # Do not show warnings related to (char * | unsigned char *) type
1463       # difference.
1464       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1465       ;;
1466     *)
1467       # These should be ok using -Werror
1468       ;;
1469   esac
1471   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1472   # warning: the address of `builtin_modules' will always evaluate as `true'
1473   # This hits the object_lock and foreach_module macros in particular.
1474   # It would be okay to put something in the macros to avoid the warning,
1475   # but currently this seems to require defining parallel macros that skip
1476   # the NULL check, and that's too ugly.  So we instead disable the warning.
1477   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1478   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1479   for warning_flag in -Wno-address -Wno-always-true; do
1480     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1481     EL_SAVE_FLAGS
1482     CFLAGS="$CFLAGS $warning_flag"
1483     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1484       [AC_MSG_RESULT([yes])
1485        break],
1486       [AC_MSG_RESULT([no])])
1487     EL_RESTORE_FLAGS
1488   done
1490   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1491   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1492   # "warning: assuming signed overflow does not occur when assuming
1493   # that (X + c) > X is always true", which may be an incorrect
1494   # optimization (although allowed by the standard), and breaks the
1495   # build with -Werror.
1496   #
1497   # All of the following tests included -S -Wall -Wextra:
1498   #
1499   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1500   # * gcc-4.0 -O0: OK, compares the values
1501   # * gcc-4.0 -O2: assumes no overflow, does not warn
1502   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1503   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1504   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1505   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1506   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1507   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1508   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1509   #
1510   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1511   # * gcc-4.1 -O0: assumes no overflow, does not warn
1512   # * gcc-4.1 -O2: assumes no overflow, does not warn
1513   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1514   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1515   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1516   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1517   # * gcc-4.1 -O2 -ftrapv: compares the values
1518   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1519   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1520   #
1521   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1522   # * gcc-4.2 -O0: OK, compares the values
1523   # * gcc-4.2 -O2: assumes no overflow, warns about it
1524   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1525   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1526   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1527   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1528   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1529   # * gcc-4.2 -O2 -ftrapv: compares the values
1530   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1531   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1532   #
1533   # Apparently, -ftrapv does not work reliably at all.
1534   for overflow_flag in -fno-strict-overflow -fwrapv; do
1535     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1536     EL_SAVE_FLAGS
1537     CFLAGS="$CFLAGS $overflow_flag"
1538     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1539       [AC_MSG_RESULT([yes])
1540        break],
1541       [AC_MSG_RESULT([no])])
1542     EL_RESTORE_FLAGS
1543   done
1546 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1547 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1548 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1549 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1551 # ===================================================================
1552 # Colored make output
1553 # ===================================================================
1555 if test $(`which tput` colors) -ge 4; then
1556         MAKE_COLOR=1
1557         AC_SUBST(MAKE_COLOR)
1560 # ===================================================================
1561 # Generated files
1562 # ===================================================================
1564 AC_CONFIG_FILES([ \
1565  Makefile.config \
1566  contrib/elinks.spec \
1567  contrib/lua/hooks.lua \
1568  contrib/conv/w3m2links.awk \
1569  doc/Doxyfile \
1570  doc/man/man1/elinks.1 \
1571  src/intl/gettext/ref-add.sed \
1572  src/intl/gettext/ref-del.sed
1574 AC_OUTPUT
1576 abs_srcdir="$(cd "$srcdir" && pwd)"
1577 # builddir is always absolute!
1578 if test "$abs_srcdir" != "$builddir"; then
1579         # Bootstrap the Makefile creation
1580         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1581         "$MAKE" "SRC=$abs_srcdir" init
1583         # Make cg-status ignore this build directory
1584         echo "*" > "$builddir/.gitignore"
1587 # ===================================================================
1588 # Configuration summary
1589 # ===================================================================
1591 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1592 cat features.log