Fix a potential memleak.
[elinks.git] / configure.in
blobe8f2b268050ea269ea7519458d70c9355d9701c3
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 PACKAGE=elinks
8 VERSION=0.12.GIT
9 AC_SUBST(PACKAGE)
10 AC_SUBST(VERSION)
11 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
12 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
13 AC_CONFIG_HEADERS(config.h)
15 AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
16 AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
17 AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
19 MAKE=
21 for make in gnumake gmake make false; do
22         if test "x$MAKE" = x; then
23                 AC_PATH_PROGS(MAKE, "$make")
24         fi
25 done
27 builddir="`pwd`"
29 # Cleanup if we are configuring with a previous build in the tree
30 if test -e Makefile.config; then
31         AC_MSG_CHECKING([for previous build to clean])
32         "$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
33         AC_MSG_RESULT(done)
36 dnl ===================================================================
37 dnl Load feature configuration file and start logging features.
38 dnl ===================================================================
40 features="features.conf"
41 AC_CHECK_FILE("$srcdir/$features", [ . $srcdir/$features ])
42 AC_CHECK_FILE("$builddir/$features", [ . $builddir/$features ])
43 echo "Feature summary:" > features.log
45 dnl ===================================================================
46 dnl Checks for programs.
47 dnl ===================================================================
49 AC_PROG_CC
50 AC_PROG_AWK
51 AC_PATH_PROGS(AWK, "$AWK")
52 AC_PROG_RANLIB
53 AC_PROG_INSTALL
55 AC_PATH_PROGS(CG_COMMIT_ID, "cg-commit-id")
56 AC_PATH_PROGS(SPARSE, "sparse")
58 CONFIG_ASCIIDOC="no"
59 CONFIG_POD2HTML="no"
60 CONFIG_XMLTO="no"
61 CONFIG_JW="no"
63 if test "x$CONFIG_DOC" != xno; then
64         AC_PATH_PROGS(ASCIIDOC, "asciidoc")
65         if test "x$ASCIIDOC" != "x"; then
66                 EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
67                 EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
68                 EL_CONFIG(MAN_ASCIIDOC, [HTML])
70                 echo > config.asciidoc-unsafe.txt
71                 if "$ASCIIDOC" --unsafe config.asciidoc-unsafe.txt >&/dev/null; then
72                         ASCIIDOC_FLAGS=--unsafe
73                 fi
74                 rm config.asciidoc-unsafe.*
75         fi
77         AC_PATH_PROGS(XMLTO, "xmlto")
78         if test "x$XMLTO" != "x"; then
79                 EL_CONFIG(CONFIG_XMLTO, [XmlTo])
80                 EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
81                 EL_CONFIG(MAN_XMLTO, [man (groff)])
82         fi
84         AC_PATH_PROGS(JW, "jw")
85         if test "x$JW" != "x"; then
86                 EL_CONFIG(CONFIG_JW, [JadeWrapper])
87                 EL_CONFIG(MANUAL_JW, [PDF])
88         fi
90         AC_PATH_PROGS(POD2HTML, "pod2html")
91         if test "x$POD2HTML" != "x"; then
92                 EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
93         fi
96 AC_SUBST(ASCIIDOC_FLAGS)
97 AC_SUBST(CONFIG_ASCIIDOC)
98 AC_SUBST(CONFIG_POD2HTML)
99 AC_SUBST(CONFIG_XMLTO)
100 AC_SUBST(CONFIG_JW)
102 EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_JW CONFIG_POD2HTML], [Documentation])
104 if test "$CONFIG_ASCIIDOC" = yes &&
105    test "$CONFIG_XMLTO" = yes &&
106    test "$CONFIG_JW" = yes; then
107         EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manual Formats])
110 if test "$CONFIG_ASCIIDOC" = yes &&
111    test "$CONFIG_XMLTO" = yes; then
112         EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
115 AC_SUBST(CONFIG_ASCIIDOC)
116 AC_SUBST(CONFIG_POD2HTML)
117 AC_SUBST(CONFIG_XMLTO)
118 AC_SUBST(CONFIG_JW)
120 dnl gcc specific options (to be continued at the bottom of configure)
121 if test "x$ac_cv_prog_gcc" = "xyes"; then
122   dnl We want to see all warnings and live with none.
123   dnl We can't set up -Werror here as there may be some warnings in test
124   dnl suite of configure, and we don't want to fail them.
125   CFLAGS="$CFLAGS -Wall"
128 dnl ===================================================================
129 dnl Checks for special OSes.
130 dnl ===================================================================
132 dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
133 AC_DEFUN([EL_CHECK_COMPILER_MACROS],
135         AC_MSG_CHECKING([for $2])
137         for flag in $3; do
138                 AC_TRY_COMPILE(, [#ifndef $flag
139 kill me!
140 #endif ], $1=yes, $1=no)
141                 if test "[$]$1" = yes; then
142                         EL_CONFIG([$1], [$2])
143                         break
144                 fi
145         done
147         AC_MSG_RESULT([$]$1)
150 EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
151 AC_SUBST(CONFIG_OS_BEOS)
153 EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
154 AC_SUBST(CONFIG_OS_RISCOS)
156 EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
157 AC_SUBST(CONFIG_OS_WIN32)
159 EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
160 AC_SUBST(CONFIG_OS_OS2)
161 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
163 AC_MSG_CHECKING([for UNIX])
164 dnl FIXME: some depend kind of mechanism
165 if test "$CONFIG_OS_BEOS" = no && \
166    test "$CONFIG_OS_RISCOS" = no && \
167    test "$CONFIG_OS_WIN32" = no && \
168    test "$CONFIG_OS_OS2" = no; then
169         EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
170 else
171         CONFIG_OS_UNIX=no
173 AC_MSG_RESULT($CONFIG_OS_UNIX)
174 AC_SUBST(CONFIG_OS_UNIX)
176 dnl ===================================================================
177 dnl Checks for header files.
178 dnl ===================================================================
180 AC_HEADER_DIRENT
181 AC_HEADER_STDC
182 AC_HEADER_SYS_WAIT
183 AC_HEADER_TIME
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(net/if.h 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(stdint.h inttypes.h)
201 AC_CHECK_HEADERS(locale.h pwd.h)
202 AC_CHECK_HEADERS(termios.h)
205 AC_CHECK_HEADERS(sys/un.h,
206         [CONFIG_INTERLINK=yes
207          EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
208         [CONFIG_INTERLINK=no])
209 AC_SUBST(CONFIG_INTERLINK)
211 dnl ===================================================================
212 dnl Checks for typedefs, structures, and compiler characteristics.
213 dnl ===================================================================
215 AC_STRUCT_TM
216 AC_C_CONST
217 AC_C_INLINE
218 EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
220 AC_SYS_LARGEFILE
221 AC_TYPE_SIZE_T
222 AC_TYPE_OFF_T
223 EL_CHECK_TYPE(ssize_t, int)
224 EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
225 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
226 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
227 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
229 AC_CHECK_SIZEOF(char, 1)
230 AC_CHECK_SIZEOF(short, 2)
231 AC_CHECK_SIZEOF(int, 4)
232 AC_CHECK_SIZEOF(long, 4)
233 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
235 dnl Check for variadic macros
236 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
237                 [#include <stdio.h>
238                  #define a(b,c...) printf(b,##c)],
239                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
241 dnl Check for -rdynamic
242 dnl FIXME: This check doesn't work. Something to do with the compiler
243 dnl happily ignoring it and stderr not being checked for error messages.
244 AC_MSG_CHECKING([for -rdynamic])
245 LDFLAGS_X="$LDFLAGS"
246 LDFLAGS="$LDFLAGS -rdynamic"
247 AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no)
248 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
249 AC_MSG_RESULT($have_rdynamic)
251 dnl ===================================================================
252 dnl Check for POSIX <regex.h>
253 dnl ===================================================================
255 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
257 dnl ===================================================================
258 dnl Checks for library functions.
259 dnl ===================================================================
261 AC_PROG_GCC_TRADITIONAL
262 AC_FUNC_MEMCMP
263 AC_FUNC_MMAP
264 AC_FUNC_STRFTIME
265 AC_CHECK_FUNCS(cfmakeraw gethostbyaddr herror strerror)
266 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
267 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
268 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
269 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
270 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
271 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
272 AC_CHECK_FUNCS(gettimeofday clock_gettime)
274 AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path)
276 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
277 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
278 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
280 dnl These aren't probably needed now, as they are commented in links.h.
281 dnl I've no idea about their historical background, but I keep them here
282 dnl just in the case they will help later. --pasky
283 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
284 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
285 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
286 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
288 if test x"$HAVE_RAISE" = x; then
289         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
290                 AC_ERROR([Unable to emulate raise()])
291         fi
294 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
295 AC_TRY_LINK([#include <stdarg.h>
296 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
297 el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)])
298 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
299         EL_DEFINE(HAVE_VA_COPY, __va_copy)
302 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
303 AC_TRY_LINK([#include <unistd.h>
304 ], [int page_size = sysconf(_SC_PAGE_SIZE);],
305 el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)])
306 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
307         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
310 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
311 AC_TRY_RUN([
312 #include <stdio.h>
313 #include <stdarg.h>
314 #include <stdlib.h>
315 #include <string.h>
317 char buf[8];
319 int bar(char *buf, const char *format, va_list ap)
321        return vsnprintf(buf, 0, format, ap);
324 void foo(const char *format, ...) {
325        va_list ap;
326        int len;
328        va_start(ap, format);
329        len = bar(buf, format, ap);
330        va_end(ap);
331        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
333        va_start(ap, format);
334        len = bar(buf, format, ap);
335        va_end(ap);
336        if ((len != 6) && (len != 7)) exit(1);
338        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
340        exit(0);
342 main() { foo("hello\n"); }
344 el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)])
345 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
346         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
349 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
351 dnl ===================================================================
352 dnl Checks for libraries.
353 dnl ===================================================================
355 dnl Replace `main' with a function in -lsocket:
356 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
357 if test "$cf_result" = no; then
358         AC_CHECK_LIB(socket, socket)
361 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
362 if test "$cf_result" = no; then
363         AC_CHECK_LIB(socket, setsockopt)
366 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
367 if test "$cf_result" = no; then
368         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
369         if test "$cf_result" = no; then
370                 AC_CHECK_LIB(nsl, gethostbyname)
371         else
372                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
373         fi
376 dnl ===================================================================
377 dnl Checks for packaging specific options.
378 dnl ===================================================================
380 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
381             [ if test "$withval" != no && test "$withval" != yes; then
382                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
383               fi ])
385 dnl ===================================================================
386 dnl Checks for a libraries, optional even if installed.
387 dnl ===================================================================
389 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
390 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
392         AC_MSG_CHECKING([for $2 support])
394         if test "[$]$1" != no; then
395                 AC_MSG_RESULT(yes)
396                 EL_SAVE_FLAGS
397                 if test -n "$withval" && test -d "$withval"; then
398                         CFLAGS="$CFLAGS -I$withval/include";
399                         CPPFLAGS="$CPPFLAGS -I$withval/include";
400                         LDFLAGS="$LDFLAGS -L$withval/lib";
401                 fi
403                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
404                 if test "[$]$1" = yes; then
405                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
406                 fi
408                 if test "[$]$1" = yes; then
409                         EL_CONFIG([$1], [$2])
410                         LIBS="$LIBS -l$4"
411                 else
412                         if test -n "[$]WITHVAL_$1" &&
413                            test "[$]WITHVAL_$1" != xno; then
414                                 AC_MSG_ERROR([$2 not found])
415                         fi
416                         EL_RESTORE_FLAGS
417                 fi
418         else
419                 AC_MSG_RESULT(disabled)
420         fi
423 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
424 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
426         $1=yes
427         WITHVAL_$1=
429         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
430         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
432         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
434         EL_LOG_CONFIG([$1], [$2], [])
437 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
438         [  --without-gpm           disable gpm (mouse) support])
440 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzdopen,
441         [  --without-zlib          disable zlib support])
443 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
444         [  --without-bzlib         disable bzlib support])
446 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
447         [  --without-idn           disable international domain names support])
449 dnl ===================================================================
450 dnl Bookmark and XBEL support
451 dnl ===================================================================
453 EL_SAVE_FLAGS
455 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
456               [  --disable-bookmarks     disable bookmark support])
458 # Check whether --enable-xbel or --disable-xbel was given.
459 if test "x${enable_xbel}" != xno; then
460         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
462         if test "$HAVE_LIBEXPAT" = yes; then
463                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
464                 if test "$HAVE_LIBEXPAT" = yes; then
465                         LIBS="$LIBS -lexpat"
466                 fi
467         fi
471 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
472               [XBEL bookmarks],
473               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
475 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
476         EL_RESTORE_FLAGS
479 dnl ===================================================================
480 dnl Checks for BSD sysmouse
481 dnl ===================================================================
483 HAVE_SYSMOUSE_HEADER="no"
485 # Either of these header files provides the (same) sysmouse interface
486 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
488 dnl ===================================================================
489 dnl Checks for OS/2
490 dnl ===================================================================
492 if test "$CONFIG_OS_OS2" = yes; then
493         EL_CONFIG_OS_OS2
496 dnl ===================================================================
497 dnl Checks for Win32
498 dnl ===================================================================
500 if test "$CONFIG_OS_WIN32" = yes; then
501         EL_CONFIG_OS_WIN32
504 dnl ===================================================================
505 dnl Check for SEE (Simple Ecmascript Engine)
506 dnl ===================================================================
507 AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE) support],
508             [ if test "x$withval" != xno; then enable_see=yes; fi ])
510 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
511 # SEE_FLAGS but I really don't want to require people to have Guile in order
512 # to compile CVS. Also, the macro seems to be really stupid regarding searching
513 # for Guile in $PATH etc. --pasky
515 AC_MSG_CHECKING([for SEE])
517 CONFIG_ECMASCRIPT_SEE=no
519 if test "$enable_see" = "yes"; then
520         AC_MSG_RESULT(yes);
521         ## Based on the SEE_FLAGS macro.
523         if test -d "$withval"; then
524                 SEE_PATH="$withval:$PATH"
525         else
526                 SEE_PATH="$PATH"
527         fi
529         AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
531         ## First, let's just see if we can find Guile at all.
532         if test "$SEE_CONFIG" != no; then
533                 cf_result="yes";
535                 SEE_LIBS="`$SEE_CONFIG --libs`"
536                 SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
537                 LIBS="$SEE_LIBS $LIBS"
538                 CPPFLAGS="$CPPFLAGS $SEE_CFLAGS"
539                 EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
540                 AC_SUBST(SEE_CFLAGS)
541         else
542                 if test -n "$withval" && test "x$withval" != xno; then
543                         AC_MSG_ERROR([SEE not found])
544                 else
545                         AC_MSG_WARN([SEE support disabled])
546                 fi
547         fi
548 else
549         AC_MSG_RESULT(no);
553 dnl ===================================================================
554 dnl Check for SpiderMonkey, optional even if installed.
555 dnl ===================================================================
557 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
558             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
559 AC_MSG_CHECKING([for SpiderMonkey])
561 EL_SAVE_FLAGS
562 cf_result=no
564 if test -z "$disable_spidermonkey"; then
565         if test ! -d "$withval"; then
566                 withval="";
567         fi
568         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
569                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs"; do
570                         for spidermonkeylib in js smjs; do
571                                 if test "$cf_result" = no; then
572                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
574                                         if test ! -z "$spidermonkeydir"; then
575                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
576                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
577                                         fi
579                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
580                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
581                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
583                                         AC_TRY_LINK([#define XP_UNIX
584                                                      #include <jsapi.h>],
585                                                      [JS_GetImplementationVersion()],
586                                                      cf_result=yes, cf_result=no)
587                                 fi
588                         done
589                 done
590         done
593 AC_MSG_RESULT($cf_result)
594 CONFIG_SPIDERMONKEY="$cf_result"
595 EL_RESTORE_FLAGS
597 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
598    test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
599         EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
600 else
601         CONFIG_ECMASCRIPT_SMJS=no
604 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
605 AC_SUBST(CONFIG_ECMASCRIPT_SEE)
606 AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
609 dnl ===================================================================
610 dnl Optional Spidermonkey-based ECMAScript browser scripting
611 dnl ===================================================================
613 AC_ARG_ENABLE(sm-scripting,
614               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
615               [if test "$enableval" != no; then enableval="yes"; fi
616                CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
618 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
619    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
620         EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
621 else
622         CONFIG_SCRIPTING_SPIDERMONKEY=no
625 if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
626    test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
627         LIBS="$LIBS $SPIDERMONKEY_LIBS"
628         AC_SUBST(SPIDERMONKEY_LIBS)
629         AC_SUBST(SPIDERMONKEY_CFLAGS)
630         AC_SUBST(CONFIG_SPIDERMONKEY)
633 dnl ===================================================================
634 dnl Check for Guile, optional even if installed.
635 dnl ===================================================================
637 enable_guile="no";
639 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
640             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
642 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
643 # GUILE_FLAGS but I really don't want to require people to have Guile in order
644 # to compile CVS. Also, the macro seems to be really stupid regarding searching
645 # for Guile in $PATH etc. --pasky
647 AC_MSG_CHECKING([for Guile])
649 if test "$enable_guile" = "yes"; then
650         AC_MSG_RESULT(yes);
651         ## Based on the GUILE_FLAGS macro.
653         if test -d "$withval"; then
654                 GUILE_PATH="$withval:$PATH"
655         else
656                 GUILE_PATH="$PATH"
657         fi
659         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
661         ## First, let's just see if we can find Guile at all.
662         if test "$GUILE_CONFIG" != no; then
663                 cf_result="yes";
665                 GUILE_LIBS="`guile-config link`"
666                 GUILE_CFLAGS="`guile-config compile`"
667                 LIBS="$GUILE_LIBS $LIBS"
668                 CPPFLAGS="$CPPFLAGS $GUILE_CFLAGS"
669                 EL_CONFIG(CONFIG_SCRIPTING_GUILE, [Guile])
670                 AC_SUBST(GUILE_CFLAGS)
671                 cat <<EOF
672 ***********************************************************************
673 The Guile support is incomplete and not so well integrated to ELinks
674 yet. That means, ie., that you have no Guile console and there might
675 not be all the necessary hooks. Also, the Guile interface is not too
676 well tested (success stories heartily welcomed!).  See
677 src/scripting/guile/README for further details and hints.
678 ***********************************************************************
680         else
681                 if test -n "$withval" && test "x$withval" != xno; then
682                         AC_MSG_ERROR([Guile not found])
683                 else
684                         AC_MSG_WARN([Guile support disabled])
685                 fi
686         fi
687 else
688         AC_MSG_RESULT(no);
691 dnl ===================================================================
692 dnl Check for Perl
693 dnl ===================================================================
694 enable_perl="no";
696 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
697             [
698 if test "$withval" = yes; then
699         # FIXME: If withval is a valid directory append it to PATH
700         # so that you can specify one of several perl installations.
701         withval="";
702         enable_perl=yes;
704             ])
706 AC_MSG_CHECKING([for Perl])
708 cf_result=no
710 EL_SAVE_FLAGS
712 if test "$enable_perl" = "yes"; then
713         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
714         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
715         LIBS="$PERL_LIBS $LIBS"
716         CFLAGS="$PERL_CFLAGS $CFLAGS"
717         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
718         AC_TRY_LINK([
719 #include <EXTERN.h>
720 #include <perl.h>
721 #include <perlapi.h>
723                     [PerlInterpreter *my_perl = perl_alloc();],
724                     cf_result=yes, cf_result=no)
727 if test "$cf_result" != "yes"; then
728         EL_RESTORE_FLAGS
729 else
730         EL_CONFIG(CONFIG_SCRIPTING_PERL, [Perl])
732         CFLAGS="$CFLAGS_X"
733         AC_SUBST(PERL_LIBS)
734         AC_SUBST(PERL_CFLAGS)
737 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
738 dnl ===================================================================
739 dnl Check for Python
740 dnl ===================================================================
741 enable_python="no";
743 AC_ARG_WITH(python, [  --with-python           enable Python support],
744             [
745 if test "$withval" = yes; then
746         # FIXME: If withval is a valid directory append it to PATH
747         # so that you can specify one of several Python installations.
748         withval="";
749         enable_python=yes;
750         cat <<EOF
751 ***********************************************************************
752 The Python support is incomplete and not so well integrated to ELinks
753 yet. That means, ie., that you have no Python console and there might
754 not be all the necessary hooks. Also, the Python interface is not too
755 well tested (success stories heartily welcomed!).
756 ***********************************************************************
759             ])
761 AC_MSG_CHECKING([for Python])
763 cf_result=no
765 EL_SAVE_FLAGS
767 if test "$enable_python" = "yes"; then
768         PYTHON_LIBS="-lpython"
769         PYTHON_CFLAGS="-I`python -c 'from distutils import sysconfig; print sysconfig.get_python_inc()' 2> /dev/null`"
770         LIBS="$PYTHON_LIBS $LIBS"
771         CFLAGS="$PYTHON_CFLAGS $CFLAGS"
772         CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
773         AC_TRY_LINK([
774 #include <Python.h>
776                     [Py_Initialize();],
777                     cf_result=yes, cf_result=no)
780 if test "$cf_result" != "yes"; then
781         EL_RESTORE_FLAGS
782 else
783         EL_CONFIG(CONFIG_SCRIPTING_PYTHON, [Python])
785         CFLAGS="$CFLAGS_X"
786         AC_SUBST(PYTHON_LIBS)
787         AC_SUBST(PYTHON_CFLAGS)
790 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
793 dnl ===================================================================
794 dnl Check for Lua, optional even if installed.
795 dnl ===================================================================
797 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
798 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
800 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
801             [if test "$withval" = no; then disable_lua=yes; fi])
802 AC_MSG_CHECKING([for Lua])
804 EL_SAVE_FLAGS
805 cf_result=no
807 if test -z "$disable_lua"; then
808         if test ! -d "$withval"; then
809                 withval="";
810         fi
811         for luadir in "$withval" "" /usr /usr/local; do
812                 for suffix in "" 50 51; do
813                         if test "$cf_result" = no; then
814                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
816                                 if test ! -z "$luadir"; then
817                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
818                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
819                                 fi
821                                 LIBS="$LUA_LIBS $LIBS_X"
822                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
823                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
825                                 # Check that it is a compatible Lua version
826                                 AC_TRY_LINK([   #include <lua.h>
827                                                 #include <lualib.h>],
828                                             [   lua_State *L = lua_open();
829                                                 lua_baselibopen(L);
830                                                 lua_mathlibopen(L);
831                                                 lua_strlibopen(L);
832                                                 lua_tablibopen(L);
833                                                 lua_pushboolean(L, 1);
834                                                 lua_close(L);],
835                                             cf_result=yes, cf_result=no)
836                         fi
837                 done
838         done
841 AC_MSG_RESULT($cf_result)
843 if test "$cf_result" != yes; then
844         EL_RESTORE_FLAGS
845 else
846         EL_CONFIG(CONFIG_SCRIPTING_LUA, [Lua])
847         AC_CHECK_HEADERS(lauxlib.h)
849         CFLAGS="$CFLAGS_X"
850         AC_SUBST(LUA_LIBS)
851         AC_SUBST(LUA_CFLAGS)
855 dnl ===================================================================
856 dnl Check for Ruby, optional even if installed.
857 dnl ===================================================================
859 EL_CONFIG_SCRIPTING_RUBY
861 dnl ===================================================================
862 dnl Setup global scripting
863 dnl ===================================================================
865 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])
866 AC_SUBST(CONFIG_SCRIPTING_GUILE)
867 AC_SUBST(CONFIG_SCRIPTING_LUA)
868 AC_SUBST(CONFIG_SCRIPTING_PERL)
869 AC_SUBST(CONFIG_SCRIPTING_PYTHON)
870 AC_SUBST(CONFIG_SCRIPTING_RUBY)
871 AC_SUBST(CONFIG_SCRIPTING_SPIDERMONKEY)
872 AC_SUBST(CONFIG_SCRIPTING)
875 dnl ===================================================================
876 dnl Check for SSL support.
877 dnl ===================================================================
879 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
880 dnl is enabled, we won't try to use OpenSSL anymore.
882 dnl For wiping SSL hooks..
883 #ifdef CONFIG_SSL
885 disable_openssl=""
886 disable_gnutls=""
887 enable_gnutls=""
889 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
890             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
891 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
892             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
893 gnutls_withval="$withval"
895 if test "$enable_gnutls" = yes; then
896         disable_openssl=yes;
899 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
900             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
901 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
902 openssl_withval="$withval"
904 dnl ---- OpenSSL
906 AC_MSG_CHECKING([for OpenSSL])
908 EL_SAVE_FLAGS
909 cf_result="no"
911 if test "$disable_openssl" = yes; then
912         cf_result="not used"
913 else
914         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
915                          /usr/lib/openssl /usr/local/ssl \
916                          /usr/local/www /usr/lib/ssl /usr/local \
917                          /usr/pkg /opt /opt/openssl; do
918                 if test "$cf_result" = no; then
919                         if test -d "$ssldir"; then
920                                 OPENSSL_CFLAGS="-I$ssldir/include"
921                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
922                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
923                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
924 #                               # FIXME: This created serious portability problems. --pasky
925 #                               if test "$CC" == "gcc"; then
926 #                                       # I'm not sure about compatibility here. --pasky
927 #                                       LIBS="$LIBS -R$ssldir/lib"
928 #                               fi
929                         else
930                                 LIBS="-lssl -lcrypto $LIBS_X"
931                         fi
932                         AC_TRY_LINK([#include <openssl/ssl.h>],
933                                     [OpenSSL_add_all_algorithms()],
934                                     cf_result=yes, cf_result=no)
935                         if test "$cf_result" != yes; then
936                                 AC_TRY_LINK([#include <openssl/ssl.h>],
937                                             [SSLeay_add_ssl_algorithms()],
938                                             cf_result=yes, cf_result=no)
939                         fi
940                 fi
941         done
943         if test "$cf_result" != yes; then
944                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
945                         AC_MSG_ERROR([OpenSSL not found])
946                 fi
947                 EL_RESTORE_FLAGS
948         else
949                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
951                 CFLAGS="$CFLAGS_X"
952                 AC_SUBST(OPENSSL_CFLAGS)
953         fi
956 AC_MSG_RESULT($cf_result)
958 dnl ---- GNU TLS
959 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
960 dnl it looks ugly then.
962 if test "$cf_result" = yes; then
963         cf_result="not used"
965 else
966         EL_SAVE_FLAGS
967         cf_result="no"
969         if test -z "$disable_gnutls"; then
970                 # Sure, we maybe _could_ use their macro, but how to ensure
971                 # that the ./configure script won't fail if the macro won't be
972                 # found..? :( --pasky
974                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
976                 if test -d "$gnutls_withval"; then
977                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
978                 fi
980                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
982                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
983                         cf_result=no
984                 else
985                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
986                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
988                         LIBS="$GNUTLS_LIBS $LIBS_X"
989                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
990                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
992                         # Verify if it's really usable.  gnutls_session was
993                         # renamed to gnutls_session_t before GNU TLS 1.2.0
994                         # (on 2004-06-13); ELinks now requires this.
995                         AC_TRY_LINK([#include <gnutls/gnutls.h>],
996                                     [gnutls_session_t dummy;
997                                      gnutls_check_version(NULL)],
998                                     cf_result=yes, cf_result=no)
999                 fi
1001                 if test "$cf_result" = yes; then
1002                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
1004                         CFLAGS="$CFLAGS_X"
1005                         AC_SUBST(GNUTLS_CFLAGS)
1007                         # Verify if the MD5 compatibility layer is usable.
1008                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
1009                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
1010                                                   [GNU TLS OpenSSL compatibility],
1011                                                   gnutls/openssl.h, gnutls-openssl,
1012                                                   MD5_Init)
1013                 else
1014                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
1015                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
1016                         fi
1017                         EL_RESTORE_FLAGS
1018                 fi
1019         fi
1022 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
1023 AC_MSG_RESULT($cf_result)
1025 dnl Final SSL setup
1027 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
1028 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
1029 AC_SUBST(CONFIG_OPENSSL)
1030 AC_SUBST(CONFIG_GNUTLS)
1032 #endif
1034 AC_MSG_CHECKING([whether to be or not to be])
1035 AC_MSG_RESULT([needs to be determined experimentally])
1037 dnl ===================================================================
1038 dnl Check for IPv6 support and related functions.
1039 dnl ===================================================================
1041 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
1042 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
1043 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
1045 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1046 if test "$HAVE_GETADDRINFO" != yes; then
1047         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
1048         if test "$HAVE_GETADDRINFO" = yes; then
1049                 LIBS="$LIBS -linet6"
1050         fi
1054 dnl ===================================================================
1055 dnl Checking for X11 (window title restoring).
1056 dnl ===================================================================
1058 AC_PATH_X
1059 if test x"$no_x" != xyes; then
1060         if test -n "$x_includes"; then
1061                 X_CFLAGS="-I$x_includes"
1062                 CPPFLAGS="$CPPFLAGS -I$x_includes"
1063         fi
1064         if test -n "$x_libraries"; then
1065                 LDFLAGS="$LDFLAGS -L$x_libraries"
1066         fi
1067         LIBS="-lX11 $LIBS"
1068         EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1069         AC_SUBST(X_CFLAGS)
1073 dnl ===================================================================
1074 dnl Backtraces displaying support.
1075 dnl ===================================================================
1077 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1078 # possible checks for other system-specific means go here
1081 dnl ===================================================================
1082 dnl SMB protocol support.
1083 dnl ===================================================================
1085 AC_CHECK_PROG(HAVE_SMBCLIENT, smbclient, yes, no)
1088 dnl ===================================================================
1089 dnl Gettext grey zone. Beware.
1090 dnl ===================================================================
1092 ALL_LINGUAS="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"
1094 AM_GNU_GETTEXT
1096 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1097 dnl # f33r d4 l33t... I hope it's portable. :)
1098 dnl cf_result=$((48#z - 48#a + 1));
1099 dnl AC_MSG_RESULT($cf_result)
1102 dnl ===================================================================
1103 dnl Compile-time features control
1104 dnl ===================================================================
1106 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1107               [  --disable-cookies       disable cookie support])
1109 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1110               [  --disable-formhist      disable form history support])
1112 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1113               [  --disable-globhist      disable global history support])
1116 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1117               [  --disable-mailcap       disable mailcap support])
1119 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1120               [  --disable-mimetypes     disable mimetypes files support])
1123 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1124               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1125               [IPv6],
1126               [  --disable-ipv6          disable IPv6 support])
1128 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1129               [  --enable-bittorrent     enable BitTorrent protocol support])
1131 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1132               [  --disable-data          disable data protocol support])
1134 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1135               [  --disable-uri-rewrite   disable URI rewrite support])
1137 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1138               [  --enable-cgi            enable local CGI support])
1140 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1141               [  --enable-finger         enable finger protocol support])
1143 dnl ===================================================================
1144 dnl FSP protocol
1145 dnl ===================================================================
1146 EL_SAVE_FLAGS
1148 if test "x${enable_fsp}" != xno; then
1149         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1151         if test "$HAVE_FSPLIB" = yes; then
1152                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1153                 if test "$HAVE_FSPLIB" = yes; then
1154                         LIBS="$LIBS -lfsplib"
1155                 else
1156                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1157                         if test "$HAVE_FSPLIB" = yes; then
1158                                 LIBS="$LIBS -lfsp"
1159                         fi
1160                 fi
1161         fi
1164 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1165               [  --enable-fsp            enable FSP protocol support])
1167 if test "x$CONFIG_FSP" = xno; then
1168         EL_RESTORE_FLAGS
1171 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1172               [  --disable-ftp           disable ftp protocol support])
1174 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1175               [  --enable-gopher         enable gopher protocol support])
1177 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1178               [  --enable-nntp           enable nntp protocol support])
1180 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [SMB protocol],
1181               [  --disable-smb           disable SMB protocol support (requires smbclient)])
1184 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1185               [  --disable-mouse         disable mouse support])
1187 # GPM mouse is Linux specific, so ...
1188 CONFIG_SYSMOUSE=yes
1189 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1190               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1191               [BSD sysmouse],
1192               [  --disable-sysmouse      disable BSD sysmouse support])
1194 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1195               [  --enable-88-colors      enable 88 color support])
1197 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1198               [  --enable-256-colors     enable 256 color support])
1201 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1202               [  --enable-exmode         enable exmode (CLI) interface])
1204 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1205               [  --disable-leds          disable LEDs support])
1207 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1208               [  --disable-marks         disable document marks support])
1211 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1212               [  --disable-css           disable Cascading Style Sheet support])
1214 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1215               [  --enable-html-highlight HTML highlighting using DOM engine])
1217 dnl Everything in the tree already uses CONFIG_DOM
1218 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1219 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1221 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1222               [  --disable-backtrace     disable backtrace support])
1224 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1225               [  --enable-no-root        enable prevention of usage by root])
1228 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1229               [  --enable-debug          enable leak debug and internal error checking])
1231 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1232               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1234 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1235               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1237 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1238               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
1240 AC_ARG_ENABLE(weehoofooboomookerchoo,
1241               [
1242     Also check out the features.conf file for more information about features!
1243               ],
1244               [AC_MSG_ERROR(Are you strange, or what?)])
1247 dnl == EMX hack
1249 test "$CONFIG_OS_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1250 test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1253 dnl ===================================================================
1254 dnl Export directory paths
1255 dnl ===================================================================
1257 # Set up the ``entry points'' if they were not supplied by builder
1258 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1259 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1261 # Create CONFDIR #define for config.h
1263 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1264 # it's autoconf fault to force us to do such hacks ;p.
1265 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1266   # sysconfdir is set to its default value... fine, let's append /elinks/
1267   # XXX: We can't modify listing of the default in ./configure --help :-(
1268   sysconfdir_n=`eval echo "$sysconfdir"`
1269   sysconfdir=$sysconfdir_n
1270   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1271         sysconfdir="$sysconfdir/elinks"
1274 CONFDIR=$sysconfdir
1275 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1276 AC_SUBST(CONFDIR)
1278 # Create LOCALEDIR #define for config.h
1279 LOCALEDIR=`eval echo "$datadir/locale"`
1280 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1281 AC_SUBST(LOCALEDIR)
1283 # Create LIBDIR #define for config.h
1284 LIBDIR=`eval echo "$libdir"`
1285 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1286 AC_SUBST(LIBDIR)
1288 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1289 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1291 dnl ===================================================================
1292 dnl A little fine tuning of gcc specific options (continued)
1293 dnl ===================================================================
1295 if test "x$ac_cv_prog_gcc" = "xyes"; then
1296   if test "$CONFIG_DEBUG" = "yes"; then
1297     dnl We want to see all warnings and live with none (in debug mode).
1298     CFLAGS="$CFLAGS -Werror"
1299   fi
1301   case "`$CC -dumpversion`" in
1302     3.0|3.1|3.2)
1303       # These should be ok using -Werror
1304       ;;
1305     3.*)
1306       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1307       # "dereferencing type-punned pointer will break strict-aliasing rules"
1308       # warnings. Disable them by not doing any strict-aliasing. The
1309       # alternative is just too ugly. Thanks gcc guys!! ;)
1310       CFLAGS="$CFLAGS -fno-strict-aliasing"
1311       ;;
1312     4.*)
1313       # Do not show warnings related to (char * | unsigned char *) type
1314       # difference.
1315       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1316       ;;
1317     *)
1318       # These should be ok using -Werror
1319       ;;
1320   esac
1323 # CFLAGS doesn't contain all compile flags. Some will be added only when
1324 # needed in the respective source directory. To get all compile flags
1325 # easily just add CPPFLAGS.
1326 ALL_CFLAGS="$CFLAGS $CPPFLAGS"
1328 EL_LOG_CONFIG(ALL_CFLAGS, [Compiler options (CFLAGS)], [])
1329 EL_LOG_CONFIG(LIBS, [Linker options (LIBS)], [])
1331 dnl ===================================================================
1332 dnl Colored make output
1333 dnl ===================================================================
1335 if test $(`which tput` colors) -ge 4; then
1336         MAKE_COLOR=1
1337         AC_SUBST(MAKE_COLOR)
1340 dnl ===================================================================
1341 dnl Generated files
1342 dnl ===================================================================
1344 AC_OUTPUT([ \
1345  Makefile.config \
1346  contrib/elinks.spec \
1347  contrib/lua/hooks.lua \
1348  contrib/conv/w3m2links.awk \
1349  doc/man/man1/elinks.1 \
1350  src/intl/gettext/ref-add.sed \
1351  src/intl/gettext/ref-del.sed
1354 abs_srcdir="$(cd "$srcdir" && pwd)"
1355 # builddir is always absolute!
1356 if test "$abs_srcdir" != "$builddir"; then
1357         # Bootstrap the Makefile creation
1358         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1359         "$MAKE" "SRC=$abs_srcdir" init
1361         # Make cg-status ignore this build directory
1362         echo "*" > "$builddir/.gitignore"
1365 dnl ===================================================================
1366 dnl Configuration summary
1367 dnl ===================================================================
1369 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1370 cat features.log