Pass $LIBS to the linker
[elinks.git] / configure.in
blobdb602af5dbd5541f0bbc77cc3418cec14fa53c53
1 dnl Process this file with autoconf to produce a configure script.
3 AC_PREREQ(2.13)
4 AC_INIT(src/main/main.c)
5 AC_CONFIG_AUX_DIR(config)
7 AM_INIT_AUTOMAKE(elinks, 0.11.GIT)
8 AM_CONFIG_HEADER(config.h)
10 AC_PROG_MAKE_SET
12 builddir="`pwd`"
14 dnl ===================================================================
15 dnl Load feature configuration file and start logging features.
16 dnl ===================================================================
18 features="features.conf"
19 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
20 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
21 echo "Feature summary:" > features.log
23 dnl ===================================================================
24 dnl Checks for programs.
25 dnl ===================================================================
27 AC_PROG_CC
28 AC_PROG_AWK
29 AC_PATH_PROGS(AWK, "$AWK")
30 AC_PROG_RANLIB
32 CONFIG_ASCIIDOC="no"
33 CONFIG_POD2HTML="no"
34 CONFIG_XMLTO="no"
35 CONFIG_JW="no"
37 if test "x$CONFIG_DOC" != xno; then
38         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
39         if test "x$ASCIIDOC" != "x"; then
40                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
41                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
42                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
43         fi
45         AC_PATH_PROGS(XMLTO, "xmlto")
46         if test "x$XMLTO" != "x"; then
47                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
48                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
49                 EL_CONFIG(MAN_XMLTO, [man (groff)])
50         fi
52         AC_PATH_PROGS(JW, "jw")
53         if test "x$JW" != "x"; then
54                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
55                 EL_CONFIG(MANUAL_JW, [PDF])
56         fi
58         AC_PATH_PROGS(POD2HTML, "pod2html")
59         if test "x$POD2HTML" != "x"; then
60                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
61         fi
64 AC_SUBST(CONFIG_ASCIIDOC)
65 AC_SUBST(CONFIG_POD2HTML)
66 AC_SUBST(CONFIG_XMLTO)
67 AC_SUBST(CONFIG_JW)
69 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation])
71 if test "$CONFIG_ASCIIDOC" = yes &&
72    test "$CONFIG_XMLTO" = yes &&
73    test "$CONFIG_JW" = yes; then
74         EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
77 if test "$CONFIG_ASCIIDOC" = yes &&
78    test "$CONFIG_XMLTO" = yes; then
79         EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
82 AC_SUBST(CONFIG_ASCIIDOC)
83 AM_CONDITIONAL(CONFIG_ASCIIDOC, test "$CONFIG_ASCIIDOC" = yes)
84 AC_SUBST(CONFIG_POD2HTML)
85 AM_CONDITIONAL(CONFIG_POD2HTML, test "$CONFIG_POD2HTML" = yes)
86 AC_SUBST(CONFIG_XMLTO)
87 AM_CONDITIONAL(CONFIG_XMLTO, test "$CONFIG_XMLTO" = yes)
88 AC_SUBST(CONFIG_JW)
89 AM_CONDITIONAL(CONFIG_JW, test "$CONFIG_JW" = yes)
91 dnl gcc specific options (to be continued at the bottom of configure)
92 if test "x$ac_cv_prog_gcc" = "xyes"; then
93   dnl We want to see all warnings and live with none.
94   dnl We can't set up -Werror here as there may be some warnings in test
95   dnl suite of configure, and we don't want to fail them.
96   CFLAGS="$CFLAGS -Wall"
99 dnl ===================================================================
100 dnl Checks for special OSes.
101 dnl ===================================================================
103 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
104 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
106         AC_MSG_CHECKING([for $2])
108         for flag in $3; do
109                 AC_TRY_COMPILE(, [#ifndef $flag
110 kill me!
111 #endif ], $1=yes, $1=no)
112                 if test "[$]$1" = yes; then
113                         EL_CONFIG([$1], [$2])
114                         break
115                 fi
116         done
118         AC_MSG_RESULT([$]$1)
121 EL_CHECK_COMPILER_MACROS(CONFIG_BEOS, [BEOS], [__BEOS__])
122 AC_SUBST(CONFIG_BEOS)
123 AM_CONDITIONAL(CONFIG_BEOS, test "$CONFIG_BEOS" = yes)
125 EL_CHECK_COMPILER_MACROS(CONFIG_RISCOS, [RISCOS], [__riscos__])
126 AC_SUBST(CONFIG_RISCOS)
127 AM_CONDITIONAL(CONFIG_RISCOS, test "$CONFIG_RISCOS" = yes)
129 EL_CHECK_COMPILER_MACROS(CONFIG_WIN32, [WIN32], [_WIN32 __WIN32__])
130 AC_SUBST(CONFIG_WIN32)
131 AM_CONDITIONAL(CONFIG_WIN32, test "$CONFIG_WIN32" = yes)
133 EL_CHECK_COMPILER_MACROS(CONFIG_OS2, [EMX], [__EMX__])
134 AC_SUBST(CONFIG_OS2)
135 AM_CONDITIONAL(CONFIG_OS2, test "$CONFIG_OS2" = yes)
136 test "$CONFIG_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
138 AC_MSG_CHECKING([for UNIX])
139 dnl FIXME: some depend kind of mechanism
140 if test "$CONFIG_BEOS" = no && \
141    test "$CONFIG_RISCOS" = no && \
142    test "$CONFIG_WIN32" = no && \
143    test "$CONFIG_OS2" = no; then
144         EL_CONFIG(CONFIG_UNIX, [UNIX])
145 else
146         CONFIG_UNIX=no
148 AC_MSG_RESULT($CONFIG_UNIX)
149 AC_SUBST(CONFIG_UNIX)
150 AM_CONDITIONAL(CONFIG_UNIX, test "$CONFIG_UNIX" = yes)
152 dnl ===================================================================
153 dnl Checks for header files.
154 dnl ===================================================================
156 AC_HEADER_DIRENT
157 AC_HEADER_STDC
158 AC_HEADER_SYS_WAIT
159 AC_HEADER_TIME
161 AC_CHECK_HEADERS(fcntl.h limits.h time.h unistd.h)
162 AC_CHECK_HEADERS(sigaction.h)
163 AC_CHECK_HEADERS(arpa/inet.h)
164 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
165 AC_CHECK_HEADERS(net/if.h netdb.h netinet/in.h netinet/in6_var.h)
166 AC_CHECK_HEADERS(ifaddrs.h)
167 AC_CHECK_HEADERS(sys/cygwin.h io.h)
168 AC_CHECK_HEADERS(sys/fmutex.h)
169 AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
170 AC_CHECK_HEADERS(sys/resource.h)
171 AC_CHECK_HEADERS(sys/select.h)
172 AC_CHECK_HEADERS(sys/signal.h)
173 AC_CHECK_HEADERS(sys/socket.h)
174 AC_CHECK_HEADERS(sys/time.h)
175 AC_CHECK_HEADERS(sys/utsname.h)
176 AC_CHECK_HEADERS(stdint.h inttypes.h)
177 AC_CHECK_HEADERS(locale.h pwd.h)
178 AC_CHECK_HEADERS(termios.h)
181 AC_CHECK_HEADERS(sys/un.h,
182         [CONFIG_INTERLINK=yes
183          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
184         [CONFIG_INTERLINK=no])
185 AC_SUBST(CONFIG_INTERLINK)
186 AM_CONDITIONAL(CONFIG_INTERLINK, test "$CONFIG_INTERLINK" = yes)
188 dnl ===================================================================
189 dnl Checks for typedefs, structures, and compiler characteristics.
190 dnl ===================================================================
192 AC_STRUCT_TM
193 AC_C_CONST
194 AC_C_INLINE
195 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
197 AC_SYS_LARGEFILE
198 AC_TYPE_SIZE_T
199 AC_TYPE_OFF_T
200 EL_CHECK_TYPE(ssize_t, int)
201 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
202 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
203 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
204 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
206 AC_CHECK_SIZEOF(char, 1)
207 AC_CHECK_SIZEOF(short, 2)
208 AC_CHECK_SIZEOF(int, 4)
209 AC_CHECK_SIZEOF(long, 4)
210 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
212 dnl Check for variadic macros
213 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
214                 [#include <stdio.h>
215                  #define a(b,c...) printf(b,##c)],
216                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
218 dnl Check for -rdynamic
219 dnl FIXME: This check doesn't work. Something to do with the compiler
220 dnl happily ignoring it and stderr not being checked for error messages.
221 AC_MSG_CHECKING([for -rdynamic])
222 LDFLAGS_X="$LDFLAGS"
223 LDFLAGS="$LDFLAGS -rdynamic"
224 AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no)
225 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
226 AC_MSG_RESULT($have_rdynamic)
228 dnl ===================================================================
229 dnl Check for POSIX <regex.h>
230 dnl ===================================================================
232 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
234 dnl ===================================================================
235 dnl Checks for library functions.
236 dnl ===================================================================
238 AC_PROG_GCC_TRADITIONAL
239 AC_FUNC_MEMCMP
240 AC_FUNC_MMAP
241 AC_FUNC_STRFTIME
242 AC_CHECK_FUNCS(cfmakeraw gethostbyaddr herror strerror)
243 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
244 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
245 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
246 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
247 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
248 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
249 AC_CHECK_FUNCS(gettimeofday clock_gettime)
251 AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path)
253 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
254 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
255 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
257 dnl These aren't probably needed now, as they are commented in links.h.
258 dnl I've no idea about their historical background, but I keep them here
259 dnl just in the case they will help later. --pasky
260 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
261 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
262 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
263 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
265 if test x"$HAVE_RAISE" = x; then
266         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
267                 AC_ERROR([Unable to emulate raise()])
268         fi
271 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
272 AC_TRY_LINK([#include <stdarg.h>
273 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
274 el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)])
275 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
276         EL_DEFINE(HAVE_VA_COPY, __va_copy)
279 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
280 AC_TRY_LINK([#include <unistd.h>
281 ], [int page_size = sysconf(_SC_PAGE_SIZE);],
282 el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)])
283 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
284         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
287 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
288 AC_TRY_RUN([
289 #include <stdio.h>
290 #include <stdarg.h>
291 #include <stdlib.h>
292 #include <string.h>
294 char buf[8];
296 int bar(char *buf, const char *format, va_list ap)
298        return vsnprintf(buf, 0, format, ap);
301 void foo(const char *format, ...) {
302        va_list ap;
303        int len;
305        va_start(ap, format);
306        len = bar(buf, format, ap);
307        va_end(ap);
308        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
310        va_start(ap, format);
311        len = bar(buf, format, ap);
312        va_end(ap);
313        if ((len != 6) && (len != 7)) exit(1);
315        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
317        exit(0);
319 main() { foo("hello\n"); }
321 el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)])
322 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
323         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
326 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
328 dnl ===================================================================
329 dnl Checks for libraries.
330 dnl ===================================================================
332 dnl Replace `main' with a function in -lsocket:
333 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
334 if test "$cf_result" = no; then
335         AC_CHECK_LIB(socket, socket)
338 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
339 if test "$cf_result" = no; then
340         AC_CHECK_LIB(socket, setsockopt)
343 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
344 if test "$cf_result" = no; then
345         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
346         if test "$cf_result" = no; then
347                 AC_CHECK_LIB(nsl, gethostbyname)
348         else
349                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
350         fi
353 dnl ===================================================================
354 dnl Checks for packaging specific options.
355 dnl ===================================================================
357 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
358             [ if test "$withval" != no && test "$withval" != yes; then
359                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
360               fi ])
362 dnl ===================================================================
363 dnl Checks for a libraries, optional even if installed.
364 dnl ===================================================================
366 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
367 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
369         AC_MSG_CHECKING([for $2 support])
371         if test "[$]$1" != no; then
372                 AC_MSG_RESULT(yes)
373                 EL_SAVE_FLAGS
374                 if test -n "$withval" && test -d "$withval"; then
375                         CFLAGS="$CFLAGS -I$withval/include";
376                         CPPFLAGS="$CPPFLAGS -I$withval/include";
377                         LDFLAGS="$LDFLAGS -L$withval/lib";
378                 fi
380                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
381                 if test "[$]$1" = yes; then
382                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
383                 fi
385                 if test "[$]$1" = yes; then
386                         EL_CONFIG([$1], [$2])
387                         LIBS="$LIBS -l$4"
388                 else
389                         if test -n "[$]WITHVAL_$1" &&
390                            test "[$]WITHVAL_$1" != xno; then
391                                 AC_MSG_ERROR([$2 not found])
392                         fi
393                         EL_RESTORE_FLAGS
394                 fi
395         else
396                 AC_MSG_RESULT(disabled)
397         fi
400 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
401 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
403         $1=yes
404         WITHVAL_$1=
406         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
407         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
409         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
411         EL_LOG_CONFIG([$1], [$2], [])
414 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
415         [  --without-gpm           disable gpm (mouse) support])
417 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzdopen,
418         [  --without-zlib          disable zlib support])
419 AC_SUBST(CONFIG_GZIP)
420 AM_CONDITIONAL(CONFIG_GZIP, test "$CONFIG_GZIP" = yes)
422 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
423         [  --without-bzlib         disable bzlib support])
424 AC_SUBST(CONFIG_BZIP2)
425 AM_CONDITIONAL(CONFIG_BZIP2, test "$CONFIG_BZIP2" = yes)
427 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
428         [  --without-idn           disable international domain names support])
430 dnl ===================================================================
431 dnl Bookmark and XBEL support
432 dnl ===================================================================
434 EL_SAVE_FLAGS
436 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
437               [  --disable-bookmarks     disable bookmark support])
438 AC_SUBST(CONFIG_BOOKMARKS)
439 AM_CONDITIONAL(CONFIG_BOOKMARKS, test "$CONFIG_BOOKMARKS" = yes)
441 # Check whether --enable-xbel or --disable-xbel was given.
442 if test "x${enable_xbel}" != xno; then
443         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
445         if test "$HAVE_LIBEXPAT" = yes; then
446                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
447                 if test "$HAVE_LIBEXPAT" = yes; then
448                         LIBS="$LIBS -lexpat"
449                 fi
450         fi
454 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
455               [XBEL bookmarks],
456               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
458 AC_SUBST(CONFIG_XBEL_BOOKMARKS)
459 AM_CONDITIONAL(CONFIG_XBEL_BOOKMARKS, test "$CONFIG_XBEL_BOOKMARKS" = yes)
461 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
462         EL_RESTORE_FLAGS
465 dnl ===================================================================
466 dnl Checks for BSD sysmouse
467 dnl ===================================================================
469 HAVE_SYSMOUSE_HEADER="no"
471 # Either of these header files provides the (same) sysmouse interface
472 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
474 dnl ===================================================================
475 dnl Checks for OS/2
476 dnl ===================================================================
478 if test "$CONFIG_OS2" = yes; then
479         EL_CONFIG_OS2
482 dnl ===================================================================
483 dnl Checks for Win32
484 dnl ===================================================================
486 if test "$CONFIG_WIN32" = yes; then
487         EL_CONFIG_WIN32
490 dnl ===================================================================
491 dnl Check for Guile, optional even if installed.
492 dnl ===================================================================
494 enable_guile="no";
496 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
497             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
499 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
500 # GUILE_FLAGS but I really don't want to require people to have Guile in order
501 # to compile CVS. Also, the macro seems to be really stupid regarding searching
502 # for Guile in $PATH etc. --pasky
504 AC_MSG_CHECKING([for Guile])
506 if test "$enable_guile" = "yes"; then
507         AC_MSG_RESULT(yes);
508         ## Based on the GUILE_FLAGS macro.
510         if test -d "$withval"; then
511                 GUILE_PATH="$withval:$PATH"
512         else
513                 GUILE_PATH="$PATH"
514         fi
516         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
518         ## First, let's just see if we can find Guile at all.
519         if test "$GUILE_CONFIG" != no; then
520                 cf_result="yes";
522                 GUILE_LIBS="`guile-config link`"
523                 GUILE_CFLAGS="`guile-config compile`"
524                 LIBS="$GUILE_LIBS $LIBS"
525                 CPPFLAGS="$CPPFLAGS $GUILE_CFLAGS"
526                 EL_CONFIG(CONFIG_GUILE, [Guile])
527                 AC_SUBST(GUILE_CFLAGS)
528                 cat <<EOF
529 ***********************************************************************
530 The Guile support is incomplete and not so well integrated to ELinks
531 yet. That means, ie., that you have no Guile console and there might
532 not be all the necessary hooks. Also, the Guile interface is not too
533 well tested (success stories heartily welcomed!).  See
534 src/scripting/guile/README for further details and hints.
535 ***********************************************************************
537         else
538                 if test -n "$withval" && test "x$withval" != xno; then
539                         AC_MSG_ERROR([Guile not found])
540                 else
541                         AC_MSG_WARN([Guile support disabled])
542                 fi
543         fi
544 else
545         AC_MSG_RESULT(no);
548 dnl ===================================================================
549 dnl Check for Perl
550 dnl ===================================================================
551 enable_perl="no";
553 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
554             [
555 if test "$withval" = yes; then
556         # FIXME: If withval is a valid directory append it to PATH
557         # so that you can specify one of several perl installations.
558         withval="";
559         enable_perl=yes;
561             ])
563 AC_MSG_CHECKING([for Perl])
565 cf_result=no
567 EL_SAVE_FLAGS
569 if test "$enable_perl" = "yes"; then
570         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
571         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
572         LIBS="$PERL_LIBS $LIBS"
573         CFLAGS="$PERL_CFLAGS $CFLAGS"
574         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
575         AC_TRY_LINK([
576 #include <EXTERN.h>
577 #include <perl.h>
578 #include <perlapi.h>
580                     [PerlInterpreter *my_perl = perl_alloc();],
581                     cf_result=yes, cf_result=no)
584 if test "$cf_result" != "yes"; then
585         EL_RESTORE_FLAGS
586 else
587         EL_CONFIG(CONFIG_PERL, [Perl])
589         CFLAGS="$CFLAGS_X"
590         AC_SUBST(PERL_LIBS)
591         AC_SUBST(PERL_CFLAGS)
594 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
595 dnl ===================================================================
596 dnl Check for Python
597 dnl ===================================================================
598 enable_python="no";
600 AC_ARG_WITH(python, [  --with-python           enable Python support],
601             [
602 if test "$withval" = yes; then
603         # FIXME: If withval is a valid directory append it to PATH
604         # so that you can specify one of several Python installations.
605         withval="";
606         enable_python=yes;
607         cat <<EOF
608 ***********************************************************************
609 The Python support is incomplete and not so well integrated to ELinks
610 yet. That means, ie., that you have no Python console and there might
611 not be all the necessary hooks. Also, the Python interface is not too
612 well tested (success stories heartily welcomed!).
613 ***********************************************************************
616             ])
618 AC_MSG_CHECKING([for Python])
620 cf_result=no
622 EL_SAVE_FLAGS
624 if test "$enable_python" = "yes"; then
625         PYTHON_LIBS="-lpython"
626         PYTHON_CFLAGS="-I`python -c 'from distutils import sysconfig; print sysconfig.get_python_inc()' 2> /dev/null`"
627         LIBS="$PYTHON_LIBS $LIBS"
628         CFLAGS="$PYTHON_CFLAGS $CFLAGS"
629         CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
630         AC_TRY_LINK([
631 #include <Python.h>
633                     [Py_Initialize();],
634                     cf_result=yes, cf_result=no)
637 if test "$cf_result" != "yes"; then
638         EL_RESTORE_FLAGS
639 else
640         EL_CONFIG(CONFIG_PYTHON, [Python])
642         CFLAGS="$CFLAGS_X"
643         AC_SUBST(PYTHON_LIBS)
644         AC_SUBST(PYTHON_CFLAGS)
647 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
650 dnl ===================================================================
651 dnl Check for Lua, optional even if installed.
652 dnl ===================================================================
654 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
655 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
657 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
658             [if test "$withval" = no; then disable_lua=yes; fi])
659 AC_MSG_CHECKING([for Lua])
661 EL_SAVE_FLAGS
662 cf_result=no
664 if test -z "$disable_lua"; then
665         if test ! -d "$withval"; then
666                 withval="";
667         fi
668         for luadir in "$withval" "" /usr /usr/local; do
669                 for suffix in "" 50 51; do
670                         if test "$cf_result" = no; then
671                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
673                                 if test ! -z "$luadir"; then
674                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
675                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
676                                 fi
678                                 LIBS="$LUA_LIBS $LIBS_X"
679                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
680                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
682                                 # Check that it is a compatible Lua version
683                                 AC_TRY_LINK([   #include <lua.h>
684                                                 #include <lualib.h>],
685                                             [   lua_State *L = lua_open();
686                                                 lua_baselibopen(L);
687                                                 lua_mathlibopen(L);
688                                                 lua_strlibopen(L);
689                                                 lua_tablibopen(L);
690                                                 lua_pushboolean(L, 1);
691                                                 lua_close(L);],
692                                             cf_result=yes, cf_result=no)
693                         fi
694                 done
695         done
698 AC_MSG_RESULT($cf_result)
700 if test "$cf_result" != yes; then
701         EL_RESTORE_FLAGS
702 else
703         EL_CONFIG(CONFIG_LUA, [Lua])
704         AC_CHECK_HEADERS(lauxlib.h)
706         CFLAGS="$CFLAGS_X"
707         AC_SUBST(LUA_LIBS)
708         AC_SUBST(LUA_CFLAGS)
712 dnl ===================================================================
713 dnl Check for Ruby, optional even if installed.
714 dnl ===================================================================
716 EL_CONFIG_RUBY
718 dnl ===================================================================
719 dnl Setup global scripting
720 dnl ===================================================================
722 EL_CONFIG_DEPENDS(CONFIG_SCRIPTING, [CONFIG_GUILE CONFIG_LUA CONFIG_PERL CONFIG_PYTHON CONFIG_RUBY], [Scripting])
723 AC_SUBST(CONFIG_GUILE)
724 AM_CONDITIONAL(CONFIG_GUILE, test "$CONFIG_GUILE" = yes)
725 AC_SUBST(CONFIG_LUA)
726 AM_CONDITIONAL(CONFIG_LUA, test "$CONFIG_LUA" = yes)
727 AC_SUBST(CONFIG_PERL)
728 AM_CONDITIONAL(CONFIG_PERL, test "$CONFIG_PERL" = yes)
729 AC_SUBST(CONFIG_PYTHON)
730 AM_CONDITIONAL(CONFIG_PYTHON, test "$CONFIG_PYTHON" = yes)
731 AC_SUBST(CONFIG_RUBY)
732 AM_CONDITIONAL(CONFIG_RUBY, test "$CONFIG_RUBY" = yes)
733 AC_SUBST(CONFIG_SCRIPTING)
734 AM_CONDITIONAL(CONFIG_SCRIPTING, test "$CONFIG_SCRIPTING" = yes)
737 dnl ===================================================================
738 dnl Check for SpiderMonkey, optional even if installed.
739 dnl ===================================================================
741 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
742             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
743 AC_MSG_CHECKING([for SpiderMonkey])
745 EL_SAVE_FLAGS
746 cf_result=no
748 if test -z "$disable_spidermonkey"; then
749         if test ! -d "$withval"; then
750                 withval="";
751         fi
752         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
753                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs"; do
754                         for spidermonkeylib in js smjs; do
755                                 if test "$cf_result" = no; then
756                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
758                                         if test ! -z "$spidermonkeydir"; then
759                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
760                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
761                                         fi
763                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
764                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
765                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
767                                         AC_TRY_LINK([#define XP_UNIX
768                                                      #include <jsapi.h>],
769                                                      [JS_GetImplementationVersion()],
770                                                      cf_result=yes, cf_result=no)
771                                 fi
772                         done
773                 done
774         done
777 AC_MSG_RESULT($cf_result)
779 if test "$cf_result" != yes; then
780         EL_RESTORE_FLAGS
781 else
782         EL_CONFIG(CONFIG_SPIDERMONKEY, [SpiderMonkey])
784         CFLAGS="$CFLAGS_X"
785         AC_SUBST(SPIDERMONKEY_LIBS)
786         AC_SUBST(SPIDERMONKEY_CFLAGS)
789 AC_SUBST(CONFIG_SPIDERMONKEY)
790 AM_CONDITIONAL(CONFIG_SPIDERMONKEY, test "$CONFIG_SPIDERMONKEY" = yes)
792 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_SPIDERMONKEY], [ECMAScript (JavaScript)])
793 AC_SUBST(CONFIG_ECMASCRIPT)
794 AM_CONDITIONAL(CONFIG_ECMASCRIPT, test "$CONFIG_ECMASCRIPT" = yes)
797 dnl ===================================================================
798 dnl Check for SSL support.
799 dnl ===================================================================
801 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
802 dnl is enabled, we won't try to use OpenSSL anymore.
804 dnl For wiping SSL hooks..
805 #ifdef CONFIG_SSL
807 disable_openssl=""
808 disable_gnutls=""
809 enable_gnutls=""
811 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
812             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
813 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
814             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
815 gnutls_withval="$withval"
817 if test "$enable_gnutls" = yes; then
818         disable_openssl=yes;
821 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
822             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
823 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
824 openssl_withval="$withval"
826 dnl ---- OpenSSL
828 AC_MSG_CHECKING([for OpenSSL])
830 EL_SAVE_FLAGS
831 cf_result="no"
833 if test "$disable_openssl" = yes; then
834         cf_result="not used"
835 else
836         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
837                          /usr/lib/openssl /usr/local/ssl \
838                          /usr/local/www /usr/lib/ssl /usr/local \
839                          /usr/pkg /opt /opt/openssl; do
840                 if test "$cf_result" = no; then
841                         if test -d "$ssldir"; then
842                                 OPENSSL_CFLAGS="-I$ssldir/include"
843                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
844                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
845                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
846 #                               # FIXME: This created serious portability problems. --pasky
847 #                               if test "$CC" == "gcc"; then
848 #                                       # I'm not sure about compatibility here. --pasky
849 #                                       LIBS="$LIBS -R$ssldir/lib"
850 #                               fi
851                         else
852                                 LIBS="-lssl -lcrypto $LIBS_X"
853                         fi
854                         AC_TRY_LINK([#include <openssl/ssl.h>],
855                                     [OpenSSL_add_all_algorithms()],
856                                     cf_result=yes, cf_result=no)
857                         if test "$cf_result" != yes; then
858                                 AC_TRY_LINK([#include <openssl/ssl.h>],
859                                             [SSLeay_add_ssl_algorithms()],
860                                             cf_result=yes, cf_result=no)
861                         fi
862                 fi
863         done
865         if test "$cf_result" != yes; then
866                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
867                         AC_MSG_ERROR([OpenSSL not found])
868                 fi
869                 EL_RESTORE_FLAGS
870         else
871                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
873                 CFLAGS="$CFLAGS_X"
874                 AC_SUBST(OPENSSL_CFLAGS)
875         fi
878 AC_MSG_RESULT($cf_result)
880 dnl ---- GNU TLS
881 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
882 dnl it looks ugly then.
884 if test "$cf_result" = yes; then
885         cf_result="not used"
887 else
888         EL_SAVE_FLAGS
889         cf_result="no"
891         if test -z "$disable_gnutls"; then
892                 # Sure, we maybe _could_ use their macro, but how to ensure
893                 # that the ./configure script won't fail if the macro won't be
894                 # found..? :( --pasky
896                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
898                 if test -d "$gnutls_withval"; then
899                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
900                 fi
902                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
904                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
905                         cf_result=no
906                 else
907                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
908                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
910                         LIBS="$GNUTLS_LIBS $LIBS_X"
911                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
912                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
914                         # Verify if it's really usable
915                         AC_TRY_LINK([#include <gnutls/gnutls.h>],
916                                     [gnutls_check_version(NULL)],
917                                     cf_result=yes, cf_result=no)
918                 fi
920                 if test "$cf_result" = yes; then
921                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
923                         CFLAGS="$CFLAGS_X"
924                         AC_SUBST(GNUTLS_CFLAGS)
926                         # Verify if the MD5 compatibility layer is usable.
927                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
928                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
929                                                   [GNU TLS OpenSSL compatibility],
930                                                   gnutls/openssl.h, gnutls-openssl,
931                                                   MD5_Init)
932                 else
933                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
934                                 AC_MSG_ERROR([GNUTLS not found])
935                         fi
936                         EL_RESTORE_FLAGS
937                 fi
938         fi
941 AC_MSG_CHECKING([for GNU TLS])
942 AC_MSG_RESULT($cf_result)
944 dnl Final SSL setup
946 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
947 AC_SUBST(CONFIG_OPENSSL)
948 AM_CONDITIONAL(CONFIG_OPENSSL, test "$CONFIG_OPENSSL" = yes)
949 AC_SUBST(CONFIG_GNUTLS)
950 AM_CONDITIONAL(CONFIG_GNUTLS, test "$CONFIG_GNUTLS" = yes)
951 AC_SUBST(CONFIG_SSL)
952 AM_CONDITIONAL(CONFIG_SSL, test "$CONFIG_SSL" = yes)
954 #endif
956 AC_MSG_CHECKING([whether to be or not to be])
957 AC_MSG_RESULT([needs to be determined experimentally])
959 dnl ===================================================================
960 dnl Check for IPv6 support and related functions.
961 dnl ===================================================================
963 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
964 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
965 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
967 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
968 if test "$HAVE_GETADDRINFO" != yes; then
969         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
970         if test "$HAVE_GETADDRINFO" = yes; then
971                 LIBS="$LIBS -linet6"
972         fi
976 dnl ===================================================================
977 dnl Checking for X11 (window title restoring).
978 dnl ===================================================================
980 AC_PATH_X
981 if test x"$no_x" != xyes; then
982         if test -n "$x_includes"; then
983                 X_CFLAGS="-I$x_includes"
984                 CPPFLAGS="$CPPFLAGS -I$x_includes"
985         fi
986         if test -n "$x_libraries"; then
987                 LDFLAGS="$LDFLAGS -L$x_libraries"
988         fi
989         LIBS="-lX11 $LIBS"
990         EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
991         AC_SUBST(X_CFLAGS)
995 dnl ===================================================================
996 dnl Backtraces displaying support.
997 dnl ===================================================================
999 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1000 # possible checks for other system-specific means go here
1003 dnl ===================================================================
1004 dnl SMB protocol support.
1005 dnl ===================================================================
1007 AC_CHECK_PROG(HAVE_SMBCLIENT, smbclient, yes, no)
1010 dnl ===================================================================
1011 dnl Gettext grey zone. Beware.
1012 dnl ===================================================================
1014 ALL_LINGUAS="be bg ca cs da de el es et fi fr gl hr hu id is it lt nl no pl pt pt_BR ro ru sk sv tr uk"
1016 AM_GNU_GETTEXT
1018 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1019 dnl # f33r d4 l33t... I hope it's portable. :)
1020 dnl cf_result=$((48#z - 48#a + 1));
1021 dnl AC_MSG_RESULT($cf_result)
1024 dnl ===================================================================
1025 dnl Compile-time features control
1026 dnl ===================================================================
1028 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1029               [  --disable-cookies       disable cookie support])
1030 AC_SUBST(CONFIG_COOKIES)
1031 AM_CONDITIONAL(CONFIG_COOKIES, test "$CONFIG_COOKIES" = yes)
1033 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1034               [  --disable-formhist      disable form history support])
1035 AC_SUBST(CONFIG_FORMHIST)
1036 AM_CONDITIONAL(CONFIG_FORMHIST, test "$CONFIG_FORMHIST" = yes)
1038 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1039               [  --disable-globhist      disable global history support])
1040 AC_SUBST(CONFIG_GLOBHIST)
1041 AM_CONDITIONAL(CONFIG_GLOBHIST, test "$CONFIG_GLOBHIST" = yes)
1044 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1045               [  --disable-mailcap       disable mailcap support])
1046 AC_SUBST(CONFIG_MAILCAP)
1047 AM_CONDITIONAL(CONFIG_MAILCAP, test "$CONFIG_MAILCAP" = yes)
1049 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1050               [  --disable-mimetypes     disable mimetypes files support])
1051 AC_SUBST(CONFIG_MIMETYPES)
1052 AM_CONDITIONAL(CONFIG_MIMETYPES, test "$CONFIG_MIMETYPES" = yes)
1055 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1056               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1057               [IPv6],
1058               [  --disable-ipv6          disable IPv6 support])
1059 AC_SUBST(CONFIG_IPV6)
1060 AM_CONDITIONAL(CONFIG_IPV6, test "$CONFIG_IPV6" = yes)
1062 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1063               [  --enable-bittorrent     enable BitTorrent protocol support])
1064 AC_SUBST(CONFIG_BITTORRENT)
1065 AM_CONDITIONAL(CONFIG_BITTORRENT, test "$CONFIG_BITTORRENT" = yes)
1067 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1068               [  --disable-data          disable data protocol support])
1069 AC_SUBST(CONFIG_DATA)
1070 AM_CONDITIONAL(CONFIG_DATA, test "$CONFIG_DATA" = yes)
1072 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1073               [  --disable-uri-rewrite   disable URI rewrite support])
1074 AC_SUBST(CONFIG_URI_REWRITE)
1075 AM_CONDITIONAL(CONFIG_URI_REWRITE, test "$CONFIG_URI_REWRITE" = yes)
1077 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1078               [  --enable-cgi            enable local CGI support])
1079 AC_SUBST(CONFIG_CGI)
1080 AM_CONDITIONAL(CONFIG_CGI, test "$CONFIG_CGI" = yes)
1082 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1083               [  --enable-finger         enable finger protocol support])
1084 AC_SUBST(CONFIG_FINGER)
1085 AM_CONDITIONAL(CONFIG_FINGER, test "$CONFIG_FINGER" = yes)
1087 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1088               [  --disable-ftp           disable ftp protocol support])
1089 AC_SUBST(CONFIG_FTP)
1090 AM_CONDITIONAL(CONFIG_FTP, test "$CONFIG_FTP" = yes)
1092 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1093               [  --enable-gopher         enable gopher protocol support])
1094 AC_SUBST(CONFIG_GOPHER)
1095 AM_CONDITIONAL(CONFIG_GOPHER, test "$CONFIG_GOPHER" = yes)
1097 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1098               [  --enable-nntp           enable nntp protocol support])
1099 AC_SUBST(CONFIG_NNTP)
1100 AM_CONDITIONAL(CONFIG_NNTP, test "$CONFIG_NNTP" = yes)
1102 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [SMB protocol],
1103               [  --disable-smb           disable SMB protocol support (requires smbclient)])
1104 AC_SUBST(CONFIG_SMB)
1105 AM_CONDITIONAL(CONFIG_SMB, test "$CONFIG_SMB" = yes)
1108 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1109               [  --disable-mouse         disable mouse support])
1110 AC_SUBST(CONFIG_MOUSE)
1111 AM_CONDITIONAL(CONFIG_MOUSE, test "$CONFIG_MOUSE" = yes)
1113 # GPM mouse is Linux specific, so ...
1114 CONFIG_SYSMOUSE=yes
1115 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1116               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1117               [BSD sysmouse],
1118               [  --disable-sysmouse      disable BSD sysmouse support])
1119 AC_SUBST(CONFIG_SYSMOUSE)
1120 AM_CONDITIONAL(CONFIG_SYSMOUSE, test "$CONFIG_SYSMOUSE" = yes)
1122 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1123               [  --enable-88-colors     enable 88 color support])
1124 AC_SUBST(CONFIG_256_COLORS)
1125 AM_CONDITIONAL(CONFIG_256_COLORS, test "$CONFIG_256_COLORS" = yes)
1127 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1128               [  --enable-256-colors     enable 256 color support])
1129 AC_SUBST(CONFIG_256_COLORS)
1130 AM_CONDITIONAL(CONFIG_256_COLORS, test "$CONFIG_256_COLORS" = yes)
1133 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1134               [  --enable-exmode         enable exmode (CLI) interface])
1135 AC_SUBST(CONFIG_EXMODE)
1136 AM_CONDITIONAL(CONFIG_EXMODE, test "$CONFIG_EXMODE" = yes)
1138 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1139               [  --disable-leds          disable LEDs support])
1140 AC_SUBST(CONFIG_LEDS)
1141 AM_CONDITIONAL(CONFIG_LEDS, test "$CONFIG_LEDS" = yes)
1143 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1144               [  --disable-marks         disable document marks support])
1145 AC_SUBST(CONFIG_MARKS)
1146 AM_CONDITIONAL(CONFIG_MARKS, test "$CONFIG_MARKS" = yes)
1149 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1150               [  --disable-css           disable Cascading Style Sheet support])
1151 AC_SUBST(CONFIG_CSS)
1152 AM_CONDITIONAL(CONFIG_CSS, test "$CONFIG_CSS" = yes)
1154 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1155               [  --enable-html-highlight HTML highlighting using DOM engine])
1156 AC_SUBST(CONFIG_HTML_HIGHLIGHT)
1157 AM_CONDITIONAL(CONFIG_HTML_HIGHLIGHT, test "$CONFIG_HTML_HIGHLIGHT" = yes)
1159 dnl Everything in the tree already uses CONFIG_DOM
1160 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1161 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1162 AC_SUBST(CONFIG_DOM)
1163 AM_CONDITIONAL(CONFIG_DOM, test "$CONFIG_DOM" = yes)
1165 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1166               [  --disable-backtrace     disable backtrace support])
1167 AC_SUBST(CONFIG_BACKTRACE)
1168 AM_CONDITIONAL(CONFIG_BACKTRACE, test "$CONFIG_BACKTRACE" = yes)
1170 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1171               [  --enable-no-root        enable prevention of usage by root])
1172 AC_SUBST(CONFIG_NO_ROOT_EXEC)
1173 AM_CONDITIONAL(CONFIG_NO_ROOT_EXEC, test "$CONFIG_NO_ROOT_EXEC" = yes)
1176 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1177               [  --enable-debug          enable leak debug and internal error checking])
1178 AC_SUBST(CONFIG_DEBUG)
1179 AM_CONDITIONAL(CONFIG_DEBUG, test "$CONFIG_DEBUG" = yes)
1181 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1182               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1183 AC_SUBST(CONFIG_FASTMEM)
1184 AM_CONDITIONAL(CONFIG_FASTMEM, test "$CONFIG_FASTMEM" = yes)
1186 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1187               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1188 AC_SUBST(CONFIG_OWN_LIBC)
1189 AM_CONDITIONAL(CONFIG_OWN_LIBC, test "$CONFIG_OWN_LIBC" = yes)
1191 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1192               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1193 AC_SUBST(CONFIG_SMALL)
1194 AM_CONDITIONAL(CONFIG_SMALL, test "$CONFIG_SMALL" = yes)
1196 if test "$CONFIG_OPENSSL" != yes &&
1197    test "$CONFIG_GNUTLS_OPENSSL_COMPAT" != yes ||
1198    test "$CONFIG_OWN_LIBC" = yes;
1199 then
1200         AC_MSG_CHECKING(for built-in MD5 support)
1201         AC_MSG_RESULT(yes)
1202         EL_CONFIG(CONFIG_MD5, [Built-in MD5])
1205 AC_SUBST(CONFIG_MD5)
1206 AM_CONDITIONAL(CONFIG_MD5, test "$CONFIG_MD5" = yes)
1208 if test "$CONFIG_BITTORRENT" = yes; then
1209         if test "$CONFIG_OPENSSL" != yes ||
1210            test "$CONFIG_OWN_LIBC" = yes;
1211         then
1212                 AC_MSG_CHECKING(for built-in SHA1 support)
1213                 AC_MSG_RESULT(yes)
1214                 EL_CONFIG(CONFIG_SHA1, [Built-in SHA1])
1215         fi
1218 AC_SUBST(CONFIG_SHA1)
1219 AM_CONDITIONAL(CONFIG_SHA1, test "$CONFIG_SHA1" = yes)
1221 if test "$CONFIG_CSS" = yes || test "$CONFIG_DOM" = yes;
1222 then
1223         EL_CONFIG(CONFIG_SCANNER, [Built-in scanner])
1225 AC_SUBST(CONFIG_SCANNER)
1226 AM_CONDITIONAL(CONFIG_SCANNER, test "$CONFIG_SCANNER" = yes)
1228 AC_ARG_ENABLE(weehoofooboomookerchoo,
1229               [
1230     Also check out the features.conf file for more information about features!
1231               ],
1232               [AC_MSG_ERROR(Are you strange, or what?)])
1235 dnl == EMX hack
1237 test "$CONFIG_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1238 test "$CONFIG_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1241 dnl ===================================================================
1242 dnl Export directory paths
1243 dnl ===================================================================
1245 # Set up the ``entry points'' if they were not supplied by builder
1246 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1247 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1249 # Create CONFDIR #define for config.h
1251 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1252 # it's autoconf fault to force us to do such hacks ;p.
1253 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1254   # sysconfdir is set to its default value... fine, let's append /elinks/
1255   # XXX: We can't modify listing of the default in ./configure --help :-(
1256   sysconfdir_n=`eval echo "$sysconfdir"`
1257   sysconfdir=$sysconfdir_n
1258   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1259         sysconfdir="$sysconfdir/elinks"
1262 CONFDIR=$sysconfdir
1263 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1264 AC_SUBST(CONFDIR)
1266 # Create LOCALEDIR #define for config.h
1267 LOCALEDIR=`eval echo "$datadir/locale"`
1268 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1269 AC_SUBST(LOCALEDIR)
1271 # Create LIBDIR #define for config.h
1272 LIBDIR=`eval echo "$libdir"`
1273 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1274 AC_SUBST(LIBDIR)
1276 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1277 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1279 dnl ===================================================================
1280 dnl A little fine tuning of gcc specific options (continued)
1281 dnl ===================================================================
1283 if test "x$ac_cv_prog_gcc" = "xyes"; then
1284   if test "$CONFIG_DEBUG" = "yes"; then
1285     dnl We want to see all warnings and live with none (in debug mode).
1286     CFLAGS="$CFLAGS -Werror"
1287   fi
1289   case "`gcc -dumpversion`" in
1290     3.0|3.1|3.2)
1291       # These should be ok using -Werror
1292       ;;
1293     3.*)
1294       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1295       # "dereferencing type-punned pointer will break strict-aliasing rules"
1296       # warnings. Disable them by not doing any strict-aliasing. The
1297       # alternative is just too ugly. Thanks gcc guys!! ;)
1298       CFLAGS="$CFLAGS -fno-strict-aliasing"
1299       ;;
1300     4.*)
1301       # Do not show warnings related to (char * | unsigned char *) type
1302       # difference.
1303       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1304       ;;
1305     *)
1306       # These should be ok using -Werror
1307       ;;
1308   esac
1311 # CFLAGS doesn't contain all compile flags. Some will be added only when
1312 # needed in the respective source directory. To get all compile flags
1313 # easily just add CPPFLAGS.
1314 ALL_CFLAGS="$CFLAGS $CPPFLAGS"
1316 EL_LOG_CONFIG(ALL_CFLAGS, [Compiler options (CFLAGS)], [])
1317 EL_LOG_CONFIG(LIBS, [Linker options (LIBS)], [])
1319 dnl ===================================================================
1320 dnl Generated files
1321 dnl ===================================================================
1323 AC_OUTPUT([ \
1324  Makefile.config \
1325  contrib/elinks.spec \
1326  contrib/lua/hooks.lua \
1327  contrib/conv/w3m2links.awk \
1328  src/Makefile \
1329  src/intl/Makefile \
1330  src/intl/gettext/ref-add.sed \
1331  src/intl/gettext/ref-del.sed \
1332  src/main/Makefile \
1333  src/mime/Makefile \
1334  src/mime/backend/Makefile \
1335  src/network/Makefile \
1336  src/osdep/Makefile \
1337  src/scripting/Makefile \
1338  src/terminal/Makefile \
1339  src/util/Makefile \
1340  src/viewer/Makefile \
1341  src/viewer/text/Makefile
1345 dnl ===================================================================
1346 dnl Configuration summary
1347 dnl ===================================================================
1349 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1350 cat features.log