SpiderMonkey: fix issue with javascript:history.back()
[elinks.git] / configure.in
blob6055a0e05ff60122bec922abd59459455d08def2
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 CONFIG_ASCIIDOC="no"
70 CONFIG_POD2HTML="no"
71 CONFIG_XMLTO="no"
72 CONFIG_JW="no"
74 if test "x$CONFIG_DOC" != xno; then
75         AC_PATH_PROGS(PYTHON, "python")
76         if test "x$PYTHON" != "x"; then
77                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
78                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
79                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
80         fi
82         AC_PATH_PROGS(XMLTO, "xmlto")
83         if test "x$XMLTO" != "x"; then
84                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
85                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
86                 EL_CONFIG(MAN_XMLTO, [man (groff)])
87         fi
89         AC_PATH_PROGS(JW, "jw")
90         if test "x$JW" != "x"; then
91                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
92                 EL_CONFIG(MANUAL_JW, [PDF])
93         fi
95         AC_PATH_PROGS(POD2HTML, "pod2html")
96         if test "x$POD2HTML" != "x"; then
97                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
98         fi
100         AC_PATH_PROGS(DOXYGEN, "doxygen")
101         if test "x$DOXYGEN" != "x"; then
102                 EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
103                 api_srcdir="$(cd "$srcdir" && pwd)/src"
104                 AC_SUBST(api_srcdir)
105         fi
108 AC_SUBST(CONFIG_ASCIIDOC)
109 AC_SUBST(CONFIG_DOXYGEN)
110 AC_SUBST(CONFIG_POD2HTML)
111 AC_SUBST(CONFIG_XMLTO)
112 AC_SUBST(CONFIG_JW)
114 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation Tools])
115 EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
116 EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
117 EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
119 # gcc specific options (to be continued at the bottom of configure)
120 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
121   # We want to see all warnings and live with none.
122   # We can't set up -Werror here as there may be some warnings in test
123   # suite of configure, and we don't want to fail them.
124   CFLAGS="$CFLAGS -Wall"
127 # ===================================================================
128 # Checks for special OSes.
129 # ===================================================================
131 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
132 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
134         AC_MSG_CHECKING([for $2])
136         for flag in $3; do
137                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
138 kill me!
139 #endif ]])],[$1=yes],[$1=no])
140                 if test "[$]$1" = yes; then
141                         EL_CONFIG([$1], [$2])
142                         break
143                 fi
144         done
146         AC_MSG_RESULT([$]$1)
149 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
150 AC_SUBST(CONFIG_OS_BEOS)
152 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
153 AC_SUBST(CONFIG_OS_RISCOS)
155 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
156 AC_SUBST(CONFIG_OS_WIN32)
158 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
159 AC_SUBST(CONFIG_OS_OS2)
160 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
162 AC_MSG_CHECKING([for UNIX])
163 dnl FIXME: some depend kind of mechanism
164 if test "$CONFIG_OS_BEOS" = no && \
165    test "$CONFIG_OS_RISCOS" = no && \
166    test "$CONFIG_OS_WIN32" = no && \
167    test "$CONFIG_OS_OS2" = no; then
168         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
169 else
170         CONFIG_OS_UNIX=no
172 AC_MSG_RESULT($CONFIG_OS_UNIX)
173 AC_SUBST(CONFIG_OS_UNIX)
175 # ===================================================================
176 # Checks for header files.
177 # ===================================================================
179 AC_HEADER_DIRENT
180 AC_HEADER_STDC
181 AC_HEADER_SYS_WAIT
182 AC_HEADER_TIME
184 AC_CHECK_HEADERS(wchar.h wctype.h)
185 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
186 AC_CHECK_HEADERS(sigaction.h)
187 AC_CHECK_HEADERS(arpa/inet.h)
188 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
189 AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/in6_var.h)
190 AC_CHECK_HEADERS(ifaddrs.h)
191 AC_CHECK_HEADERS(sys/cygwin.h io.h)
192 AC_CHECK_HEADERS(sys/fmutex.h)
193 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
194 AC_CHECK_HEADERS(sys/resource.h)
195 AC_CHECK_HEADERS(sys/select.h)
196 AC_CHECK_HEADERS(sys/signal.h)
197 AC_CHECK_HEADERS(sys/socket.h)
198 AC_CHECK_HEADERS(sys/time.h)
199 AC_CHECK_HEADERS(sys/utsname.h)
200 AC_CHECK_HEADERS([net/if.h], [], [],
201 [[#ifdef HAVE_SYS_SOCKET_H
202 # include <sys/socket.h> /* <net/if.h> on Mac OS X 10.5.4 needs this */
203 #endif
205 AC_CHECK_HEADERS(stdint.h inttypes.h)
206 AC_CHECK_HEADERS(locale.h pwd.h)
207 AC_CHECK_HEADERS(termios.h)
210 AC_CHECK_HEADERS(sys/un.h,
211         [CONFIG_INTERLINK=yes
212          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
213         [CONFIG_INTERLINK=no])
214 AC_SUBST(CONFIG_INTERLINK)
216 # ===================================================================
217 # Checks for typedefs, structures, and compiler characteristics.
218 # ===================================================================
220 AC_STRUCT_TM
221 AC_C_CONST
222 AC_C_INLINE
223 AC_MSG_CHECKING([[for C99-conforming inline]])
224 AC_COMPILE_IFELSE([[
225         int add(int change);
227         static int sum;
229         inline int
230         add(int change)
231         {
232                 sum += change;
233                 return sum;
234         }
236         int
237         sub(int change)
238         {
239                 return add(-change);
240         }]],
241         [AC_MSG_RESULT([[yes]])
242          AC_DEFINE([NONSTATIC_INLINE], [inline],
243                 [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.])],
244         [AC_MSG_RESULT([[no]])
245          AC_DEFINE([NONSTATIC_INLINE], [])])
246 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
248 AC_SYS_LARGEFILE
249 AC_TYPE_SIZE_T
250 AC_TYPE_OFF_T
251 EL_CHECK_TYPE(ssize_t, int)
252 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
253 EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
254 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
255 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
256 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
258 AC_CHECK_SIZEOF(char, 1)
259 AC_CHECK_SIZEOF(short, 2)
260 AC_CHECK_SIZEOF(int, 4)
261 AC_CHECK_SIZEOF(long, 4)
262 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
263 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
265 # Check for variadic macros
266 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
267                 [#include <stdio.h>
268                  #define a(b,c...) printf(b,##c)],
269                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
271 # ===================================================================
272 # Checks for library functions.
273 # ===================================================================
275 AC_PROG_GCC_TRADITIONAL
276 AC_FUNC_MEMCMP
277 AC_FUNC_MMAP
278 AC_FUNC_STRFTIME
279 AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
280 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
281 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
282 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
283 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
284 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
285 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
286 AC_CHECK_FUNCS(gettimeofday clock_gettime)
287 AC_CHECK_FUNCS(setitimer, HAVE_SETITIMER=yes)
289 AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
291 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
292 AC_CHECK_FUNCS(unsetenv)
293 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
294 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
296 AC_CHECK_FUNCS(wcwidth, HAVE_WCWIDTH=yes)
298 # These aren't probably needed now, as they are commented in links.h.
299 # I've no idea about their historical background, but I keep them here
300 # just in the case they will help later. --pasky
301 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
302 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
303 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
304 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
306 AC_CHECK_FUNCS(fpathconf, HAVE_FPATHCONF=yes)
308 if test x"$HAVE_RAISE" = x; then
309         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
310                 AC_MSG_ERROR([Unable to emulate raise()])
311         fi
314 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
315 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
316 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
317 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
318         EL_DEFINE(HAVE_VA_COPY, __va_copy)
321 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
322 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
323 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
324 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
325         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
328 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
329 AC_RUN_IFELSE([AC_LANG_SOURCE([[
330 #include <stdio.h>
331 #include <stdarg.h>
332 #include <stdlib.h>
333 #include <string.h>
335 char buf[8];
337 int bar(char *buf, const char *format, va_list ap)
339        return vsnprintf(buf, 0, format, ap);
342 void foo(const char *format, ...) {
343        va_list ap;
344        int len;
346        va_start(ap, format);
347        len = bar(buf, format, ap);
348        va_end(ap);
349        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
351        va_start(ap, format);
352        len = bar(buf, format, ap);
353        va_end(ap);
354        if ((len != 6) && (len != 7)) exit(1);
356        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
358        exit(0);
360 main() { foo("hello\n"); }
361 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
362 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
363         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
366 # OpenSSL and Lua frequently need dlopen
367 AC_CHECK_LIB(dl, dlopen)
369 # ===================================================================
370 # Checks for libraries.
371 # ===================================================================
373 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
374 if test "$cf_result" = no; then
375         AC_CHECK_LIB(socket, socket)
378 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
379 if test "$cf_result" = no; then
380         AC_CHECK_LIB(socket, setsockopt)
383 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
384 if test "$cf_result" = no; then
385         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
386         if test "$cf_result" = no; then
387                 AC_CHECK_LIB(nsl, gethostbyname)
388         else
389                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
390         fi
393 # ===================================================================
394 # Checks for packaging specific options.
395 # ===================================================================
397 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
398             [ if test "$withval" != no && test "$withval" != yes; then
399                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
400               fi ])
402 # ===================================================================
403 # Checks for a libraries, optional even if installed.
404 # ===================================================================
406 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
407 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
409         AC_MSG_CHECKING([for $2 support])
411         if test "[$]$1" != no; then
412                 AC_MSG_RESULT(yes)
413                 EL_SAVE_FLAGS
414                 if test -n "$withval" && test -d "$withval"; then
415                         # Be a little more careful when setting
416                         # include and lib directories. This way
417                         # $withval will work when includes are
418                         # there but the library is in the common
419                         # /usr/lib ... Does the right thing when
420                         # looking for gc on Debian.
421                         if test -d "$withval/include"; then
422                                 CFLAGS="$CFLAGS -I$withval/include"
423                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
424                         else
425                                 CFLAGS="$CFLAGS -I$withval"
426                                 CPPFLAGS="$CPPFLAGS -I$withval"
427                         fi
428                         if test -d "$withval/lib"; then
429                                 LDFLAGS="$LDFLAGS -L$withval/lib"
430                         fi
431                 fi
433                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
434                 if test "[$]$1" = yes; then
435                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
436                 fi
438                 if test "[$]$1" = yes; then
439                         EL_CONFIG([$1], [$2])
440                         LIBS="$LIBS -l$4"
441                 else
442                         if test -n "[$]WITHVAL_$1" &&
443                            test "[$]WITHVAL_$1" != xno; then
444                                 AC_MSG_ERROR([$2 not found])
445                         fi
446                         EL_RESTORE_FLAGS
447                 fi
448         else
449                 AC_MSG_RESULT(disabled)
450         fi
453 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
454 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
456         if test "x[$]$1" != xno; then $1=yes; fi
457         WITHVAL_$1=
459         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
460         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
461         if test "x[$]WITHVAL_$1" = xyes; then $1=yes; fi
463         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
465         EL_LOG_CONFIG([$1], [$2], [])
468 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
469         [  --without-gpm           disable gpm (mouse) support])
471 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
472 # enable automatic decoding of both zlib and gzip headers.  This
473 # feature was added in zlib 1.2.0.2; earlier versions return an error.
474 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
475 # that, even though ELinks does not actually call gzclearerr.
476 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
477         [  --without-zlib          disable zlib support])
479 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
480         [  --without-bzlib         disable bzlib support])
482 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
483         [  --without-idn           disable international domain names support])
485 if test "x${with_gc}" != xno; then
486         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
487                 [  --with-gc               enable Boehm's garbage collector])
490 # LZMA disabled by default, because of little usability and compilation problems
491 # with new xz
492 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
493         [  --with-lzma             enable lzma encoding support])
495 # ===================================================================
496 # Check for GSSAPI, optional even if installed.
497 # ===================================================================
499 enable_gssapi="no";
501 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
502             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
504 AC_MSG_CHECKING([for GSSAPI])
506 if test "$enable_gssapi" = "yes"; then
507         AC_MSG_RESULT(yes)
508         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
509         GSSAPI_LIBS=`krb5-config --libs gssapi`
510         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
511         LIBS="$GSSAPI_LIBS $LIBS"
512         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
513 else
514         AC_MSG_RESULT(no)
517 AC_SUBST(CONFIG_GSSAPI)
519 # ===================================================================
520 # Bookmark and XBEL support
521 # ===================================================================
523 EL_SAVE_FLAGS
525 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
526               [  --disable-bookmarks     disable bookmark support])
528 # Check whether --enable-xbel or --disable-xbel was given.
529 if test "x${enable_xbel}" != xno; then
530         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
532         if test "$HAVE_LIBEXPAT" = yes; then
533                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
534                 if test "$HAVE_LIBEXPAT" = yes; then
535                         LIBS="$LIBS -lexpat"
536                 fi
537         fi
541 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
542               [XBEL bookmarks],
543               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
545 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
546         EL_RESTORE_FLAGS
549 # ===================================================================
550 # Checks for BSD sysmouse
551 # ===================================================================
553 HAVE_SYSMOUSE_HEADER="no"
555 # Either of these header files provides the (same) sysmouse interface
556 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
558 # ===================================================================
559 # Checks for OS/2
560 # ===================================================================
562 if test "$CONFIG_OS_OS2" = yes; then
563         EL_CONFIG_OS_OS2
566 # ===================================================================
567 # Checks for Win32
568 # ===================================================================
570 if test "$CONFIG_OS_WIN32" = yes; then
571         EL_CONFIG_OS_WIN32
574 # ===================================================================
575 # Check for SEE (Simple Ecmascript Engine)
576 # ===================================================================
577 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
578             [ if test "x$withval" != xno; then enable_see=yes; fi ])
580 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
581 # GUILE_FLAGS but I really don't want to require people to have Guile in order
582 # to compile CVS. Also, the macro seems to be really stupid regarding searching
583 # for Guile in $PATH etc. --pasky
585 CONFIG_ECMASCRIPT_SEE=no
587 if test "$enable_see" = "yes"; then
588         if test -d "$withval"; then
589                 SEE_PATH="$withval:$PATH"
590         else
591                 SEE_PATH="$PATH"
592         fi
594         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
595         AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
596         if test "$SEE_CONFIG" != no; then
597                 EL_SAVE_FLAGS
598                 SEE_LIBS="`$SEE_CONFIG --libs`"
599                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
600                 CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
601                 LIBS="$SEE_LIBS $LIBS_X"
602                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
603                         #error SEE too old
604                         #endif
605                 ]])],[cf_result=yes],[cf_result=no])
606                 EL_RESTORE_FLAGS
607                 if test "$cf_result" = yes; then
608                         LIBS="$SEE_LIBS $LIBS"
609                         EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
610                         AC_SUBST(SEE_CFLAGS)
611                 fi
612                 AC_MSG_RESULT($cf_result)
613         else
614                 if test -n "$withval" && test "x$withval" != xno; then
615                         AC_MSG_ERROR([SEE not found])
616                 else
617                         AC_MSG_WARN([SEE support disabled])
618                 fi
619         fi
622 # ===================================================================
623 # Check for SpiderMonkey, optional even if installed.
624 # ===================================================================
626 xulrunner_includes=
627 xulrunner_libs=
628 AC_ARG_WITH(xulrunner_includes, [  --with-xulrunner_includes=DIR
629                           When set, the libmozjs of xulrunner is used instead of "standalone" SpiderMonkey],
630             [xulrunner_includes="$withval"])
631 AC_ARG_WITH(xulrunner_libs, [  --with-xulrunner_libs=OPTIONS
632                           Linker options for xulrunner,
633                           eg. --with-xulrunner_libs="-Wl,-R/usr/lib/xulrunner -L/usr/lib/xulrunner -lmozjs"],
634             [xulrunner_libs="$withval"])
635 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
636             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
638 AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
640 EL_SAVE_FLAGS
641 cf_result=no
643 if test -z "$disable_spidermonkey"; then
644         if test ! -d "$withval"; then
645                 withval="";
646         fi
647         if test ! -z "$xulrunner_includes"; then
648                 SPIDERMONKEY_LIBS="$xulrunner_libs"
649                 SPIDERMONKEY_CFLAGS="-I$xulrunner_includes"
650                 LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
651                 CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
652                 CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
654                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
655                 #include <jsapi.h>]], [[
656                 #ifndef JS_VERSION
657                 #error JS_VERSION
658                 #endif
659                 #if JS_VERSION < 185
660                 #error too old
661                 #endif]])],
662                 [cf_result=yes],[cf_result=no])
663         else
664                 for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
665                         for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do
666                                 for spidermonkeylib in js smjs mozjs; do
667                                         if test "$cf_result" = no; then
668                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib"
669                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
671                                                 LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
672                                                 CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
673                                                 CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
675                                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
676                                                         #define XP_UNIX
677                                                         #include <jsapi.h>]], [[
678                                                         #ifndef JS_VERSION
679                                                         #error JS_VERSION
680                                                         #endif
681                                                         #if JS_VERSION < 185
682                                                         #error too old
683                                                         #endif]])],
684                                                         [cf_result=yes],[cf_result=no])
685                                         fi
686                                 done
687                         done
688                 done
689         fi
692 AC_MSG_RESULT($cf_result)
693 CONFIG_SPIDERMONKEY="$cf_result"
694 if test "$cf_result" = "yes"; then
695         AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]])
696         AC_CHECK_FUNCS(JS_SetBranchCallback)
697         AC_CHECK_FUNCS(JS_TriggerOperationCallback, HAVE_JS_TRIGGEROPERATIONCALLBACK=yes)
699 EL_RESTORE_FLAGS
701 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
702    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
703         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
704 else
705         CONFIG_ECMASCRIPT_SMJS=no
708 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
709 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
710 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
712 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
713    test "x$HAVE_JS_TRIGGEROPERATIONCALLBACK" = xyes &&
714    test "x$HAVE_SETITIMER" = xyes; then
715         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT, [ECMAScript heartbeat support])
716 else
717         CONFIG_ECMASCRIPT_SMJS_HEARTBEAT=no
719 AC_SUBST(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
722 # ===================================================================
723 # Optional Spidermonkey-based ECMAScript browser scripting
724 # ===================================================================
726 AC_ARG_ENABLE(sm-scripting,
727               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
728               [if test "$enableval" != no; then enableval="yes"; fi
729                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
731 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
732    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
733         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
734 else
735         CONFIG_SCRIPTING_SPIDERMONKEY=no
738 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
739    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
740         LIBS="$LIBS $SPIDERMONKEY_LIBS"
741         AC_SUBST(SPIDERMONKEY_LIBS)
742         AC_SUBST(SPIDERMONKEY_CFLAGS)
743         AC_SUBST(CONFIG_SPIDERMONKEY)
746 # ===================================================================
747 # Check for Guile, optional even if installed.
748 # ===================================================================
750 enable_guile="no";
752 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
753             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
755 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
756 # GUILE_FLAGS but I really don't want to require people to have Guile in order
757 # to compile CVS. Also, the macro seems to be really stupid regarding searching
758 # for Guile in $PATH etc. --pasky
760 AC_MSG_CHECKING([for Guile])
762 if test "$enable_guile" = "yes"; then
763         AC_MSG_RESULT(yes);
764         ## Based on the GUILE_FLAGS macro.
766         if test -d "$withval"; then
767                 GUILE_PATH="$withval:$PATH"
768         else
769                 GUILE_PATH="$PATH"
770         fi
772         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
774         ## First, let's just see if we can find Guile at all.
775         if test "$GUILE_CONFIG" != no; then
776                 cf_result="yes";
778                 GUILE_LIBS="`guile-config link`"
779                 GUILE_CFLAGS="`guile-config compile`"
780                 LIBS="$GUILE_LIBS $LIBS"
781                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
782                 AC_SUBST(GUILE_CFLAGS)
783                 cat <<EOF
784 ***********************************************************************
785 The Guile support is incomplete and not so well integrated to ELinks
786 yet. That means, e.g., that you have no Guile console and there might
787 not be all the necessary hooks. Also, the Guile interface is not too
788 well tested (success stories heartily welcomed!).  See
789 src/scripting/guile/README for further details and hints.
790 ***********************************************************************
792         else
793                 if test -n "$withval" && test "x$withval" != xno; then
794                         AC_MSG_ERROR([Guile not found])
795                 else
796                         AC_MSG_WARN([Guile support disabled])
797                 fi
798         fi
799 else
800         AC_MSG_RESULT(no);
803 # ===================================================================
804 # Check for Perl
805 # ===================================================================
806 enable_perl="no";
808 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
809             [
810 if test "$withval" = yes; then
811         # FIXME: If withval is a valid directory append it to PATH
812         # so that you can specify one of several perl installations.
813         withval="";
814         enable_perl=yes;
816             ])
818 AC_MSG_CHECKING([for Perl])
820 cf_result=no
822 EL_SAVE_FLAGS
824 if test "$enable_perl" = "yes"; then
825         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
826         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
827         LIBS="$PERL_LIBS $LIBS"
828         CFLAGS="$PERL_CFLAGS $CFLAGS"
829         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
830         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
831 #include <EXTERN.h>
832 #include <perl.h>
833 #include <perlapi.h>
834 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
837 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
839 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
840 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
841 #include <EXTERN.h>
842 #include <perl.h>
843 extern PerlInterpreter *my_perl;
844 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
845 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
846                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
847 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
849 if test "$cf_result" != "yes"; then
850         EL_RESTORE_FLAGS
851 else
852         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
854         CFLAGS="$CFLAGS_X"
855         CPPFLAGS="$CPPFLAGS_X"
856         AC_SUBST(PERL_LIBS)
857         AC_SUBST(PERL_CFLAGS)
860 # ===================================================================
861 # Check for Python
862 # ===================================================================
863 enable_python="no";
865 AC_ARG_WITH(python, [[  --with-python[=DIR]     enable Python support]],
866             [ if test "x$withval" != xno; then enable_python=yes; fi ])
868 EL_SAVE_FLAGS
869 cf_result=no
871 AC_MSG_CHECKING([for Python])
873 if test "$enable_python" = "yes"; then
874         AC_MSG_RESULT(yes);
876         if test -d "$withval"; then
877                 PYTHON_PATH="$withval:$PATH"
878         else
879                 PYTHON_PATH="$PATH"
880         fi
882         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
884         if test "$PYTHON" != no; then
885                 cf_result="yes";
887                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
888                 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"))'`"
889                 LIBS="$PYTHON_LIBS $LIBS"
890                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
891                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
893                 if test "$cf_result" != "yes"; then
894                         EL_RESTORE_FLAGS
895                 else
896                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
897                         AC_SUBST(PYTHON_LIBS)
898                         AC_SUBST(PYTHON_CFLAGS)
899                         CPPFLAGS="$CPPFLAGS_X"
900                         cat <<EOF
901 ***********************************************************************
902 The Python support is incomplete and not so well integrated to ELinks
903 yet. That means, e.g., that you have no Python console and there might
904 not be all the necessary hooks. Also, the Python interface is not too
905 well tested (success stories heartily welcomed!).
906 ***********************************************************************
908                 fi
909         else
910                 if test -n "$withval" && test "x$withval" != xno; then
911                         AC_MSG_ERROR([Python not found])
912                 else
913                         AC_MSG_WARN([Python support disabled])
914                 fi
915         fi
916 else
917         AC_MSG_RESULT(no);
921 # ===================================================================
922 # Check for Lua, optional even if installed.
923 # ===================================================================
925 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
926 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
928 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
929             [if test "$withval" = no; then disable_lua=yes; fi])
930 AC_MSG_CHECKING([for Lua])
932 EL_SAVE_FLAGS
933 cf_result=no
935 if test -z "$disable_lua"; then
936         if test ! -d "$withval"; then
937                 withval="";
938         fi
939         for luadir in "$withval" "" /usr /usr/local; do
940                 for suffix in "" 5.1 51; do
941                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
942                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
943                                 LUA_LIBS="-L$luadir/lib -llua$suffix -lm"
944                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
946                                 LIBS="$LUA_LIBS $LIBS_X"
947                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
948                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
950                                 # Check that it is a compatible Lua version
951                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lauxlib.h>]
952                                                 #include <lua.h>
953                                                 #include <lualib.h>
954                                                 ], [[   lua_State *L = luaL_newstate();
955                                                 luaL_openlibs(L);
956                                                 lua_pushboolean(L, 1);
957                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
958                         fi
959                 done
960         done
963 AC_MSG_RESULT($cf_result)
965 if test "$cf_result" != yes; then
966         EL_RESTORE_FLAGS
967 else
968         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
969         AC_CHECK_HEADERS(lauxlib.h)
971         CFLAGS="$CFLAGS_X"
972         CPPFLAGS="$CPPFLAGS_X"
973         AC_SUBST(LUA_LIBS)
974         AC_SUBST(LUA_CFLAGS)
977 # ===================================================================
978 # Check for TRE library
979 # ===================================================================
981 # This section only checks that --without-tre is not given and the
982 # library seems to work, and sets TRE_CFLAGS, TRE_LIBS, and
983 # tre_log.  It does not define CONFIG_TRE, and always resets
984 # LIBS and CFLAGS back to their original values.
986 # After any --enable-utf-8 and --disable-utf-8 options have been
987 # handled, a separate section decides whether to actually use TRE.
989 # tre version 0.8.0 or higher is required which have the "tre_" prefix
990 # for functions.
992 AC_ARG_WITH([[tre]], [[  --without-tre           disable TRE regex search support]])
993 if test "$with_tre" = no; then
994         AC_MSG_CHECKING([[for TRE]])
995         AC_MSG_RESULT([[disabled]])
996         tre_log="no (explicitly disabled)"
997 else
998         AC_MSG_CHECKING([[for TRE in pkg-config]])
999         if pkg-config tre; then
1000                 TRE_CFLAGS=`pkg-config --cflags tre`
1001                 TRE_LIBS=`pkg-config --libs tre`
1002                 AC_MSG_RESULT([[yes]])
1003         else
1004                 # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
1005                 # "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
1006                 # so we look for the library even if pkg-config doesn't know about it.
1007                 TRE_CFLAGS=
1008                 TRE_LIBS=-ltre
1009                 AC_MSG_RESULT([[no, but let's try defaults]])
1010         fi
1012         AC_MSG_CHECKING([[for TRE header and library]])
1013         EL_SAVE_FLAGS
1014         CFLAGS="$TRE_CFLAGS $CFLAGS"
1015         LIBS="$TRE_LIBS $LIBS" # must be first, because of regfree conflict
1016         AC_TRY_LINK([#include <tre/tre.h>],
1017                     [regex_t re;
1018                      regmatch_t match[1];
1019                      tre_regwcomp(&re, L"zap", REG_ICASE);
1020                      tre_regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
1021                     [AC_MSG_RESULT([[yes]])
1022                      tre_log="available"],
1023                     [AC_MSG_RESULT([[no]])
1024                      tre_log="no (TRE not found)"])
1025         EL_RESTORE_FLAGS
1028 # ===================================================================
1029 # Check for Ruby, optional even if installed.
1030 # ===================================================================
1032 EL_CONFIG_SCRIPTING_RUBY
1034 # ===================================================================
1035 # Setup global scripting
1036 # ===================================================================
1038 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])
1039 AC_SUBST(CONFIG_SCRIPTING_GUILE)
1040 AC_SUBST(CONFIG_SCRIPTING_LUA)
1041 AC_SUBST(CONFIG_SCRIPTING_PERL)
1042 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
1043 AC_SUBST(CONFIG_SCRIPTING_RUBY)
1044 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
1045 AC_SUBST(CONFIG_SCRIPTING)
1048 # ===================================================================
1049 # Check for SSL support.
1050 # ===================================================================
1052 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
1053 # is enabled, we won't try to use OpenSSL anymore.
1055 # For wiping SSL hooks..
1056 #ifdef CONFIG_SSL
1058 chosen_ssl_library=""
1060 AC_ARG_WITH(gnutls, [[  --without-gnutls        disable GNUTLS SSL support]])
1061 AC_ARG_WITH(gnutls, [[  --with-gnutls           enable GNUTLS SSL support]],
1062             [case "$with_gnutls" in
1063                 "no")   : ;;
1064                 "yes")  chosen_ssl_library="GNUTLS" ;;
1065                 *)      chosen_ssl_library="GNUTLS"
1066                         AC_MSG_WARN([[Support for --with-gnutls=DIR has been removed.
1067 You may have to set the PKG_CONFIG_PATH environment variable instead.]]) ;;
1068              esac])
1070 AC_ARG_WITH(openssl, [[  --without-openssl       disable OpenSSL support]])
1071 AC_ARG_WITH(openssl, [[  --with-openssl[=DIR]    enable OpenSSL support (default)]],
1072             [case "$with_openssl" in
1073                 "no")   : ;;
1074                 *)      chosen_ssl_library="OpenSSL" ;;
1075              esac])
1077 AC_ARG_WITH(nss_compat_ossl, [[  --with-nss_compat_ossl[=DIR]
1078                           NSS compatibility SSL libraries/include files]],
1079             [case "$with_nss_compat_ossl" in
1080                 "no")   : ;;
1081                 *)      chosen_ssl_library="nss_compat_ossl" ;;
1082              esac])
1084 # ---- nss_compat_ossl
1086 if test "$with_nss_compat_ossl" = no; then
1087         # explicitly disabled
1088         :
1089 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "nss_compat_ossl"; then
1090         # not used, because $chosen_ssl_library was chosen
1091         :
1092 elif test -z "${with_nss_compat_ossl+set}"; then
1093         # SSL_library_init() in nss_compat_ossl 0.9.2 calls exit(1)
1094         # with no error message if there is no certificate database.
1095         # https://bugzilla.redhat.com/show_bug.cgi?id=463437
1096         # So ELinks uses nss_compat_ossl only if explicitly requested.
1097         :
1098 else
1099         EL_SAVE_FLAGS
1100         if test "$with_nss_compat_ossl" = yes; then
1101                 if pkg-config nss; then
1102                         CFLAGS="$CFLAGS_X `pkg-config --cflags nss`"
1103                         LIBS="$LIBS_X `pkg-config --libs nss`"
1104                 else
1105                         with_nss_compat_ossl=no
1106                 fi
1107         else
1108                 # Without pkg-config, we'll kludge in some defaults
1109                 CFLAGS="$CFLAGS_X -I$with_nss_compat_ossl/include -I/usr/include/nss3 -I/usr/include/nspr4"
1110                 LIBS="$LIBS_X -L$with_nss_compat_ossl/lib -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
1111         fi
1112         AC_CHECK_HEADERS(nss_compat_ossl/nss_compat_ossl.h,, [with_nss_compat_ossl=no], [#define NSS_COMPAT_OSSL_H])
1113         AC_CHECK_LIB(nss_compat_ossl, X509_free,, [with_nss_compat_ossl=no])
1115         if test "$with_nss_compat_ossl" = "no"; then
1116                 EL_RESTORE_FLAGS
1117         else
1118                 LIBS="$LIBS -lnss_compat_ossl"
1119                 EL_CONFIG(CONFIG_NSS_COMPAT_OSSL, [nss_compat_ossl])
1120                 chosen_ssl_library="nss_compat_ossl"
1121         fi
1124 # ---- OpenSSL
1126 AC_MSG_CHECKING([for OpenSSL])
1128 EL_SAVE_FLAGS
1130 if test "$with_openssl" = no; then
1131         cf_result="explicitly disabled"
1133 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "OpenSSL"; then
1134         cf_result="not used, because $chosen_ssl_library was chosen"
1136 else
1137         cf_result=no
1138         for ssldir in "$with_openssl" "" /usr /usr/local/openssl \
1139                          /usr/lib/openssl /usr/local/ssl \
1140                          /usr/local/www /usr/lib/ssl /usr/local \
1141                          /usr/pkg /opt /opt/openssl; do
1142                 if test "$cf_result" = no; then
1143                         if test -d "$ssldir"; then
1144                                 OPENSSL_CFLAGS="-I$ssldir/include"
1145                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1146                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1147                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1148 #                               # FIXME: This created serious portability problems. --pasky
1149 #                               if test "$CC" == "gcc"; then
1150 #                                       # I'm not sure about compatibility here. --pasky
1151 #                                       LIBS="$LIBS -R$ssldir/lib"
1152 #                               fi
1153                         else
1154                                 LIBS="-lssl -lcrypto $LIBS_X"
1155                         fi
1156                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1157                         if test "$cf_result" != yes; then
1158                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1159                         fi
1160                 fi
1161         done
1163         if test "$cf_result" != yes; then
1164                 if test "${with_openssl-no}" != "no"; then
1165                         AC_MSG_ERROR([OpenSSL not found])
1166                 fi
1167                 EL_RESTORE_FLAGS
1168         else
1169                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1170                 chosen_ssl_library="OpenSSL"
1172                 CFLAGS="$CFLAGS_X"
1173                 AC_SUBST(OPENSSL_CFLAGS)
1174         fi
1177 AC_MSG_RESULT($cf_result)
1179 # ---- GNU TLS
1181 # GnuTLS 2.2.0 changed libgnutls-openssl from GPLv2+
1182 # to GPLv3+.  Don't link that with the GPLv2 ELinks.
1183 # ELinks will use its internal MD5 code instead.
1184 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1186 if test "$with_gnutls" = no; then
1187         AC_MSG_CHECKING([[for GNUTLS]])
1188         AC_MSG_RESULT([[explicitly disabled]])
1190 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "GNUTLS"; then
1191         AC_MSG_CHECKING([[for GNUTLS]])
1192         AC_MSG_RESULT([[not used, because $chosen_ssl_library was chosen]])
1194 else
1195         cf_result=no
1196         AC_MSG_CHECKING([[for GNUTLS (1.2 or later) in pkg-config]])
1197         if pkg-config --atleast-version=1.2 gnutls; then
1198                 GNUTLS_CFLAGS=`pkg-config --cflags gnutls`
1199                 GNUTLS_LIBS=`pkg-config --libs gnutls`
1200                 AC_MSG_RESULT([[yes: $GNUTLS_CFLAGS $GNUTLS_LIBS]])
1202                 EL_SAVE_FLAGS
1203                 LIBS="$GNUTLS_LIBS $LIBS"
1204                 CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
1205                 CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
1207                 # Verify if it's really usable.  gnutls_session was
1208                 # renamed to gnutls_session_t before GNU TLS 1.2.0
1209                 # (on 2004-06-13); ELinks now requires this.
1210                 AC_MSG_CHECKING([[whether GNUTLS can be linked with]])
1211                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]],
1212                                                 [[gnutls_session_t dummy;
1213                                                   gnutls_check_version(NULL)]])],
1214                                [cf_result=yes],
1215                                [cf_result=no])
1216                 AC_MSG_RESULT([[$cf_result]])
1218                 if test "$cf_result" = yes; then
1219                         # According to gnutls/NEWS, the function was originally
1220                         # added as gnutls_set_default_priority2 in GNUTLS 2.1.4
1221                         # (released 2007-10-27) and then renamed to
1222                         # gnutls_priority_set_direct in GNUTLS 2.1.7 (released
1223                         # 2007-11-29).
1224                         AC_CHECK_FUNCS([gnutls_priority_set_direct])
1225                 fi
1227                 EL_RESTORE_FLAGS
1228         else
1229                 AC_MSG_RESULT([[$cf_result]])
1230         fi
1232         if test "$cf_result" = yes; then
1233                 EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1234                 chosen_ssl_library="GNUTLS"
1236                 LIBS="$GNUTLS_LIBS $LIBS"
1237                 AC_SUBST(GNUTLS_CFLAGS)
1239         elif test "${with_gnutls-no}" != "no"; then
1240                 AC_MSG_ERROR([[GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.]])
1241         fi
1244 # Final SSL setup
1246 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS CONFIG_NSS_COMPAT_OSSL], [SSL])
1247 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1248 AC_SUBST(CONFIG_OPENSSL)
1249 AC_SUBST(CONFIG_GNUTLS)
1250 AC_SUBST(CONFIG_NSS_COMPAT_OSSL)
1252 #endif
1254 AC_MSG_CHECKING([whether to be or not to be])
1255 AC_MSG_RESULT([needs to be determined experimentally])
1257 # ===================================================================
1258 # Check for IPv6 support and related functions.
1259 # ===================================================================
1261 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1262 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1263 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1265 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1266 if test "$HAVE_GETADDRINFO" != yes; then
1267         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1268         if test "$HAVE_GETADDRINFO" = yes; then
1269                 LIBS="$LIBS -linet6"
1270         fi
1274 # ===================================================================
1275 # Checking for X11 (window title restoring).
1276 # ===================================================================
1278 AC_PATH_X
1279 if test x"$no_x" != xyes; then
1280         EL_SAVE_FLAGS
1281         if test -n "$x_includes"; then
1282                 X_CFLAGS="-I$x_includes"
1283                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1284                 CFLAGS="$CFLAGS $X_CFLAGS"
1285         fi
1286         if test -n "$x_libraries"; then
1287                 LDFLAGS="$LDFLAGS -L$x_libraries"
1288         fi
1289         LIBS="-lX11 $LIBS"
1290         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1291         EL_RESTORE_FLAGS
1292         if test "$cf_result" = yes; then
1293                 if test -n "$x_libraries"; then
1294                         LDFLAGS="$LDFLAGS -L$x_libraries"
1295                 fi
1296                 LIBS="-lX11 $LIBS"
1297                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1298                 AC_SUBST(X_CFLAGS)
1299         fi
1303 # ===================================================================
1304 # Backtraces displaying support.
1305 # ===================================================================
1307 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1308 # possible checks for other system-specific means go here
1311 # ===================================================================
1312 # Gettext grey zone. Beware.
1313 # ===================================================================
1315 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"
1317 AM_GNU_GETTEXT
1319 # iconv is always used
1320 LIBS="$LIBS $LIBICONV"
1322 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1323 dnl # f33r d4 l33t... I hope it's portable. :)
1324 dnl cf_result=$((48#z - 48#a + 1));
1325 dnl AC_MSG_RESULT($cf_result)
1328 # ===================================================================
1329 # Compile-time features control
1330 # ===================================================================
1332 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1333               [  --disable-cookies       disable cookie support])
1335 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1336               [  --disable-formhist      disable form history support])
1338 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1339               [  --disable-globhist      disable global history support])
1342 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1343               [  --disable-mailcap       disable mailcap support])
1345 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1346               [  --disable-mimetypes     disable mimetypes files support])
1349 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1350               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1351               [IPv6],
1352               [  --disable-ipv6          disable IPv6 support])
1354 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1355               [  --enable-bittorrent     enable BitTorrent protocol support])
1357 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1358               [  --disable-data          disable data protocol support])
1360 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1361               [  --disable-uri-rewrite   disable URI rewrite support])
1363 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1364               [  --enable-cgi            enable local CGI support])
1366 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1367               [  --enable-finger         enable finger protocol support])
1369 # ===================================================================
1370 # FSP protocol
1371 # ===================================================================
1372 EL_SAVE_FLAGS
1374 if test "x${enable_fsp}" != xno; then
1375         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1377         if test "$HAVE_FSPLIB" = yes; then
1378                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1379                 if test "$HAVE_FSPLIB" = yes; then
1380                         LIBS="$LIBS -lfsplib"
1381                 else
1382                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1383                         if test "$HAVE_FSPLIB" = yes; then
1384                                 LIBS="$LIBS -lfsp"
1385                         fi
1386                 fi
1387         fi
1390 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1391               [  --enable-fsp            enable FSP protocol support])
1393 if test "x$CONFIG_FSP" = xno; then
1394         EL_RESTORE_FLAGS
1397 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1398               [  --disable-ftp           disable ftp protocol support])
1400 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1401               [  --enable-gopher         enable gopher protocol support])
1403 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1404               [  --enable-nntp           enable nntp protocol support])
1406 # ===================================================================
1407 # SMB protocol support.
1408 # ===================================================================
1409 EL_SAVE_FLAGS
1411 if test "x${enable_smb}" != xno; then
1412         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1414         if test "$HAVE_SMBCLIENT" = yes; then
1415                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1416                 if test "$HAVE_SMBCLIENT" = yes; then
1417                         LIBS="$LIBS -lsmbclient"
1418                 fi
1419         fi
1422 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1423               [  --enable-smb            enable Samba protocol support])
1425 if test "x$CONFIG_SMB" = xno; then
1426         EL_RESTORE_FLAGS
1430 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1431               [  --disable-mouse         disable mouse support])
1433 # GPM mouse is Linux specific, so ...
1434 CONFIG_SYSMOUSE=yes
1435 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1436               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1437               [BSD sysmouse],
1438               [  --disable-sysmouse      disable BSD sysmouse support])
1440 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1441               [  --enable-88-colors      enable 88 color support])
1443 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1444               [  --enable-256-colors     enable 256 color support])
1446 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1447               [  --enable-true-color     enable true color support])
1449 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1450               [  --enable-exmode         enable exmode (CLI) interface])
1452 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1453               [  --disable-leds          disable LEDs support])
1455 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1456               [  --disable-marks         disable document marks support])
1459 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1460               [  --disable-css           disable Cascading Style Sheet support])
1462 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1463               [  --enable-html-highlight HTML highlighting using DOM engine])
1465 # Everything in the tree already uses CONFIG_DOM
1466 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1467 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1469 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1470               [  --disable-backtrace     disable backtrace support])
1472 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1473               [  --enable-no-root        enable prevention of usage by root])
1476 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1477               [  --enable-debug          enable leak debug and internal error checking])
1479 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1480               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1482 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1483               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1485 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1486               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1488 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1489               [  --disable-utf-8         disable UTF-8 support])
1491 EL_ARG_DEPEND(CONFIG_COMBINE, combining, [CONFIG_UTF8:yes HAVE_WCWIDTH:yes], [Combining characters],
1492               [  --enable-combining      support Unicode combining characters (experimental)])
1495 AC_ARG_ENABLE(weehoofooboomookerchoo,
1496               [
1497     Also check out the features.conf file for more information about features!
1498               ],
1499               [AC_MSG_ERROR(Are you strange, or what?)])
1502 # ===================================================================
1503 # Decide whether to use TRE
1504 # ===================================================================
1506 # This must be done after the CONFIG_UTF8 check above.
1507 # The first part of the TRE check is separate, to get
1508 # the configure --help output in a sensible order.
1510 # After this section, nothing else must be added to the
1511 # beginning of $LIBS.
1513 if test "$tre_log" = "available"; then
1514         if test "$CONFIG_UTF8" = "yes"; then
1515                 # When CONFIG_UTF8 and CONFIG_TRE are both defined,
1516                 # src/viewer/text/search.c makes a string of
1517                 # unicode_val_T and gives it to regwexec(), which
1518                 # expects a string of wchar_t.  If the unicode_val_T
1519                 # and wchar_t types are too different, this won't
1520                 # work, so try to detect that and disable regexp
1521                 # operations entirely in that case.
1522                 #
1523                 # Currently, this code only compares the sizes of the
1524                 # types.  src/intl/charsets.h defines unicode_val_T as
1525                 # uint32_t, so we check whether wchar_t has exactly 32
1526                 # bits.  But don't use AC_CHECK_SIZEOF for this, because
1527                 # there doesn't seem to be a documented way to get the
1528                 # result of that for use in the configure script.
1529                 #
1530                 # C99 says the implementation can define
1531                 # __STDC_ISO_10646__ if wchar_t values match ISO 10646
1532                 # (or Unicode) numbers in all locales.  Do not check
1533                 # that macro here, because it is too restrictive: it
1534                 # should be enough for ELinks if the values match in
1535                 # the locales where ELinks is actually run.
1536                 AC_MSG_CHECKING([[whether wchar_t is exactly 32-bit]])
1537                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1538 #include <limits.h>
1539 #include <stddef.h>
1540 int dummy[(sizeof(wchar_t) * CHAR_BIT == 32) ? 1 : -1];]], [])],
1541                         [AC_MSG_RESULT([[yes]])
1542                          tre_log="TRE"],
1543                         [AC_MSG_RESULT([[no]])
1544                          tre_log="no (unsuitable wchar_t)"])
1545         else
1546                 # If UTF-8 is not used, then wchar_t doesn't matter.
1547                 tre_log="TRE"
1548         fi
1551 if test "$tre_log" = "TRE"; then
1552         AC_DEFINE([CONFIG_TRE], [1],
1553                 [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.])
1554         # TRE_CFLAGS will be used only where needed.
1555         #
1556         # Bug 1081: If both TRE and libc define the regfree function,
1557         # ELinks needs to use the version defined by TRE because
1558         # that's the one compatible with regex_t initialized by the
1559         # regwcomp function of TRE.  Therefore put $TRE_LIBS at the
1560         # very beginning of $LIBS so that the linker hopefully finds
1561         # regfree there before it examines libc.  In particular,
1562         # $PERL_LIBS appears to often include "-lc".
1563         #
1564         # This scheme still risks a crash if ELinks is linked with
1565         # some static library that uses GNU <regex.h> extensions that
1566         # TRE does not implement.  For example, the library might call
1567         # re_compile_pattern, which is found in GNU libc, and then
1568         # regfree, which is found in TRE and probably crashes with the
1569         # GNU-initialized regex_t.  Ways to avoid such crashes:
1570         #
1571         # - Change TRE so it defines only tre_... functions and does
1572         #   not attempt to override the POSIX names by default.
1573         #
1574         # - Change ELinks to access TRE only via dlopen and dlsym.
1575         #   The problem then is how to find the correct file name.
1576         #   There might be libtre.so.4 and libtre.so.5 with different
1577         #   ABI.  How can this configure script detect which of them
1578         #   matches the <tre/regex.h> in the include path?
1579         #
1580         # - Replace the static library with a shared library.  At
1581         #   least on GNU/Linux, when the shared library is built, the
1582         #   linker should note that e.g. regfree is defined in libc
1583         #   and has the GLIBC_2.0 version there, and write that
1584         #   version string to the shared library as well; because TRE
1585         #   does not provide regfree with that version, any regfree
1586         #   calls at run time should then get resolved to libc.
1587         LIBS="$TRE_LIBS $LIBS"
1588 else
1589         TRE_LIBS=
1590         TRE_CFLAGS=
1592 AC_SUBST(TRE_CFLAGS)
1593 AC_SUBST(TRE_LIBS)
1594 EL_LOG_CONFIG([CONFIG_TRE], [[Regexp searching]], [[$tre_log]])
1597 # ===================================================================
1598 # Further LDFLAGS tweaks
1599 # ===================================================================
1601 # == EMX hack
1603 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1604 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1607 # Check for -rdynamic
1609 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
1610 # the executable to its dynamic symbol table.  ELinks uses this for
1611 # two purposes:
1613 # 1. If ELinks detects a bug, it can try to display a backtrace by
1614 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
1615 #    manual states users of GNU ld must pass -rdynamic to make the
1616 #    symbols available to the program.
1618 # 2. It would eventually be nice to dynamically load shared
1619 #    libraries as plugins (bug 73).  The plugins must be able to
1620 #    call ELinks functions.  This can be implemented either by
1621 #    registering all callable functions in ELinks-specific data
1622 #    structures, or by letting the dynamic linker handle them.
1623 #    The latter way requires something equivalent to -rdynamic.
1625 # Because backtraces are not needed for correct operation, and bug
1626 # 73 is not yet being fixed, the configure script and makefiles
1627 # should not complain to the user if they find that -rdynamic does
1628 # not work.  Besides, it was reported at elinks-users on 2006-09-12
1629 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
1630 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
1631 # -rdynamic but does something equivalent automatically.  (This was
1632 # tested with "nm -D elinks | grep redraw_from_window".)
1634 # With Sun Studio 11 on Solaris 9, we get "cc: Warning: illegal option
1635 # -dynamic"; then, cc proceeds anyway, but the option can prevent the
1636 # linker from finding the libraries listed in -l operands.  So this
1637 # -rdynamic check needs to happen after the libraries have already
1638 # been added to $LDFLAGS.
1639 AC_MSG_CHECKING([for -rdynamic])
1640 LDFLAGS_X="$LDFLAGS"
1641 LDFLAGS="-rdynamic $LDFLAGS"
1642 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
1643 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
1644 AC_MSG_RESULT($have_rdynamic)
1646 # ===================================================================
1647 # Export directory paths
1648 # ===================================================================
1650 # Set up the ``entry points'' if they were not supplied by builder
1651 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1652 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1654 # Create CONFDIR #define for config.h
1656 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1657 # it's autoconf fault to force us to do such hacks ;p.
1658 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1659   # sysconfdir is set to its default value... fine, let's append /elinks/
1660   # XXX: We can't modify listing of the default in ./configure --help :-(
1661   sysconfdir_n=`eval echo "$sysconfdir"`
1662   sysconfdir=$sysconfdir_n
1663   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1664         sysconfdir="$sysconfdir/elinks"
1667 CONFDIR=$sysconfdir
1668 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1669 AC_SUBST(CONFDIR)
1671 # Create LOCALEDIR #define for config.h
1672 LOCALEDIR=`eval echo "$datadir/locale"`
1673 while echo "$LOCALEDIR" | grep "\\$"
1675         LOCALEDIR=`eval echo "$LOCALEDIR"`
1676 done > /dev/null 2> /dev/null
1677 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1678 AC_SUBST(LOCALEDIR)
1680 # Create LIBDIR #define for config.h
1681 LIBDIR=`eval echo "$libdir"`
1682 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1683 AC_SUBST(LIBDIR)
1685 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1686 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1689 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1690 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1691         #error not tcc
1692         #endif ]])],[cf_result=yes],[cf_result=no])
1694 if test "$cf_result" = "yes"; then
1695         AC_DEFINE([HAVE_ALLOCA])
1696         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1697                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1698                 override the alloca macro defined in <stddef.h> of TCC.
1699                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1700                 it has already been included, and does not redefine alloca.
1701                 This might not work in future glibc versions though, because
1702                 the names of the #include guard macros are not documented.
1703                 The incompatibility has been reported to the tinycc-devel
1704                 mailing list on 2008-07-14.  If a future version of TCC provides
1705                 an <alloca.h> of its own, this hack won't be needed.])
1707 # ===================================================================
1708 # A little fine tuning of gcc specific options (continued)
1709 # ===================================================================
1711 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1712   if test "$CONFIG_DEBUG" = "yes"; then
1713     # We want to see all warnings and live with none (in debug mode).
1714     CFLAGS="$CFLAGS -Werror"
1715   fi
1717   case "`$CC -dumpversion`" in
1718     3.0|3.1|3.2)
1719       # These should be ok using -Werror
1720       ;;
1721     3.*)
1722       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1723       # "dereferencing type-punned pointer will break strict-aliasing rules"
1724       # warnings. Disable them by not doing any strict-aliasing. The
1725       # alternative is just too ugly. Thanks gcc guys!! ;)
1726       CFLAGS="$CFLAGS -fno-strict-aliasing"
1727       ;;
1728     4.5*)
1729       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign -Wno-enum-compare"
1730       ;;
1731     4.*)
1732       # Do not show warnings related to (char * | unsigned char *) type
1733       # difference.
1734       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1735       ;;
1736     *)
1737       # These should be ok using -Werror
1738       ;;
1739   esac
1741   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1742   # warning: the address of `builtin_modules' will always evaluate as `true'
1743   # This hits the object_lock and foreach_module macros in particular.
1744   # It would be okay to put something in the macros to avoid the warning,
1745   # but currently this seems to require defining parallel macros that skip
1746   # the NULL check, and that's too ugly.  So we instead disable the warning.
1747   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1748   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1749   for warning_flag in -Wno-address -Wno-always-true; do
1750     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1751     EL_SAVE_FLAGS
1752     CFLAGS="$CFLAGS $warning_flag"
1753     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1754       [AC_MSG_RESULT([yes])
1755        break],
1756       [AC_MSG_RESULT([no])])
1757     EL_RESTORE_FLAGS
1758   done
1760   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1761   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1762   # "warning: assuming signed overflow does not occur when assuming
1763   # that (X + c) > X is always true", which may be an incorrect
1764   # optimization (although allowed by the standard), and breaks the
1765   # build with -Werror.
1766   #
1767   # All of the following tests included -S -Wall -Wextra:
1768   #
1769   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1770   # * gcc-4.0 -O0: OK, compares the values
1771   # * gcc-4.0 -O2: assumes no overflow, does not warn
1772   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1773   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1774   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1775   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1776   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1777   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1778   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1779   #
1780   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1781   # * gcc-4.1 -O0: assumes no overflow, does not warn
1782   # * gcc-4.1 -O2: assumes no overflow, does not warn
1783   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1784   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1785   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1786   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1787   # * gcc-4.1 -O2 -ftrapv: compares the values
1788   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1789   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1790   #
1791   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1792   # * gcc-4.2 -O0: OK, compares the values
1793   # * gcc-4.2 -O2: assumes no overflow, warns about it
1794   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1795   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1796   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1797   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1798   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1799   # * gcc-4.2 -O2 -ftrapv: compares the values
1800   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1801   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1802   #
1803   # Apparently, -ftrapv does not work reliably at all.
1804   for overflow_flag in -fno-strict-overflow -fwrapv; do
1805     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1806     EL_SAVE_FLAGS
1807     CFLAGS="$CFLAGS $overflow_flag"
1808     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1809       [AC_MSG_RESULT([yes])
1810        break],
1811       [AC_MSG_RESULT([no])])
1812     EL_RESTORE_FLAGS
1813   done
1816 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1817 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1818 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1819 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1821 # ===================================================================
1822 # Colored make output
1823 # ===================================================================
1825 if test $(`which tput` colors) -ge 4; then
1826         MAKE_COLOR=1
1827         AC_SUBST(MAKE_COLOR)
1830 # ===================================================================
1831 # Generated files
1832 # ===================================================================
1834 AC_CONFIG_FILES([ \
1835  Makefile.config \
1836  contrib/elinks.spec \
1837  contrib/lua/hooks.lua \
1838  contrib/conv/w3m2links.awk \
1839  doc/Doxyfile \
1840  doc/man/man1/elinks.1 \
1841  src/intl/gettext/ref-add.sed \
1842  src/intl/gettext/ref-del.sed
1844 AC_OUTPUT
1846 abs_srcdir="$(cd "$srcdir" && pwd)"
1847 # builddir is always absolute!
1848 if test "$abs_srcdir" != "$builddir"; then
1849         # Bootstrap the Makefile creation
1850         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1851         "$MAKE" "SRC=$abs_srcdir" init
1853         # Make cg-status ignore this build directory
1854         echo "*" > "$builddir/.gitignore"
1857 # ===================================================================
1858 # Configuration summary
1859 # ===================================================================
1861 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1862 cat features.log