Include <sys/types.h> and fix compilation on an old PPC/Debian system
[elinks/images.git] / configure.in
blobad44020ff49d926798d1ff2f8f010682edc3122e
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.11.2.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_BEOS, [BEOS], [__BEOS__])
151 AC_SUBST(CONFIG_BEOS)
153 EL_CHECK_COMPILER_MACROS(CONFIG_RISCOS, [RISCOS], [__riscos__])
154 AC_SUBST(CONFIG_RISCOS)
156 EL_CHECK_COMPILER_MACROS(CONFIG_WIN32, [WIN32], [_WIN32 __WIN32__])
157 AC_SUBST(CONFIG_WIN32)
159 EL_CHECK_COMPILER_MACROS(CONFIG_OS2, [EMX], [__EMX__])
160 AC_SUBST(CONFIG_OS2)
161 test "$CONFIG_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_BEOS" = no && \
166    test "$CONFIG_RISCOS" = no && \
167    test "$CONFIG_WIN32" = no && \
168    test "$CONFIG_OS2" = no; then
169         EL_CONFIG(CONFIG_UNIX, [UNIX])
170 else
171         CONFIG_UNIX=no
173 AC_MSG_RESULT($CONFIG_UNIX)
174 AC_SUBST(CONFIG_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_SYS_TYPE(off_t, HAVE_OFF_T, [])
226 EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
227 EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
228 EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
230 AC_CHECK_SIZEOF(char, 1)
231 AC_CHECK_SIZEOF(short, 2)
232 AC_CHECK_SIZEOF(int, 4)
233 AC_CHECK_SIZEOF(long, 4)
234 test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
235 test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
237 dnl Check for variadic macros
238 EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
239                 [#include <stdio.h>
240                  #define a(b,c...) printf(b,##c)],
241                 [a("foo");a("%s","bar");a("%s%s","baz","quux");])
243 dnl Check for -rdynamic
244 dnl FIXME: This check doesn't work. Something to do with the compiler
245 dnl happily ignoring it and stderr not being checked for error messages.
246 AC_MSG_CHECKING([for -rdynamic])
247 LDFLAGS_X="$LDFLAGS"
248 LDFLAGS="$LDFLAGS -rdynamic"
249 AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no)
250 test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X"
251 AC_MSG_RESULT($have_rdynamic)
253 dnl ===================================================================
254 dnl Check for POSIX <regex.h>
255 dnl ===================================================================
257 EL_CHECK_SYS_TYPE(regex_t, HAVE_REGEX_H, [#include <regex.h>])
259 dnl ===================================================================
260 dnl Checks for library functions.
261 dnl ===================================================================
263 AC_PROG_GCC_TRADITIONAL
264 AC_FUNC_MEMCMP
265 AC_FUNC_MMAP
266 AC_FUNC_STRFTIME
267 AC_CHECK_FUNCS(cfmakeraw gethostbyaddr herror strerror)
268 AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
269 AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
270 AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
271 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
272 AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
273 AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
274 AC_CHECK_FUNCS(gettimeofday clock_gettime)
276 AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path)
278 AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
279 AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
280 AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
282 dnl These aren't probably needed now, as they are commented in links.h.
283 dnl I've no idea about their historical background, but I keep them here
284 dnl just in the case they will help later. --pasky
285 AC_CHECK_FUNCS(getpid, HAVE_GETPID=yes)
286 AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
287 AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
288 AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
290 if test x"$HAVE_RAISE" = x; then
291         if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then
292                 AC_ERROR([Unable to emulate raise()])
293         fi
296 AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[
297 AC_TRY_LINK([#include <stdarg.h>
298 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
299 el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)])
300 if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then
301         EL_DEFINE(HAVE_VA_COPY, __va_copy)
304 AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
305 AC_TRY_LINK([#include <unistd.h>
306 ], [int page_size = sysconf(_SC_PAGE_SIZE);],
307 el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)])
308 if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
309         EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
312 AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
313 AC_TRY_RUN([
314 #include <stdio.h>
315 #include <stdarg.h>
316 #include <stdlib.h>
317 #include <string.h>
319 char buf[8];
321 int bar(char *buf, const char *format, va_list ap)
323        return vsnprintf(buf, 0, format, ap);
326 void foo(const char *format, ...) {
327        va_list ap;
328        int len;
330        va_start(ap, format);
331        len = bar(buf, format, ap);
332        va_end(ap);
333        if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
335        va_start(ap, format);
336        len = bar(buf, format, ap);
337        va_end(ap);
338        if ((len != 6) && (len != 7)) exit(1);
340        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
342        exit(0);
344 main() { foo("hello\n"); }
346 el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)])
347 if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
348         EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
351 AC_CHECK_LIB(dl, dlopen) # OpenSSL and Lua frequently needs it
353 dnl ===================================================================
354 dnl Checks for libraries.
355 dnl ===================================================================
357 dnl Replace `main' with a function in -lsocket:
358 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
359 if test "$cf_result" = no; then
360         AC_CHECK_LIB(socket, socket)
363 AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
364 if test "$cf_result" = no; then
365         AC_CHECK_LIB(socket, setsockopt)
368 AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
369 if test "$cf_result" = no; then
370         AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
371         if test "$cf_result" = no; then
372                 AC_CHECK_LIB(nsl, gethostbyname)
373         else
374                 test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
375         fi
378 dnl ===================================================================
379 dnl Checks for packaging specific options.
380 dnl ===================================================================
382 AC_ARG_WITH(xterm, [  --with-xterm            how to invoke the X terminal emulator],
383             [ if test "$withval" != no && test "$withval" != yes; then
384                 AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
385               fi ])
387 dnl ===================================================================
388 dnl Checks for a libraries, optional even if installed.
389 dnl ===================================================================
391 dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
392 AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
394         AC_MSG_CHECKING([for $2 support])
396         if test "[$]$1" != no; then
397                 AC_MSG_RESULT(yes)
398                 EL_SAVE_FLAGS
399                 if test -n "$withval" && test -d "$withval"; then
400                         CFLAGS="$CFLAGS -I$withval/include";
401                         CPPFLAGS="$CPPFLAGS -I$withval/include";
402                         LDFLAGS="$LDFLAGS -L$withval/lib";
403                 fi
405                 AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
406                 if test "[$]$1" = yes; then
407                         AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
408                 fi
410                 if test "[$]$1" = yes; then
411                         EL_CONFIG([$1], [$2])
412                         LIBS="$LIBS -l$4"
413                 else
414                         if test -n "[$]WITHVAL_$1" &&
415                            test "[$]WITHVAL_$1" != xno; then
416                                 AC_MSG_ERROR([$2 not found])
417                         fi
418                         EL_RESTORE_FLAGS
419                 fi
420         else
421                 AC_MSG_RESULT(disabled)
422         fi
425 dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
426 AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
428         $1=yes
429         WITHVAL_$1=
431         AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
432         if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
434         EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
436         EL_LOG_CONFIG([$1], [$2], [])
439 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
440         [  --without-gpm           disable gpm (mouse) support])
442 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzdopen,
443         [  --without-zlib          disable zlib support])
445 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
446         [  --without-bzlib         disable bzlib support])
448 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
449         [  --without-idn           disable international domain names support])
451 dnl ===================================================================
452 dnl Bookmark and XBEL support
453 dnl ===================================================================
455 EL_SAVE_FLAGS
457 EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
458               [  --disable-bookmarks     disable bookmark support])
460 # Check whether --enable-xbel or --disable-xbel was given.
461 if test "x${enable_xbel}" != xno; then
462         AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
464         if test "$HAVE_LIBEXPAT" = yes; then
465                 AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
466                 if test "$HAVE_LIBEXPAT" = yes; then
467                         LIBS="$LIBS -lexpat"
468                 fi
469         fi
473 EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
474               [XBEL bookmarks],
475               [  --disable-xbel          disable XBEL bookmark support (requires expat)])
477 if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
478         EL_RESTORE_FLAGS
481 dnl ===================================================================
482 dnl Checks for BSD sysmouse
483 dnl ===================================================================
485 HAVE_SYSMOUSE_HEADER="no"
487 # Either of these header files provides the (same) sysmouse interface
488 AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
490 dnl ===================================================================
491 dnl Checks for OS/2
492 dnl ===================================================================
494 if test "$CONFIG_OS2" = yes; then
495         EL_CONFIG_OS2
498 dnl ===================================================================
499 dnl Checks for Win32
500 dnl ===================================================================
502 if test "$CONFIG_WIN32" = yes; then
503         EL_CONFIG_WIN32
506 dnl ===================================================================
507 dnl Check for SpiderMonkey, optional even if installed.
508 dnl ===================================================================
510 AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey Mozilla JavaScript engine support],
511             [if test "$withval" = no; then disable_spidermonkey=yes; fi])
512 AC_MSG_CHECKING([for SpiderMonkey])
514 EL_SAVE_FLAGS
515 cf_result=no
517 if test -z "$disable_spidermonkey"; then
518         if test ! -d "$withval"; then
519                 withval="";
520         fi
521         for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do
522                 for spidermonkeyinclude in "/include" "/include/js" "/include/smjs"; do
523                         for spidermonkeylib in js smjs; do
524                                 if test "$cf_result" = no; then
525                                         SPIDERMONKEY_LIBS="-l$spidermonkeylib"
527                                         if test ! -z "$spidermonkeydir"; then
528                                                 SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS"
529                                                 SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude"
530                                         fi
532                                         LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
533                                         CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS"
534                                         CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
536                                         AC_TRY_LINK([#define XP_UNIX
537                                                      #include <jsapi.h>],
538                                                      [JS_GetImplementationVersion()],
539                                                      cf_result=yes, cf_result=no)
540                                 fi
541                         done
542                 done
543         done
546 AC_MSG_RESULT($cf_result)
548 if test "$cf_result" != yes; then
549         EL_RESTORE_FLAGS
550 else
551         EL_CONFIG(CONFIG_SPIDERMONKEY, [SpiderMonkey])
553         CFLAGS="$CFLAGS_X"
554         AC_SUBST(SPIDERMONKEY_LIBS)
555         AC_SUBST(SPIDERMONKEY_CFLAGS)
558 AC_SUBST(CONFIG_SPIDERMONKEY)
560 EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_SPIDERMONKEY], [ECMAScript (JavaScript)])
563 dnl ===================================================================
564 dnl Check for Guile, optional even if installed.
565 dnl ===================================================================
567 enable_guile="no";
569 AC_ARG_WITH(guile, [  --with-guile            enable Guile support],
570             [ if test "x$withval" != xno; then enable_guile=yes; fi ])
572 # The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
573 # GUILE_FLAGS but I really don't want to require people to have Guile in order
574 # to compile CVS. Also, the macro seems to be really stupid regarding searching
575 # for Guile in $PATH etc. --pasky
577 AC_MSG_CHECKING([for Guile])
579 if test "$enable_guile" = "yes"; then
580         AC_MSG_RESULT(yes);
581         ## Based on the GUILE_FLAGS macro.
583         if test -d "$withval"; then
584                 GUILE_PATH="$withval:$PATH"
585         else
586                 GUILE_PATH="$PATH"
587         fi
589         AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $GUILE_PATH)
591         ## First, let's just see if we can find Guile at all.
592         if test "$GUILE_CONFIG" != no; then
593                 cf_result="yes";
595                 GUILE_LIBS="`guile-config link`"
596                 GUILE_CFLAGS="`guile-config compile`"
597                 LIBS="$GUILE_LIBS $LIBS"
598                 CPPFLAGS="$CPPFLAGS $GUILE_CFLAGS"
599                 EL_CONFIG(CONFIG_GUILE, [Guile])
600                 AC_SUBST(GUILE_CFLAGS)
601                 cat <<EOF
602 ***********************************************************************
603 The Guile support is incomplete and not so well integrated to ELinks
604 yet. That means, ie., that you have no Guile console and there might
605 not be all the necessary hooks. Also, the Guile interface is not too
606 well tested (success stories heartily welcomed!).  See
607 src/scripting/guile/README for further details and hints.
608 ***********************************************************************
610         else
611                 if test -n "$withval" && test "x$withval" != xno; then
612                         AC_MSG_ERROR([Guile not found])
613                 else
614                         AC_MSG_WARN([Guile support disabled])
615                 fi
616         fi
617 else
618         AC_MSG_RESULT(no);
621 dnl ===================================================================
622 dnl Check for Perl
623 dnl ===================================================================
624 enable_perl="no";
626 AC_ARG_WITH(perl, [  --with-perl             enable Perl support],
627             [
628 if test "$withval" = yes; then
629         # FIXME: If withval is a valid directory append it to PATH
630         # so that you can specify one of several perl installations.
631         withval="";
632         enable_perl=yes;
634             ])
636 AC_MSG_CHECKING([for Perl])
638 cf_result=no
640 EL_SAVE_FLAGS
642 if test "$enable_perl" = "yes"; then
643         PERL_LIBS="`perl -MExtUtils::Embed -e ldopts`"
644         PERL_CFLAGS="`perl -MExtUtils::Embed -e ccopts`"
645         LIBS="$PERL_LIBS $LIBS"
646         CFLAGS="$PERL_CFLAGS $CFLAGS"
647         CPPFLAGS="$CPPFLAGS $PERL_CFLAGS"
648         AC_TRY_LINK([
649 #include <EXTERN.h>
650 #include <perl.h>
651 #include <perlapi.h>
653                     [PerlInterpreter *my_perl = perl_alloc();],
654                     cf_result=yes, cf_result=no)
657 if test "$cf_result" != "yes"; then
658         EL_RESTORE_FLAGS
659 else
660         EL_CONFIG(CONFIG_PERL, [Perl])
662         CFLAGS="$CFLAGS_X"
663         AC_SUBST(PERL_LIBS)
664         AC_SUBST(PERL_CFLAGS)
667 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
668 dnl ===================================================================
669 dnl Check for Python
670 dnl ===================================================================
671 enable_python="no";
673 AC_ARG_WITH(python, [  --with-python           enable Python support],
674             [
675 if test "$withval" = yes; then
676         # FIXME: If withval is a valid directory append it to PATH
677         # so that you can specify one of several Python installations.
678         withval="";
679         enable_python=yes;
680         cat <<EOF
681 ***********************************************************************
682 The Python support is incomplete and not so well integrated to ELinks
683 yet. That means, ie., that you have no Python console and there might
684 not be all the necessary hooks. Also, the Python interface is not too
685 well tested (success stories heartily welcomed!).
686 ***********************************************************************
689             ])
691 AC_MSG_CHECKING([for Python])
693 cf_result=no
695 EL_SAVE_FLAGS
697 if test "$enable_python" = "yes"; then
698         PYTHON_LIBS="-lpython"
699         PYTHON_CFLAGS="-I`python -c 'from distutils import sysconfig; print sysconfig.get_python_inc()' 2> /dev/null`"
700         LIBS="$PYTHON_LIBS $LIBS"
701         CFLAGS="$PYTHON_CFLAGS $CFLAGS"
702         CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
703         AC_TRY_LINK([
704 #include <Python.h>
706                     [Py_Initialize();],
707                     cf_result=yes, cf_result=no)
710 if test "$cf_result" != "yes"; then
711         EL_RESTORE_FLAGS
712 else
713         EL_CONFIG(CONFIG_PYTHON, [Python])
715         CFLAGS="$CFLAGS_X"
716         AC_SUBST(PYTHON_LIBS)
717         AC_SUBST(PYTHON_CFLAGS)
720 if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi
723 dnl ===================================================================
724 dnl Check for Lua, optional even if installed.
725 dnl ===================================================================
727 dnl Do this the long way, as FreeBSD reportedly needs -L<dir> for
728 dnl anything other than /usr/lib, and Lua is very often in /usr/local/lib.
730 AC_ARG_WITH(lua, [  --without-lua           disable Lua support],
731             [if test "$withval" = no; then disable_lua=yes; fi])
732 AC_MSG_CHECKING([for Lua])
734 EL_SAVE_FLAGS
735 cf_result=no
737 if test -z "$disable_lua"; then
738         if test ! -d "$withval"; then
739                 withval="";
740         fi
741         for luadir in "$withval" "" /usr /usr/local; do
742                 for suffix in "" 50 51; do
743                         if test "$cf_result" = no; then
744                                 LUA_LIBS="-llua$suffix -llualib$suffix -lm"
746                                 if test ! -z "$luadir"; then
747                                         LUA_LIBS="-L$luadir/lib $LUA_LIBS"
748                                         LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
749                                 fi
751                                 LIBS="$LUA_LIBS $LIBS_X"
752                                 CFLAGS="$CFLAGS_X $LUA_CFLAGS"
753                                 CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
755                                 # Check that it is a compatible Lua version
756                                 AC_TRY_LINK([   #include <lua.h>
757                                                 #include <lualib.h>],
758                                             [   lua_State *L = lua_open();
759                                                 lua_baselibopen(L);
760                                                 lua_mathlibopen(L);
761                                                 lua_strlibopen(L);
762                                                 lua_tablibopen(L);
763                                                 lua_pushboolean(L, 1);
764                                                 lua_close(L);],
765                                             cf_result=yes, cf_result=no)
766                         fi
767                 done
768         done
771 AC_MSG_RESULT($cf_result)
773 if test "$cf_result" != yes; then
774         EL_RESTORE_FLAGS
775 else
776         EL_CONFIG(CONFIG_LUA, [Lua])
777         AC_CHECK_HEADERS(lauxlib.h)
779         CFLAGS="$CFLAGS_X"
780         AC_SUBST(LUA_LIBS)
781         AC_SUBST(LUA_CFLAGS)
785 dnl ===================================================================
786 dnl Check for Ruby, optional even if installed.
787 dnl ===================================================================
789 EL_CONFIG_RUBY
791 dnl ===================================================================
792 dnl Optional Spidermonkey-based ECMAScript browser scripting
793 dnl ===================================================================
795 AC_ARG_ENABLE(sm-scripting,
796               [  --disable-sm-scripting  ECMAScript browser scripting (requires Spidermonkey)],
797               [if test "$enableval" != no; then enableval="yes"; fi
798                CONFIG_SM_SCRIPTING="$enableval";])
800 if test "x$CONFIG_SPIDERMONKEY" = xyes &&
801    test "x$CONFIG_SM_SCRIPTING" = xyes; then
802         EL_CONFIG(CONFIG_SM_SCRIPTING, [SpiderMonkey])
803 else
804         CONFIG_SM_SCRIPTING=no
807 dnl ===================================================================
808 dnl Setup global scripting
809 dnl ===================================================================
811 EL_CONFIG_DEPENDS(CONFIG_SCRIPTING, [CONFIG_GUILE CONFIG_LUA CONFIG_PERL CONFIG_PYTHON CONFIG_RUBY CONFIG_SM_SCRIPTING], [Browser scripting])
812 AC_SUBST(CONFIG_GUILE)
813 AC_SUBST(CONFIG_LUA)
814 AC_SUBST(CONFIG_PERL)
815 AC_SUBST(CONFIG_PYTHON)
816 AC_SUBST(CONFIG_RUBY)
817 AC_SUBST(CONFIG_SM_SCRIPTING)
818 AC_SUBST(CONFIG_SCRIPTING)
821 dnl ===================================================================
822 dnl Check for SSL support.
823 dnl ===================================================================
825 dnl We by default use OpenSSL, and we always prefer it. However, when GNUTLS
826 dnl is enabled, we won't try to use OpenSSL anymore.
828 dnl For wiping SSL hooks..
829 #ifdef CONFIG_SSL
831 disable_openssl=""
832 disable_gnutls=""
833 enable_gnutls=""
835 AC_ARG_WITH(gnutls, [  --without-gnutls        disable GNUTLS SSL support],
836             [if test "$with_gnutls" = no;  then disable_gnutls=yes; fi])
837 AC_ARG_WITH(gnutls, [  --with-gnutls[=DIR]     enable GNUTLS SSL support],
838             [if test "$with_gnutls" != no;  then enable_gnutls=yes; fi])
839 gnutls_withval="$withval"
841 if test "$enable_gnutls" = yes; then
842         disable_openssl=yes;
845 AC_ARG_WITH(openssl, [  --without-openssl       disable OpenSSL support],
846             [if test "$with_openssl" = no;  then disable_openssl=yes; fi])
847 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    enable OpenSSL support (default)])
848 openssl_withval="$withval"
850 dnl ---- OpenSSL
852 AC_MSG_CHECKING([for OpenSSL])
854 EL_SAVE_FLAGS
855 cf_result="no"
857 if test "$disable_openssl" = yes; then
858         cf_result="not used"
859 else
860         for ssldir in "$openssl_withval" "" /usr /usr/local/openssl \
861                          /usr/lib/openssl /usr/local/ssl \
862                          /usr/local/www /usr/lib/ssl /usr/local \
863                          /usr/pkg /opt /opt/openssl; do
864                 if test "$cf_result" = no; then
865                         if test -d "$ssldir"; then
866                                 OPENSSL_CFLAGS="-I$ssldir/include"
867                                 LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_X"
868                                 CFLAGS="$CFLAGS_X $OPENSSL_CFLAGS"
869                                 CPPFLAGS="$CPPFLAGS_X $OPENSSL_CFLAGS"
870 #                               # FIXME: This created serious portability problems. --pasky
871 #                               if test "$CC" == "gcc"; then
872 #                                       # I'm not sure about compatibility here. --pasky
873 #                                       LIBS="$LIBS -R$ssldir/lib"
874 #                               fi
875                         else
876                                 LIBS="-lssl -lcrypto $LIBS_X"
877                         fi
878                         AC_TRY_LINK([#include <openssl/ssl.h>],
879                                     [OpenSSL_add_all_algorithms()],
880                                     cf_result=yes, cf_result=no)
881                         if test "$cf_result" != yes; then
882                                 AC_TRY_LINK([#include <openssl/ssl.h>],
883                                             [SSLeay_add_ssl_algorithms()],
884                                             cf_result=yes, cf_result=no)
885                         fi
886                 fi
887         done
889         if test "$cf_result" != yes; then
890                 if test -n "$openssl_withval" && test "x$openssl_withval" != xno; then
891                         AC_MSG_ERROR([OpenSSL not found])
892                 fi
893                 EL_RESTORE_FLAGS
894         else
895                 EL_CONFIG(CONFIG_OPENSSL, [OpenSSL])
897                 CFLAGS="$CFLAGS_X"
898                 AC_SUBST(OPENSSL_CFLAGS)
899         fi
902 AC_MSG_RESULT($cf_result)
904 CONFIG_GNUTLS_OPENSSL_COMPAT=no
905 dnl ---- GNU TLS
906 dnl We can't have AC_MSG_CHECKING here, because AC_PATH_PROG prints its own and
907 dnl it looks ugly then.
909 if test "$cf_result" = yes; then
910         cf_result="not used"
912 else
913         EL_SAVE_FLAGS
914         cf_result="no"
916         if test -z "$disable_gnutls"; then
917                 # Sure, we maybe _could_ use their macro, but how to ensure
918                 # that the ./configure script won't fail if the macro won't be
919                 # found..? :( --pasky
921                 GNUTLS_PATH="$PATH:/usr/local/gnutls:/opt:/opt/gnutls"
923                 if test -d "$gnutls_withval"; then
924                         GNUTLS_PATH="$gnutls_withval:$GNUTLS_PATH"
925                 fi
927                 AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no, $GNUTLS_PATH)
929                 if test "$LIBGNUTLS_CONFIG" = "no" ; then
930                         cf_result=no
931                 else
932                         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags`
933                         GNUTLS_LIBS=`$LIBGNUTLS_CONFIG --libs`
935                         LIBS="$GNUTLS_LIBS $LIBS_X"
936                         CFLAGS="$CFLAGS_X $GNUTLS_CFLAGS"
937                         CPPFLAGS="$CPPFLAGS_X $GNUTLS_CFLAGS"
939                         # Verify if it's really usable.  gnutls_session was
940                         # renamed to gnutls_session_t before GNU TLS 1.2.0
941                         # (on 2004-06-13); ELinks now requires this.
942                         AC_TRY_LINK([#include <gnutls/gnutls.h>],
943                                     [gnutls_session_t dummy;
944                                      gnutls_check_version(NULL)],
945                                     cf_result=yes, cf_result=no)
946                 fi
948                 if test "$cf_result" = yes; then
949                         EL_CONFIG(CONFIG_GNUTLS, [GNUTLS])
951                         CFLAGS="$CFLAGS_X"
952                         AC_SUBST(GNUTLS_CFLAGS)
954                         # Verify if the MD5 compatibility layer is usable.
955                         CONFIG_GNUTLS_OPENSSL_COMPAT=yes
956                         EL_CHECK_OPTIONAL_LIBRARY(CONFIG_GNUTLS_OPENSSL_COMPAT,
957                                                   [GNU TLS OpenSSL compatibility],
958                                                   gnutls/openssl.h, gnutls-openssl,
959                                                   MD5_Init)
960                 else
961                         if test -n "$gnutls_withval" && test "x$gnutls_withval" != xno; then
962                                 AC_MSG_ERROR([GNUTLS (1.2 or later) not found.  ELinks no longer supports GNUTLS 1.1.])
963                         fi
964                         EL_RESTORE_FLAGS
965                 fi
966         fi
969 AC_MSG_CHECKING([for GNU TLS (1.2 or later)])
970 AC_MSG_RESULT($cf_result)
972 dnl Final SSL setup
974 EL_CONFIG_DEPENDS(CONFIG_SSL, [CONFIG_OPENSSL CONFIG_GNUTLS], [SSL])
975 AC_SUBST(CONFIG_GNUTLS_OPENSSL_COMPAT)
976 AC_SUBST(CONFIG_OPENSSL)
977 AC_SUBST(CONFIG_GNUTLS)
979 #endif
981 AC_MSG_CHECKING([whether to be or not to be])
982 AC_MSG_RESULT([needs to be determined experimentally])
984 dnl ===================================================================
985 dnl Check for IPv6 support and related functions.
986 dnl ===================================================================
988 EL_CHECK_NET_TYPE(struct sockaddr_storage, HAVE_SA_STORAGE, [])
989 EL_CHECK_NET_TYPE(struct sockaddr_in6, HAVE_SA_IN6, [#include <netinet/in.h>])
990 EL_CHECK_NET_TYPE(struct addrinfo, HAVE_ADDRINFO, [#include <netdb.h>])
992 AC_CHECK_FUNC(getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
993 if test "$HAVE_GETADDRINFO" != yes; then
994         AC_CHECK_LIB(inet6, getaddrinfo, HAVE_GETADDRINFO=yes, HAVE_GETADDRINFO=no)
995         if test "$HAVE_GETADDRINFO" = yes; then
996                 LIBS="$LIBS -linet6"
997         fi
1001 dnl ===================================================================
1002 dnl Checking for X11 (window title restoring).
1003 dnl ===================================================================
1005 AC_PATH_X
1006 if test x"$no_x" != xyes; then
1007         if test -n "$x_includes"; then
1008                 X_CFLAGS="-I$x_includes"
1009                 CPPFLAGS="$CPPFLAGS -I$x_includes"
1010         fi
1011         if test -n "$x_libraries"; then
1012                 LDFLAGS="$LDFLAGS -L$x_libraries"
1013         fi
1014         LIBS="-lX11 $LIBS"
1015         EL_DEFINE(HAVE_X11, [X11 for restoring window titles])
1016         AC_SUBST(X_CFLAGS)
1020 dnl ===================================================================
1021 dnl Backtraces displaying support.
1022 dnl ===================================================================
1024 AC_CHECK_HEADERS(execinfo.h, HAVE_EXECINFO=yes, HAVE_EXECINFO=no)
1025 # possible checks for other system-specific means go here
1028 dnl ===================================================================
1029 dnl SMB protocol support.
1030 dnl ===================================================================
1032 AC_CHECK_PROG(HAVE_SMBCLIENT, smbclient, yes, no)
1035 dnl ===================================================================
1036 dnl Gettext grey zone. Beware.
1037 dnl ===================================================================
1039 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"
1041 AM_GNU_GETTEXT
1043 dnl AC_MSG_CHECKING([how many characters your English alphabet has])
1044 dnl # f33r d4 l33t... I hope it's portable. :)
1045 dnl cf_result=$((48#z - 48#a + 1));
1046 dnl AC_MSG_RESULT($cf_result)
1049 dnl ===================================================================
1050 dnl Compile-time features control
1051 dnl ===================================================================
1053 EL_ARG_ENABLE(CONFIG_COOKIES, cookies, [Cookies],
1054               [  --disable-cookies       disable cookie support])
1056 EL_ARG_ENABLE(CONFIG_FORMHIST, formhist, [Form history],
1057               [  --disable-formhist      disable form history support])
1059 EL_ARG_ENABLE(CONFIG_GLOBHIST, globhist, [Global history],
1060               [  --disable-globhist      disable global history support])
1063 EL_ARG_ENABLE(CONFIG_MAILCAP, mailcap, [Mailcap],
1064               [  --disable-mailcap       disable mailcap support])
1066 EL_ARG_ENABLE(CONFIG_MIMETYPES, mimetypes, [Mimetypes files],
1067               [  --disable-mimetypes     disable mimetypes files support])
1070 EL_ARG_DEPEND(CONFIG_IPV6, ipv6,
1071               [HAVE_SA_STORAGE:yes HAVE_SA_IN6:yes HAVE_ADDRINFO:yes HAVE_GETADDRINFO:yes],
1072               [IPv6],
1073               [  --disable-ipv6          disable IPv6 support])
1075 EL_ARG_ENABLE(CONFIG_BITTORRENT, bittorrent, [BitTorrent protocol],
1076               [  --enable-bittorrent     enable BitTorrent protocol support])
1078 EL_ARG_ENABLE(CONFIG_DATA, data, [Data protocol],
1079               [  --disable-data          disable data protocol support])
1081 EL_ARG_ENABLE(CONFIG_URI_REWRITE, uri-rewrite, [URI rewriting],
1082               [  --disable-uri-rewrite   disable URI rewrite support])
1084 EL_ARG_DEPEND(CONFIG_CGI, cgi, [HAVE_SETENV_OR_PUTENV:yes], [Local CGI],
1085               [  --enable-cgi            enable local CGI support])
1087 EL_ARG_ENABLE(CONFIG_FINGER, finger, [Finger protocol],
1088               [  --enable-finger         enable finger protocol support])
1090 dnl ===================================================================
1091 dnl FSP protocol
1092 dnl ===================================================================
1093 EL_SAVE_FLAGS
1095 if test "x${enable_fsp}" != xno; then
1096         AC_CHECK_HEADERS(fsplib.h, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1098         if test "$HAVE_FSPLIB" = yes; then
1099                 AC_CHECK_LIB(fsplib, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1100                 if test "$HAVE_FSPLIB" = yes; then
1101                         LIBS="$LIBS -lfsplib"
1102                 else
1103                         AC_CHECK_LIB(fsp, fsp_open_session, HAVE_FSPLIB=yes, HAVE_FSPLIB=no)
1104                         if test "$HAVE_FSPLIB" = yes; then
1105                                 LIBS="$LIBS -lfsp"
1106                         fi
1107                 fi
1108         fi
1111 EL_ARG_DEPEND(CONFIG_FSP, fsp, [HAVE_FSPLIB:yes], [FSP protocol],
1112               [  --enable-fsp            enable FSP protocol support])
1114 if test "x$CONFIG_FSP" = xno; then
1115         EL_RESTORE_FLAGS
1118 EL_ARG_ENABLE(CONFIG_FTP, ftp, [FTP protocol],
1119               [  --disable-ftp           disable ftp protocol support])
1121 EL_ARG_ENABLE(CONFIG_GOPHER, gopher, [Gopher protocol],
1122               [  --enable-gopher         enable gopher protocol support])
1124 EL_ARG_ENABLE(CONFIG_NNTP, nntp, [NNTP protocol],
1125               [  --enable-nntp           enable nntp protocol support])
1127 dnl Force disable SMB before EL_ARG_DEPEND so that it logs the correct value.
1128 if test "${enable_smb-no}" != no || test "${CONFIG_SMB-no}" != no; then
1129   AC_MSG_WARN([Forcing --disable-smb because of vulnerability CVE-2006-5925.
1130 If you want to use SMB, please vote for bug 844 or post a patch.])
1132 enable_smb=no
1133 CONFIG_SMB=no
1134 EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [SMB protocol],
1135               [  --enable-smb            not currently allowed])
1136 dnl EL_ARG_DEPEND(CONFIG_SMB, smb, [HAVE_SMBCLIENT:yes], [SMB protocol],
1137 dnl           [  --disable-smb           disable SMB protocol support (requires smbclient)])
1140 EL_ARG_ENABLE(CONFIG_MOUSE, mouse, [Mouse handling],
1141               [  --disable-mouse         disable mouse support])
1143 # GPM mouse is Linux specific, so ...
1144 CONFIG_SYSMOUSE=yes
1145 EL_ARG_DEPEND(CONFIG_SYSMOUSE, sysmouse,
1146               [CONFIG_MOUSE:yes CONFIG_GPM:no HAVE_SYSMOUSE_HEADER:yes],
1147               [BSD sysmouse],
1148               [  --disable-sysmouse      disable BSD sysmouse support])
1150 EL_ARG_ENABLE(CONFIG_88_COLORS, 88-colors, [88 colors],
1151               [  --enable-88-colors      enable 88 color support])
1153 EL_ARG_ENABLE(CONFIG_256_COLORS, 256-colors, [256 colors],
1154               [  --enable-256-colors     enable 256 color support])
1157 EL_ARG_ENABLE(CONFIG_EXMODE, exmode, [Exmode interface],
1158               [  --enable-exmode         enable exmode (CLI) interface])
1160 EL_ARG_ENABLE(CONFIG_LEDS, leds, [LEDs],
1161               [  --disable-leds          disable LEDs support])
1163 EL_ARG_ENABLE(CONFIG_MARKS, marks, [Marks],
1164               [  --disable-marks         disable document marks support])
1167 EL_ARG_ENABLE(CONFIG_CSS, css, [Cascading Style Sheets],
1168               [  --disable-css           disable Cascading Style Sheet support])
1170 EL_ARG_DEPEND(CONFIG_HTML_HIGHLIGHT, html-highlight, [CONFIG_CSS:yes], [HTML highlighting],
1171               [  --enable-html-highlight HTML highlighting using DOM engine])
1173 dnl Everything in the tree already uses CONFIG_DOM
1174 dnl so resolve CONFIG_HTML_HIGHLIGHT to CONFIG_DOM
1175 EL_CONFIG_DEPENDS(CONFIG_DOM, [CONFIG_HTML_HIGHLIGHT], [DOM engine])
1177 EL_ARG_DEPEND(CONFIG_BACKTRACE, backtrace, [HAVE_EXECINFO:yes], [Backtrace],
1178               [  --disable-backtrace     disable backtrace support])
1180 EL_ARG_DEPEND(CONFIG_NO_ROOT_EXEC, no-root, [HAVE_GETUID:yes HAVE_GETEUID:yes], [No root exec],
1181               [  --enable-no-root        enable prevention of usage by root])
1184 EL_ARG_ENABLE(CONFIG_DEBUG, debug, [Debug mode],
1185               [  --enable-debug          enable leak debug and internal error checking])
1187 EL_ARG_DEPEND(CONFIG_FASTMEM, fastmem, [CONFIG_DEBUG:no], [Fast mode],
1188               [  --enable-fastmem        enable direct use of system allocation functions, not usable with --enable-debug])
1190 EL_ARG_ENABLE(CONFIG_OWN_LIBC, own-libc, [Own libc stubs],
1191               [  --enable-own-libc       force use of internal functions instead of those of system libc])
1193 EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary],
1194               [  --enable-small          reduce binary size as far as possible (but see the bottom of doc/small.txt!)])
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)
1207 if test "$CONFIG_BITTORRENT" = yes; then
1208         if test "$CONFIG_OPENSSL" != yes ||
1209            test "$CONFIG_OWN_LIBC" = yes;
1210         then
1211                 AC_MSG_CHECKING(for built-in SHA1 support)
1212                 AC_MSG_RESULT(yes)
1213                 EL_CONFIG(CONFIG_SHA1, [Built-in SHA1])
1214         fi
1217 AC_SUBST(CONFIG_SHA1)
1219 if test "$CONFIG_CSS" = yes || test "$CONFIG_DOM" = yes;
1220 then
1221         EL_CONFIG(CONFIG_SCANNER, [Built-in scanner])
1223 AC_SUBST(CONFIG_SCANNER)
1225 AC_ARG_ENABLE(weehoofooboomookerchoo,
1226               [
1227     Also check out the features.conf file for more information about features!
1228               ],
1229               [AC_MSG_ERROR(Are you strange, or what?)])
1232 dnl == EMX hack
1234 test "$CONFIG_OS2" = yes && LDFLAGS="$LDFLAGS -Zexe"
1235 test "$CONFIG_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zbin-files//g"`
1238 dnl ===================================================================
1239 dnl Export directory paths
1240 dnl ===================================================================
1242 # Set up the ``entry points'' if they were not supplied by builder
1243 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1244 test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1246 # Create CONFDIR #define for config.h
1248 # XXX: This may be dependent on a particular version of autoconf. Whatever,
1249 # it's autoconf fault to force us to do such hacks ;p.
1250 if test x"$sysconfdir" = x"\${prefix}/etc"; then
1251   # sysconfdir is set to its default value... fine, let's append /elinks/
1252   # XXX: We can't modify listing of the default in ./configure --help :-(
1253   sysconfdir_n=`eval echo "$sysconfdir"`
1254   sysconfdir=$sysconfdir_n
1255   (echo "$sysconfdir" | grep elinks >/dev/null 2>/dev/null) || \
1256         sysconfdir="$sysconfdir/elinks"
1259 CONFDIR=$sysconfdir
1260 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR", [Directory containing default config])
1261 AC_SUBST(CONFDIR)
1263 # Create LOCALEDIR #define for config.h
1264 LOCALEDIR=`eval echo "$datadir/locale"`
1265 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [Directory containing locales])
1266 AC_SUBST(LOCALEDIR)
1268 # Create LIBDIR #define for config.h
1269 LIBDIR=`eval echo "$libdir"`
1270 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Directory containing libraries])
1271 AC_SUBST(LIBDIR)
1273 EL_LOG_CONFIG(CONFDIR, [System configuration directory], [])
1274 EL_LOG_CONFIG(LOCALEDIR, [Locale catalogs directory], [])
1276 dnl ===================================================================
1277 dnl A little fine tuning of gcc specific options (continued)
1278 dnl ===================================================================
1280 if test "x$ac_cv_prog_gcc" = "xyes"; then
1281   if test "$CONFIG_DEBUG" = "yes"; then
1282     dnl We want to see all warnings and live with none (in debug mode).
1283     CFLAGS="$CFLAGS -Werror"
1284   fi
1286   case "`$CC -dumpversion`" in
1287     3.0|3.1|3.2)
1288       # These should be ok using -Werror
1289       ;;
1290     3.*)
1291       # If gcc is version 3.3 (or higher?) it emits lots of false positive
1292       # "dereferencing type-punned pointer will break strict-aliasing rules"
1293       # warnings. Disable them by not doing any strict-aliasing. The
1294       # alternative is just too ugly. Thanks gcc guys!! ;)
1295       CFLAGS="$CFLAGS -fno-strict-aliasing"
1296       ;;
1297     4.*)
1298       # Do not show warnings related to (char * | unsigned char *) type
1299       # difference.
1300       CFLAGS="$CFLAGS -fno-strict-aliasing -Wno-pointer-sign"
1301       ;;
1302     *)
1303       # These should be ok using -Werror
1304       ;;
1305   esac
1308 # CFLAGS doesn't contain all compile flags. Some will be added only when
1309 # needed in the respective source directory. To get all compile flags
1310 # easily just add CPPFLAGS.
1311 ALL_CFLAGS="$CFLAGS $CPPFLAGS"
1313 EL_LOG_CONFIG(ALL_CFLAGS, [Compiler options (CFLAGS)], [])
1314 EL_LOG_CONFIG(LIBS, [Linker options (LIBS)], [])
1316 dnl ===================================================================
1317 dnl Colored make output
1318 dnl ===================================================================
1320 if test $(`which tput` colors) -ge 4; then
1321         MAKE_COLOR=1
1322         AC_SUBST(MAKE_COLOR)
1325 dnl ===================================================================
1326 dnl Generated files
1327 dnl ===================================================================
1329 AC_OUTPUT([ \
1330  Makefile.config \
1331  contrib/elinks.spec \
1332  contrib/lua/hooks.lua \
1333  contrib/conv/w3m2links.awk \
1334  doc/man/man1/elinks.1 \
1335  src/intl/gettext/ref-add.sed \
1336  src/intl/gettext/ref-del.sed
1339 abs_srcdir="$(cd "$srcdir" && pwd)"
1340 # builddir is always absolute!
1341 if test "$abs_srcdir" != "$builddir"; then
1342         # Bootstrap the Makefile creation
1343         echo "include $abs_srcdir/Makefile" > "$builddir/Makefile"
1344         "$MAKE" "SRC=$abs_srcdir" init
1345         # Make cg-status ignore this build directory
1346         echo "*" > "$builddir/.gitignore"
1350 dnl ===================================================================
1351 dnl Configuration summary
1352 dnl ===================================================================
1354 AC_MSG_RESULT(The following feature summary has been saved to features.log)
1355 cat features.log