[SCons] define with_krb5 for SCons build
[lighttpd.git] / configure.ac
blobcee5220846b0316b9d98b0c5812180fa21000ffd
1 dnl                                               -*- Autoconf -*-
2 dnl Process this file with autoconf to produce a configure script.
3 AC_PREREQ(2.57)
4 AC_INIT([lighttpd], [1.4.42], [contact@lighttpd.net])
5 AC_CONFIG_SRCDIR([src/server.c])
6 AC_CONFIG_HEADER([config.h])
7 AC_CONFIG_MACRO_DIR([m4])
9 AC_CANONICAL_HOST
11 dnl HOW FUCKING BROKEN IS AUTOMAKE...
12 dnl serial-tests is not recognized before 1.12, and required for serial tests with 1.13, sane version checks "impossible"
13 dnl if you don't use the default (symlinked) automake on your box, set AUTOMAKE to the path you're using
14 m4_define([serial_tests], [
15     m4_esyscmd([case `${AUTOMAKE:-automake} --version | head -n 1` in
16       *1.11.*|*1.10.*|*1.9.*);;
17       *) echo serial-tests;;
18       esac])
21 AM_INIT_AUTOMAKE([-Wall -Wno-portability -Wno-override foreign dist-xz tar-ustar] serial_tests)
23 dnl enable with --enable-silent-rules or make V=0 (needs automake >= 1.11)
24 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
27 dnl @synopsis TRY_CFLAGS [compiler flags]
28 dnl @summary check whether compiler supports given flags and adds them to CFLAGS
29 AC_DEFUN([TRY_CFLAGS],
30 [dnl
31   AC_MSG_CHECKING([if $CC supports $1])
32   AC_LANG_PUSH([C])
33   ac_try_cflags_saved_cflags="${CFLAGS}"
34   CFLAGS="${CFLAGS} $1"
35   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
36     [AC_MSG_RESULT([yes])],
37     [
38       AC_MSG_ERROR([no])
39       CFLAGS="${ac_try_cflags_saved_cflags}"
40     ]
41   )
42   AC_LANG_POP([C])
45 dnl @synopsis TRY_LDFLAGS [linker flags]
46 dnl @summary check whether linker supports given flags and adds them to LDFLAGS
47 AC_DEFUN([TRY_LDFLAGS],
48 [dnl
49   AC_MSG_CHECKING([if $LD supports $1])
50   AC_LANG_PUSH([C])
51   ac_try_ldflags_saved_ldflags="${LDFLAGS}"
52   LDFLAGS="${LDFLAGS} $1"
53   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
54     [AC_MSG_RESULT([yes])],
55     [
56       AC_MSG_ERROR([no])
57       LDFLAGS="${ac_try_ldflags_saved_cflags}"
58     ]
59   )
60   AC_LANG_POP([C])
63 dnl Checks for programs.
64 AC_PROG_CC
65 AM_PROG_CC_C_O
66 AC_PROG_LD
67 AC_PROG_INSTALL
68 AC_PROG_AWK
69 AC_PROG_CPP
70 dnl AC_PROG_CXX
71 AC_PROG_LN_S
72 AC_PROG_MAKE_SET
74 dnl AM_PROG_AR is needed for some linker stuff
75 dnl AC_USE_SYSTEM_EXTENSIONS requires autoconf 2.60
76 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_USE_SYSTEM_EXTENSIONS])
77 dnl AM_PROG_AR requires automake 1.11 (and uses AC_COMPILE_IFELSE which wants AC_USE_SYSTEM_EXTENSIONS)
78 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
80 dnl check environment
81 AC_AIX
82 AC_ISC_POSIX
83 AC_MINIX
85 dnl AC_CANONICAL_HOST
86 case $host_os in
87         *darwin*|*cygwin*|*aix*|*mingw* ) NO_RDYNAMIC=yes;;
88         * ) NO_RDYNAMIC=no;;
89 esac
90 AM_CONDITIONAL(NO_RDYNAMIC, test x$NO_RDYNAMIC = xyes)
92 if test -z "$LIGHTTPD_STATIC"; then
93   LIGHTTPD_STATIC=no
95 AM_CONDITIONAL(LIGHTTPD_STATIC, test x$LIGHTTPD_STATIC = xyes)
97 AC_EXEEXT
99 dnl libtool
100 AC_DISABLE_STATIC
101 AC_ENABLE_SHARED
103 AC_LIBTOOL_DLOPEN
104 AC_PROG_LIBTOOL
106 dnl for solaris
107 CPPFLAGS="${CPPFLAGS} -D_REENTRANT -D__EXTENSIONS__"
109 dnl Checks for header files.
110 AC_HEADER_STDC
111 AC_HEADER_SYS_WAIT
112 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h \
113 sys/socket.h sys/time.h unistd.h sys/sendfile.h sys/uio.h \
114 getopt.h sys/epoll.h sys/select.h poll.h sys/poll.h sys/devpoll.h sys/filio.h \
115 sys/mman.h sys/event.h port.h pwd.h \
116 sys/resource.h sys/un.h syslog.h sys/prctl.h uuid/uuid.h])
118 dnl Checks for typedefs, structures, and compiler characteristics.
119 AC_C_CONST
120 AC_C_INLINE
121 AC_C_CHAR_UNSIGNED
122 AC_TYPE_OFF_T
123 AC_TYPE_PID_T
124 AC_TYPE_SIZE_T
126 AC_CHECK_MEMBER(struct tm.tm_gmtoff,[AC_DEFINE([HAVE_STRUCT_TM_GMTOFF],[1],[gmtoff in struct tm])],,[#include <time.h>])
127 AC_CHECK_TYPES(struct sockaddr_storage,,,[#include <sys/socket.h>])
128 AC_CHECK_TYPES(socklen_t,,,[#include <sys/types.h>
129 #include <sys/socket.h>])
131 dnl Checks for library functions.
132 AC_FUNC_FORK
133 dnl AC_FUNC_MALLOC
134 dnl AC_FUNC_MMAP
135 dnl AC_FUNC_REALLOC
136 AC_TYPE_SIGNAL
137 AC_FUNC_STAT
138 AC_FUNC_STRFTIME
140 if test -z "$PKG_CONFIG"; then
141   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
144 dnl checking for libev
145 AC_MSG_CHECKING(for libev support)
146 AC_ARG_WITH(libev,
147     AC_HELP_STRING([--with-libev@<:@=PATH@:>@],[Include libev support for fdevent handlers in PATH/include and PATH/lib]),
148     [WITH_LIBEV=$withval],[WITH_LIBEV=no])
150 LIBEV_CFLAGS=""
151 LIBEV_LIBS=""
153 if test "$WITH_LIBEV" != "no"; then
154         PKG_CHECK_MODULES(LIBEV, libev, [], [
155                 dnl no pkg-config for libev, searching manually:
157                 if test "$WITH_LIBEV" != "yes"; then
158                         LIBEV_CFLAGS="-I$WITH_LIBEV/include"
159                         LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
160                 else
161                         AC_CHECK_HEADERS([ev.h],[
162                                 AC_CHECK_LIB([ev], [ev_time], [
163                                                 LIBEV_CFLAGS=""
164                                                 LIBEV_LIBS="-lev"
165                                         ],[
166                                         AC_MSG_ERROR([libev not found])
167                                         ]
168                                 )],[
169                                         AC_MSG_ERROR([libev not found])
170                                 ]
171                         )
172                 fi
173         ])
175         AC_DEFINE([HAVE_LIBEV], [1], [libev support])
178 AC_SUBST(LIBEV_CFLAGS)
179 AC_SUBST(LIBEV_LIBS)
181 dnl Checks for database.
182 MYSQL_INCLUDE=""
183 MYSQL_LIBS=""
185 AC_MSG_CHECKING(for MySQL support)
186 AC_ARG_WITH(mysql,
187     AC_HELP_STRING([--with-mysql@<:@=PATH@:>@],[Include MySQL support. PATH is the path to 'mysql_config']),
188     [WITH_MYSQL=$withval],[WITH_MYSQL=no])
190 if test "$WITH_MYSQL" != "no"; then
191   AC_MSG_RESULT(yes)
192   if test "$WITH_MYSQL" = "yes"; then
193     AC_PATH_PROG(MYSQL_CONFIG, mysql_config)
194   else
195     MYSQL_CONFIG=$WITH_MYSQL
196   fi
198   if test "$MYSQL_CONFIG" = ""; then
199     AC_MSG_ERROR(mysql_config is not found)
200   fi
201   if test \! -x $MYSQL_CONFIG; then
202     AC_MSG_ERROR(mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config)
203   fi
205   if $MYSQL_CONFIG | grep -- '--include' > /dev/null ; then
206     MYSQL_INCLUDE="`$MYSQL_CONFIG --include | sed s/\'//g`"
207   else
208     MYSQL_INCLUDE="`$MYSQL_CONFIG --cflags | sed s/\'//g`"
209   fi
210   MYSQL_LIBS="`$MYSQL_CONFIG --libs | sed s/\'//g`"
212   AC_MSG_CHECKING(for MySQL includes at)
213   AC_MSG_RESULT($MYSQL_INCLUDE)
215   AC_MSG_CHECKING(for MySQL libraries at)
216   AC_MSG_RESULT($MYSQL_LIBS)
217 dnl check for errmsg.h, which isn't installed by some versions of 3.21
218   old_CPPFLAGS="$CPPFLAGS"
219   CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
220   AC_CHECK_HEADERS(errmsg.h mysql.h)
221   CPPFLAGS="$old_CPPFLAGS"
223   AC_DEFINE([HAVE_MYSQL], [1], [mysql support])
224 else
225   AC_MSG_RESULT(no)
228 AC_SUBST(MYSQL_LIBS)
229 AC_SUBST(MYSQL_INCLUDE)
231 dnl Check for LDAP
232 AC_MSG_CHECKING(for LDAP support)
233 AC_ARG_WITH(ldap, AC_HELP_STRING([--with-ldap],[enable LDAP support]),
234 [WITH_LDAP=$withval], [WITH_LDAP=no])
235 AC_MSG_RESULT([$withval])
236 if test "$WITH_LDAP" != "no"; then
237  AC_CHECK_LIB(ldap, ldap_bind, [
238   AC_CHECK_HEADERS([ldap.h],[
239     LDAP_LIB=-lldap
240     AC_DEFINE([HAVE_LIBLDAP], [1], [libldap])
241     AC_DEFINE([HAVE_LDAP_H], [1])
242     AC_DEFINE([LDAP_DEPRECATED], [1], [Using deprecated ldap api])
243   ])
244  ])
245  AC_SUBST(LDAP_LIB)
246  AC_CHECK_LIB(lber, ber_printf, [
247   AC_CHECK_HEADERS([lber.h],[
248     LBER_LIB=-llber
249     AC_DEFINE([HAVE_LIBLBER], [1], [liblber])
250     AC_DEFINE([HAVE_LBER_H], [1])
251   ])
252  ])
253  AC_SUBST(LBER_LIB)
256 dnl Check for xattr
257 AC_MSG_CHECKING(for extended attributes support)
258 AC_ARG_WITH(attr, AC_HELP_STRING([--with-attr],[enable extended attribute support]),
259 [WITH_ATTR=$withval],[WITH_ATTR=no])
260 AC_MSG_RESULT($withval)
261 if test "$WITH_ATTR" != "no"; then
262   # libattr (linux only?)
263   AC_CHECK_LIB(attr, attr_get, [
264     AC_CHECK_HEADERS([attr/attributes.h],[
265       ATTR_LIB=-lattr
266       AC_DEFINE([HAVE_XATTR], [1], [libattr])
267       AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
268     ])
269   ])
270   AC_SUBST(ATTR_LIB)
272   # (Free)BSD extattr
273   AC_CHECK_FUNC([extattr_get_file], [
274     AC_CHECK_HEADERS([sys/extattr.h],[
275       AC_DEFINE([HAVE_EXTATTR], [1], [BSD extended attributes])
276       AC_DEFINE([HAVE_SYS_EXTATTR_H], [1])
277     ])
278   ])
281 dnl openssl on solaris needs -lsocket -lnsl
282 AC_SEARCH_LIBS(socket,socket)
283 AC_SEARCH_LIBS(gethostbyname,nsl socket)
284 AC_SEARCH_LIBS(hstrerror,resolv)
286 dnl On Haiku accept() and friends are in libnetwork
287 AC_SEARCH_LIBS(accept,network)
289 dnl clock_gettime() needs -lrt with glibc < 2.17, and possibly other platforms
290 AC_SEARCH_LIBS([clock_gettime],[rt])
292 save_LIBS=$LIBS
293 AC_SEARCH_LIBS(dlopen,dl,[
294   AC_CHECK_HEADERS([dlfcn.h],[
295     if test "$ac_cv_search_dlopen" != no; then
296       test "$ac_cv_search_dlopen" = "none required" || DL_LIB="$ac_cv_search_dlopen"
297     fi
299     AC_DEFINE([HAVE_LIBDL], [1], [libdl])
300     AC_DEFINE([HAVE_DLFCN_H], [1])
301   ])
303 LIBS=$save_LIBS
304 AC_SUBST(DL_LIB)
306 dnl Check for valgrind
307 AC_MSG_CHECKING(for valgrind)
308 AC_ARG_WITH(valgrind, AC_HELP_STRING([--with-valgrind],[enable internal support for valgrind]),
309 [WITH_VALGRIND=$withval],[WITH_VALGRIND=no])
310 AC_MSG_RESULT([$WITH_VALGRIND])
311 if test "$WITH_VALGRIND" != "no"; then
312  AC_CHECK_HEADERS([valgrind/valgrind.h])
315 dnl Checking for libunwind
316 AC_MSG_CHECKING(for libunwind)
317 AC_ARG_WITH(libunwind,
318     AC_HELP_STRING([--with-libunwind],[Include libunwind support for backtraces on assert failures]),
319     [WITH_LIBUNWIND=$withval],[WITH_LIBUNWIND=no])
321 if test "$WITH_LIBUNWIND" != "no"; then
322   PKG_CHECK_MODULES(LIBUNWIND, libunwind)
323   AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
325 AC_MSG_RESULT([$WITH_LIBUNWIND])
327 dnl Checking for kerberos5
328 AC_MSG_CHECKING(for kerberos5)
329 AC_ARG_WITH(krb5,
330         AC_HELP_STRING([--with-krb5@<:@=DIR@:>@],[Use Kerberos 5]),
331         [WITH_KRB5=$withval],[WITH_KRB5=no])
332 if test "$WITH_KRB5" != "no"; then
333         use_krb5=yes
334         if test "x$WITH_KRB5" != "xyes"; then
335                 CPPFLAGS="$CPPFLAGS -I$WITH_KRB5/include"
336                 LDFLAGS="$LDFLAGS -L$WITH_KRB5/lib"
337         fi
338 else
339         use_krb5=no
341 AC_MSG_RESULT([$use_krb5])
343 AC_ARG_WITH(krb5-includes,
344         AC_HELP_STRING([--with-krb5-includes=DIR],[Kerberos includes]),
345         [ use_krb5=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
348 AC_ARG_WITH(krb5-libs,
349         AC_HELP_STRING([--with-krb5-libs=DIR],[Kerberos libraries]),
350         [ use_krb5=yes LDFLAGS="$LDFLAGS -L$withval" ]
353 if test "x$use_krb5" = "xyes"; then
354         AC_CHECK_LIB(gssapi_krb5, gss_acquire_cred, [
355                 AC_CHECK_HEADERS([gssapi/gssapi_krb5.h],[
356                         KRB5_LIB="-lresolv -lkrb5 -lgssapi_krb5"
357                         AC_DEFINE(HAVE_KRB5, [1], [libgssapi_krb5])
358                 ])
359         ])
360         if test "x$KRB5_LIB" = x; then
361                 AC_MSG_ERROR([gssapi_krb5 headers and/or libs where not found, install them or build with --without-krb5])
362         fi
364 AC_SUBST(KRB5_LIB)
366 dnl Check for openssl
367 AC_MSG_CHECKING(for OpenSSL)
368 AC_ARG_WITH(openssl,
369     AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[Include openssl support (default no)]),
370     [WITH_OPENSSL=$withval],[WITH_OPENSSL=no])
372 if test "$WITH_OPENSSL" != "no"; then
373     use_openssl=yes
374     if test "$WITH_OPENSSL" != "yes"; then
375         CPPFLAGS="$CPPFLAGS -I$WITH_OPENSSL/include"
376         LDFLAGS="$LDFLAGS -L$WITH_OPENSSL/lib"
377     fi
378 else
379     use_openssl=no
381 AC_MSG_RESULT([$use_openssl])
383 AC_ARG_WITH(openssl-includes,
384     AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
385     [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
388 AC_ARG_WITH(openssl-libs,
389     AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
390     [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
393 if test "x$use_openssl" = "xyes"; then
394     if test "x$use_krb5" = "xyes"; then
395         AC_DEFINE([USE_OPENSSL_KERBEROS], [1], [with kerberos])
396     fi
398     AC_CHECK_HEADERS([openssl/ssl.h])
399     OLDLIBS="$LIBS"
400     AC_CHECK_LIB(crypto, BIO_f_base64, [
401       AC_CHECK_LIB(ssl, SSL_new, [ SSL_LIB="-lssl -lcrypto"
402                                  AC_DEFINE(HAVE_LIBSSL, [], [Have libssl]) ], [], [ -lcrypto "$DL_LIB" ])
403     ], [], [])
404     LIBS="$OLDLIBS"
405     AC_SUBST(SSL_LIB)
408 AC_MSG_CHECKING(for perl regular expressions support)
409 AC_ARG_WITH(pcre, AC_HELP_STRING([--with-pcre],[Enable pcre support (default yes)]),
410     [WITH_PCRE=$withval],[WITH_PCRE=yes])
411 AC_MSG_RESULT([$WITH_PCRE])
413 if test "$WITH_PCRE" != "no"; then
414                 if test "$WITH_PCRE" != "yes"; then
415                         PCRE_LIB="-L$WITH_PCRE/lib -lpcre"
416                         CPPFLAGS="$CPPFLAGS -I$WITH_PCRE/include"
417                 else
418                         AC_PATH_PROG(PCRECONFIG, pcre-config)
419                         if test x"$PCRECONFIG" != x; then
420                                 PCRE_LIB=`$PCRECONFIG --libs`
421                                 CPPFLAGS="$CPPFLAGS `$PCRECONFIG --cflags`"
422                         fi
423                 fi
425   if test x"$PCRE_LIB" != x; then
426     AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre])
427     AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h])
428     AC_SUBST(PCRE_LIB)
429   else
430     AC_MSG_ERROR([pcre-config not found, install the pcre-devel package or build with --without-pcre])
431   fi
434 AC_MSG_CHECKING(for zlib support)
435 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],[Enable zlib support for mod_compress]),
436     [WITH_ZLIB=$withval],[WITH_ZLIB=yes])
437 AC_MSG_RESULT([$WITH_ZLIB])
439 if test "$WITH_ZLIB" != "no"; then
440                 if test "$WITH_ZLIB" != "yes"; then
441                         Z_LIB="-L$WITH_ZLIB -lz"
442                         CPPFLAGS="$CPPFLAGS -I$WITH_ZLIB"
443                 else
444                         AC_CHECK_LIB(z, deflate, [
445                           AC_CHECK_HEADERS([zlib.h],[Z_LIB=-lz])
446                         ])
447                 fi
449   if test x"$Z_LIB" != x; then
450     AC_DEFINE([HAVE_LIBZ], [1], [libz])
451     AC_DEFINE([HAVE_ZLIB_H], [1])
452     AC_SUBST(Z_LIB)
453   else
454     AC_MSG_ERROR([zlib-headers and/or libs were not found, install them or build with --without-zlib])
455   fi
458 AC_MSG_CHECKING(for bzip2 support)
459 AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2],[Enable bzip2 support for mod_compress]),
460     [WITH_BZIP2=$withval],[WITH_BZIP2=yes])
461 AC_MSG_RESULT([$WITH_BZIP2])
463 if test "$WITH_BZIP2" != "no"; then
464                 if test "$WITH_BZIP2" != "yes"; then
465                         BZ_LIB="-L$WITH_BZIP2 -lbz2"
466                         CPPFLAGS="$CPPFLAGS -I$WITH_BZIP2"
467                 else
468                         AC_CHECK_LIB(bz2, BZ2_bzCompress, [
469                           AC_CHECK_HEADERS([bzlib.h],[BZ_LIB=-lbz2])
470                         ])
471                 fi
473   if test x"$BZ_LIB" != x; then
474     AC_DEFINE([HAVE_LIBBZ2], [1], [libbz2])
475     AC_DEFINE([HAVE_BZLIB_H], [1])
476     AC_SUBST(BZ_LIB)
477   else
478     AC_MSG_ERROR([bzip2-headers and/or libs were not found, install them or build with --without-bzip2])
479   fi
482 dnl Check for gamin
483 AC_MSG_CHECKING(for FAM)
484 AC_ARG_WITH(fam, AC_HELP_STRING([--with-fam],[fam/gamin for reducing number of stat() calls]),
485 [WITH_FAM=$withval],[WITH_FAM=no])
486 AC_MSG_RESULT([$WITH_FAM])
488 if test "$WITH_FAM" != "no"; then
489                 if test "$WITH_FAM" != "yes"; then
490                         FAM_LIBS="-L$WITH_FAM -lfam"
491                         CPPFLAGS="$CPPFLAGS -I$WITH_FAM"
492                 else
493                         AC_CHECK_LIB(fam, FAMOpen2, [
494                           AC_CHECK_HEADERS([fam.h],[FAM_LIBS=-lfam])
495                         ])
496                         if test "x$FAM_LIBS" = x; then
497                           PKG_CHECK_MODULES(FAM, gamin >= 0.1.0)
498                         fi
499                 fi
501   if test x"$FAM_LIBS" != x; then
502     OLD_LIBS=$LIBS
503     LIBS=$FAM_LIBS
504     AC_CHECK_FUNCS([FAMNoExists])
505     LIBS=$OLD_LIBS
507     AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
508     AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
509     AC_SUBST(FAM_LIBS)
510   else
511      AC_MSG_ERROR([fam/gamin-headers and/or libs were not found, install them or build with --without-fam])
512   fi
515 AC_MSG_CHECKING(for properties in mod_webdav)
516 AC_ARG_WITH(webdav-props, AC_HELP_STRING([--with-webdav-props],[properties in mod_webdav]),
517 [WITH_WEBDAV_PROPS=$withval],[WITH_WEBDAV_PROPS=no])
518 AC_MSG_RESULT([$WITH_WEBDAV_PROPS])
520 if test "$WITH_WEBDAV_PROPS" != "no"; then
522   AC_MSG_CHECKING(for libxml2)
523   AC_ARG_WITH(libxml, AC_HELP_STRING([--with-libxml],[libxml2 for properties in mod_webdav]),
524   [WITH_LIBXML=$withval],[WITH_LIBXML=yes])
525   AC_MSG_RESULT([$WITH_LIBXML])
527   if test "$WITH_LIBXML" != "no"; then
528                 if test "$WITH_LIBXML" != "yes"; then
529                         XML_LIBS="-L$WITH_LIBXML/.libs -lxml2"
530                         XML_CFLAGS="-I$WITH_LIBXML/include"
531                 else
532                         PKG_CHECK_MODULES(XML, libxml-2.0)
533                 fi
535     if test x"$XML_LIBS" != x; then
536       AC_DEFINE([HAVE_LIBXML2], [1], [libxml2])
537       AC_DEFINE([HAVE_LIBXML_H], [1], [libxml.h])
538       AC_SUBST(XML_LIBS)
539       AC_SUBST(XML_CFLAGS)
540     else
541       AC_MSG_ERROR([libxml2-headers and/or libs were not found, install them or build with --without-webdav-props])
542     fi
543   fi
545   AC_MSG_CHECKING(for sqlite)
546   AC_ARG_WITH(sqlite, AC_HELP_STRING([--with-sqlite],[sqlite for properties in mod_webdav]),
547   [WITH_SQLITE=$withval],[WITH_SQLITE=yes])
548   AC_MSG_RESULT([$WITH_SQLITE])
550   if test "$WITH_SQLITE" != "no"; then
551                 if test "$WITH_SQLITE" != "yes"; then
552                         SQLITE_LIBS="-L$WITH_SQLITE/.libs -lsqlite3"
553                         SQLITE_CFLAGS="-I$WITH_SQLITE"
554                 else
555                         PKG_CHECK_MODULES(SQLITE, sqlite3)
556                 fi
558     if test x"$SQLITE_LIBS" != x; then
559       AC_DEFINE([HAVE_SQLITE3], [1], [libsqlite3])
560       AC_DEFINE([HAVE_SQLITE3_H], [1], [sqlite3.h])
561       AC_SUBST(SQLITE_LIBS)
562       AC_SUBST(SQLITE_CFLAGS)
563     else
564       AC_MSG_ERROR([sqlite-headers and/or libs were not found, install them or build with --without-webdav-props])
565     fi
566   fi
568   AC_MSG_CHECKING(for locks in mod_webdav)
569   AC_ARG_WITH(webdav-locks, AC_HELP_STRING([--with-webdav-locks],[locks in mod_webdav]),
570   [WITH_WEBDAV_LOCKS=$withval],[WITH_WEBDAV_LOCKS=no])
571   AC_MSG_RESULT([$WITH_WEBDAV_LOCKS])
573   if test "$WITH_WEBDAV_LOCKS" != "no"; then
575     AC_MSG_CHECKING(for libuuid)
576     AC_ARG_WITH(uuid, AC_HELP_STRING([--with-uuid],[uuid for locks in mod_webdav]),
577     [WITH_UUID=$withval],[WITH_UUID=yes])
578     AC_MSG_RESULT([$WITH_UUID])
580     if test "$WITH_UUID" != "no"; then
581                 if test "$WITH_UUID" != "yes"; then
582                         UUID_LIBS="-L$WITH_UUID -luuid"
583                         CPPFLAGS="$CPPFLAGS -I$WITH_UUID"
584                 else
585                         AC_CHECK_LIB(uuid, uuid_unparse, [
586                           AC_CHECK_HEADERS([uuid/uuid.h],[UUID_LIBS=-luuid])
587                         ])
588                 fi
590       if test x"$UUID_LIBS" != x; then
591         AC_DEFINE([HAVE_UUID], [1], [libuuid])
592         AC_DEFINE([HAVE_UUID_H], [1], [uuid/uuid.h is available])
593         AC_SUBST(UUID_LIBS)
594       else
595         AC_MSG_ERROR([uuid-headers and/or libs were not found, install them or build with --without-webdav-locks])
596       fi
597     fi
599   fi
603 dnl Check for gdbm
604 AC_MSG_CHECKING(for gdbm)
605 AC_ARG_WITH(gdbm, AC_HELP_STRING([--with-gdbm],[gdbm storage for mod_trigger_b4_dl]),
606 [WITH_GDBM=$withval],[WITH_GDBM=no])
607 AC_MSG_RESULT([$WITH_GDBM])
609 if test "$WITH_GDBM" != "no"; then
610                 if test "$WITH_GDBM" != "yes"; then
611                         GDBM_LIB="-L$WITH_GDBM -lgdbm"
612                         CPPFLAGS="$CPPFLAGS -I$WITH_GDBM"
613                 else
614                         AC_CHECK_LIB(gdbm, gdbm_open, [
615                           AC_CHECK_HEADERS([gdbm.h],[GDBM_LIB=-lgdbm])
616                         ])
617                 fi
619   if test x"$GDBM_LIB" != x; then
620     AC_DEFINE([HAVE_GDBM], [1], [libgdbm])
621     AC_DEFINE([HAVE_GDBM_H], [1])
622     AC_SUBST(GDBM_LIB)
623   else
624     AC_MSG_ERROR([gdbm headers and/or libs were not found, install them or build with --without-gdbm])
625   fi
628 dnl Check for GeoIP
629 AC_MSG_CHECKING(for GeoIP)
630 AC_ARG_WITH(geoip, AC_HELP_STRING([--with-geoip],[IP-based geolocation lookup]),
631 [WITH_GEOIP=$withval],[WITH_GEOIP=no])
632 AC_MSG_RESULT([$WITH_GEOIP])
634 if test "$WITH_GEOIP" != "no"; then
635                 if test "$WITH_GEOIP" != "yes"; then
636                         GEOIP_LIB="-L$WITH_GEOIP -lGeoIP"
637                         CPPFLAGS="$CPPFLAGS -I$WITH_GEOIP"
638                 else
639                         AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_addr, [
640                           AC_CHECK_HEADERS([GeoIP.h],[GEOIP_LIB=-lGeoIP])
641                         ])
642                 fi
644   if test x"$GEOIP_LIB" != x; then
645     AC_DEFINE([HAVE_GEOIP], [1], [libGeoIP])
646     AC_DEFINE([HAVE_GEOIP_H], [1])
647     AC_SUBST(GEOIP_LIB)
648   else
649     AC_MSG_ERROR([GeoIP headers and/or libs were not found, install them or build with --without-geoip])
650   fi
653 dnl Check for memcached
654 AC_MSG_CHECKING(for memcached)
655 AC_ARG_WITH(memcached, AC_HELP_STRING([--with-memcached],[memcached storage for mod_trigger_b4_dl]),
656 [WITH_MEMCACHED=$withval],[WITH_MEMCACHED=no])
657 AC_MSG_RESULT([$WITH_MEMCACHED])
659 if test "$WITH_MEMCACHED" != "no"; then
660                 if test "$WITH_MEMCACHED" != "yes"; then
661                         MEMCACHED_LIB="-L$WITH_MEMCACHED -lMEMCACHED"
662                         CPPFLAGS="$CPPFLAGS -I$WITH_MEMCACHED"
663                 else
664                         AC_CHECK_LIB(memcached, memcached, [
665                           AC_CHECK_HEADERS([libmemcached/memcached.h],[
666                             MEMCACHED_LIB=-lmemcached
667                           ])
668                         ])
669                 fi
671   if test x"$MEMCACHED_LIB" != x; then
672     AC_DEFINE([USE_MEMCACHED], [1], [libmemcached])
673     AC_SUBST(MEMCACHED_LIB)
674   else
675     AC_MSG_ERROR([memcached headers and/or libs were not found, install them or build with --without-memcached])
676   fi
679 dnl Check for lua
680 AC_MSG_CHECKING(if lua-support is requested)
681 AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[lua engine for mod_cml]),
682 [WITH_LUA=$withval],[WITH_LUA=no])
684 AC_MSG_RESULT($WITH_LUA)
685 if test "$WITH_LUA" != "no"; then
686   found_lua=0
687   if test "$WITH_LUA" != "yes"; then
688     PKG_CHECK_MODULES(LUA, $WITH_LUA >= 5.1, [
689       found_lua=1
690     ],[
691       AC_MSG_NOTICE([Couldn't find requested lua pkg-config module $WITH_LUA])
692     ])
693     if test "$found_lua" = "0"; then
694       LUA_LIBS="-L$WITH_LUA -llua"
695       LUA_CFLAGS="-I$WITH_LUA"
696     fi
697   else
698     for luaname in lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua; do
699       if test "$found_lua" = "0"; then
700         PKG_CHECK_MODULES(LUA, $luaname >= 5.1, [
701           found_lua=1
702         ], [
703           AC_MSG_NOTICE([Couldn't find $luaname])
704         ])
705       fi
706     done
707     if test "$found_lua" = "0"; then
708       AC_MSG_ERROR([Couldn't find any lua pkg-config module])
709     fi
710   fi
712   if test x"$LUA_LIBS" != x; then
713     AC_DEFINE([HAVE_LUA], [1], [liblua])
714     AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
715     AC_SUBST(LUA_LIBS)
716     AC_SUBST(LUA_CFLAGS)
717   else
718     AC_MSG_ERROR([lua headers and/or libs were not found, install them or build with --without-lua])
719   fi
722 dnl search for crypt_r and (fallback) for crypt
723 save_LIBS=$LIBS
724 LIBS=
725 AC_SEARCH_LIBS([crypt_r],[crypt],[
726   AC_DEFINE([HAVE_CRYPT_R], [1], [crypt_r])
727   AC_CHECK_HEADERS([crypt.h],[
728     AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
729   ])
731   CRYPT_LIB=$LIBS
733   AC_SEARCH_LIBS([crypt],[crypt],[
734     AC_DEFINE([HAVE_CRYPT], [1], [crypt])
735     AC_CHECK_HEADERS([crypt.h],[
736       AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
737     ])
739     CRYPT_LIB=$LIBS
740   ])
742 LIBS=$save_LIBS
743 AC_SUBST([CRYPT_LIB])
745 save_LIBS=$LIBS
746 AC_SEARCH_LIBS(sendfilev,sendfile,[
747   if test "$ac_cv_search_sendfilev" != no; then
748     test "$ac_cv_search_sendfilev" = "none required" || SENDFILE_LIB="$ac_cv_search_sendfilev"
749     AC_DEFINE([HAVE_SENDFILEV], [1], [solaris sendfilev])
750   fi
752 LIBS=$save_LIBS
753 AC_SUBST(SENDFILE_LIB)
755 case $host_os in
756         *mingw* ) LIBS="$LIBS -lwsock32";;
757         * ) ;;
758 esac
760 AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop inet_pton issetugid memset mmap munmap strchr \
761                   strdup strerror strstr strtol sendfile  getopt socket lstat \
762                   gethostbyname poll epoll_ctl getrlimit chroot \
763                   getuid select signal pathconf madvise posix_fadvise posix_madvise \
764                   writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
765                   memset_s explicit_bzero clock_gettime])
767 AC_MSG_CHECKING(if weak symbols are supported)
768 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
769                 __attribute__((weak)) void __dummy(void *x) { }
770                 void f(void *x) { __dummy(x); }
771         ]])],
772         [
773                 AC_MSG_RESULT(yes)
774                 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [weak symbols are supported])
775         ],[AC_MSG_RESULT(no)])
777 AC_MSG_CHECKING(for Large File System support)
778 AC_ARG_ENABLE(lfs,
779  AC_HELP_STRING([--enable-lfs],[Turn on Large File System (default)]),
780  [case "${enableval}" in
781    yes) CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES" ;;
782     no) ;;
783      *) AC_MSG_ERROR(bad value ${enableval} for --enable-lfs) ;;
784   esac],[CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
785          enable_lfs=yes])
786 AC_MSG_RESULT($enableval)
788 AC_CHECK_SIZEOF(long)
789 AC_CHECK_SIZEOF(off_t)
791 if test "x$ac_cv_func_sendfile" = xyes; then
792         dnl check if sendfile works
793         AC_MSG_CHECKING(if sendfile works)
794         if test "x$cross_compiling" = xno; then
795         AC_TRY_RUN([
796                     #ifdef HAVE_SYS_SENDFILE_H
797                     #include <sys/sendfile.h>
798                     #endif /* HAVE_SYS_SENDFILE_H */
799                     #include <errno.h>
800                     int main() {
801                       int o = 0;
802                       if (-1 == sendfile(-1, 0, &o, 0) && errno == ENOSYS) return -1;
803                       return 0;
804                     } ],
805                     AC_MSG_RESULT(yes),
806                     [ AC_MSG_RESULT(no)
807                     AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile]) ] )
808         else
809               AC_MSG_RESULT(no, cross-compiling)
810               AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile])
811         fi
814 dnl Check for IPv6 support
816 AC_ARG_ENABLE(ipv6,
817  AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
818  [case "${enableval}" in
819    yes) ipv6=true ;;
820     no) ipv6=false ;;
821      *) AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
822   esac],[ipv6=true])
824 if test x$ipv6 = xtrue; then
825   AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
826   [AC_TRY_LINK([ #include <sys/types.h>
827 #include <sys/socket.h>
828 #include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ],
829   [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
831   if test "$ac_cv_ipv6_support" = yes; then
832     AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
833   fi
836 # disable mmap by default; if a mmapped file gets truncated, the process gets a SIGBUS signal
837 # on reading the truncated area which we can't handle (yet).
838 # lighttpd may always use mmap with files it owns (created tmp files)
839 AC_ARG_ENABLE(mmap,
840   AC_HELP_STRING([--enable-mmap],[use mmap if available (DANGEROUS, allows local users to trigger SIGBUS crashes)]),
841   [case "${enableval}" in
842    yes) mmap=true ;;
843     no) mmap=false ;;
844      *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmap) ;;
845   esac],[mmap=false])
847 if test x$mmap = xtrue; then
848   AC_DEFINE(ENABLE_MMAP, [1], [Use mmap if available])
852 AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
854 dnl check for fastcgi lib, for the tests only
855 fastcgi_found=no
856 AC_CHECK_LIB(fcgi, FCGI_Accept, [
857  AC_CHECK_HEADERS([fastcgi.h fastcgi/fastcgi.h],[
858    fastcgi_found=yes
859  ])
862 AM_CONDITIONAL(CHECK_WITH_FASTCGI, test "x$fastcgi_found" = xyes)
865 dnl check for extra compiler options (warning options)
866 if test "${GCC}" = "yes"; then
867   TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
868   TRY_CFLAGS([-std=gnu99])
871 AC_ARG_ENABLE(extra-warnings,
872  AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
873  [case "${enableval}" in
874    yes) extrawarnings=true ;;
875     no) extrawarnings=false ;;
876      *) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
877   esac],[extrawarnings=false])
879 if test x$extrawarnings = xtrue; then
880   TRY_CFLAGS([-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security])
881   TRY_LDFLAGS([-Wl,--as-needed])
884 dnl build version-id
885 LIGHTTPD_VERSION_ID=`echo $PACKAGE_VERSION | $AWK -F '.' '{print "(" $1 " << 16 | " $2 " << 8 | " $3 ")"}'`
886 AC_DEFINE_UNQUOTED([LIGHTTPD_VERSION_ID], [$LIGHTTPD_VERSION_ID], [lighttpd-version-id])
888 AC_CONFIG_FILES([Makefile src/Makefile
889                  doc/config/conf.d/Makefile \
890                  doc/config/vhosts.d/Makefile \
891                  doc/config/Makefile \
892                  doc/scripts/Makefile \
893                  doc/initscripts/Makefile \
894                  doc/systemd/Makefile \
895                  doc/outdated/Makefile \
896                  doc/Makefile \
897                  tests/Makefile \
898                  tests/docroot/Makefile \
899                  tests/docroot/123/Makefile \
900                  tests/docroot/www/Makefile \
901                  tests/docroot/www/go/Makefile \
902                  tests/docroot/www/indexfile/Makefile \
903                  tests/docroot/www/expire/Makefile \
904                  distribute.sh])
905 AC_OUTPUT
908 do_build="mod_cgi mod_fastcgi mod_extforward mod_proxy mod_evhost mod_simple_vhost mod_access mod_alias mod_setenv mod_usertrack mod_auth mod_status mod_accesslog"
909 do_build="$do_build mod_rrdtool mod_secdownload mod_expire mod_compress mod_dirlisting mod_indexfile mod_userdir mod_webdav mod_staticfile mod_scgi mod_flv_streaming mod_ssi mod_deflate"
911 plugins="mod_rewrite mod_redirect mod_trigger_b4_dl"
912 features="regex-conditionals"
913 if test ! "x$PCRE_LIB" = x; then
914         do_build="$do_build $plugins"
915         enable_feature="$features"
916 else
917         no_build="$no_build $plugins"
918         disable_feature="$features"
921 plugins="mod_mysql_vhost"
922 if test ! "x$MYSQL_LIBS" = x; then
923         do_build="$do_build $plugins"
924 else
925         no_build="$no_build $plugins"
928 plugins="mod_cml mod_magnet"
929 if test ! "x$LUA_LIBS" = x; then
930         do_build="$do_build $plugins"
931 else
932         no_build="$no_build $plugins"
935 features="storage-gdbm"
936 if test ! "x$GDBM_LIB" = x; then
937         enable_feature="$enable_feature $features"
938 else
939         disable_feature="$disable_feature $features"
942 features="storage-memcached"
943 if test ! "x$MEMCACHED_LIB" = x; then
944         enable_feature="$enable_feature $features"
945 else
946         disable_feature="$disable_feature $features"
949 features="compress-gzip compress-deflate"
950 if test ! "x$Z_LIB" = x; then
951         enable_feature="$enable_feature $features"
952 else
953         disable_feature="$disable_feature $features"
956 features="compress-bzip2"
957 if test ! "x$BZ_LIB" = x; then
958         enable_feature="$enable_feature $features"
959 else
960         disable_feature="$disable_feature $features"
963 features="auth-ldap"
964 if test ! "x$LDAP_LIB" = x; then
965         enable_feature="$enable_feature $features"
966 else
967         disable_feature="$disable_feature $features"
970 features="network-openssl"
971 if test ! "x$SSL_LIB" = x; then
972         enable_feature="$enable_feature $features"
973 else
974         disable_feature="$disable_feature $features"
977 dnl no crypt call
978 features="auth-crypt"
979 if test "$ac_cv_search_crypt" = no; then
980         disable_feature="$disable_feature $features"
981 else
982         enable_feature="$enable_feature $features"
985 features="network-ipv6"
986 if test "$ac_cv_ipv6_support" = yes; then
987         enable_feature="$enable_feature $features"
988 else
989         disable_feature="$disable_feature $features"
992 features="large-files"
993 if test "$enable_lfs" = yes; then
994         enable_feature="$enable_feature $features"
995 else
996         disable_feature="$disable_feature $features"
999 features="stat-cache-fam"
1000 if test ! "x$FAM_LIBS" = x; then
1001         enable_feature="$enable_feature $features"
1002 else
1003         disable_feature="$disable_feature $features"
1006 features="webdav-properties"
1007 if test "x$XML_LIBS" \!= x -a "x$SQLITE_LIBS" \!= x; then
1008         enable_feature="$enable_feature $features"
1009 else
1010         disable_feature="$disable_feature $features"
1013 features="webdav-locks"
1014 if test "x$UUID_LIBS" \!= x; then
1015         enable_feature="$enable_feature $features"
1016 else
1017         disable_feature="$disable_feature $features"
1021 dnl output
1023 $ECHO
1024 $ECHO "Plugins:"
1025 $ECHO
1027 $ECHO "enabled: "
1028 for p in $do_build; do
1029         $ECHO "  $p"
1030 done | sort
1032 $ECHO "disabled: "
1033 for p in $no_build; do
1034         $ECHO "  $p"
1035 done | sort
1037 $ECHO
1038 $ECHO "Features:"
1039 $ECHO
1041 $ECHO "enabled: "
1042 for p in $enable_feature; do
1043         $ECHO "  $p"
1044 done | sort
1046 $ECHO "disabled: "
1047 for p in $disable_feature; do
1048         $ECHO "  $p"
1049 done | sort
1051 $ECHO