iconv: Bail out of the loop when an illegal sequence of bytes occurs.
[elinks/elinks-j605.git] / configure.in
blob023af06db9175ee4654ac3cfb4b20f580d08ddc6
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 AC_CHECK_FUNCS(fork)
300 # These aren't probably needed now, as they are commented in links.h.
301 # I've no idea about their historical background, but I keep them here
302 # just in the case they will help later. --pasky
303 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
304 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
305 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
306 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
308 AC_CHECK_FUNCS(fpathconf, HAVE_FPATHCONF=yes)
310 if test x"$HAVE_RAISE" = x; then
311         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
312                 AC_MSG_ERROR([Unable to emulate raise()])
313         fi
316 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
317 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
318 va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])])
319 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
320         EL_DEFINE(HAVE_VA_COPY, __va_copy)
323 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
324 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
325 ]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
326 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
327         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
330 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
331 AC_RUN_IFELSE([AC_LANG_SOURCE([[
332 #include <stdio.h>
333 #include <stdarg.h>
334 #include <stdlib.h>
335 #include <string.h>
337 char buf[8];
339 int bar(char *buf, const char *format, va_list ap)
341        return vsnprintf(buf, 0, format, ap);
344 void foo(const char *format, ...) {
345        va_list ap;
346        int len;
348        va_start(ap, format);
349        len = bar(buf, format, ap);
350        va_end(ap);
351        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
353        va_start(ap, format);
354        len = bar(buf, format, ap);
355        va_end(ap);
356        if ((len != 6) && (len != 7)) exit(1);
358        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
360        exit(0);
362 main() { foo("hello\n"); }
363 ]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
364 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
365         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
368 # OpenSSL and Lua frequently need dlopen
369 AC_CHECK_LIB(dl, dlopen)
371 # ===================================================================
372 # Checks for libraries.
373 # ===================================================================
375 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
376 if test "$cf_result" = no; then
377         AC_CHECK_LIB(socket, socket)
380 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
381 if test "$cf_result" = no; then
382         AC_CHECK_LIB(socket, setsockopt)
385 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
386 if test "$cf_result" = no; then
387         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
388         if test "$cf_result" = no; then
389                 AC_CHECK_LIB(nsl, gethostbyname)
390         else
391                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
392         fi
395 # ===================================================================
396 # Checks for packaging specific options.
397 # ===================================================================
399 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
400             [ if test "$withval" != no && test "$withval" != yes; then
401                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
402               fi ])
404 # ===================================================================
405 # Checks for a libraries, optional even if installed.
406 # ===================================================================
408 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
409 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
411         AC_MSG_CHECKING([for $2 support])
413         if test "[$]$1" != no; then
414                 AC_MSG_RESULT(yes)
415                 EL_SAVE_FLAGS
416                 if test -n "$withval" && test -d "$withval"; then
417                         # Be a little more careful when setting
418                         # include and lib directories. This way
419                         # $withval will work when includes are
420                         # there but the library is in the common
421                         # /usr/lib ... Does the right thing when
422                         # looking for gc on Debian.
423                         if test -d "$withval/include"; then
424                                 CFLAGS="$CFLAGS -I$withval/include"
425                                 CPPFLAGS="$CPPFLAGS -I$withval/include"
426                         else
427                                 CFLAGS="$CFLAGS -I$withval"
428                                 CPPFLAGS="$CPPFLAGS -I$withval"
429                         fi
430                         if test -d "$withval/lib"; then
431                                 LDFLAGS="$LDFLAGS -L$withval/lib"
432                         fi
433                 fi
435                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
436                 if test "[$]$1" = yes; then
437                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
438                 fi
440                 if test "[$]$1" = yes; then
441                         EL_CONFIG([$1], [$2])
442                         LIBS="$LIBS -l$4"
443                 else
444                         if test -n "[$]WITHVAL_$1" &&
445                            test "x[$]WITHVAL_$1" != xno; then
446                                 AC_MSG_ERROR([$2 not found])
447                         fi
448                         EL_RESTORE_FLAGS
449                 fi
450         else
451                 AC_MSG_RESULT(disabled)
452         fi
455 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
456 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
458         if test "x[$]$1" != xno; then $1=yes; fi
459         WITHVAL_$1=
461         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
462         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
463         if test "x[$]WITHVAL_$1" = xyes; then $1=yes; fi
465         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
467         EL_LOG_CONFIG([$1], [$2], [])
470 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
471         [  --without-gpm           disable gpm (mouse) support])
473 # ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
474 # enable automatic decoding of both zlib and gzip headers.  This
475 # feature was added in zlib 1.2.0.2; earlier versions return an error.
476 # The gzclearerr function was also added in zlib 1.2.0.2, so check for
477 # that, even though ELinks does not actually call gzclearerr.
478 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
479         [  --without-zlib          disable zlib support])
481 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
482         [  --without-bzlib         disable bzlib support])
484 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
485         [  --without-idn           disable international domain names support])
487 if test "x${with_gc}" != xno; then
488         EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
489                 [  --with-gc               enable Boehm's garbage collector])
492 # LZMA disabled by default, because of little usability and compilation problems
493 # with new xz
494 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
495         [  --with-lzma             enable lzma encoding support])
497 # ===================================================================
498 # Check for GSSAPI, optional even if installed.
499 # ===================================================================
501 enable_gssapi="no";
503 AC_ARG_WITH(gssapi, [  --with-gssapi           enable GSSAPI support],
504             [ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
506 AC_MSG_CHECKING([for GSSAPI])
508 if test "$enable_gssapi" = "yes"; then
509         AC_MSG_RESULT(yes)
510         GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
511         GSSAPI_LIBS=`krb5-config --libs gssapi`
512         CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
513         LIBS="$GSSAPI_LIBS $LIBS"
514         EL_CONFIG(CONFIG_GSSAPI, [GssApi])
515 else
516         AC_MSG_RESULT(no)
519 AC_SUBST(CONFIG_GSSAPI)
521 # ===================================================================
522 # Bookmark and XBEL support
523 # ===================================================================
525 EL_SAVE_FLAGS
527 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
528               [  --disable-bookmarks     disable bookmark support])
530 # Check whether --enable-xbel or --disable-xbel was given.
531 if test "x${enable_xbel}" != xno; then
532         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
534         if test "$HAVE_LIBEXPAT" = yes; then
535                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
536                 if test "$HAVE_LIBEXPAT" = yes; then
537                         LIBS="$LIBS -lexpat"
538                 fi
539         fi
543 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
544               [XBEL bookmarks],
545               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
547 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
548         EL_RESTORE_FLAGS
551 # ===================================================================
552 # Checks for BSD sysmouse
553 # ===================================================================
555 HAVE_SYSMOUSE_HEADER="no"
557 # Either of these header files provides the (same) sysmouse interface
558 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
560 # ===================================================================
561 # Checks for OS/2
562 # ===================================================================
564 if test "$CONFIG_OS_OS2" = yes; then
565         EL_CONFIG_OS_OS2
568 # ===================================================================
569 # Checks for Win32
570 # ===================================================================
572 if test "$CONFIG_OS_WIN32" = yes; then
573         EL_CONFIG_OS_WIN32
576 # ===================================================================
577 # Check for SpiderMonkey, optional even if installed.
578 # ===================================================================
580 # This option sets the $with_spidermonkey variable.
581 AC_ARG_WITH([spidermonkey],
582         [AS_HELP_STRING([--without-spidermonkey],
583                 [disable SpiderMonkey Mozilla JavaScript engine support])])
585 # CONFIG_SPIDERMONKEY is initially blank.  We change it to "yes" or "no"
586 # when we know for sure whether we're going to use SpiderMonkey or not.
587 # (features.conf is not supposed to define it.)
588 CONFIG_SPIDERMONKEY=
589 EL_SAVE_FLAGS
591 case "$with_spidermonkey" in
592         no)
593                 # The user specified --without-spidermonkey.
594                 # That overrides the other SpiderMonkey options.
595                 AC_MSG_CHECKING([for SpiderMonkey])
596                 AC_MSG_RESULT([disabled])
597                 CONFIG_SPIDERMONKEY="no"
598                 ;;
599         "" | yes)
600                 ;;
601         *)
602                 AC_MSG_WARN([This version of ELinks does not support --with-spidermonkey=DIRECTORY.])
603                 ;;
604 esac
606 # The SpiderMonkey 1.8.5 standalone sources install mozjs185.pc,
607 # but the Debian libmozjs-dev package installs mozilla-js.pc.
608 # Check mozjs185 first, because it has the version number in the name
609 # and therefore is less likely to be a newer incompatible version.
610 # (This configure script rejects older incompatible versions
611 # but can let newer ones through.)
612 for package in mozjs185 mozilla-js; do
613         if test -n "$CONFIG_SPIDERMONKEY"; then
614                 break
615         else
616                 AC_MSG_CHECKING([for SpiderMonkey (1.8.5 or later) in pkg-config $package])
617                 # In pkg-config 0.25, pkg-config --exists mozjs185
618                 # returns 0 (success) even if mozjs185 depends on
619                 # nspr, which has not been installed.  However,
620                 # pkg-config --cflags mozjs185 returns 1 then.
621                 if pkg-config --cflags --libs $package > /dev/null 2>&AS_MESSAGE_LOG_FD; then
622                         SPIDERMONKEY_LIBS="$(pkg-config --libs $package)"
623                         SPIDERMONKEY_CFLAGS="$(pkg-config --cflags $package)"
624                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
625                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
626                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
627                         AC_LINK_IFELSE(
628                                 [AC_LANG_PROGRAM([[
629                                         /* mozilla-js.pc may have -DXP_UNIX or similar in Cflags.
630                                          * Avoid warnings about conflicting definitions.  */
631                                         #if !defined(XP_BEOS) && !defined(XP_OS2) && !defined(XP_UNIX) && !defined(XP_WIN)
632                                         # define XP_UNIX 1
633                                         #endif
634                                         #include <jsapi.h>
635                                         #ifndef JS_VERSION
636                                         # error <jsapi.h> did not define JS_VERSION
637                                         #elif JS_VERSION < 185
638                                         # error too old
639                                         #endif]], [])],
640                                 [CONFIG_SPIDERMONKEY=yes
641                                  AC_MSG_RESULT([yes])],
642                                 [# Leave CONFIG_SPIDERMONKEY blank, to continue the search.
643                                  AC_MSG_RESULT([found but unusable])])
644                 else
645                         AC_MSG_RESULT([no])
646                 fi
647         fi
648 done
650 if test -z "$CONFIG_SPIDERMONKEY"; then
651         # Didn't find SpiderMonkey anywhere.
652         CONFIG_SPIDERMONKEY=no
655 if test "$CONFIG_SPIDERMONKEY" = "yes"; then
656         # LIBS, CFLAGS, and CPPFLAGS still include the SpiderMonkey options.
657         AC_CHECK_FUNCS([JS_ReportAllocationOverflow])
658         AC_CHECK_FUNCS([JS_SetBranchCallback])
659         AC_CHECK_FUNCS([JS_TriggerOperationCallback], [HAVE_JS_TRIGGEROPERATIONCALLBACK=yes])
660 elif test -n "$with_spidermonkey" && test "x$with_spidermonkey" != "xno"; then
661         AC_MSG_WARN([SpiderMonkey was not found even though you specified --with-spidermonkey.])
663 EL_RESTORE_FLAGS
665 if test "x$CONFIG_SPIDERMONKEY" = xyes; then
666         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
667 else
668         CONFIG_ECMASCRIPT_SMJS=no
671 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
672 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
674 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
675    test "x$HAVE_JS_TRIGGEROPERATIONCALLBACK" = xyes &&
676    test "x$HAVE_SETITIMER" = xyes; then
677         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT, [ECMAScript heartbeat support])
678 else
679         CONFIG_ECMASCRIPT_SMJS_HEARTBEAT=no
681 AC_SUBST(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
684 # ===================================================================
685 # Optional Spidermonkey-based ECMAScript browser scripting
686 # ===================================================================
688 AC_ARG_ENABLE(sm-scripting,
689               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
690               [if test "$enableval" != no; then enableval="yes"; fi
691                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
693 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
694    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
695         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
696 else
697         CONFIG_SCRIPTING_SPIDERMONKEY=no
700 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
701    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
702         LIBS="$LIBS $SPIDERMONKEY_LIBS"
703         AC_SUBST(SPIDERMONKEY_LIBS)
704         AC_SUBST(SPIDERMONKEY_CFLAGS)
705         AC_SUBST(CONFIG_SPIDERMONKEY)
708 # ===================================================================
709 # Check for Guile, optional even if installed.
710 # ===================================================================
712 enable_guile="no";
714 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
715             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
717 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
718 # GUILE_FLAGS but I really don't want to require people to have Guile in order
719 # to compile CVS. Also, the macro seems to be really stupid regarding searching
720 # for Guile in $PATH etc. --pasky
722 AC_MSG_CHECKING([for Guile])
724 if test "$enable_guile" = "yes"; then
725         AC_MSG_RESULT(yes);
726         ## Based on the GUILE_FLAGS macro.
728         if test -d "$withval"; then
729                 GUILE_PATH="$withval:$PATH"
730         else
731                 GUILE_PATH="$PATH"
732         fi
734         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
736         ## First, let's just see if we can find Guile at all.
737         if test "$GUILE_CONFIG" != no; then
738                 cf_result="yes";
740                 GUILE_LIBS="`guile-config link`"
741                 GUILE_CFLAGS="`guile-config compile`"
742                 LIBS="$GUILE_LIBS $LIBS"
743                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
744                 AC_SUBST(GUILE_CFLAGS)
745                 cat <<EOF
746 ***********************************************************************
747 The Guile support is incomplete and not so well integrated to ELinks
748 yet. That means, e.g., that you have no Guile console and there might
749 not be all the necessary hooks. Also, the Guile interface is not too
750 well tested (success stories heartily welcomed!).  See
751 src/scripting/guile/README for further details and hints.
752 ***********************************************************************
754         else
755                 if test -n "$withval" && test "x$withval" != xno; then
756                         AC_MSG_ERROR([Guile not found])
757                 else
758                         AC_MSG_WARN([Guile support disabled])
759                 fi
760         fi
761 else
762         AC_MSG_RESULT(no);
765 # ===================================================================
766 # Check for Perl
767 # ===================================================================
768 enable_perl="no";
770 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
771             [
772 if test "$withval" = yes; then
773         # FIXME: If withval is a valid directory append it to PATH
774         # so that you can specify one of several perl installations.
775         withval="";
776         enable_perl=yes;
778             ])
780 AC_MSG_CHECKING([for Perl])
782 cf_result=no
784 EL_SAVE_FLAGS
786 if test "$enable_perl" = "yes"; then
787         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
788         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
789         LIBS="$PERL_LIBS $LIBS"
790         CFLAGS="$PERL_CFLAGS $CFLAGS"
791         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
792         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
793 #include <EXTERN.h>
794 #include <perl.h>
795 #include <perlapi.h>
796 ]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no])
799 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
801 AC_MSG_CHECKING([whether POPpx works without an n_a variable])
802 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
803 #include <EXTERN.h>
804 #include <perl.h>
805 extern PerlInterpreter *my_perl;
806 ]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes])
807 AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1],
808                 [Define if using Perl 5.8.8 or later, where the "POPpx" macro
809 no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])])
811 if test "$cf_result" != "yes"; then
812         EL_RESTORE_FLAGS
813 else
814         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
816         CFLAGS="$CFLAGS_X"
817         CPPFLAGS="$CPPFLAGS_X"
818         AC_SUBST(PERL_LIBS)
819         AC_SUBST(PERL_CFLAGS)
822 # ===================================================================
823 # Check for Python
824 # ===================================================================
825 enable_python="no";
827 AC_ARG_WITH(python, [[  --with-python[=DIR]     enable Python support]],
828             [ if test "x$withval" != xno; then enable_python=yes; fi ])
830 EL_SAVE_FLAGS
831 cf_result=no
833 AC_MSG_CHECKING([for Python])
835 if test "$enable_python" = "yes"; then
836         AC_MSG_RESULT(yes);
838         if test -d "$withval"; then
839                 PYTHON_PATH="$withval:$PATH"
840         else
841                 PYTHON_PATH="$PATH"
842         fi
844         AC_PATH_PROG(PYTHON, python, no, $PYTHON_PATH)
846         if test "$PYTHON" != no; then
847                 cf_result="yes";
849                 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; print "-I%s -I%s" % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True))'`"
850                 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"))'`"
851                 LIBS="$PYTHON_LIBS $LIBS"
852                 CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
853                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no])
855                 if test "$cf_result" != "yes"; then
856                         EL_RESTORE_FLAGS
857                 else
858                         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
859                         AC_SUBST(PYTHON_LIBS)
860                         AC_SUBST(PYTHON_CFLAGS)
861                         CPPFLAGS="$CPPFLAGS_X"
862                         cat <<EOF
863 ***********************************************************************
864 The Python support is incomplete and not so well integrated to ELinks
865 yet. That means, e.g., that you have no Python console and there might
866 not be all the necessary hooks. Also, the Python interface is not too
867 well tested (success stories heartily welcomed!).
868 ***********************************************************************
870                 fi
871         else
872                 if test -n "$withval" && test "x$withval" != xno; then
873                         AC_MSG_ERROR([Python not found])
874                 else
875                         AC_MSG_WARN([Python support disabled])
876                 fi
877         fi
878 else
879         AC_MSG_RESULT(no);
883 # ===================================================================
884 # Check for Lua, optional even if installed.
885 # ===================================================================
887 # Do this the long way, as FreeBSD reportedly needs -L<dir> for
888 # anything other than /usr/lib, and Lua is very often in /usr/local/lib.
890 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
891             [if test "$withval" = no; then disable_lua=yes; fi])
892 AC_MSG_CHECKING([for Lua])
894 EL_SAVE_FLAGS
895 cf_result=no
897 if test -z "$disable_lua"; then
898         if test ! -d "$withval"; then
899                 withval="";
900         fi
901         for luadir in "$withval" "" /usr /usr/local; do
902                 for suffix in "" 5.1 51; do
903                         if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
904                            test -f "$luadir/include/lua$suffix/lua.h" ) ; then
905                                 LUA_LIBS="-L$luadir/lib -llua$suffix -lm"
906                                 LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
908                                 LIBS="$LUA_LIBS $LIBS_X"
909                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
910                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
912                                 # Check that it is a compatible Lua version
913                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[      #include <lauxlib.h>]
914                                                 #include <lua.h>
915                                                 #include <lualib.h>
916                                                 ], [[   lua_State *L = luaL_newstate();
917                                                 luaL_openlibs(L);
918                                                 lua_pushboolean(L, 1);
919                                                 lua_close(L);]])],[cf_result=yes],[cf_result=no])
920                         fi
921                 done
922         done
925 AC_MSG_RESULT($cf_result)
927 if test "$cf_result" != yes; then
928         EL_RESTORE_FLAGS
929 else
930         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
931         AC_CHECK_HEADERS(lauxlib.h)
933         CFLAGS="$CFLAGS_X"
934         CPPFLAGS="$CPPFLAGS_X"
935         AC_SUBST(LUA_LIBS)
936         AC_SUBST(LUA_CFLAGS)
939 # ===================================================================
940 # Check for TRE library
941 # ===================================================================
943 # This section only checks that --without-tre is not given and the
944 # library seems to work, and sets TRE_CFLAGS, TRE_LIBS, and
945 # tre_log.  It does not define CONFIG_TRE, and always resets
946 # LIBS and CFLAGS back to their original values.
948 # After any --enable-utf-8 and --disable-utf-8 options have been
949 # handled, a separate section decides whether to actually use TRE.
951 # tre version 0.8.0 or higher is required which have the "tre_" prefix
952 # for functions.
954 AC_ARG_WITH([[tre]], [[  --without-tre           disable TRE regex search support]])
955 if test "$with_tre" = no; then
956         AC_MSG_CHECKING([[for TRE]])
957         AC_MSG_RESULT([[disabled]])
958         tre_log="no (explicitly disabled)"
959 else
960         AC_MSG_CHECKING([[for TRE in pkg-config]])
961         if pkg-config tre; then
962                 TRE_CFLAGS=`pkg-config --cflags tre`
963                 TRE_LIBS=`pkg-config --libs tre`
964                 AC_MSG_RESULT([[yes]])
965         else
966                 # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
967                 # "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
968                 # so we look for the library even if pkg-config doesn't know about it.
969                 TRE_CFLAGS=
970                 TRE_LIBS=-ltre
971                 AC_MSG_RESULT([[no, but let's try defaults]])
972         fi
974         AC_MSG_CHECKING([[for TRE header and library]])
975         EL_SAVE_FLAGS
976         CFLAGS="$TRE_CFLAGS $CFLAGS"
977         LIBS="$TRE_LIBS $LIBS" # must be first, because of regfree conflict
978         AC_TRY_LINK([#include <tre/tre.h>],
979                     [regex_t re;
980                      regmatch_t match[1];
981                      tre_regwcomp(&re, L"zap", REG_ICASE);
982                      tre_regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
983                     [AC_MSG_RESULT([[yes]])
984                      tre_log="available"],
985                     [AC_MSG_RESULT([[no]])
986                      tre_log="no (TRE not found)"])
987         EL_RESTORE_FLAGS
990 # ===================================================================
991 # Check for Ruby, optional even if installed.
992 # ===================================================================
994 EL_CONFIG_SCRIPTING_RUBY
996 # ===================================================================
997 # Setup global scripting
998 # ===================================================================
1000 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])
1001 AC_SUBST(CONFIG_SCRIPTING_GUILE)
1002 AC_SUBST(CONFIG_SCRIPTING_LUA)
1003 AC_SUBST(CONFIG_SCRIPTING_PERL)
1004 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
1005 AC_SUBST(CONFIG_SCRIPTING_RUBY)
1006 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
1007 AC_SUBST(CONFIG_SCRIPTING)
1010 # ===================================================================
1011 # Check for SSL support.
1012 # ===================================================================
1014 # We by default use OpenSSL, and we always prefer it. However, when GNUTLS
1015 # is enabled, we won't try to use OpenSSL anymore.
1017 # For wiping SSL hooks..
1018 #ifdef CONFIG_SSL
1020 chosen_ssl_library=""
1022 AC_ARG_WITH(gnutls, [[  --without-gnutls        disable GNUTLS SSL support]])
1023 AC_ARG_WITH(gnutls, [[  --with-gnutls           enable GNUTLS SSL support]],
1024             [case "$with_gnutls" in
1025                 "no")   : ;;
1026                 "yes")  chosen_ssl_library="GNUTLS" ;;
1027                 *)      chosen_ssl_library="GNUTLS"
1028                         AC_MSG_WARN([[Support for --with-gnutls=DIR has been removed.
1029 You may have to set the PKG_CONFIG_PATH environment variable instead.]]) ;;
1030              esac])
1032 AC_ARG_WITH(openssl, [[  --without-openssl       disable OpenSSL support]])
1033 AC_ARG_WITH(openssl, [[  --with-openssl[=DIR]    enable OpenSSL support (default)]],
1034             [case "$with_openssl" in
1035                 "no")   : ;;
1036                 *)      chosen_ssl_library="OpenSSL" ;;
1037              esac])
1039 AC_ARG_WITH(nss_compat_ossl, [[  --with-nss_compat_ossl[=DIR]
1040                           NSS compatibility SSL libraries/include files]],
1041             [case "$with_nss_compat_ossl" in
1042                 "no")   : ;;
1043                 *)      chosen_ssl_library="nss_compat_ossl" ;;
1044              esac])
1046 # ---- nss_compat_ossl
1048 if test "$with_nss_compat_ossl" = no; then
1049         # explicitly disabled
1050         :
1051 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "nss_compat_ossl"; then
1052         # not used, because $chosen_ssl_library was chosen
1053         :
1054 elif test -z "${with_nss_compat_ossl+set}"; then
1055         # SSL_library_init() in nss_compat_ossl 0.9.2 calls exit(1)
1056         # with no error message if there is no certificate database.
1057         # https://bugzilla.redhat.com/show_bug.cgi?id=463437
1058         # So ELinks uses nss_compat_ossl only if explicitly requested.
1059         :
1060 else
1061         EL_SAVE_FLAGS
1062         if test "$with_nss_compat_ossl" = yes; then
1063                 if pkg-config nss; then
1064                         CFLAGS="$CFLAGS_X `pkg-config --cflags nss`"
1065                         LIBS="$LIBS_X `pkg-config --libs nss`"
1066                 else
1067                         with_nss_compat_ossl=no
1068                 fi
1069         else
1070                 # Without pkg-config, we'll kludge in some defaults
1071                 CFLAGS="$CFLAGS_X -I$with_nss_compat_ossl/include -I/usr/include/nss3 -I/usr/include/nspr4"
1072                 LIBS="$LIBS_X -L$with_nss_compat_ossl/lib -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
1073         fi
1074         AC_CHECK_HEADERS(nss_compat_ossl/nss_compat_ossl.h,, [with_nss_compat_ossl=no], [#define NSS_COMPAT_OSSL_H])
1075         AC_CHECK_LIB(nss_compat_ossl, X509_free,, [with_nss_compat_ossl=no])
1077         if test "$with_nss_compat_ossl" = "no"; then
1078                 EL_RESTORE_FLAGS
1079         else
1080                 LIBS="$LIBS -lnss_compat_ossl"
1081                 EL_CONFIG(CONFIG_NSS_COMPAT_OSSL, [nss_compat_ossl])
1082                 chosen_ssl_library="nss_compat_ossl"
1083         fi
1086 # ---- OpenSSL
1088 AC_MSG_CHECKING([for OpenSSL])
1090 EL_SAVE_FLAGS
1092 if test "$with_openssl" = no; then
1093         cf_result="explicitly disabled"
1095 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "OpenSSL"; then
1096         cf_result="not used, because $chosen_ssl_library was chosen"
1098 else
1099         cf_result=no
1100         for ssldir in "$with_openssl" "" /usr /usr/local/openssl \
1101                          /usr/lib/openssl /usr/local/ssl \
1102                          /usr/local/www /usr/lib/ssl /usr/local \
1103                          /usr/pkg /opt /opt/openssl; do
1104                 if test "$cf_result" = no; then
1105                         if test -d "$ssldir"; then
1106                                 OPENSSL_CFLAGS="-I$ssldir/include"
1107                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
1108                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
1109                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
1110 #                               # FIXME: This created serious portability problems. --pasky
1111 #                               if test "$CC" == "gcc"; then
1112 #                                       # I'm not sure about compatibility here. --pasky
1113 #                                       LIBS="$LIBS -R$ssldir/lib"
1114 #                               fi
1115                         else
1116                                 LIBS="-lssl -lcrypto $LIBS_X"
1117                         fi
1118                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no])
1119                         if test "$cf_result" != yes; then
1120                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no])
1121                         fi
1122                 fi
1123         done
1125         if test "$cf_result" != yes; then
1126                 if test "${with_openssl-no}" != "no"; then
1127                         AC_MSG_ERROR([OpenSSL not found])
1128                 fi
1129                 EL_RESTORE_FLAGS
1130         else
1131                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
1132                 chosen_ssl_library="OpenSSL"
1134                 CFLAGS="$CFLAGS_X"
1135                 AC_SUBST(OPENSSL_CFLAGS)
1136         fi
1139 AC_MSG_RESULT($cf_result)
1141 # ---- GNU TLS
1143 # GnuTLS 2.2.0 changed libgnutls-openssl from GPLv2+
1144 # to GPLv3+.  Don't link that with the GPLv2 ELinks.
1145 # ELinks will use its internal MD5 code instead.
1146 CONFIG_GNUTLS_OPENSSL_COMPAT=no
1148 if test "$with_gnutls" = no; then
1149         AC_MSG_CHECKING([[for GNUTLS]])
1150         AC_MSG_RESULT([[explicitly disabled]])
1152 elif test -n "$chosen_ssl_library" && test "$chosen_ssl_library" != "GNUTLS"; then
1153         AC_MSG_CHECKING([[for GNUTLS]])
1154         AC_MSG_RESULT([[not used, because $chosen_ssl_library was chosen]])
1156 else
1157         cf_result=no
1158         AC_MSG_CHECKING([[for GNUTLS (1.2 or later) in pkg-config]])
1159         if pkg-config --atleast-version=1.2 gnutls; then
1160                 GNUTLS_CFLAGS=`pkg-config --cflags gnutls`
1161                 GNUTLS_LIBS=`pkg-config --libs gnutls`
1162                 AC_MSG_RESULT([[yes: $GNUTLS_CFLAGS $GNUTLS_LIBS]])
1164                 EL_SAVE_FLAGS
1165                 LIBS="$GNUTLS_LIBS $LIBS"
1166                 CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
1167                 CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
1169                 # Verify if it's really usable.  gnutls_session was
1170                 # renamed to gnutls_session_t before GNU TLS 1.2.0
1171                 # (on 2004-06-13); ELinks now requires this.
1172                 AC_MSG_CHECKING([[whether GNUTLS can be linked with]])
1173                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]],
1174                                                 [[gnutls_session_t dummy;
1175                                                   gnutls_check_version(NULL)]])],
1176                                [cf_result=yes],
1177                                [cf_result=no])
1178                 AC_MSG_RESULT([[$cf_result]])
1180                 if test "$cf_result" = yes; then
1181                         # According to gnutls/NEWS, the function was originally
1182                         # added as gnutls_set_default_priority2 in GNUTLS 2.1.4
1183                         # (released 2007-10-27) and then renamed to
1184                         # gnutls_priority_set_direct in GNUTLS 2.1.7 (released
1185                         # 2007-11-29).
1186                         AC_CHECK_FUNCS([gnutls_priority_set_direct])
1187                 fi
1189                 EL_RESTORE_FLAGS
1190         else
1191                 AC_MSG_RESULT([[$cf_result]])
1192         fi
1194         if test "$cf_result" = yes; then
1195                 EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1196                 chosen_ssl_library="GNUTLS"
1198                 # gcry_create_nounce is part of libgcrypt
1199                 LIBGCRYPT_CFLAGS=`libgcrypt-config --cflags`
1200                 LIBGCRYPT_LIBS=`libgcrypt-config --libs`
1202                 LIBS="$LIBGCRYPT_LIBS $GNUTLS_LIBS $LIBS"
1203                 AC_SUBST(LIBGCRYPT_CFLAGS)
1204                 AC_SUBST(GNUTLS_CFLAGS)
1206         elif test "${with_gnutls-no}" != "no"; then
1207                 AC_MSG_ERROR([[GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.]])
1208         fi
1211 # Final SSL setup
1213 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS CONFIG_NSS_COMPAT_OSSL], [SSL])
1214 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1215 AC_SUBST(CONFIG_OPENSSL)
1216 AC_SUBST(CONFIG_GNUTLS)
1217 AC_SUBST(CONFIG_NSS_COMPAT_OSSL)
1219 #endif
1221 AC_MSG_CHECKING([whether to be or not to be])
1222 AC_MSG_RESULT([needs to be determined experimentally])
1224 # ===================================================================
1225 # Check for IPv6 support and related functions.
1226 # ===================================================================
1228 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1229 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1230 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1232 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1233 if test "$HAVE_GETADDRINFO" != yes; then
1234         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1235         if test "$HAVE_GETADDRINFO" = yes; then
1236                 LIBS="$LIBS -linet6"
1237         fi
1241 # ===================================================================
1242 # Checking for X11 (window title restoring).
1243 # ===================================================================
1245 AC_PATH_X
1246 if test x"$no_x" != xyes; then
1247         EL_SAVE_FLAGS
1248         if test -n "$x_includes"; then
1249                 X_CFLAGS="-I$x_includes"
1250                 CPPFLAGS="$CPPLAGS $X_CFLAGS"
1251                 CFLAGS="$CFLAGS $X_CFLAGS"
1252         fi
1253         if test -n "$x_libraries"; then
1254                 LDFLAGS="$LDFLAGS -L$x_libraries"
1255         fi
1256         LIBS="-lX11 $LIBS"
1257         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no])
1258         EL_RESTORE_FLAGS
1259         if test "$cf_result" = yes; then
1260                 if test -n "$x_libraries"; then
1261                         LDFLAGS="$LDFLAGS -L$x_libraries"
1262                 fi
1263                 LIBS="-lX11 $LIBS"
1264                 EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1265                 AC_SUBST(X_CFLAGS)
1266         fi
1270 # ===================================================================
1271 # Backtraces displaying support.
1272 # ===================================================================
1274 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1275 # possible checks for other system-specific means go here
1278 # ===================================================================
1279 # Gettext grey zone. Beware.
1280 # ===================================================================
1282 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"
1284 AM_GNU_GETTEXT
1286 # iconv is always used
1287 LIBS="$LIBS $LIBICONV"
1289 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1290 dnl # f33r d4 l33t... I hope it's portable. :)
1291 dnl cf_result=$((48#z - 48#a + 1));
1292 dnl AC_MSG_RESULT($cf_result)
1295 # ===================================================================
1296 # Compile-time features control
1297 # ===================================================================
1299 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1300               [  --disable-cookies       disable cookie support])
1302 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1303               [  --disable-formhist      disable form history support])
1305 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1306               [  --disable-globhist      disable global history support])
1309 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1310               [  --disable-mailcap       disable mailcap support])
1312 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1313               [  --disable-mimetypes     disable mimetypes files support])
1316 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1317               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1318               [IPv6],
1319               [  --disable-ipv6          disable IPv6 support])
1321 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1322               [  --enable-bittorrent     enable BitTorrent protocol support])
1324 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1325               [  --disable-data          disable data protocol support])
1327 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1328               [  --disable-uri-rewrite   disable URI rewrite support])
1330 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1331               [  --enable-cgi            enable local CGI support])
1333 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1334               [  --enable-finger         enable finger protocol support])
1336 # ===================================================================
1337 # FSP protocol
1338 # ===================================================================
1339 EL_SAVE_FLAGS
1341 if test "x${enable_fsp}" != xno; then
1342         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1344         if test "$HAVE_FSPLIB" = yes; then
1345                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1346                 if test "$HAVE_FSPLIB" = yes; then
1347                         LIBS="$LIBS -lfsplib"
1348                 else
1349                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1350                         if test "$HAVE_FSPLIB" = yes; then
1351                                 LIBS="$LIBS -lfsp"
1352                         fi
1353                 fi
1354         fi
1357 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1358               [  --enable-fsp            enable FSP protocol support])
1360 if test "x$CONFIG_FSP" = xno; then
1361         EL_RESTORE_FLAGS
1364 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1365               [  --disable-ftp           disable ftp protocol support])
1367 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1368               [  --enable-gopher         enable gopher protocol support])
1370 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1371               [  --enable-nntp           enable nntp protocol support])
1373 # ===================================================================
1374 # SMB protocol support.
1375 # ===================================================================
1376 EL_SAVE_FLAGS
1378 if test "x${enable_smb}" != xno; then
1379         AC_CHECK_HEADERS(libsmbclient.h, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1381         if test "$HAVE_SMBCLIENT" = yes; then
1382                 AC_CHECK_LIB(smbclient, smbc_init, HAVE_SMBCLIENT=yes, HAVE_SMBCLIENT=no)
1383                 if test "$HAVE_SMBCLIENT" = yes; then
1384                         LIBS="$LIBS -lsmbclient"
1385                 fi
1386         fi
1389 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [Samba protocol],
1390               [  --enable-smb            enable Samba protocol support])
1392 if test "x$CONFIG_SMB" = xno; then
1393         EL_RESTORE_FLAGS
1397 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1398               [  --disable-mouse         disable mouse support])
1400 # GPM mouse is Linux specific, so ...
1401 CONFIG_SYSMOUSE=yes
1402 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1403               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1404               [BSD sysmouse],
1405               [  --disable-sysmouse      disable BSD sysmouse support])
1407 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1408               [  --enable-88-colors      enable 88 color support])
1410 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1411               [  --enable-256-colors     enable 256 color support])
1413 EL_ARG_ENABLE(CONFIG_TRUE_COLOR, true-color, [true color],
1414               [  --enable-true-color     enable true color support])
1416 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1417               [  --enable-exmode         enable exmode (CLI) interface])
1419 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1420               [  --disable-leds          disable LEDs support])
1422 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1423               [  --disable-marks         disable document marks support])
1426 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1427               [  --disable-css           disable Cascading Style Sheet support])
1429 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1430               [  --enable-html-highlight HTML highlighting using DOM engine])
1432 # Everything in the tree already uses CONFIG_DOM
1433 # so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1434 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1436 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1437               [  --disable-backtrace     disable backtrace support])
1439 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1440               [  --enable-no-root        enable prevention of usage by root])
1443 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1444               [  --enable-debug          enable leak debug and internal error checking])
1446 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1447               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1449 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1450               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1452 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1453               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1455 EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8],
1456               [  --disable-utf-8         disable UTF-8 support])
1458 EL_ARG_DEPEND(CONFIG_COMBINE, combining, [CONFIG_UTF8:yes HAVE_WCWIDTH:yes], [Combining characters],
1459               [  --enable-combining      support Unicode combining characters (experimental)])
1462 AC_ARG_ENABLE(weehoofooboomookerchoo,
1463               [
1464     Also check out the features.conf file for more information about features!
1465               ],
1466               [AC_MSG_ERROR(Are you strange, or what?)])
1469 # ===================================================================
1470 # Decide whether to use TRE
1471 # ===================================================================
1473 # This must be done after the CONFIG_UTF8 check above.
1474 # The first part of the TRE check is separate, to get
1475 # the configure --help output in a sensible order.
1477 # After this section, nothing else must be added to the
1478 # beginning of $LIBS.
1480 if test "$tre_log" = "available"; then
1481         if test "$CONFIG_UTF8" = "yes"; then
1482                 # When CONFIG_UTF8 and CONFIG_TRE are both defined,
1483                 # src/viewer/text/search.c makes a string of
1484                 # unicode_val_T and gives it to regwexec(), which
1485                 # expects a string of wchar_t.  If the unicode_val_T
1486                 # and wchar_t types are too different, this won't
1487                 # work, so try to detect that and disable regexp
1488                 # operations entirely in that case.
1489                 #
1490                 # Currently, this code only compares the sizes of the
1491                 # types.  src/intl/charsets.h defines unicode_val_T as
1492                 # uint32_t, so we check whether wchar_t has exactly 32
1493                 # bits.  But don't use AC_CHECK_SIZEOF for this, because
1494                 # there doesn't seem to be a documented way to get the
1495                 # result of that for use in the configure script.
1496                 #
1497                 # C99 says the implementation can define
1498                 # __STDC_ISO_10646__ if wchar_t values match ISO 10646
1499                 # (or Unicode) numbers in all locales.  Do not check
1500                 # that macro here, because it is too restrictive: it
1501                 # should be enough for ELinks if the values match in
1502                 # the locales where ELinks is actually run.
1503                 AC_MSG_CHECKING([[whether wchar_t is exactly 32-bit]])
1504                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1505 #include <limits.h>
1506 #include <stddef.h>
1507 int dummy[(sizeof(wchar_t) * CHAR_BIT == 32) ? 1 : -1];]], [])],
1508                         [AC_MSG_RESULT([[yes]])
1509                          tre_log="TRE"],
1510                         [AC_MSG_RESULT([[no]])
1511                          tre_log="no (unsuitable wchar_t)"])
1512         else
1513                 # If UTF-8 is not used, then wchar_t doesn't matter.
1514                 tre_log="TRE"
1515         fi
1518 if test "$tre_log" = "TRE"; then
1519         AC_DEFINE([CONFIG_TRE], [1],
1520                 [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.])
1521         # TRE_CFLAGS will be used only where needed.
1522         #
1523         # Bug 1081: If both TRE and libc define the regfree function,
1524         # ELinks needs to use the version defined by TRE because
1525         # that's the one compatible with regex_t initialized by the
1526         # regwcomp function of TRE.  Therefore put $TRE_LIBS at the
1527         # very beginning of $LIBS so that the linker hopefully finds
1528         # regfree there before it examines libc.  In particular,
1529         # $PERL_LIBS appears to often include "-lc".
1530         #
1531         # This scheme still risks a crash if ELinks is linked with
1532         # some static library that uses GNU <regex.h> extensions that
1533         # TRE does not implement.  For example, the library might call
1534         # re_compile_pattern, which is found in GNU libc, and then
1535         # regfree, which is found in TRE and probably crashes with the
1536         # GNU-initialized regex_t.  Ways to avoid such crashes:
1537         #
1538         # - Change TRE so it defines only tre_... functions and does
1539         #   not attempt to override the POSIX names by default.
1540         #
1541         # - Change ELinks to access TRE only via dlopen and dlsym.
1542         #   The problem then is how to find the correct file name.
1543         #   There might be libtre.so.4 and libtre.so.5 with different
1544         #   ABI.  How can this configure script detect which of them
1545         #   matches the <tre/regex.h> in the include path?
1546         #
1547         # - Replace the static library with a shared library.  At
1548         #   least on GNU/Linux, when the shared library is built, the
1549         #   linker should note that e.g. regfree is defined in libc
1550         #   and has the GLIBC_2.0 version there, and write that
1551         #   version string to the shared library as well; because TRE
1552         #   does not provide regfree with that version, any regfree
1553         #   calls at run time should then get resolved to libc.
1554         LIBS="$TRE_LIBS $LIBS"
1555 else
1556         TRE_LIBS=
1557         TRE_CFLAGS=
1559 AC_SUBST(TRE_CFLAGS)
1560 AC_SUBST(TRE_LIBS)
1561 EL_LOG_CONFIG([CONFIG_TRE], [[Regexp searching]], [[$tre_log]])
1564 # ===================================================================
1565 # Further LDFLAGS tweaks
1566 # ===================================================================
1568 # == EMX hack
1570 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1571 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1574 # Check for -rdynamic
1576 # gcc -rdynamic calls ld -export-dynamic, which adds all symbols of
1577 # the executable to its dynamic symbol table.  ELinks uses this for
1578 # two purposes:
1580 # 1. If ELinks detects a bug, it can try to display a backtrace by
1581 #    calling backtrace_symbols_fd() in the GNU libc.  The glibc-2.3.6
1582 #    manual states users of GNU ld must pass -rdynamic to make the
1583 #    symbols available to the program.
1585 # 2. It would eventually be nice to dynamically load shared
1586 #    libraries as plugins (bug 73).  The plugins must be able to
1587 #    call ELinks functions.  This can be implemented either by
1588 #    registering all callable functions in ELinks-specific data
1589 #    structures, or by letting the dynamic linker handle them.
1590 #    The latter way requires something equivalent to -rdynamic.
1592 # Because backtraces are not needed for correct operation, and bug
1593 # 73 is not yet being fixed, the configure script and makefiles
1594 # should not complain to the user if they find that -rdynamic does
1595 # not work.  Besides, it was reported at elinks-users on 2006-09-12
1596 # that gcc-3.4.2 with "ld: Software Generation Utilities - Solaris
1597 # Link Editors: 5.8-1.284" on Sun Solaris 8 Sparc does not support
1598 # -rdynamic but does something equivalent automatically.  (This was
1599 # tested with "nm -D elinks | grep redraw_from_window".)
1601 # With Sun Studio 11 on Solaris 9, we get "cc: Warning: illegal option
1602 # -dynamic"; then, cc proceeds anyway, but the option can prevent the
1603 # linker from finding the libraries listed in -l operands.  So this
1604 # -rdynamic check needs to happen after the libraries have already
1605 # been added to $LDFLAGS.
1606 AC_MSG_CHECKING([for -rdynamic])
1607 LDFLAGS_X="$LDFLAGS"
1608 LDFLAGS="-rdynamic $LDFLAGS"
1609 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no])
1610 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
1611 AC_MSG_RESULT($have_rdynamic)
1613 # ===================================================================
1614 # Export directory paths
1615 # ===================================================================
1617 # Set up the ``entry points'' if they were not supplied by builder
1618 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1619 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1621 # Create CONFDIR #define for config.h
1623 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1624 # it's autoconf fault to force us to do such hacks ;p.
1625 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1626   # sysconfdir is set to its default value... fine, let's append /elinks/
1627   # XXX: We can't modify listing of the default in ./configure --help :-(
1628   sysconfdir_n=`eval echo "$sysconfdir"`
1629   sysconfdir=$sysconfdir_n
1630   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1631         sysconfdir="$sysconfdir/elinks"
1634 CONFDIR=$sysconfdir
1635 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1636 AC_SUBST(CONFDIR)
1638 # Create LOCALEDIR #define for config.h
1639 LOCALEDIR=`eval echo "$datadir/locale"`
1640 while echo "$LOCALEDIR" | grep "\\$"
1642         LOCALEDIR=`eval echo "$LOCALEDIR"`
1643 done > /dev/null 2> /dev/null
1644 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1645 AC_SUBST(LOCALEDIR)
1647 # Create LIBDIR #define for config.h
1648 LIBDIR=`eval echo "$libdir"`
1649 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1650 AC_SUBST(LIBDIR)
1652 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1653 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1656 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
1657 ]], [[#if !defined(__TINYC__) || !defined(alloca)
1658         #error not tcc
1659         #endif ]])],[cf_result=yes],[cf_result=no])
1661 if test "$cf_result" = "yes"; then
1662         AC_DEFINE([HAVE_ALLOCA])
1663         AC_DEFINE([_ALLOCA_H], [1], [Define as 1 if you are using Tiny C Compiler
1664                 with the GNU C Library, and <alloca.h> of glibc would otherwise
1665                 override the alloca macro defined in <stddef.h> of TCC.
1666                 If <alloca.h> of glibc sees the _ALLOCA_H macro, it assumes
1667                 it has already been included, and does not redefine alloca.
1668                 This might not work in future glibc versions though, because
1669                 the names of the #include guard macros are not documented.
1670                 The incompatibility has been reported to the tinycc-devel
1671                 mailing list on 2008-07-14.  If a future version of TCC provides
1672                 an <alloca.h> of its own, this hack won't be needed.])
1674 # ===================================================================
1675 # A little fine tuning of gcc specific options (continued)
1676 # ===================================================================
1678 GETTEXT_CFLAGS=
1679 if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
1680   if test "$CONFIG_DEBUG" = "yes"; then
1681     # We want to see all warnings and live with none (in debug mode).
1682     CFLAGS="$CFLAGS -Werror"
1683   fi
1684   GETTEXT_CFLAGS="-Wno-uninitialized"
1686   case "`$CC -dumpversion`" in
1687     3.0|3.1|3.2)
1688       # These should be ok using -Werror
1689       ;;
1690     3.*)
1691       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1692       # "dereferencing type-punned pointer will break strict-aliasing rules"
1693       # warnings. Disable them by not doing any strict-aliasing. The
1694       # alternative is just too ugly. Thanks gcc guys!! ;)
1695       CFLAGS="$CFLAGS -fno-strict-aliasing"
1696       ;;
1697     4.5*)
1698       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign -Wno-enum-compare"
1699       ;;
1700     4.*)
1701       # Do not show warnings related to (char * | unsigned char *) type
1702       # difference.
1703       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1704       ;;
1705     *)
1706       # These should be ok using -Werror
1707       ;;
1708   esac
1710   # GCC 4.2.1 warns if we use the address of an object in Boolean context:
1711   # warning: the address of `builtin_modules' will always evaluate as `true'
1712   # This hits the object_lock and foreach_module macros in particular.
1713   # It would be okay to put something in the macros to avoid the warning,
1714   # but currently this seems to require defining parallel macros that skip
1715   # the NULL check, and that's too ugly.  So we instead disable the warning.
1716   # GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
1717   # GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
1718   for warning_flag in -Wno-address -Wno-always-true; do
1719     AC_MSG_CHECKING([whether $CC accepts $warning_flag])
1720     EL_SAVE_FLAGS
1721     CFLAGS="$CFLAGS $warning_flag"
1722     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1723       [AC_MSG_RESULT([yes])
1724        break],
1725       [AC_MSG_RESULT([no])])
1726     EL_RESTORE_FLAGS
1727   done
1729   # Bug 1012: Some parts of ELinks do arithmetic with signed integers
1730   # in such a way that an overflow is possible.  GCC 4.2.1 warns
1731   # "warning: assuming signed overflow does not occur when assuming
1732   # that (X + c) > X is always true", which may be an incorrect
1733   # optimization (although allowed by the standard), and breaks the
1734   # build with -Werror.
1735   #
1736   # All of the following tests included -S -Wall -Wextra:
1737   #
1738   # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
1739   # * gcc-4.0 -O0: OK, compares the values
1740   # * gcc-4.0 -O2: assumes no overflow, does not warn
1741   # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option
1742   # * gcc-4.0 -O0 -fwrapv: OK, compares the values
1743   # * gcc-4.0 -O2 -fwrapv: OK, compares the values
1744   # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3
1745   # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn
1746   # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1747   # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values
1748   #
1749   # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)
1750   # * gcc-4.1 -O0: assumes no overflow, does not warn
1751   # * gcc-4.1 -O2: assumes no overflow, does not warn
1752   # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option
1753   # * gcc-4.1 -O0 -fwrapv: OK, compares the values
1754   # * gcc-4.1 -O2 -fwrapv: OK, compares the values
1755   # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3
1756   # * gcc-4.1 -O2 -ftrapv: compares the values
1757   # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1758   # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values
1759   #
1760   # GCC: (GNU) 4.2.1 (Debian 4.2.1-5)
1761   # * gcc-4.2 -O0: OK, compares the values
1762   # * gcc-4.2 -O2: assumes no overflow, warns about it
1763   # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values
1764   # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values
1765   # * gcc-4.2 -O0 -fwrapv: OK, compares the values
1766   # * gcc-4.2 -O2 -fwrapv: OK, compares the values
1767   # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3
1768   # * gcc-4.2 -O2 -ftrapv: compares the values
1769   # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3
1770   # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values
1771   #
1772   # Apparently, -ftrapv does not work reliably at all.
1773   for overflow_flag in -fno-strict-overflow -fwrapv; do
1774     AC_MSG_CHECKING([whether $CC accepts $overflow_flag])
1775     EL_SAVE_FLAGS
1776     CFLAGS="$CFLAGS $overflow_flag"
1777     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1778       [AC_MSG_RESULT([yes])
1779        break],
1780       [AC_MSG_RESULT([no])])
1781     EL_RESTORE_FLAGS
1782   done
1785 AC_SUBST(GETTEXT_CFLAGS)
1786 EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
1787 EL_LOG_CONFIG(CPPFLAGS, [Preprocessor flags (CPPFLAGS)], [])
1788 EL_LOG_CONFIG(LDFLAGS, [Linker flags (LDFLAGS)], [])
1789 EL_LOG_CONFIG(LIBS, [Library flags (LIBS)], [])
1791 # ===================================================================
1792 # Colored make output
1793 # ===================================================================
1795 if test $(`which tput` colors 2> /dev/null || echo 0) -ge 4; then
1796         MAKE_COLOR=1
1797         AC_SUBST(MAKE_COLOR)
1800 # ===================================================================
1801 # Generated files
1802 # ===================================================================
1804 AC_CONFIG_FILES([ \
1805  Makefile.config \
1806  contrib/elinks.spec \
1807  contrib/lua/hooks.lua \
1808  contrib/conv/w3m2links.awk \
1809  doc/Doxyfile \
1810  doc/man/man1/elinks.1 \
1811  src/intl/gettext/ref-add.sed \
1812  src/intl/gettext/ref-del.sed
1814 AC_OUTPUT
1816 abs_srcdir="$(cd "$srcdir" && pwd)"
1817 # builddir is always absolute!
1818 if test "$abs_srcdir" != "$builddir"; then
1819         # Bootstrap the Makefile creation
1820         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1821         "$MAKE" "SRC=$abs_srcdir" init
1823         # Make cg-status ignore this build directory
1824         echo "*" > "$builddir/.gitignore"
1827 # ===================================================================
1828 # Configuration summary
1829 # ===================================================================
1831 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1832 cat features.log