Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
[elinks.git] / configure.in
blobcba0c815ad0bb7fb5ed551f99672455c88bd0b57
1 dnl Process this file with autoconf to produce a configure script.
3 AC_PREREQ(2.13)
4 AC_INIT(src/main/main.c)
5 AC_CONFIG_AUX_DIR(config)
7 PACKAGE=elinks
8 VERSION=0.12.GIT
9 AC_SUBST(PACKAGE)
10 AC_SUBST(VERSION)
11 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
12 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
13 AC_CONFIG_HEADERS(config.h)
15 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
16 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
17 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
19 MAKE=
21 for make in gnumake gmake make false; do
22         if test "x$MAKE" = x; then
23                 AC_PATH_PROGS(MAKE, "$make")
24         fi
25 done
27 builddir="`pwd`"
29 # Cleanup if we are configuring with a previous build in the tree
30 if test -e Makefile.config; then
31         AC_MSG_CHECKING([for previous build to clean])
32         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
33         AC_MSG_RESULT(done)
36 dnl ===================================================================
37 dnl Load feature configuration file and start logging features.
38 dnl ===================================================================
40 features="features.conf"
41 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
42 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
43 echo "Feature summary:" > features.log
45 dnl ===================================================================
46 dnl Checks for programs.
47 dnl ===================================================================
49 AC_PROG_CC
50 AC_PROG_AWK
51 AC_PATH_PROGS(AWK, "$AWK")
52 AC_PROG_RANLIB
53 AC_PROG_INSTALL
55 AC_PATH_PROGS(CG_COMMIT_ID, "cg-commit-id")
56 AC_PATH_PROGS(SPARSE, "sparse")
58 CONFIG_ASCIIDOC="no"
59 CONFIG_POD2HTML="no"
60 CONFIG_XMLTO="no"
61 CONFIG_JW="no"
63 if test "x$CONFIG_DOC" != xno; then
64         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
65         if test "x$ASCIIDOC" != "x"; then
66                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
67                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
68                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
70                 echo > config.asciidoc-unsafe.txt
71                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >/dev/null 2>/dev/null; then
72                         ASCIIDOC_FLAGS=--unsafe
73                 fi
74                 rm config.asciidoc-unsafe.*
75         fi
77         AC_PATH_PROGS(XMLTO, "xmlto")
78         if test "x$XMLTO" != "x"; then
79                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
80                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
81                 EL_CONFIG(MAN_XMLTO, [man (groff)])
82         fi
84         AC_PATH_PROGS(JW, "jw")
85         if test "x$JW" != "x"; then
86                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
87                 EL_CONFIG(MANUAL_JW, [PDF])
88         fi
90         AC_PATH_PROGS(POD2HTML, "pod2html")
91         if test "x$POD2HTML" != "x"; then
92                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
93         fi
96 AC_SUBST(ASCIIDOC_FLAGS)
97 AC_SUBST(CONFIG_ASCIIDOC)
98 AC_SUBST(CONFIG_POD2HTML)
99 AC_SUBST(CONFIG_XMLTO)
100 AC_SUBST(CONFIG_JW)
102 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
103 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
104 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
106 dnl gcc specific options (to be continued at the bottom of configure)
107 if test "x$ac_cv_prog_gcc" = "xyes"; then
108   dnl We want to see all warnings and live with none.
109   dnl We can't set up -Werror here as there may be some warnings in test
110   dnl suite of configure, and we don't want to fail them.
111   CFLAGS="$CFLAGS -Wall"
114 dnl ===================================================================
115 dnl Checks for special OSes.
116 dnl ===================================================================
118 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
119 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
121         AC_MSG_CHECKING([for $2])
123         for flag in $3; do
124                 AC_TRY_COMPILE(, [#ifndef $flag
125 kill me!
126 #endif ], $1=yes, $1=no)
127                 if test "[$]$1" = yes; then
128                         EL_CONFIG([$1], [$2])
129                         break
130                 fi
131         done
133         AC_MSG_RESULT([$]$1)
136 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
137 AC_SUBST(CONFIG_OS_BEOS)
139 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
140 AC_SUBST(CONFIG_OS_RISCOS)
142 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
143 AC_SUBST(CONFIG_OS_WIN32)
145 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
146 AC_SUBST(CONFIG_OS_OS2)
147 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
149 AC_MSG_CHECKING([for UNIX])
150 dnl FIXME: some depend kind of mechanism
151 if test "$CONFIG_OS_BEOS" = no && \
152    test "$CONFIG_OS_RISCOS" = no && \
153    test "$CONFIG_OS_WIN32" = no && \
154    test "$CONFIG_OS_OS2" = no; then
155         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
156 else
157         CONFIG_OS_UNIX=no
159 AC_MSG_RESULT($CONFIG_OS_UNIX)
160 AC_SUBST(CONFIG_OS_UNIX)
162 dnl ===================================================================
163 dnl Checks for header files.
164 dnl ===================================================================
166 AC_HEADER_DIRENT
167 AC_HEADER_STDC
168 AC_HEADER_SYS_WAIT
169 AC_HEADER_TIME
171 AC_CHECK_HEADERS(wctype.h)
172 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
173 AC_CHECK_HEADERS(sigaction.h)
174 AC_CHECK_HEADERS(arpa/inet.h)
175 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
176 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
177 AC_CHECK_HEADERS(ifaddrs.h)
178 AC_CHECK_HEADERS(sys/cygwin.h io.h)
179 AC_CHECK_HEADERS(sys/fmutex.h)
180 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
181 AC_CHECK_HEADERS(sys/resource.h)
182 AC_CHECK_HEADERS(sys/select.h)
183 AC_CHECK_HEADERS(sys/signal.h)
184 AC_CHECK_HEADERS(sys/socket.h)
185 AC_CHECK_HEADERS(sys/time.h)
186 AC_CHECK_HEADERS(sys/utsname.h)
187 AC_CHECK_HEADERS(stdint.h inttypes.h)
188 AC_CHECK_HEADERS(locale.h pwd.h)
189 AC_CHECK_HEADERS(termios.h)
192 AC_CHECK_HEADERS(sys/un.h,
193         [CONFIG_INTERLINK=yes
194          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
195         [CONFIG_INTERLINK=no])
196 AC_SUBST(CONFIG_INTERLINK)
198 dnl ===================================================================
199 dnl Checks for typedefs, structures, and compiler characteristics.
200 dnl ===================================================================
202 AC_STRUCT_TM
203 AC_C_CONST
204 AC_C_INLINE
205 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
207 AC_SYS_LARGEFILE
208 AC_TYPE_SIZE_T
209 AC_TYPE_OFF_T
210 EL_CHECK_TYPE(ssize_t, int)
211 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
212 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
213 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
214 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
215 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
217 AC_CHECK_SIZEOF(char, 1)
218 AC_CHECK_SIZEOF(short, 2)
219 AC_CHECK_SIZEOF(int, 4)
220 AC_CHECK_SIZEOF(long, 4)
221 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
222 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
224 dnl Check for variadic macros
225 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
226                 [#include <stdio.h>
227                  #define a(b,c...) printf(b,##c)],
228                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
230 dnl Check for -rdynamic
232 dnl gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
233 dnl the executable to its dynamic symbol table.  ELinks uses this for
234 dnl two purposes:
236 dnl 1. If ELinks detects a bug, it can try to display a backtrace by
237 dnl    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
238 dnl    manual states users of GNU ld must pass -rdynamic to make the
239 dnl    symbols available to the program.
241 dnl 2. It would eventually be nice to dynamically load shared
242 dnl    libraries as plugins (bug 73).  The plugins must be able to
243 dnl    call ELinks functions.  This can be implemented either by
244 dnl    registering all callable functions in ELinks-specific data
245 dnl    structures, or by letting the dynamic linker handle them.
246 dnl    The latter way requires something equivalent to -rdynamic.
248 dnl Because backtraces are not needed for correct operation, and bug
249 dnl 73 is not yet being fixed, the configure script and makefiles
250 dnl should not complain to the user if they find that -rdynamic does
251 dnl not work.  Besides, it was reported at elinks-users on 2006-09-12
252 dnl that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
253 dnl Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
254 dnl -rdynamic but does something equivalent automatically.  (This was
255 dnl tested with "nm -D elinks | grep redraw_from_window".)
257 dnl FIXME: This check doesn't work. Something to do with the compiler
258 dnl happily ignoring it and stderr not being checked for error messages.
259 AC_MSG_CHECKING([for -rdynamic])
260 LDFLAGS_X="$LDFLAGS"
261 LDFLAGS="$LDFLAGS -rdynamic"
262 AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no)
263 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
264 AC_MSG_RESULT($have_rdynamic)
266 dnl ===================================================================
267 dnl Check for POSIX <regex.h>
268 dnl ===================================================================
270 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
272 dnl ===================================================================
273 dnl Checks for library functions.
274 dnl ===================================================================
276 AC_PROG_GCC_TRADITIONAL
277 AC_FUNC_MEMCMP
278 AC_FUNC_MMAP
279 AC_FUNC_STRFTIME
280 AC_CHECK_FUNCS(atoll cfmakeraw gethostbyaddr herror strerror)
281 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
282 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
283 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
284 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
285 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
286 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
287 AC_CHECK_FUNCS(gettimeofday clock_gettime)
289 AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path)
291 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
292 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
293 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
295 dnl These aren't probably needed now, as they are commented in links.h.
296 dnl I've no idea about their historical background, but I keep them here
297 dnl just in the case they will help later. --pasky
298 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
299 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
300 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
301 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
303 if test x"$HAVE_RAISE" = x; then
304         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
305                 AC_ERROR([Unable to emulate raise()])
306         fi
309 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
310 AC_TRY_LINK([#include <stdarg.h>
311 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
312 el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)])
313 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
314         EL_DEFINE(HAVE_VA_COPY, __va_copy)
317 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
318 AC_TRY_LINK([#include <unistd.h>
319 ], [int page_size = sysconf(_SC_PAGE_SIZE);],
320 el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)])
321 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
322         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
325 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
326 AC_TRY_RUN([
327 #include <stdio.h>
328 #include <stdarg.h>
329 #include <stdlib.h>
330 #include <string.h>
332 char buf[8];
334 int bar(char *buf, const char *format, va_list ap)
336        return vsnprintf(buf, 0, format, ap);
339 void foo(const char *format, ...) {
340        va_list ap;
341        int len;
343        va_start(ap, format);
344        len = bar(buf, format, ap);
345        va_end(ap);
346        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
348        va_start(ap, format);
349        len = bar(buf, format, ap);
350        va_end(ap);
351        if ((len != 6) && (len != 7)) exit(1);
353        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
355        exit(0);
357 main() { foo("hello\n"); }
359 el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)])
360 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
361         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
364 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
366 dnl ===================================================================
367 dnl Checks for libraries.
368 dnl ===================================================================
370 dnl Replace `main' with a function in -lsocket:
371 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
372 if test "$cf_result" = no; then
373         AC_CHECK_LIB(socket, socket)
376 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
377 if test "$cf_result" = no; then
378         AC_CHECK_LIB(socket, setsockopt)
381 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
382 if test "$cf_result" = no; then
383         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
384         if test "$cf_result" = no; then
385                 AC_CHECK_LIB(nsl, gethostbyname)
386         else
387                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
388         fi
391 dnl ===================================================================
392 dnl Checks for packaging specific options.
393 dnl ===================================================================
395 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
396             [ if test "$withval" != no && test "$withval" != yes; then
397                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
398               fi ])
400 dnl ===================================================================
401 dnl Checks for a libraries, optional even if installed.
402 dnl ===================================================================
404 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
405 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
407         AC_MSG_CHECKING([for $2 support])
409         if test "[$]$1" != no; then
410                 AC_MSG_RESULT(yes)
411                 EL_SAVE_FLAGS
412                 if test -n "$withval" && test -d "$withval"; then
413                         # Be a little more careful when setting
414                         # include and lib directories. This way
415                         # $withval will work when includes are
416                         # there but the library is in the common
417                         # /usr/lib ... Does the right thing when
418                         # looking for gc on Debian.
419                         if test -d "$withval/include"; then
420                                 CFLAGS="$CFLAGS -I$withval/include"
421                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
422                         else
423                                 CFLAGS="$CFLAGS -I$withval"
424                                 CPPFLAGS="$CPPFLAGS -I$withval"
425                         fi
426                         if test -d "$withval/lib"; then
427                                 LDFLAGS="$LDFLAGS -L$withval/lib"
428                         fi
429                 fi
431                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
432                 if test "[$]$1" = yes; then
433                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
434                 fi
436                 if test "[$]$1" = yes; then
437                         EL_CONFIG([$1], [$2])
438                         LIBS="$LIBS -l$4"
439                 else
440                         if test -n "[$]WITHVAL_$1" &&
441                            test "[$]WITHVAL_$1" != xno; then
442                                 AC_MSG_ERROR([$2 not found])
443                         fi
444                         EL_RESTORE_FLAGS
445                 fi
446         else
447                 AC_MSG_RESULT(disabled)
448         fi
451 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
452 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
454         $1=yes
455         WITHVAL_$1=
457         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
458         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
460         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
462         EL_LOG_CONFIG([$1], [$2], [])
465 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
466         [  --without-gpm           disable gpm (mouse) support])
468 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzdopen,
469         [  --without-zlib          disable zlib support])
471 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
472         [  --without-bzlib         disable bzlib support])
474 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
475         [  --without-idn           disable international domain names support])
477 if test "x{with_gc}" != xno; then
478         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
479                 [  --with-gc               enable Boehm's garbage collector])
482 EL_ARG_ENABLE(CONFIG_LZMA, lzma, [lzma],
483               [  --enable-lzma           enable lzma encoding support])
485 dnl ===================================================================
486 dnl Check for GSSAPI, optional even if installed.
487 dnl ===================================================================
489 enable_gssapi="no";
491 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
492             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
494 AC_MSG_CHECKING([for GSSAPI])
496 if test "$enable_gssapi" = "yes"; then
497         AC_MSG_RESULT(yes)
498         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
499         GSSAPI_LIBS=`krb5-config --libs gssapi`
500         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
501         LIBS="$GSSAPI_LIBS $LIBS"
502         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
503 else
504         AC_MSG_RESULT(no)
507 AC_SUBST(CONFIG_GSSAPI)
509 dnl ===================================================================
510 dnl Bookmark and XBEL support
511 dnl ===================================================================
513 EL_SAVE_FLAGS
515 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
516               [  --disable-bookmarks     disable bookmark support])
518 # Check whether --enable-xbel or --disable-xbel was given.
519 if test "x${enable_xbel}" != xno; then
520         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
522         if test "$HAVE_LIBEXPAT" = yes; then
523                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
524                 if test "$HAVE_LIBEXPAT" = yes; then
525                         LIBS="$LIBS -lexpat"
526                 fi
527         fi
531 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
532               [XBEL bookmarks],
533               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
535 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
536         EL_RESTORE_FLAGS
539 dnl ===================================================================
540 dnl Checks for BSD sysmouse
541 dnl ===================================================================
543 HAVE_SYSMOUSE_HEADER="no"
545 # Either of these header files provides the (same) sysmouse interface
546 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
548 dnl ===================================================================
549 dnl Checks for OS/2
550 dnl ===================================================================
552 if test "$CONFIG_OS_OS2" = yes; then
553         EL_CONFIG_OS_OS2
556 dnl ===================================================================
557 dnl Checks for Win32
558 dnl ===================================================================
560 if test "$CONFIG_OS_WIN32" = yes; then
561         EL_CONFIG_OS_WIN32
564 dnl ===================================================================
565 dnl Check for SEE (Simple Ecmascript Engine)
566 dnl ===================================================================
567 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
568             [ if test "x$withval" != xno; then enable_see=yes; fi ])
570 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
571 # SEE_FLAGS but I really don't want to require people to have Guile in order
572 # to compile CVS. Also, the macro seems to be really stupid regarding searching
573 # for Guile in $PATH etc. --pasky
575 AC_MSG_CHECKING([for SEE])
577 CONFIG_ECMASCRIPT_SEE=no
579 if test "$enable_see" = "yes"; then
580         AC_MSG_RESULT(yes);
581         ## Based on the SEE_FLAGS macro.
583         if test -d "$withval"; then
584                 SEE_PATH="$withval:$PATH"
585         else
586                 SEE_PATH="$PATH"
587         fi
589         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
591         ## First, let's just see if we can find Guile at all.
592         if test "$SEE_CONFIG" != no; then
593                 cf_result="yes";
595                 SEE_LIBS="`$SEE_CONFIG --libs`"
596                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
597                 LIBS="$SEE_LIBS $LIBS"
598                 EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
599                 AC_SUBST(SEE_CFLAGS)
600         else
601                 if test -n "$withval" && test "x$withval" != xno; then
602                         AC_MSG_ERROR([SEE not found])
603                 else
604                         AC_MSG_WARN([SEE support disabled])
605                 fi
606         fi
607 else
608         AC_MSG_RESULT(no);
612 dnl ===================================================================
613 dnl Check for SpiderMonkey, optional even if installed.
614 dnl ===================================================================
616 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
617             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
618 AC_MSG_CHECKING([for SpiderMonkey])
620 EL_SAVE_FLAGS
621 cf_result=no
623 if test -z "$disable_spidermonkey"; then
624         if test ! -d "$withval"; then
625                 withval="";
626         fi
627         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
628                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
629                         for spidermonkeylib in js smjs mozjs; do
630                                 if test "$cf_result" = no; then
631                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
633                                         if test ! -z "$spidermonkeydir"; then
634                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
635                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
636                                         fi
638                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
639                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
640                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
642                                         AC_TRY_LINK([#define XP_UNIX
643                                                      #include <jsapi.h>],
644                                                      [JS_GetImplementationVersion()],
645                                                      cf_result=yes, cf_result=no)
646                                 fi
647                         done
648                 done
649         done
652 AC_MSG_RESULT($cf_result)
653 CONFIG_SPIDERMONKEY="$cf_result"
654 EL_RESTORE_FLAGS
656 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
657    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
658         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
659 else
660         CONFIG_ECMASCRIPT_SMJS=no
663 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
664 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
665 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
668 dnl ===================================================================
669 dnl Optional Spidermonkey-based ECMAScript browser scripting
670 dnl ===================================================================
672 AC_ARG_ENABLE(sm-scripting,
673               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
674               [if test "$enableval" != no; then enableval="yes"; fi
675                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
677 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
678    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
679         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
680 else
681         CONFIG_SCRIPTING_SPIDERMONKEY=no
684 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
685    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
686         LIBS="$LIBS $SPIDERMONKEY_LIBS"
687         AC_SUBST(SPIDERMONKEY_LIBS)
688         AC_SUBST(SPIDERMONKEY_CFLAGS)
689         AC_SUBST(CONFIG_SPIDERMONKEY)
692 dnl ===================================================================
693 dnl Check for Guile, optional even if installed.
694 dnl ===================================================================
696 enable_guile="no";
698 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
699             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
701 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
702 # GUILE_FLAGS but I really don't want to require people to have Guile in order
703 # to compile CVS. Also, the macro seems to be really stupid regarding searching
704 # for Guile in $PATH etc. --pasky
706 AC_MSG_CHECKING([for Guile])
708 if test "$enable_guile" = "yes"; then
709         AC_MSG_RESULT(yes);
710         ## Based on the GUILE_FLAGS macro.
712         if test -d "$withval"; then
713                 GUILE_PATH="$withval:$PATH"
714         else
715                 GUILE_PATH="$PATH"
716         fi
718         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
720         ## First, let's just see if we can find Guile at all.
721         if test "$GUILE_CONFIG" != no; then
722                 cf_result="yes";
724                 GUILE_LIBS="`guile-config link`"
725                 GUILE_CFLAGS="`guile-config compile`"
726                 LIBS="$GUILE_LIBS $LIBS"
727                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
728                 AC_SUBST(GUILE_CFLAGS)
729                 cat <<EOF
730 ***********************************************************************
731 The Guile support is incomplete and not so well integrated to ELinks
732 yet. That means, e.g., that you have no Guile console and there might
733 not be all the necessary hooks. Also, the Guile interface is not too
734 well tested (success stories heartily welcomed!).  See
735 src/scripting/guile/README for further details and hints.
736 ***********************************************************************
738         else
739                 if test -n "$withval" && test "x$withval" != xno; then
740                         AC_MSG_ERROR([Guile not found])
741                 else
742                         AC_MSG_WARN([Guile support disabled])
743                 fi
744         fi
745 else
746         AC_MSG_RESULT(no);
749 dnl ===================================================================
750 dnl Check for Perl
751 dnl ===================================================================
752 enable_perl="no";
754 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
755             [
756 if test "$withval" = yes; then
757         # FIXME: If withval is a valid directory append it to PATH
758         # so that you can specify one of several perl installations.
759         withval="";
760         enable_perl=yes;
762             ])
764 AC_MSG_CHECKING([for Perl])
766 cf_result=no
768 EL_SAVE_FLAGS
770 if test "$enable_perl" = "yes"; then
771         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
772         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
773         LIBS="$PERL_LIBS $LIBS"
774         CFLAGS="$PERL_CFLAGS $CFLAGS"
775         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
776         AC_TRY_LINK([
777 #include <EXTERN.h>
778 #include <perl.h>
779 #include <perlapi.h>
781                     [PerlInterpreter *my_perl = perl_alloc();],
782                     cf_result=yes, cf_result=no)
785 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
787 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
788 AC_TRY_COMPILE([
789 #include <EXTERN.h>
790 #include <perl.h>
791 extern PerlInterpreter *my_perl;
793         [dSP; (void) POPpx;],
794         [AC_MSG_RESULT([yes])
795 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
796                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
797 no longer needs an "n_a" variable like it did in 5.8.7])],
798         [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_TRY_LINK([#include <Python.h>],
843                     [Py_Initialize();],
844                     cf_result=yes, cf_result=no)
846                 if test "$cf_result" != "yes"; then
847                         EL_RESTORE_FLAGS
848                 else
849                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
850                         AC_SUBST(PYTHON_LIBS)
851                         AC_SUBST(PYTHON_CFLAGS)
852                         CPPFLAGS="$CPPFLAGS_X"
853                         cat <<EOF
854 ***********************************************************************
855 The Python support is incomplete and not so well integrated to ELinks
856 yet. That means, e.g., that you have no Python console and there might
857 not be all the necessary hooks. Also, the Python interface is not too
858 well tested (success stories heartily welcomed!).
859 ***********************************************************************
861                 fi
862         else
863                 if test -n "$withval" && test "x$withval" != xno; then
864                         AC_MSG_ERROR([Python not found])
865                 else
866                         AC_MSG_WARN([Python support disabled])
867                 fi
868         fi
869 else
870         AC_MSG_RESULT(no);
874 dnl ===================================================================
875 dnl Check for Lua, optional even if installed.
876 dnl ===================================================================
878 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
879 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
881 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
882             [if test "$withval" = no; then disable_lua=yes; fi])
883 AC_MSG_CHECKING([for Lua])
885 EL_SAVE_FLAGS
886 cf_result=no
888 if test -z "$disable_lua"; then
889         if test ! -d "$withval"; then
890                 withval="";
891         fi
892         for luadir in "$withval" "" /usr /usr/local; do
893                 for suffix in "" 50 51; do
894                         if test "$cf_result" = no; then
895                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
897                                 if test ! -z "$luadir"; then
898                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
899                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
900                                 fi
902                                 LIBS="$LUA_LIBS $LIBS_X"
903                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
904                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
906                                 # Check that it is a compatible Lua version
907                                 AC_TRY_LINK([   #include <lua.h>
908                                                 #include <lualib.h>],
909                                             [   lua_State *L = lua_open();
910                                                 luaopen_base(L);
911                                                 luaopen_table(L);
912                                                 luaopen_io(L);
913                                                 luaopen_string(L);
914                                                 luaopen_math(L);
915                                                 lua_pushboolean(L, 1);
916                                                 lua_close(L);],
917                                             cf_result=yes, cf_result=no)
918                         fi
919                 done
920         done
923 AC_MSG_RESULT($cf_result)
925 if test "$cf_result" != yes; then
926         EL_RESTORE_FLAGS
927 else
928         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
929         AC_CHECK_HEADERS(lauxlib.h)
931         CFLAGS="$CFLAGS_X"
932         CPPFLAGS="$CPPFLAGS_X"
933         AC_SUBST(LUA_LIBS)
934         AC_SUBST(LUA_CFLAGS)
938 dnl ===================================================================
939 dnl Check for Ruby, optional even if installed.
940 dnl ===================================================================
942 EL_CONFIG_SCRIPTING_RUBY
944 dnl ===================================================================
945 dnl Setup global scripting
946 dnl ===================================================================
948 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])
949 AC_SUBST(CONFIG_SCRIPTING_GUILE)
950 AC_SUBST(CONFIG_SCRIPTING_LUA)
951 AC_SUBST(CONFIG_SCRIPTING_PERL)
952 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
953 AC_SUBST(CONFIG_SCRIPTING_RUBY)
954 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
955 AC_SUBST(CONFIG_SCRIPTING)
958 dnl ===================================================================
959 dnl Check for SSL support.
960 dnl ===================================================================
962 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
963 dnl is enabled, we won't try to use OpenSSL anymore.
965 dnl For wiping SSL hooks..
966 #ifdef CONFIG_SSL
968 disable_openssl=""
969 disable_gnutls=""
970 enable_gnutls=""
972 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
973             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
974 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
975             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
976 gnutls_withval="$withval"
978 if test "$enable_gnutls" = yes; then
979         disable_openssl=yes;
982 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
983             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
984 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
985 openssl_withval="$withval"
987 dnl ---- OpenSSL
989 AC_MSG_CHECKING([for OpenSSL])
991 EL_SAVE_FLAGS
992 cf_result="no"
994 if test "$disable_openssl" = yes; then
995         cf_result="not used"
996 else
997         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
998                          /usr/lib/openssl /usr/local/ssl \
999                          /usr/local/www /usr/lib/ssl /usr/local \
1000                          /usr/pkg /opt /opt/openssl; do
1001                 if test "$cf_result" = no; then
1002                         if test -d "$ssldir"; then
1003                                 OPENSSL_CFLAGS="-I$ssldir/include"
1004                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1005                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1006                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1007 #                               # FIXME: This created serious portability problems. --pasky
1008 #                               if test "$CC" == "gcc"; then
1009 #                                       # I'm not sure about compatibility here. --pasky
1010 #                                       LIBS="$LIBS -R$ssldir/lib"
1011 #                               fi
1012                         else
1013                                 LIBS="-lssl -lcrypto $LIBS_X"
1014                         fi
1015                         AC_TRY_LINK([#include <openssl/ssl.h>],
1016                                     [OpenSSL_add_all_algorithms()],
1017                                     cf_result=yes, cf_result=no)
1018                         if test "$cf_result" != yes; then
1019                                 AC_TRY_LINK([#include <openssl/ssl.h>],
1020                                             [SSLeay_add_ssl_algorithms()],
1021                                             cf_result=yes, cf_result=no)
1022                         fi
1023                 fi
1024         done
1026         if test "$cf_result" != yes; then
1027                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
1028                         AC_MSG_ERROR([OpenSSL not found])
1029                 fi
1030                 EL_RESTORE_FLAGS
1031         else
1032                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1034                 CFLAGS="$CFLAGS_X"
1035                 AC_SUBST(OPENSSL_CFLAGS)
1036         fi
1039 AC_MSG_RESULT($cf_result)
1041 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1042 dnl ---- GNU TLS
1043 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
1044 dnl it looks ugly then.
1046 if test "$cf_result" = yes; then
1047         cf_result="not used"
1049 else
1050         EL_SAVE_FLAGS
1051         cf_result="no"
1053         if test -z "$disable_gnutls"; then
1054                 # Sure, we maybe _could_ use their macro, but how to ensure
1055                 # that the ./configure script won't fail if the macro won't be
1056                 # found..? :( --pasky
1058                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
1060                 if test -d "$gnutls_withval"; then
1061                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
1062                 fi
1064                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
1066                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
1067                         cf_result=no
1068                 else
1069                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
1070                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
1072                         LIBS="$GNUTLS_LIBS $LIBS_X"
1073                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
1074                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
1076                         # Verify if it's really usable.  gnutls_session was
1077                         # renamed to gnutls_session_t before GNU TLS 1.2.0
1078                         # (on 2004-06-13); ELinks now requires this.
1079                         AC_TRY_LINK([#include <gnutls/gnutls.h>],
1080                                     [gnutls_session_t dummy;
1081                                      gnutls_check_version(NULL)],
1082                                     cf_result=yes, cf_result=no)
1083                 fi
1085                 if test "$cf_result" = yes; then
1086                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1088                         CFLAGS="$CFLAGS_X"
1089                         AC_SUBST(GNUTLS_CFLAGS)
1091                         # Verify if the MD5 compatibility layer is usable.
1092                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1093                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1094                                                   [GNU TLS OpenSSL compatibility],
1095                                                   gnutls/openssl.h, gnutls-openssl,
1096                                                   MD5_Init)
1097                 else
1098                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1099                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1100                         fi
1101                         EL_RESTORE_FLAGS
1102                 fi
1103         fi
1106 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1107 AC_MSG_RESULT($cf_result)
1109 dnl Final SSL setup
1111 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1112 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1113 AC_SUBST(CONFIG_OPENSSL)
1114 AC_SUBST(CONFIG_GNUTLS)
1116 #endif
1118 AC_MSG_CHECKING([whether to be or not to be])
1119 AC_MSG_RESULT([needs to be determined experimentally])
1121 dnl ===================================================================
1122 dnl Check for IPv6 support and related functions.
1123 dnl ===================================================================
1125 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1126 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1127 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1129 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1130 if test "$HAVE_GETADDRINFO" != yes; then
1131         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1132         if test "$HAVE_GETADDRINFO" = yes; then
1133                 LIBS="$LIBS -linet6"
1134         fi
1138 dnl ===================================================================
1139 dnl Checking for X11 (window title restoring).
1140 dnl ===================================================================
1142 AC_PATH_X
1143 if test x"$no_x" != xyes; then
1144         if test -n "$x_includes"; then
1145                 X_CFLAGS="-I$x_includes"
1146         fi
1147         if test -n "$x_libraries"; then
1148                 LDFLAGS="$LDFLAGS -L$x_libraries"
1149         fi
1150         LIBS="-lX11 $LIBS"
1151         EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1152         AC_SUBST(X_CFLAGS)
1156 dnl ===================================================================
1157 dnl Backtraces displaying support.
1158 dnl ===================================================================
1160 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1161 # possible checks for other system-specific means go here
1164 dnl ===================================================================
1165 dnl Gettext grey zone. Beware.
1166 dnl ===================================================================
1168 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"
1170 AM_GNU_GETTEXT
1172 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1173 dnl # f33r d4 l33t... I hope it's portable. :)
1174 dnl cf_result=$((48#z - 48#a + 1));
1175 dnl AC_MSG_RESULT($cf_result)
1178 dnl ===================================================================
1179 dnl Compile-time features control
1180 dnl ===================================================================
1182 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1183               [  --disable-cookies       disable cookie support])
1185 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1186               [  --disable-formhist      disable form history support])
1188 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1189               [  --disable-globhist      disable global history support])
1192 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1193               [  --disable-mailcap       disable mailcap support])
1195 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1196               [  --disable-mimetypes     disable mimetypes files support])
1199 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1200               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1201               [IPv6],
1202               [  --disable-ipv6          disable IPv6 support])
1204 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1205               [  --enable-bittorrent     enable BitTorrent protocol support])
1207 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1208               [  --disable-data          disable data protocol support])
1210 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1211               [  --disable-uri-rewrite   disable URI rewrite support])
1213 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1214               [  --enable-cgi            enable local CGI support])
1216 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1217               [  --enable-finger         enable finger protocol support])
1219 dnl ===================================================================
1220 dnl FSP protocol
1221 dnl ===================================================================
1222 EL_SAVE_FLAGS
1224 if test "x${enable_fsp}" != xno; then
1225         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1227         if test "$HAVE_FSPLIB" = yes; then
1228                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1229                 if test "$HAVE_FSPLIB" = yes; then
1230                         LIBS="$LIBS -lfsplib"
1231                 else
1232                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1233                         if test "$HAVE_FSPLIB" = yes; then
1234                                 LIBS="$LIBS -lfsp"
1235                         fi
1236                 fi
1237         fi
1240 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1241               [  --enable-fsp            enable FSP protocol support])
1243 if test "x$CONFIG_FSP" = xno; then
1244         EL_RESTORE_FLAGS
1247 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1248               [  --disable-ftp           disable ftp protocol support])
1250 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1251               [  --enable-gopher         enable gopher protocol support])
1253 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1254               [  --enable-nntp           enable nntp protocol support])
1256 dnl ===================================================================
1257 dnl SMB protocol support.
1258 dnl ===================================================================
1259 EL_SAVE_FLAGS
1261 if test "x${enable_smb}" != xno; then
1262         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1264         if test "$HAVE_SMBCLIENT" = yes; then
1265                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1266                 if test "$HAVE_SMBCLIENT" = yes; then
1267                         LIBS="$LIBS -lsmbclient"
1268                 fi
1269         fi
1272 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1273               [  --enable-smb            enable Samba protocol support])
1275 if test "x$CONFIG_SMB" = xno; then
1276         EL_RESTORE_FLAGS
1280 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1281               [  --disable-mouse         disable mouse support])
1283 # GPM mouse is Linux specific, so ...
1284 CONFIG_SYSMOUSE=yes
1285 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1286               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1287               [BSD sysmouse],
1288               [  --disable-sysmouse      disable BSD sysmouse support])
1290 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1291               [  --enable-88-colors      enable 88 color support])
1293 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1294               [  --enable-256-colors     enable 256 color support])
1296 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1297               [  --enable-true-color     enable true color support])
1299 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1300               [  --enable-exmode         enable exmode (CLI) interface])
1302 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1303               [  --disable-leds          disable LEDs support])
1305 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1306               [  --disable-marks         disable document marks support])
1309 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1310               [  --disable-css           disable Cascading Style Sheet support])
1312 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1313               [  --enable-html-highlight HTML highlighting using DOM engine])
1315 dnl Everything in the tree already uses CONFIG_DOM
1316 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1317 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1319 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1320               [  --disable-backtrace     disable backtrace support])
1322 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1323               [  --enable-no-root        enable prevention of usage by root])
1326 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1327               [  --enable-debug          enable leak debug and internal error checking])
1329 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1330               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1332 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1333               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1335 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1336               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1338 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1339               [  --enable-utf-8          enable UTF-8 support])
1342 AC_ARG_ENABLE(weehoofooboomookerchoo,
1343               [
1344     Also check out the features.conf file for more information about features!
1345               ],
1346               [AC_MSG_ERROR(Are you strange, or what?)])
1349 dnl == EMX hack
1351 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1352 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1355 dnl ===================================================================
1356 dnl Export directory paths
1357 dnl ===================================================================
1359 # Set up the ``entry points'' if they were not supplied by builder
1360 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1361 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1363 # Create CONFDIR #define for config.h
1365 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1366 # it's autoconf fault to force us to do such hacks ;p.
1367 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1368   # sysconfdir is set to its default value... fine, let's append /elinks/
1369   # XXX: We can't modify listing of the default in ./configure --help :-(
1370   sysconfdir_n=`eval echo "$sysconfdir"`
1371   sysconfdir=$sysconfdir_n
1372   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1373         sysconfdir="$sysconfdir/elinks"
1376 CONFDIR=$sysconfdir
1377 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1378 AC_SUBST(CONFDIR)
1380 # Create LOCALEDIR #define for config.h
1381 LOCALEDIR=`eval echo "$datadir/locale"`
1382 while echo "$LOCALEDIR" | grep "\\$"
1384         LOCALEDIR=`eval echo "$LOCALEDIR"`
1385 done > /dev/null 2> /dev/null
1386 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1387 AC_SUBST(LOCALEDIR)
1389 # Create LIBDIR #define for config.h
1390 LIBDIR=`eval echo "$libdir"`
1391 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1392 AC_SUBST(LIBDIR)
1394 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1395 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1397 dnl ===================================================================
1398 dnl A little fine tuning of gcc specific options (continued)
1399 dnl ===================================================================
1401 if test "x$ac_cv_prog_gcc" = "xyes"; then
1402   if test "$CONFIG_DEBUG" = "yes"; then
1403     dnl We want to see all warnings and live with none (in debug mode).
1404     CFLAGS="$CFLAGS -Werror"
1405   fi
1407   case "`$CC -dumpversion`" in
1408     3.0|3.1|3.2)
1409       # These should be ok using -Werror
1410       ;;
1411     3.*)
1412       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1413       # "dereferencing type-punned pointer will break strict-aliasing rules"
1414       # warnings. Disable them by not doing any strict-aliasing. The
1415       # alternative is just too ugly. Thanks gcc guys!! ;)
1416       CFLAGS="$CFLAGS -fno-strict-aliasing"
1417       ;;
1418     4.*)
1419       # Do not show warnings related to (char * | unsigned char *) type
1420       # difference.
1421       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1422       ;;
1423     *)
1424       # These should be ok using -Werror
1425       ;;
1426   esac
1428   # GCC 4.2 snapshots warn that comparisons like &object != NULL
1429   # always return true.  Some macros in ELinks check whether pointer
1430   # arguments are NULL, and giving them addresses of named objects
1431   # triggers the warning.  These warnings have not revealed any real
1432   # bugs, so shut them up instead of complicating the code.  GCC 4.1
1433   # does not recognize -Wno-always-true and exits with code 1 if it is
1434   # given.
1435   AC_MSG_CHECKING([whether $CC accepts -Wno-always-true])
1436   EL_SAVE_FLAGS
1437   CFLAGS="$CFLAGS -Wno-always-true"
1438   AC_TRY_COMPILE([], [],
1439     [AC_MSG_RESULT([yes])],
1440     [EL_RESTORE_FLAGS
1441      AC_MSG_RESULT([no])])
1444 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1445 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1446 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1447 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1449 dnl ===================================================================
1450 dnl Colored make output
1451 dnl ===================================================================
1453 if test $(`which tput` colors) -ge 4; then
1454         MAKE_COLOR=1
1455         AC_SUBST(MAKE_COLOR)
1458 dnl ===================================================================
1459 dnl Generated files
1460 dnl ===================================================================
1462 AC_OUTPUT([ \
1463  Makefile.config \
1464  contrib/elinks.spec \
1465  contrib/lua/hooks.lua \
1466  contrib/conv/w3m2links.awk \
1467  doc/man/man1/elinks.1 \
1468  src/intl/gettext/ref-add.sed \
1469  src/intl/gettext/ref-del.sed
1472 abs_srcdir="$(cd "$srcdir" && pwd)"
1473 # builddir is always absolute!
1474 if test "$abs_srcdir" != "$builddir"; then
1475         # Bootstrap the Makefile creation
1476         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1477         "$MAKE" "SRC=$abs_srcdir" init
1479         # Make cg-status ignore this build directory
1480         echo "*" > "$builddir/.gitignore"
1483 dnl ===================================================================
1484 dnl Configuration summary
1485 dnl ===================================================================
1487 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1488 cat features.log