Revert "Shorten add_chars. Do not call compare_fg_color and compare_bg_color."
[elinks.git] / configure.in
blob58548fefbfefcc85d9cf95911950a7cc1840c3cd
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.61 is installed in the computer that generates our nightly
10 dnl snapshots, so we need to be compatible with that.  (Also, some files
11 dnl in Autoconf 2.62 and 2.63 sources are not GPLv2 compatible.)
12 AC_PREREQ(2.61)
13 AC_INIT
14 AC_CONFIG_SRCDIR([src/main/main.c])
15 AC_CONFIG_AUX_DIR(config)
17 PACKAGE=elinks
18 VERSION=0.13.GIT
19 AC_SUBST(PACKAGE)
20 AC_SUBST(VERSION)
21 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
22 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
23 AC_CONFIG_HEADERS(config.h)
25 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
26 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
27 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
29 MAKE=
31 for make in gnumake gmake make false; do
32         if test "x$MAKE" = x; then
33                 AC_PATH_PROGS(MAKE, "$make")
34         fi
35 done
37 builddir="`pwd`"
39 # Cleanup if we are configuring with a previous build in the tree
40 if test -e Makefile.config; then
41         AC_MSG_CHECKING([for previous build to clean])
42         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
43         AC_MSG_RESULT(done)
46 # ===================================================================
47 # Load feature configuration file and start logging features.
48 # ===================================================================
50 features="features.conf"
51 test -f "$srcdir/$features" && . "$srcdir/$features"
52 test -f "$builddir/$features" && . "$builddir/$features"
53 echo "Feature summary:" > features.log
55 # ===================================================================
56 # Checks for programs.
57 # ===================================================================
59 AC_PROG_CC
60 AC_CHECK_TOOL([LD], [ld])
61 AC_PROG_AWK
62 AC_PATH_PROGS(AWK, "$AWK")
63 AC_PROG_RANLIB
64 AC_PROG_INSTALL
66 AC_PATH_PROGS(GIT, "git")
67 AC_PATH_PROGS(SPARSE, "sparse")
69 PKG_PROG_PKG_CONFIG
71 CONFIG_ASCIIDOC="no"
72 CONFIG_POD2HTML="no"
73 CONFIG_XMLTO="no"
74 CONFIG_JW="no"
76 if test "x$CONFIG_DOC" != xno; then
77         AC_PATH_PROGS(PYTHON, "python")
78         if test "x$PYTHON" != "x"; then
79                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
80                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
81                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
82         fi
84         AC_PATH_PROGS(XMLTO, "xmlto")
85         if test "x$XMLTO" != "x"; then
86                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
87                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
88                 EL_CONFIG(MAN_XMLTO, [man (groff)])
89         fi
91         AC_PATH_PROGS(JW, "jw")
92         if test "x$JW" != "x"; then
93                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
94                 EL_CONFIG(MANUAL_JW, [PDF])
95         fi
97         AC_PATH_PROGS(POD2HTML, "pod2html")
98         if test "x$POD2HTML" != "x"; then
99                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
100         fi
102         AC_PATH_PROGS(DOXYGEN, "doxygen")
103         if test "x$DOXYGEN" != "x"; then
104                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
105                 api_srcdir="$(cd "$srcdir" && pwd)/src"
106                 AC_SUBST(api_srcdir)
107         fi
110 AC_SUBST(CONFIG_ASCIIDOC)
111 AC_SUBST(CONFIG_DOXYGEN)
112 AC_SUBST(CONFIG_POD2HTML)
113 AC_SUBST(CONFIG_XMLTO)
114 AC_SUBST(CONFIG_JW)
116 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
117 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
118 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
119 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
121 # gcc specific options (to be continued at the bottom of configure)
122 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
123   # We want to see all warnings and live with none.
124   # We can't set up -Werror here as there may be some warnings in test
125   # suite of configure, and we don't want to fail them.
126   CFLAGS="$CFLAGS -Wall"
129 # ===================================================================
130 # Checks for special OSes.
131 # ===================================================================
133 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
134 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
136         AC_MSG_CHECKING([for $2])
138         for flag in $3; do
139                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
140 kill me!
141 #endif ]])],[$1=yes],[$1=no])
142                 if test "[$]$1" = yes; then
143                         EL_CONFIG([$1], [$2])
144                         break
145                 fi
146         done
148         AC_MSG_RESULT([$]$1)
151 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
152 AC_SUBST(CONFIG_OS_BEOS)
154 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
155 AC_SUBST(CONFIG_OS_RISCOS)
157 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
158 AC_SUBST(CONFIG_OS_WIN32)
160 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
161 AC_SUBST(CONFIG_OS_OS2)
162 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
164 AC_MSG_CHECKING([for UNIX])
165 dnl FIXME: some depend kind of mechanism
166 if test "$CONFIG_OS_BEOS" = no && \
167    test "$CONFIG_OS_RISCOS" = no && \
168    test "$CONFIG_OS_WIN32" = no && \
169    test "$CONFIG_OS_OS2" = no; then
170         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
171 else
172         CONFIG_OS_UNIX=no
174 AC_MSG_RESULT($CONFIG_OS_UNIX)
175 AC_SUBST(CONFIG_OS_UNIX)
177 # ===================================================================
178 # Checks for header files.
179 # ===================================================================
181 AC_HEADER_DIRENT
182 AC_HEADER_STDC
183 AC_HEADER_SYS_WAIT
184 AC_HEADER_TIME
186 AC_CHECK_HEADERS(wchar.h wctype.h)
187 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
188 AC_CHECK_HEADERS(sigaction.h)
189 AC_CHECK_HEADERS(arpa/inet.h)
190 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
191 AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/in6_var.h)
192 AC_CHECK_HEADERS(ifaddrs.h)
193 AC_CHECK_HEADERS(sys/cygwin.h io.h)
194 AC_CHECK_HEADERS(sys/fmutex.h)
195 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
196 AC_CHECK_HEADERS(sys/resource.h)
197 AC_CHECK_HEADERS(sys/select.h)
198 AC_CHECK_HEADERS(sys/signal.h)
199 AC_CHECK_HEADERS(sys/socket.h)
200 AC_CHECK_HEADERS(sys/time.h)
201 AC_CHECK_HEADERS(sys/utsname.h)
202 AC_CHECK_HEADERS([net/if.h], [], [],
203 [[#ifdef HAVE_SYS_SOCKET_H
204 # include <sys/socket.h> /* <net/if.h> on Mac OS X 10.5.4 needs this */
205 #endif
207 AC_CHECK_HEADERS(stdint.h inttypes.h)
208 AC_CHECK_HEADERS(locale.h pwd.h)
209 AC_CHECK_HEADERS(termios.h)
212 AC_CHECK_HEADERS(sys/un.h,
213         [CONFIG_INTERLINK=yes
214          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
215         [CONFIG_INTERLINK=no])
216 AC_SUBST(CONFIG_INTERLINK)
218 # ===================================================================
219 # Checks for typedefs, structures, and compiler characteristics.
220 # ===================================================================
222 AC_STRUCT_TM
223 AC_C_CONST
224 AC_C_INLINE
225 AC_MSG_CHECKING([[for C99-conforming inline]])
226 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
227         int add(int change);
229         static int sum;
231         inline int
232         add(int change)
233         {
234                 sum += change;
235                 return sum;
236         }
238         int
239         sub(int change)
240         {
241                 return add(-change);
242         }]])],
243         [AC_MSG_RESULT([[yes]])
244          AC_DEFINE([NONSTATIC_INLINE], [inline],
245                 [Define as inline if the compiler lets you declare a function without inline, then define it with inline, and have that definition refer to identifiers with internal linkage.  This is allowed by C99 6.7.4p6 and 6.7.4p3 together.  Otherwise define as nothing.])],
246         [AC_MSG_RESULT([[no]])
247          AC_DEFINE([NONSTATIC_INLINE], [])])
248 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
250 AC_SYS_LARGEFILE
251 AC_TYPE_SIZE_T
252 AC_TYPE_OFF_T
253 EL_CHECK_TYPE(ssize_t, int)
254 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
255 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
256 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
257 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
258 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
260 AC_CHECK_SIZEOF(char, 1)
261 AC_CHECK_SIZEOF(short, 2)
262 AC_CHECK_SIZEOF(int, 4)
263 AC_CHECK_SIZEOF(long, 4)
264 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
265 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
267 # Check for variadic macros
268 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
269                 [#include <stdio.h>
270                  #define a(b,c...) printf(b,##c)],
271                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
273 # ===================================================================
274 # Checks for library functions.
275 # ===================================================================
277 AC_PROG_GCC_TRADITIONAL
278 AC_FUNC_MEMCMP
279 AC_FUNC_MMAP
280 AC_FUNC_STRFTIME
281 AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
282 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
283 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
284 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
285 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
286 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
287 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
288 AC_CHECK_FUNCS(gettimeofday clock_gettime)
289 AC_CHECK_FUNCS(setitimer, HAVE_SETITIMER=yes)
291 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
293 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
294 AC_CHECK_FUNCS(unsetenv)
295 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
296 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
298 AC_CHECK_FUNCS(wcwidth, HAVE_WCWIDTH=yes)
300 AC_CHECK_FUNCS(fork)
302 # These aren't probably needed now, as they are commented in links.h.
303 # I've no idea about their historical background, but I keep them here
304 # just in the case they will help later. --pasky
305 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
306 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
307 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
308 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
310 AC_CHECK_FUNCS(fpathconf, HAVE_FPATHCONF=yes)
312 if test x"$HAVE_RAISE" = x; then
313         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
314                 AC_MSG_ERROR([Unable to emulate raise()])
315         fi
318 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
319 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
320 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
321 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
322         EL_DEFINE(HAVE_VA_COPY, __va_copy)
325 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
326 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
327 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
328 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
329         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
332 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
333 AC_RUN_IFELSE([AC_LANG_SOURCE([[
334 #include <stdio.h>
335 #include <stdarg.h>
336 #include <stdlib.h>
337 #include <string.h>
339 char buf[8];
341 int bar(char *buf, const char *format, va_list ap)
343        return vsnprintf(buf, 0, format, ap);
346 void foo(const char *format, ...) {
347        va_list ap;
348        int len;
350        va_start(ap, format);
351        len = bar(buf, format, ap);
352        va_end(ap);
353        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
355        va_start(ap, format);
356        len = bar(buf, format, ap);
357        va_end(ap);
358        if ((len != 6) && (len != 7)) exit(1);
360        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
362        exit(0);
364 main() { foo("hello\n"); }
365 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
366 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
367         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
370 # OpenSSL and Lua frequently need dlopen
371 AC_CHECK_LIB(dl, dlopen)
373 # ===================================================================
374 # Checks for libraries.
375 # ===================================================================
377 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
378 if test "$cf_result" = no; then
379         AC_CHECK_LIB(socket, socket)
382 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
383 if test "$cf_result" = no; then
384         AC_CHECK_LIB(socket, setsockopt)
387 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
388 if test "$cf_result" = no; then
389         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
390         if test "$cf_result" = no; then
391                 AC_CHECK_LIB(nsl, gethostbyname)
392         else
393                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
394         fi
397 # ===================================================================
398 # Checks for packaging specific options.
399 # ===================================================================
401 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
402             [ if test "$withval" != no && test "$withval" != yes; then
403                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
404               fi ])
406 # ===================================================================
407 # Checks for a libraries, optional even if installed.
408 # ===================================================================
410 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
411 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
413         AC_MSG_CHECKING([for $2 support])
415         if test "[$]$1" != no; then
416                 AC_MSG_RESULT(yes)
417                 EL_SAVE_FLAGS
418                 if test -n "$withval" && test -d "$withval"; then
419                         # Be a little more careful when setting
420                         # include and lib directories. This way
421                         # $withval will work when includes are
422                         # there but the library is in the common
423                         # /usr/lib ... Does the right thing when
424                         # looking for gc on Debian.
425                         if test -d "$withval/include"; then
426                                 CFLAGS="$CFLAGS -I$withval/include"
427                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
428                         else
429                                 CFLAGS="$CFLAGS -I$withval"
430                                 CPPFLAGS="$CPPFLAGS -I$withval"
431                         fi
432                         if test -d "$withval/lib"; then
433                                 LDFLAGS="$LDFLAGS -L$withval/lib"
434                         fi
435                 fi
437                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
438                 if test "[$]$1" = yes; then
439                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
440                 fi
442                 if test "[$]$1" = yes; then
443                         EL_CONFIG([$1], [$2])
444                         LIBS="$LIBS -l$4"
445                 else
446                         if test -n "[$]WITHVAL_$1" &&
447                            test "x[$]WITHVAL_$1" != xno; then
448                                 AC_MSG_ERROR([$2 not found])
449                         fi
450                         EL_RESTORE_FLAGS
451                 fi
452         else
453                 AC_MSG_RESULT(disabled)
454         fi
457 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
458 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
460         if test "x[$]$1" != xno; then $1=yes; fi
461         WITHVAL_$1=
463         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
464         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
465         if test "x[$]WITHVAL_$1" = xyes; then $1=yes; fi
467         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
469         EL_LOG_CONFIG([$1], [$2], [])
472 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
473         [  --without-gpm           disable gpm (mouse) support])
475 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
476 # enable automatic decoding of both zlib and gzip headers.  This
477 # feature was added in zlib 1.2.0.2; earlier versions return an error.
478 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
479 # that, even though ELinks does not actually call gzclearerr.
480 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
481         [  --without-zlib          disable zlib support])
483 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
484         [  --without-bzlib         disable bzlib support])
486 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
487         [  --without-idn           disable international domain names support])
489 # LZMA disabled by default, because of little usability and compilation problems
490 # with new xz
491 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
492         [  --with-lzma             enable lzma encoding support])
494 # ===================================================================
495 # Check for GSSAPI, optional even if installed.
496 # ===================================================================
498 enable_gssapi="no";
500 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
501             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
503 AC_MSG_CHECKING([for GSSAPI])
505 if test "$enable_gssapi" = "yes"; then
506         AC_MSG_RESULT(yes)
507         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
508         GSSAPI_LIBS=`krb5-config --libs gssapi`
509         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
510         LIBS="$GSSAPI_LIBS $LIBS"
511         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
512 else
513         AC_MSG_RESULT(no)
516 AC_SUBST(CONFIG_GSSAPI)
518 # ===================================================================
519 # Bookmark and XBEL support
520 # ===================================================================
522 EL_SAVE_FLAGS
524 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
525               [  --disable-bookmarks     disable bookmark support])
527 # Check whether --enable-xbel or --disable-xbel was given.
528 if test "x${enable_xbel}" != xno; then
529         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
531         if test "$HAVE_LIBEXPAT" = yes; then
532                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
533                 if test "$HAVE_LIBEXPAT" = yes; then
534                         LIBS="$LIBS -lexpat"
535                 fi
536         fi
540 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
541               [XBEL bookmarks],
542               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
544 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
545         EL_RESTORE_FLAGS
548 # ===================================================================
549 # Checks for BSD sysmouse
550 # ===================================================================
552 HAVE_SYSMOUSE_HEADER="no"
554 # Either of these header files provides the (same) sysmouse interface
555 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
557 # ===================================================================
558 # Checks for OS/2
559 # ===================================================================
561 if test "$CONFIG_OS_OS2" = yes; then
562         EL_CONFIG_OS_OS2
565 # ===================================================================
566 # Checks for Win32
567 # ===================================================================
569 if test "$CONFIG_OS_WIN32" = yes; then
570         EL_CONFIG_OS_WIN32
573 # ===================================================================
574 # Check for SpiderMonkey, optional even if installed.
575 # ===================================================================
577 # This option sets the $with_spidermonkey variable.
578 AC_ARG_WITH([spidermonkey],
579         [AS_HELP_STRING([--without-spidermonkey],
580                 [disable SpiderMonkey Mozilla JavaScript engine support])])
582 # CONFIG_SPIDERMONKEY is initially blank.  We change it to "yes" or "no"
583 # when we know for sure whether we're going to use SpiderMonkey or not.
584 # (features.conf is not supposed to define it.)
585 CONFIG_SPIDERMONKEY=
586 EL_SAVE_FLAGS
588 case "$with_spidermonkey" in
589         no)
590                 # The user specified --without-spidermonkey.
591                 # That overrides the other SpiderMonkey options.
592                 AC_MSG_CHECKING([for SpiderMonkey])
593                 AC_MSG_RESULT([disabled])
594                 CONFIG_SPIDERMONKEY="no"
595                 ;;
596         "" | yes)
597                 ;;
598         *)
599                 AC_MSG_WARN([This version of ELinks does not support --with-spidermonkey=DIRECTORY.])
600                 ;;
601 esac
603 # The SpiderMonkey 1.8.5 standalone sources install mozjs185.pc,
604 # but the Debian libmozjs-dev package installs mozilla-js.pc.
605 # Check mozjs185 first, because it has the version number in the name
606 # and therefore is less likely to be a newer incompatible version.
607 # (This configure script rejects older incompatible versions
608 # but can let newer ones through.)
609 for package in mozjs185 mozilla-js; do
610         if test -n "$CONFIG_SPIDERMONKEY"; then
611                 break
612         else
613                 AC_MSG_CHECKING([for SpiderMonkey (1.8.5 or later) in pkg-config $package])
614                 # In pkg-config 0.25, pkg-config --exists mozjs185
615                 # returns 0 (success) even if mozjs185 depends on
616                 # nspr, which has not been installed.  However,
617                 # pkg-config --cflags mozjs185 returns 1 then.
618                 if $PKG_CONFIG --cflags --libs $package > /dev/null 2>&AS_MESSAGE_LOG_FD; then
619                         SPIDERMONKEY_LIBS="$($PKG_CONFIG --libs $package)"
620                         SPIDERMONKEY_CFLAGS="$($PKG_CONFIG --cflags $package)"
621                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
622                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
623                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
624                         AC_LINK_IFELSE(
625                                 [AC_LANG_PROGRAM([[
626                                         /* mozilla-js.pc may have -DXP_UNIX or similar in Cflags.
627                                          * Avoid warnings about conflicting definitions.  */
628                                         #if !defined(XP_BEOS) && !defined(XP_OS2) && !defined(XP_UNIX) && !defined(XP_WIN)
629                                         # define XP_UNIX 1
630                                         #endif
631                                         #include <jsapi.h>
632                                         #ifndef JS_VERSION
633                                         # error <jsapi.h> did not define JS_VERSION
634                                         #elif JS_VERSION < 185
635                                         # error too old
636                                         #endif]], [])],
637                                 [CONFIG_SPIDERMONKEY=yes
638                                  AC_MSG_RESULT([yes])],
639                                 [# Leave CONFIG_SPIDERMONKEY blank, to continue the search.
640                                  AC_MSG_RESULT([found but unusable])])
641                 else
642                         AC_MSG_RESULT([no])
643                 fi
644         fi
645 done
647 if test -z "$CONFIG_SPIDERMONKEY"; then
648         # Didn't find SpiderMonkey anywhere.
649         CONFIG_SPIDERMONKEY=no
652 if test "$CONFIG_SPIDERMONKEY" = "yes"; then
653         # LIBS, CFLAGS, and CPPFLAGS still include the SpiderMonkey options.
654         AC_CHECK_FUNCS([JS_ReportAllocationOverflow])
655         AC_CHECK_FUNCS([JS_SetBranchCallback])
656         AC_CHECK_FUNCS([JS_TriggerOperationCallback], [HAVE_JS_TRIGGEROPERATIONCALLBACK=yes])
657 elif test -n "$with_spidermonkey" && test "x$with_spidermonkey" != "xno"; then
658         AC_MSG_WARN([SpiderMonkey was not found even though you specified --with-spidermonkey.])
660 EL_RESTORE_FLAGS
662 if test "x$CONFIG_SPIDERMONKEY" = xyes; then
663         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
664 else
665         CONFIG_ECMASCRIPT_SMJS=no
668 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
669 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
671 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
672    test "x$HAVE_JS_TRIGGEROPERATIONCALLBACK" = xyes &&
673    test "x$HAVE_SETITIMER" = xyes; then
674         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT, [ECMAScript heartbeat support])
675 else
676         CONFIG_ECMASCRIPT_SMJS_HEARTBEAT=no
678 AC_SUBST(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
681 # ===================================================================
682 # Optional Spidermonkey-based ECMAScript browser scripting
683 # ===================================================================
685 AC_ARG_ENABLE(sm-scripting,
686               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
687               [if test "$enableval" != no; then enableval="yes"; fi
688                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
690 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
691    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
692         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
693 else
694         CONFIG_SCRIPTING_SPIDERMONKEY=no
697 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
698    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
699         LIBS="$LIBS $SPIDERMONKEY_LIBS"
700         AC_SUBST(SPIDERMONKEY_LIBS)
701         AC_SUBST(SPIDERMONKEY_CFLAGS)
702         AC_SUBST(CONFIG_SPIDERMONKEY)
705 # ===================================================================
706 # Check for Guile, optional even if installed.
707 # ===================================================================
709 enable_guile="no";
711 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
712             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
714 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
715 # GUILE_FLAGS but I really don't want to require people to have Guile in order
716 # to compile CVS. Also, the macro seems to be really stupid regarding searching
717 # for Guile in $PATH etc. --pasky
719 AC_MSG_CHECKING([for Guile])
721 if test "$enable_guile" = "yes"; then
722         AC_MSG_RESULT(yes);
723         ## Based on the GUILE_FLAGS macro.
725         if test -d "$withval"; then
726                 GUILE_PATH="$withval:$PATH"
727         else
728                 GUILE_PATH="$PATH"
729         fi
731         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
733         ## First, let's just see if we can find Guile at all.
734         if test "$GUILE_CONFIG" != no; then
735                 cf_result="yes";
737                 GUILE_LIBS="`guile-config link`"
738                 GUILE_CFLAGS="`guile-config compile`"
739                 LIBS="$GUILE_LIBS $LIBS"
740                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
741                 AC_SUBST(GUILE_CFLAGS)
742                 cat <<EOF
743 ***********************************************************************
744 The Guile support is incomplete and not so well integrated to ELinks
745 yet. That means, e.g., that you have no Guile console and there might
746 not be all the necessary hooks. Also, the Guile interface is not too
747 well tested (success stories heartily welcomed!).  See
748 src/scripting/guile/README for further details and hints.
749 ***********************************************************************
751         else
752                 if test -n "$withval" && test "x$withval" != xno; then
753                         AC_MSG_ERROR([Guile not found])
754                 else
755                         AC_MSG_WARN([Guile support disabled])
756                 fi
757         fi
758 else
759         AC_MSG_RESULT(no);
762 # ===================================================================
763 # Check for Perl
764 # ===================================================================
765 enable_perl="no";
767 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
768             [
769 if test "$withval" = yes; then
770         # FIXME: If withval is a valid directory append it to PATH
771         # so that you can specify one of several perl installations.
772         withval="";
773         enable_perl=yes;
775             ])
777 AC_MSG_CHECKING([for Perl])
779 cf_result=no
781 EL_SAVE_FLAGS
783 if test "$enable_perl" = "yes"; then
784         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
785         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
786         LIBS="$PERL_LIBS $LIBS"
787         CFLAGS="$PERL_CFLAGS $CFLAGS"
788         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
789         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
790 #include <EXTERN.h>
791 #include <perl.h>
792 #include <perlapi.h>
793 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
796 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
798 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
800 #include <EXTERN.h>
801 #include <perl.h>
802 extern PerlInterpreter *my_perl;
803 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
804 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
805                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
806 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
808 if test "$cf_result" != "yes"; then
809         EL_RESTORE_FLAGS
810 else
811         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
813         CFLAGS="$CFLAGS_X"
814         CPPFLAGS="$CPPFLAGS_X"
815         AC_SUBST(PERL_LIBS)
816         AC_SUBST(PERL_CFLAGS)
819 # ===================================================================
820 # Check for Python
821 # ===================================================================
822 enable_python="no";
824 AC_ARG_WITH(python, [[  --with-python[=DIR]     enable Python support]],
825             [ if test "x$withval" != xno; then enable_python=yes; fi ])
827 EL_SAVE_FLAGS
828 cf_result=no
830 AC_MSG_CHECKING([for Python])
832 if test "$enable_python" = "yes"; then
833         AC_MSG_RESULT(yes);
835         if test -d "$withval"; then
836                 PYTHON_PATH="$withval:$PATH"
837         else
838                 PYTHON_PATH="$PATH"
839         fi
841         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
843         if test "$PYTHON" != no; then
844                 cf_result="yes";
846                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
847                 PYTHON_LIBS="`$PYTHON -c 'from distutils import sysconfig; var = sysconfig.get_config_var; print "%s %s %s -L%s -lpython%s" % (var("LINKFORSHARED"), var("LIBS"), var("SYSLIBS"), var("LIBPL"), var("VERSION"))'`"
848                 LIBS="$PYTHON_LIBS $LIBS"
849                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
850                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
852                 if test "$cf_result" != "yes"; then
853                         EL_RESTORE_FLAGS
854                 else
855                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
856                         AC_SUBST(PYTHON_LIBS)
857                         AC_SUBST(PYTHON_CFLAGS)
858                         CPPFLAGS="$CPPFLAGS_X"
859                         cat <<EOF
860 ***********************************************************************
861 The Python support is incomplete and not so well integrated to ELinks
862 yet. That means, e.g., that you have no Python console and there might
863 not be all the necessary hooks. Also, the Python interface is not too
864 well tested (success stories heartily welcomed!).
865 ***********************************************************************
867                 fi
868         else
869                 if test -n "$withval" && test "x$withval" != xno; then
870                         AC_MSG_ERROR([Python not found])
871                 else
872                         AC_MSG_WARN([Python support disabled])
873                 fi
874         fi
875 else
876         AC_MSG_RESULT(no);
880 # ===================================================================
881 # Check for Lua, optional even if installed.
882 # ===================================================================
884 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
885 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
887 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
888             [if test "$withval" = no; then disable_lua=yes; fi])
889 AC_MSG_CHECKING([for Lua])
891 EL_SAVE_FLAGS
892 cf_result=no
894 if test -z "$disable_lua"; then
895         if test ! -d "$withval"; then
896                 withval="";
897         fi
898         for luadir in "$withval" "" /usr /usr/local; do
899                 for suffix in "" 5.1 51; do
900                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
901                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
902                                 LUA_LIBS="-L$luadir/lib -llua$suffix -lm"
903                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
905                                 LIBS="$LUA_LIBS $LIBS_X"
906                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
907                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
909                                 # Check that it is a compatible Lua version
910                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lauxlib.h>]
911                                                 #include <lua.h>
912                                                 #include <lualib.h>
913                                                 ], [[   lua_State *L = luaL_newstate();
914                                                 luaL_openlibs(L);
915                                                 lua_pushboolean(L, 1);
916                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
917                         fi
918                 done
919         done
922 AC_MSG_RESULT($cf_result)
924 if test "$cf_result" != yes; then
925         EL_RESTORE_FLAGS
926 else
927         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
928         AC_CHECK_HEADERS(lauxlib.h)
930         CFLAGS="$CFLAGS_X"
931         CPPFLAGS="$CPPFLAGS_X"
932         AC_SUBST(LUA_LIBS)
933         AC_SUBST(LUA_CFLAGS)
936 # ===================================================================
937 # Check for TRE library
938 # ===================================================================
940 # This section only checks that --without-tre is not given and the
941 # library seems to work, and sets TRE_CFLAGS, TRE_LIBS, and
942 # tre_log.  It does not define CONFIG_TRE, and always resets
943 # LIBS and CFLAGS back to their original values.
945 # After any --enable-utf-8 and --disable-utf-8 options have been
946 # handled, a separate section decides whether to actually use TRE.
948 # tre version 0.8.0 or higher is required which have the "tre_" prefix
949 # for functions.
951 AC_ARG_WITH([[tre]], [[  --without-tre           disable TRE regex search support]])
952 if test "$with_tre" = no; then
953         AC_MSG_CHECKING([[for TRE]])
954         AC_MSG_RESULT([[disabled]])
955         tre_log="no (explicitly disabled)"
956 else
957         AC_MSG_CHECKING([[for TRE in pkg-config]])
958         if $PKG_CONFIG tre; then
959                 TRE_CFLAGS=`$PKG_CONFIG --cflags tre`
960                 TRE_LIBS=`$PKG_CONFIG --libs tre`
961                 AC_MSG_RESULT([[yes]])
962         else
963                 # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
964                 # "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
965                 # so we look for the library even if pkg-config doesn't know about it.
966                 TRE_CFLAGS=
967                 TRE_LIBS=-ltre
968                 AC_MSG_RESULT([[no, but let's try defaults]])
969         fi
971         AC_MSG_CHECKING([[for TRE header and library]])
972         EL_SAVE_FLAGS
973         CFLAGS="$TRE_CFLAGS $CFLAGS"
974         LIBS="$TRE_LIBS $LIBS" # must be first, because of regfree conflict
975         AC_TRY_LINK([#include <tre/tre.h>],
976                     [regex_t re;
977                      regmatch_t match[1];
978                      tre_regwcomp(&re, L"zap", REG_ICASE);
979                      tre_regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
980                     [AC_MSG_RESULT([[yes]])
981                      tre_log="available"],
982                     [AC_MSG_RESULT([[no]])
983                      tre_log="no (TRE not found)"])
984         EL_RESTORE_FLAGS
987 # ===================================================================
988 # Check for Ruby, optional even if installed.
989 # ===================================================================
991 EL_CONFIG_SCRIPTING_RUBY
993 # ===================================================================
994 # Setup global scripting
995 # ===================================================================
997 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])
998 AC_SUBST(CONFIG_SCRIPTING_GUILE)
999 AC_SUBST(CONFIG_SCRIPTING_LUA)
1000 AC_SUBST(CONFIG_SCRIPTING_PERL)
1001 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
1002 AC_SUBST(CONFIG_SCRIPTING_RUBY)
1003 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
1004 AC_SUBST(CONFIG_SCRIPTING)
1007 # ===================================================================
1008 # Check for SSL support.
1009 # ===================================================================
1011 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
1012 # is enabled, we won't try to use OpenSSL anymore.
1014 # For wiping SSL hooks..
1015 #ifdef CONFIG_SSL
1017 chosen_ssl_library=""
1019 AC_ARG_WITH(gnutls, [[  --without-gnutls        disable GNUTLS SSL support]])
1020 AC_ARG_WITH(gnutls, [[  --with-gnutls           enable GNUTLS SSL support]],
1021             [case "$with_gnutls" in
1022                 "no")   : ;;
1023                 "yes")  chosen_ssl_library="GNUTLS" ;;
1024                 *)      chosen_ssl_library="GNUTLS"
1025                         AC_MSG_WARN([[Support for --with-gnutls=DIR has been removed.
1026 You may have to set the PKG_CONFIG_PATH environment variable instead.]]) ;;
1027              esac])
1029 AC_ARG_WITH(openssl, [[  --without-openssl       disable OpenSSL support]])
1030 AC_ARG_WITH(openssl, [[  --with-openssl[=DIR]    enable OpenSSL support (default)]],
1031             [case "$with_openssl" in
1032                 "no")   : ;;
1033                 *)      chosen_ssl_library="OpenSSL" ;;
1034              esac])
1036 AC_ARG_WITH(nss_compat_ossl, [[  --with-nss_compat_ossl[=DIR]
1037                           NSS compatibility SSL libraries/include files]],
1038             [case "$with_nss_compat_ossl" in
1039                 "no")   : ;;
1040                 *)      chosen_ssl_library="nss_compat_ossl" ;;
1041              esac])
1043 # ---- nss_compat_ossl
1045 if test "$with_nss_compat_ossl" = no; then
1046         # explicitly disabled
1047         :
1048 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "nss_compat_ossl"; then
1049         # not used, because $chosen_ssl_library was chosen
1050         :
1051 elif test -z "${with_nss_compat_ossl+set}"; then
1052         # SSL_library_init() in nss_compat_ossl 0.9.2 calls exit(1)
1053         # with no error message if there is no certificate database.
1054         # https://bugzilla.redhat.com/show_bug.cgi?id=463437
1055         # So ELinks uses nss_compat_ossl only if explicitly requested.
1056         :
1057 else
1058         EL_SAVE_FLAGS
1059         if test "$with_nss_compat_ossl" = yes; then
1060                 if $PKG_CONFIG nss; then
1061                         CFLAGS="$CFLAGS_X `$PKG_CONFIG --cflags nss`"
1062                         LIBS="$LIBS_X `$PKG_CONFIG --libs nss`"
1063                 else
1064                         with_nss_compat_ossl=no
1065                 fi
1066         else
1067                 # Without pkg-config, we'll kludge in some defaults
1068                 CFLAGS="$CFLAGS_X -I$with_nss_compat_ossl/include -I/usr/include/nss3 -I/usr/include/nspr4"
1069                 LIBS="$LIBS_X -L$with_nss_compat_ossl/lib -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
1070         fi
1071         AC_CHECK_HEADERS(nss_compat_ossl/nss_compat_ossl.h,, [with_nss_compat_ossl=no], [#define NSS_COMPAT_OSSL_H])
1072         AC_CHECK_LIB(nss_compat_ossl, X509_free,, [with_nss_compat_ossl=no])
1074         if test "$with_nss_compat_ossl" = "no"; then
1075                 EL_RESTORE_FLAGS
1076         else
1077                 LIBS="$LIBS -lnss_compat_ossl"
1078                 EL_CONFIG(CONFIG_NSS_COMPAT_OSSL, [nss_compat_ossl])
1079                 chosen_ssl_library="nss_compat_ossl"
1080         fi
1083 # ---- OpenSSL
1085 AC_MSG_CHECKING([for OpenSSL])
1087 EL_SAVE_FLAGS
1089 if test "$with_openssl" = no; then
1090         cf_result="explicitly disabled"
1092 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "OpenSSL"; then
1093         cf_result="not used, because $chosen_ssl_library was chosen"
1095 else
1096         cf_result=no
1097         for ssldir in "$with_openssl" "" /usr /usr/local/openssl \
1098                          /usr/lib/openssl /usr/local/ssl \
1099                          /usr/local/www /usr/lib/ssl /usr/local \
1100                          /usr/pkg /opt /opt/openssl; do
1101                 if test "$cf_result" = no; then
1102                         if test -d "$ssldir"; then
1103                                 OPENSSL_CFLAGS="-I$ssldir/include"
1104                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1105                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1106                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1107 #                               # FIXME: This created serious portability problems. --pasky
1108 #                               if test "$CC" == "gcc"; then
1109 #                                       # I'm not sure about compatibility here. --pasky
1110 #                                       LIBS="$LIBS -R$ssldir/lib"
1111 #                               fi
1112                         else
1113                                 LIBS="-lssl -lcrypto $LIBS_X"
1114                         fi
1115                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1116                         if test "$cf_result" != yes; then
1117                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1118                         fi
1119                 fi
1120         done
1122         if test "$cf_result" != yes; then
1123                 if test "${with_openssl-no}" != "no"; then
1124                         AC_MSG_ERROR([OpenSSL not found])
1125                 fi
1126                 EL_RESTORE_FLAGS
1127         else
1128                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1129                 chosen_ssl_library="OpenSSL"
1131                 CFLAGS="$CFLAGS_X"
1132                 AC_SUBST(OPENSSL_CFLAGS)
1133         fi
1136 AC_MSG_RESULT($cf_result)
1138 # ---- GNU TLS
1140 # GnuTLS 2.2.0 changed libgnutls-openssl from GPLv2+
1141 # to GPLv3+.  Don't link that with the GPLv2 ELinks.
1142 # ELinks will use its internal MD5 code instead.
1143 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1145 if test "$with_gnutls" = no; then
1146         AC_MSG_CHECKING([[for GNUTLS]])
1147         AC_MSG_RESULT([[explicitly disabled]])
1149 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "GNUTLS"; then
1150         AC_MSG_CHECKING([[for GNUTLS]])
1151         AC_MSG_RESULT([[not used, because $chosen_ssl_library was chosen]])
1153 else
1154         cf_result=no
1155         AC_MSG_CHECKING([[for GNUTLS (1.2 or later) in pkg-config]])
1156         if $PKG_CONFIG --atleast-version=1.2 gnutls; then
1157                 GNUTLS_CFLAGS=`$PKG_CONFIG --cflags gnutls`
1158                 GNUTLS_LIBS=`$PKG_CONFIG --libs gnutls`
1159                 AC_MSG_RESULT([[yes: $GNUTLS_CFLAGS $GNUTLS_LIBS]])
1161                 EL_SAVE_FLAGS
1162                 LIBS="$GNUTLS_LIBS $LIBS"
1163                 CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
1164                 CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
1166                 # Verify if it's really usable.  gnutls_session was
1167                 # renamed to gnutls_session_t before GNU TLS 1.2.0
1168                 # (on 2004-06-13); ELinks now requires this.
1169                 AC_MSG_CHECKING([[whether GNUTLS can be linked with]])
1170                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]],
1171                                                 [[gnutls_session_t dummy;
1172                                                   gnutls_check_version(NULL)]])],
1173                                [cf_result=yes],
1174                                [cf_result=no])
1175                 AC_MSG_RESULT([[$cf_result]])
1177                 if test "$cf_result" = yes; then
1178                         # According to gnutls/NEWS, the function was originally
1179                         # added as gnutls_set_default_priority2 in GNUTLS 2.1.4
1180                         # (released 2007-10-27) and then renamed to
1181                         # gnutls_priority_set_direct in GNUTLS 2.1.7 (released
1182                         # 2007-11-29).
1183                         AC_CHECK_FUNCS([gnutls_priority_set_direct])
1184                 fi
1186                 EL_RESTORE_FLAGS
1187         else
1188                 AC_MSG_RESULT([[$cf_result]])
1189         fi
1191         if test "$cf_result" = yes; then
1192                 EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1193                 chosen_ssl_library="GNUTLS"
1195                 # gcry_create_nounce is part of libgcrypt
1196                 LIBGCRYPT_CFLAGS=`libgcrypt-config --cflags`
1197                 LIBGCRYPT_LIBS=`libgcrypt-config --libs`
1199                 LIBS="$LIBGCRYPT_LIBS $GNUTLS_LIBS $LIBS"
1200                 AC_SUBST(LIBGCRYPT_CFLAGS)
1201                 AC_SUBST(GNUTLS_CFLAGS)
1203         elif test "${with_gnutls-no}" != "no"; then
1204                 AC_MSG_ERROR([[GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.]])
1205         fi
1208 # Final SSL setup
1210 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS CONFIG_NSS_COMPAT_OSSL], [SSL])
1211 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1212 AC_SUBST(CONFIG_OPENSSL)
1213 AC_SUBST(CONFIG_GNUTLS)
1214 AC_SUBST(CONFIG_NSS_COMPAT_OSSL)
1216 #endif
1218 AC_MSG_CHECKING([whether to be or not to be])
1219 AC_MSG_RESULT([needs to be determined experimentally])
1221 # ===================================================================
1222 # Check for IPv6 support and related functions.
1223 # ===================================================================
1225 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1226 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1227 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1229 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1230 if test "$HAVE_GETADDRINFO" != yes; then
1231         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1232         if test "$HAVE_GETADDRINFO" = yes; then
1233                 LIBS="$LIBS -linet6"
1234         fi
1238 # ===================================================================
1239 # Checking for X11 (window title restoring).
1240 # ===================================================================
1242 AC_PATH_X
1243 if test x"$no_x" != xyes; then
1244         EL_SAVE_FLAGS
1245         if test -n "$x_includes"; then
1246                 X_CFLAGS="-I$x_includes"
1247                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1248                 CFLAGS="$CFLAGS $X_CFLAGS"
1249         fi
1250         if test -n "$x_libraries"; then
1251                 LDFLAGS="$LDFLAGS -L$x_libraries"
1252         fi
1253         LIBS="-lX11 $LIBS"
1254         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1255         EL_RESTORE_FLAGS
1256         if test "$cf_result" = yes; then
1257                 if test -n "$x_libraries"; then
1258                         LDFLAGS="$LDFLAGS -L$x_libraries"
1259                 fi
1260                 LIBS="-lX11 $LIBS"
1261                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1262                 AC_SUBST(X_CFLAGS)
1263         fi
1267 # ===================================================================
1268 # Backtraces displaying support.
1269 # ===================================================================
1271 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1272 # possible checks for other system-specific means go here
1275 # ===================================================================
1276 # Gettext grey zone. Beware.
1277 # ===================================================================
1279 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"
1281 AM_GNU_GETTEXT
1283 # iconv is always used
1284 LIBS="$LIBS $LIBICONV"
1286 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1287 dnl # f33r d4 l33t... I hope it's portable. :)
1288 dnl cf_result=$((48#z - 48#a + 1));
1289 dnl AC_MSG_RESULT($cf_result)
1292 # ===================================================================
1293 # Compile-time features control
1294 # ===================================================================
1296 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1297               [  --disable-cookies       disable cookie support])
1299 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1300               [  --disable-formhist      disable form history support])
1302 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1303               [  --disable-globhist      disable global history support])
1306 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1307               [  --disable-mailcap       disable mailcap support])
1309 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1310               [  --disable-mimetypes     disable mimetypes files support])
1313 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1314               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1315               [IPv6],
1316               [  --disable-ipv6          disable IPv6 support])
1318 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1319               [  --enable-bittorrent     enable BitTorrent protocol support])
1321 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1322               [  --disable-data          disable data protocol support])
1324 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1325               [  --disable-uri-rewrite   disable URI rewrite support])
1327 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1328               [  --enable-cgi            enable local CGI support])
1330 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1331               [  --enable-finger         enable finger protocol support])
1333 # ===================================================================
1334 # FSP protocol
1335 # ===================================================================
1336 EL_SAVE_FLAGS
1338 if test "x${enable_fsp}" != xno; then
1339         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1341         if test "$HAVE_FSPLIB" = yes; then
1342                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1343                 if test "$HAVE_FSPLIB" = yes; then
1344                         LIBS="$LIBS -lfsplib"
1345                 else
1346                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1347                         if test "$HAVE_FSPLIB" = yes; then
1348                                 LIBS="$LIBS -lfsp"
1349                         fi
1350                 fi
1351         fi
1354 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1355               [  --enable-fsp            enable FSP protocol support])
1357 if test "x$CONFIG_FSP" = xno; then
1358         EL_RESTORE_FLAGS
1361 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1362               [  --disable-ftp           disable ftp protocol support])
1364 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1365               [  --enable-gopher         enable gopher protocol support])
1367 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1368               [  --enable-nntp           enable nntp protocol support])
1370 # ===================================================================
1371 # SMB protocol support.
1372 # ===================================================================
1373 EL_SAVE_FLAGS
1375 if test "x${enable_smb}" != xno; then
1376         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1378         if test "$HAVE_SMBCLIENT" = yes; then
1379                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1380                 if test "$HAVE_SMBCLIENT" = yes; then
1381                         LIBS="$LIBS -lsmbclient"
1382                 fi
1383         fi
1386 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1387               [  --enable-smb            enable Samba protocol support])
1389 if test "x$CONFIG_SMB" = xno; then
1390         EL_RESTORE_FLAGS
1394 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1395               [  --disable-mouse         disable mouse support])
1397 # GPM mouse is Linux specific, so ...
1398 CONFIG_SYSMOUSE=yes
1399 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1400               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1401               [BSD sysmouse],
1402               [  --disable-sysmouse      disable BSD sysmouse support])
1404 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1405               [  --enable-88-colors      enable 88 color support])
1407 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1408               [  --enable-256-colors     enable 256 color support])
1410 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1411               [  --enable-true-color     enable true color support])
1413 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1414               [  --enable-exmode         enable exmode (CLI) interface])
1416 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1417               [  --disable-leds          disable LEDs support])
1419 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1420               [  --disable-marks         disable document marks support])
1423 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1424               [  --disable-css           disable Cascading Style Sheet support])
1426 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1427               [  --enable-html-highlight HTML highlighting using DOM engine])
1429 # Everything in the tree already uses CONFIG_DOM
1430 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1431 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1433 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1434               [  --disable-backtrace     disable backtrace support])
1436 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1437               [  --enable-no-root        enable prevention of usage by root])
1440 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1441               [  --enable-debug          enable leak debug and internal error checking])
1443 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1444               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1446 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1447               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1449 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1450               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1452 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1453               [  --disable-utf-8         disable UTF-8 support])
1455 EL_ARG_DEPEND(CONFIG_COMBINE, combining, [CONFIG_UTF8:yes HAVE_WCWIDTH:yes], [Combining characters],
1456               [  --enable-combining      support Unicode combining characters (experimental)])
1459 AC_ARG_ENABLE(weehoofooboomookerchoo,
1460               [
1461     Also check out the features.conf file for more information about features!
1462               ],
1463               [AC_MSG_ERROR(Are you strange, or what?)])
1466 # ===================================================================
1467 # Decide whether to use TRE
1468 # ===================================================================
1470 # This must be done after the CONFIG_UTF8 check above.
1471 # The first part of the TRE check is separate, to get
1472 # the configure --help output in a sensible order.
1474 # After this section, nothing else must be added to the
1475 # beginning of $LIBS.
1477 if test "$tre_log" = "available"; then
1478         if test "$CONFIG_UTF8" = "yes"; then
1479                 # When CONFIG_UTF8 and CONFIG_TRE are both defined,
1480                 # src/viewer/text/search.c makes a string of
1481                 # unicode_val_T and gives it to regwexec(), which
1482                 # expects a string of wchar_t.  If the unicode_val_T
1483                 # and wchar_t types are too different, this won't
1484                 # work, so try to detect that and disable regexp
1485                 # operations entirely in that case.
1486                 #
1487                 # Currently, this code only compares the sizes of the
1488                 # types.  src/intl/charsets.h defines unicode_val_T as
1489                 # uint32_t, so we check whether wchar_t has exactly 32
1490                 # bits.  But don't use AC_CHECK_SIZEOF for this, because
1491                 # there doesn't seem to be a documented way to get the
1492                 # result of that for use in the configure script.
1493                 #
1494                 # C99 says the implementation can define
1495                 # __STDC_ISO_10646__ if wchar_t values match ISO 10646
1496                 # (or Unicode) numbers in all locales.  Do not check
1497                 # that macro here, because it is too restrictive: it
1498                 # should be enough for ELinks if the values match in
1499                 # the locales where ELinks is actually run.
1500                 AC_MSG_CHECKING([[whether wchar_t is exactly 32-bit]])
1501                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1502 #include <limits.h>
1503 #include <stddef.h>
1504 int dummy[(sizeof(wchar_t) * CHAR_BIT == 32) ? 1 : -1];]], [])],
1505                         [AC_MSG_RESULT([[yes]])
1506                          tre_log="TRE"],
1507                         [AC_MSG_RESULT([[no]])
1508                          tre_log="no (unsuitable wchar_t)"])
1509         else
1510                 # If UTF-8 is not used, then wchar_t doesn't matter.
1511                 tre_log="TRE"
1512         fi
1515 if test "$tre_log" = "TRE"; then
1516         AC_DEFINE([CONFIG_TRE], [1],
1517                 [Define as 1 to use the TRE library for regular expression searching.  This requires the <tre/regex.h> header file.  If you define CONFIG_UTF8 too, then wchar_t must be exactly 32-bit so that it matches unicode_val_T.])
1518         # TRE_CFLAGS will be used only where needed.
1519         #
1520         # Bug 1081: If both TRE and libc define the regfree function,
1521         # ELinks needs to use the version defined by TRE because
1522         # that's the one compatible with regex_t initialized by the
1523         # regwcomp function of TRE.  Therefore put $TRE_LIBS at the
1524         # very beginning of $LIBS so that the linker hopefully finds
1525         # regfree there before it examines libc.  In particular,
1526         # $PERL_LIBS appears to often include "-lc".
1527         #
1528         # This scheme still risks a crash if ELinks is linked with
1529         # some static library that uses GNU <regex.h> extensions that
1530         # TRE does not implement.  For example, the library might call
1531         # re_compile_pattern, which is found in GNU libc, and then
1532         # regfree, which is found in TRE and probably crashes with the
1533         # GNU-initialized regex_t.  Ways to avoid such crashes:
1534         #
1535         # - Change TRE so it defines only tre_... functions and does
1536         #   not attempt to override the POSIX names by default.
1537         #
1538         # - Change ELinks to access TRE only via dlopen and dlsym.
1539         #   The problem then is how to find the correct file name.
1540         #   There might be libtre.so.4 and libtre.so.5 with different
1541         #   ABI.  How can this configure script detect which of them
1542         #   matches the <tre/regex.h> in the include path?
1543         #
1544         # - Replace the static library with a shared library.  At
1545         #   least on GNU/Linux, when the shared library is built, the
1546         #   linker should note that e.g. regfree is defined in libc
1547         #   and has the GLIBC_2.0 version there, and write that
1548         #   version string to the shared library as well; because TRE
1549         #   does not provide regfree with that version, any regfree
1550         #   calls at run time should then get resolved to libc.
1551         LIBS="$TRE_LIBS $LIBS"
1552 else
1553         TRE_LIBS=
1554         TRE_CFLAGS=
1556 AC_SUBST(TRE_CFLAGS)
1557 AC_SUBST(TRE_LIBS)
1558 EL_LOG_CONFIG([CONFIG_TRE], [[Regexp searching]], [[$tre_log]])
1561 # ===================================================================
1562 # Further LDFLAGS tweaks
1563 # ===================================================================
1565 # == EMX hack
1567 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1568 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1571 # Check for -rdynamic
1573 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
1574 # the executable to its dynamic symbol table.  ELinks uses this for
1575 # two purposes:
1577 # 1. If ELinks detects a bug, it can try to display a backtrace by
1578 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
1579 #    manual states users of GNU ld must pass -rdynamic to make the
1580 #    symbols available to the program.
1582 # 2. It would eventually be nice to dynamically load shared
1583 #    libraries as plugins (bug 73).  The plugins must be able to
1584 #    call ELinks functions.  This can be implemented either by
1585 #    registering all callable functions in ELinks-specific data
1586 #    structures, or by letting the dynamic linker handle them.
1587 #    The latter way requires something equivalent to -rdynamic.
1589 # Because backtraces are not needed for correct operation, and bug
1590 # 73 is not yet being fixed, the configure script and makefiles
1591 # should not complain to the user if they find that -rdynamic does
1592 # not work.  Besides, it was reported at elinks-users on 2006-09-12
1593 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
1594 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
1595 # -rdynamic but does something equivalent automatically.  (This was
1596 # tested with "nm -D elinks | grep redraw_from_window".)
1598 # With Sun Studio 11 on Solaris 9, we get "cc: Warning: illegal option
1599 # -dynamic"; then, cc proceeds anyway, but the option can prevent the
1600 # linker from finding the libraries listed in -l operands.  So this
1601 # -rdynamic check needs to happen after the libraries have already
1602 # been added to $LDFLAGS.
1603 AC_MSG_CHECKING([for -rdynamic])
1604 LDFLAGS_X="$LDFLAGS"
1605 LDFLAGS="-rdynamic $LDFLAGS"
1606 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
1607 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
1608 AC_MSG_RESULT($have_rdynamic)
1610 # ===================================================================
1611 # Export directory paths
1612 # ===================================================================
1614 # Set up the ``entry points'' if they were not supplied by builder
1615 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1616 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1618 # Create CONFDIR #define for config.h
1620 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1621 # it's autoconf fault to force us to do such hacks ;p.
1622 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1623   # sysconfdir is set to its default value... fine, let's append /elinks/
1624   # XXX: We can't modify listing of the default in ./configure --help :-(
1625   sysconfdir_n=`eval echo "$sysconfdir"`
1626   sysconfdir=$sysconfdir_n
1627   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1628         sysconfdir="$sysconfdir/elinks"
1631 CONFDIR=$sysconfdir
1632 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1633 AC_SUBST(CONFDIR)
1635 # Create LOCALEDIR #define for config.h
1636 LOCALEDIR=`eval echo "$datadir/locale"`
1637 while echo "$LOCALEDIR" | grep "\\$"
1639         LOCALEDIR=`eval echo "$LOCALEDIR"`
1640 done > /dev/null 2> /dev/null
1641 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1642 AC_SUBST(LOCALEDIR)
1644 # Create LIBDIR #define for config.h
1645 LIBDIR=`eval echo "$libdir"`
1646 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1647 AC_SUBST(LIBDIR)
1649 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1650 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1653 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1654 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1655         #error not tcc
1656         #endif ]])],[cf_result=yes],[cf_result=no])
1658 if test "$cf_result" = "yes"; then
1659         AC_DEFINE([HAVE_ALLOCA])
1660         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1661                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1662                 override the alloca macro defined in <stddef.h> of TCC.
1663                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1664                 it has already been included, and does not redefine alloca.
1665                 This might not work in future glibc versions though, because
1666                 the names of the #include guard macros are not documented.
1667                 The incompatibility has been reported to the tinycc-devel
1668                 mailing list on 2008-07-14.  If a future version of TCC provides
1669                 an <alloca.h> of its own, this hack won't be needed.])
1671 # ===================================================================
1672 # A little fine tuning of gcc specific options (continued)
1673 # ===================================================================
1675 GETTEXT_CFLAGS=
1676 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1677   if test "$CONFIG_DEBUG" = "yes"; then
1678     # We want to see all warnings and live with none (in debug mode).
1679     CFLAGS="$CFLAGS -Werror"
1680   fi
1681   GETTEXT_CFLAGS="-Wno-uninitialized"
1683   case "`$CC -dumpversion`" in
1684     3.0|3.1|3.2)
1685       # These should be ok using -Werror
1686       ;;
1687     3.*)
1688       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1689       # "dereferencing type-punned pointer will break strict-aliasing rules"
1690       # warnings. Disable them by not doing any strict-aliasing. The
1691       # alternative is just too ugly. Thanks gcc guys!! ;)
1692       CFLAGS="$CFLAGS -fno-strict-aliasing"
1693       ;;
1694     4.5*)
1695       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign -Wno-enum-compare"
1696       ;;
1697     4.*)
1698       # Do not show warnings related to (char * | unsigned char *) type
1699       # difference.
1700       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1701       ;;
1702     *)
1703       # These should be ok using -Werror
1704       ;;
1705   esac
1707   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1708   # warning: the address of `builtin_modules' will always evaluate as `true'
1709   # This hits the object_lock and foreach_module macros in particular.
1710   # It would be okay to put something in the macros to avoid the warning,
1711   # but currently this seems to require defining parallel macros that skip
1712   # the NULL check, and that's too ugly.  So we instead disable the warning.
1713   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1714   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1715   for warning_flag in -Wno-address -Wno-always-true; do
1716     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1717     EL_SAVE_FLAGS
1718     CFLAGS="$CFLAGS $warning_flag"
1719     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1720       [AC_MSG_RESULT([yes])
1721        break],
1722       [AC_MSG_RESULT([no])])
1723     EL_RESTORE_FLAGS
1724   done
1726   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1727   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1728   # "warning: assuming signed overflow does not occur when assuming
1729   # that (X + c) > X is always true", which may be an incorrect
1730   # optimization (although allowed by the standard), and breaks the
1731   # build with -Werror.
1732   #
1733   # All of the following tests included -S -Wall -Wextra:
1734   #
1735   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1736   # * gcc-4.0 -O0: OK, compares the values
1737   # * gcc-4.0 -O2: assumes no overflow, does not warn
1738   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1739   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1740   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1741   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1742   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1743   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1744   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1745   #
1746   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1747   # * gcc-4.1 -O0: assumes no overflow, does not warn
1748   # * gcc-4.1 -O2: assumes no overflow, does not warn
1749   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1750   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1751   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1752   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1753   # * gcc-4.1 -O2 -ftrapv: compares the values
1754   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1755   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1756   #
1757   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1758   # * gcc-4.2 -O0: OK, compares the values
1759   # * gcc-4.2 -O2: assumes no overflow, warns about it
1760   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1761   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1762   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1763   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1764   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1765   # * gcc-4.2 -O2 -ftrapv: compares the values
1766   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1767   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1768   #
1769   # Apparently, -ftrapv does not work reliably at all.
1770   for overflow_flag in -fno-strict-overflow -fwrapv; do
1771     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1772     EL_SAVE_FLAGS
1773     CFLAGS="$CFLAGS $overflow_flag"
1774     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1775       [AC_MSG_RESULT([yes])
1776        break],
1777       [AC_MSG_RESULT([no])])
1778     EL_RESTORE_FLAGS
1779   done
1782 AC_SUBST(GETTEXT_CFLAGS)
1783 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1784 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1785 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1786 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1788 # ===================================================================
1789 # Colored make output
1790 # ===================================================================
1792 if test $(`which tput` colors 2> /dev/null || echo 0) -ge 4; then
1793         MAKE_COLOR=1
1794         AC_SUBST(MAKE_COLOR)
1797 # ===================================================================
1798 # Generated files
1799 # ===================================================================
1801 AC_CONFIG_FILES([ \
1802  Makefile.config \
1803  contrib/elinks.spec \
1804  contrib/lua/hooks.lua \
1805  contrib/conv/w3m2links.awk \
1806  doc/Doxyfile \
1807  doc/man/man1/elinks.1 \
1808  src/intl/gettext/ref-add.sed \
1809  src/intl/gettext/ref-del.sed
1811 AC_OUTPUT
1813 abs_srcdir="$(cd "$srcdir" && pwd)"
1814 # builddir is always absolute!
1815 if test "$abs_srcdir" != "$builddir"; then
1816         # Bootstrap the Makefile creation
1817         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1818         "$MAKE" "SRC=$abs_srcdir" init
1820         # Make cg-status ignore this build directory
1821         echo "*" > "$builddir/.gitignore"
1824 # ===================================================================
1825 # Configuration summary
1826 # ===================================================================
1828 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1829 cat features.log