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