[mod_evhost] mod-evhost.t tests (#1194)
[lighttpd.git] / configure.ac
blob9f563b989c1532196acf418be06f6302a1c2c1ba
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.43], [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)
180 AC_MSG_RESULT([$WITH_LIBEV])
182 dnl Checks for database.
183 MYSQL_INCLUDE=""
184 MYSQL_LIBS=""
186 AC_MSG_CHECKING(for MySQL support)
187 AC_ARG_WITH(mysql,
188     AC_HELP_STRING([--with-mysql@<:@=PATH@:>@],[Include MySQL support. PATH is the path to 'mysql_config']),
189     [WITH_MYSQL=$withval],[WITH_MYSQL=no])
191 if test "$WITH_MYSQL" != "no"; then
192   AC_MSG_RESULT(yes)
193   if test "$WITH_MYSQL" = "yes"; then
194     AC_PATH_PROG(MYSQL_CONFIG, mysql_config)
195   else
196     MYSQL_CONFIG=$WITH_MYSQL
197   fi
199   if test "$MYSQL_CONFIG" = ""; then
200     AC_MSG_ERROR(mysql_config is not found)
201   fi
202   if test \! -x $MYSQL_CONFIG; then
203     AC_MSG_ERROR(mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config)
204   fi
206   if $MYSQL_CONFIG | grep -- '--include' > /dev/null ; then
207     MYSQL_INCLUDE="`$MYSQL_CONFIG --include | sed s/\'//g`"
208   else
209     MYSQL_INCLUDE="`$MYSQL_CONFIG --cflags | sed s/\'//g`"
210   fi
211   MYSQL_LIBS="`$MYSQL_CONFIG --libs | sed s/\'//g`"
213   AC_MSG_CHECKING(for MySQL includes at)
214   AC_MSG_RESULT($MYSQL_INCLUDE)
216   AC_MSG_CHECKING(for MySQL libraries at)
217   AC_MSG_RESULT($MYSQL_LIBS)
218 dnl check for errmsg.h, which isn't installed by some versions of 3.21
219   old_CPPFLAGS="$CPPFLAGS"
220   CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
221   AC_CHECK_HEADERS(errmsg.h mysql.h)
222   CPPFLAGS="$old_CPPFLAGS"
224   AC_DEFINE([HAVE_MYSQL], [1], [mysql support])
225 else
226   AC_MSG_RESULT(no)
228 AM_CONDITIONAL(BUILD_WITH_MYSQL, test ! $WITH_MYSQL = no)
230 AC_SUBST(MYSQL_LIBS)
231 AC_SUBST(MYSQL_INCLUDE)
233 dnl Check for LDAP
234 AC_MSG_CHECKING(for LDAP support)
235 AC_ARG_WITH(ldap, AC_HELP_STRING([--with-ldap],[enable LDAP support]),
236 [WITH_LDAP=$withval], [WITH_LDAP=no])
237 AC_MSG_RESULT([$withval])
238 if test "$WITH_LDAP" != "no"; then
239  AC_CHECK_LIB(ldap, ldap_bind, [
240   AC_CHECK_HEADERS([ldap.h],[
241     LDAP_LIB=-lldap
242     AC_DEFINE([HAVE_LIBLDAP], [1], [libldap])
243     AC_DEFINE([HAVE_LDAP_H], [1])
244     AC_DEFINE([LDAP_DEPRECATED], [1], [Using deprecated ldap api])
245   ])
246  ])
247  AC_SUBST(LDAP_LIB)
248  AC_CHECK_LIB(lber, ber_printf, [
249   AC_CHECK_HEADERS([lber.h],[
250     LBER_LIB=-llber
251     AC_DEFINE([HAVE_LIBLBER], [1], [liblber])
252     AC_DEFINE([HAVE_LBER_H], [1])
253   ])
254  ])
255  AC_SUBST(LBER_LIB)
257 AM_CONDITIONAL(BUILD_WITH_LDAP, test ! $WITH_LDAP = no)
259 dnl Check for xattr
260 AC_MSG_CHECKING(for extended attributes support)
261 AC_ARG_WITH(attr, AC_HELP_STRING([--with-attr],[enable extended attribute support]),
262 [WITH_ATTR=$withval],[WITH_ATTR=no])
263 AC_MSG_RESULT($withval)
264 if test "$WITH_ATTR" != "no"; then
265   # libattr (linux only?)
266   AC_CHECK_LIB(attr, attr_get, [
267     AC_CHECK_HEADERS([attr/attributes.h],[
268       ATTR_LIB=-lattr
269       AC_DEFINE([HAVE_XATTR], [1], [libattr])
270       AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
271     ])
272   ])
273   AC_SUBST(ATTR_LIB)
275   # (Free)BSD extattr
276   AC_CHECK_FUNC([extattr_get_file], [
277     AC_CHECK_HEADERS([sys/extattr.h],[
278       AC_DEFINE([HAVE_EXTATTR], [1], [BSD extended attributes])
279       AC_DEFINE([HAVE_SYS_EXTATTR_H], [1])
280     ])
281   ])
284 dnl openssl on solaris needs -lsocket -lnsl
285 AC_SEARCH_LIBS(socket,socket)
286 AC_SEARCH_LIBS(gethostbyname,nsl socket)
288 dnl On Haiku accept() and friends are in libnetwork
289 AC_SEARCH_LIBS(accept,network)
291 dnl clock_gettime() needs -lrt with glibc < 2.17, and possibly other platforms
292 AC_SEARCH_LIBS([clock_gettime],[rt])
294 save_LIBS=$LIBS
295 AC_SEARCH_LIBS(dlopen,dl,[
296   AC_CHECK_HEADERS([dlfcn.h],[
297     if test "$ac_cv_search_dlopen" != no; then
298       test "$ac_cv_search_dlopen" = "none required" || DL_LIB="$ac_cv_search_dlopen"
299     fi
301     AC_DEFINE([HAVE_LIBDL], [1], [libdl])
302     AC_DEFINE([HAVE_DLFCN_H], [1])
303   ])
305 LIBS=$save_LIBS
306 AC_SUBST(DL_LIB)
308 dnl Check for valgrind
309 AC_MSG_CHECKING(for valgrind)
310 AC_ARG_WITH(valgrind, AC_HELP_STRING([--with-valgrind],[enable internal support for valgrind]),
311 [WITH_VALGRIND=$withval],[WITH_VALGRIND=no])
312 AC_MSG_RESULT([$WITH_VALGRIND])
313 if test "$WITH_VALGRIND" != "no"; then
314  AC_CHECK_HEADERS([valgrind/valgrind.h])
317 dnl Checking for libunwind
318 AC_MSG_CHECKING(for libunwind)
319 AC_ARG_WITH(libunwind,
320     AC_HELP_STRING([--with-libunwind],[Include libunwind support for backtraces on assert failures]),
321     [WITH_LIBUNWIND=$withval],[WITH_LIBUNWIND=no])
323 if test "$WITH_LIBUNWIND" != "no"; then
324   PKG_CHECK_MODULES(LIBUNWIND, libunwind)
325   AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
327 AC_MSG_RESULT([$WITH_LIBUNWIND])
329 dnl Checking for kerberos5
330 AC_MSG_CHECKING(for kerberos5)
331 AC_ARG_WITH(krb5,
332         AC_HELP_STRING([--with-krb5@<:@=DIR@:>@],[Use Kerberos 5]),
333         [WITH_KRB5=$withval],[WITH_KRB5=no])
334 if test "$WITH_KRB5" != "no"; then
335         use_krb5=yes
336         if test "x$WITH_KRB5" != "xyes"; then
337                 CPPFLAGS="$CPPFLAGS -I$WITH_KRB5/include"
338                 LDFLAGS="$LDFLAGS -L$WITH_KRB5/lib"
339         fi
340 else
341         use_krb5=no
343 AC_MSG_RESULT([$use_krb5])
344 AM_CONDITIONAL(BUILD_WITH_KRB5, test ! $WITH_KRB5 = no)
346 AC_ARG_WITH(krb5-includes,
347         AC_HELP_STRING([--with-krb5-includes=DIR],[Kerberos includes]),
348         [ use_krb5=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
351 AC_ARG_WITH(krb5-libs,
352         AC_HELP_STRING([--with-krb5-libs=DIR],[Kerberos libraries]),
353         [ use_krb5=yes LDFLAGS="$LDFLAGS -L$withval" ]
356 if test "x$use_krb5" = "xyes"; then
357         AC_CHECK_LIB(gssapi_krb5, gss_acquire_cred, [
358                 AC_CHECK_HEADERS([gssapi/gssapi_krb5.h],[
359                         KRB5_LIB="-lkrb5 -lgssapi_krb5"
360                         AC_DEFINE(HAVE_KRB5, [1], [libgssapi_krb5])
361                 ])
362         ])
363         if test "x$KRB5_LIB" = x; then
364                 AC_MSG_ERROR([gssapi_krb5 headers and/or libs where not found, install them or build with --without-krb5])
365         fi
367 AC_SUBST(KRB5_LIB)
369 dnl Check for openssl
370 AC_MSG_CHECKING(for OpenSSL)
371 AC_ARG_WITH(openssl,
372     AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[Include openssl support (default no)]),
373     [WITH_OPENSSL=$withval],[WITH_OPENSSL=no])
375 if test "$WITH_OPENSSL" != "no"; then
376     use_openssl=yes
377     if test "$WITH_OPENSSL" != "yes"; then
378         CPPFLAGS="$CPPFLAGS -I$WITH_OPENSSL/include"
379         LDFLAGS="$LDFLAGS -L$WITH_OPENSSL/lib"
380     fi
381 else
382     use_openssl=no
384 AC_MSG_RESULT([$use_openssl])
386 AC_ARG_WITH(openssl-includes,
387     AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
388     [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
391 AC_ARG_WITH(openssl-libs,
392     AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
393     [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
396 if test "x$use_openssl" = "xyes"; then
397     if test "x$use_krb5" = "xyes"; then
398         AC_DEFINE([USE_OPENSSL_KERBEROS], [1], [with kerberos])
399     fi
401     AC_CHECK_HEADERS([openssl/ssl.h])
402     OLDLIBS="$LIBS"
403     AC_CHECK_LIB(crypto, BIO_f_base64, [
404       AC_CHECK_LIB(ssl, SSL_new, [ SSL_LIB="-lssl -lcrypto"
405                                  AC_DEFINE(HAVE_LIBSSL, [], [Have libssl]) ], [], [ -lcrypto "$DL_LIB" ])
406     ], [], [])
407     LIBS="$OLDLIBS"
408     AC_SUBST(SSL_LIB)
411 AC_MSG_CHECKING(for perl regular expressions support)
412 AC_ARG_WITH(pcre, AC_HELP_STRING([--with-pcre],[Enable pcre support (default yes)]),
413     [WITH_PCRE=$withval],[WITH_PCRE=yes])
414 AC_MSG_RESULT([$WITH_PCRE])
416 if test "$WITH_PCRE" != "no"; then
417                 if test "$WITH_PCRE" != "yes"; then
418                         PCRE_LIB="-L$WITH_PCRE/lib -lpcre"
419                         CPPFLAGS="$CPPFLAGS -I$WITH_PCRE/include"
420                 else
421                         AC_PATH_PROG(PCRECONFIG, pcre-config)
422                         if test x"$PCRECONFIG" != x; then
423                                 PCRE_LIB=`$PCRECONFIG --libs`
424                                 CPPFLAGS="$CPPFLAGS `$PCRECONFIG --cflags`"
425                         fi
426                 fi
428   if test x"$PCRE_LIB" != x; then
429     AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre])
430     AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h])
431     AC_SUBST(PCRE_LIB)
432   else
433     AC_MSG_ERROR([pcre-config not found, install the pcre-devel package or build with --without-pcre])
434   fi
437 AC_MSG_CHECKING(for zlib support)
438 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],[Enable zlib support for mod_compress]),
439     [WITH_ZLIB=$withval],[WITH_ZLIB=yes])
440 AC_MSG_RESULT([$WITH_ZLIB])
442 if test "$WITH_ZLIB" != "no"; then
443                 if test "$WITH_ZLIB" != "yes"; then
444                         Z_LIB="-L$WITH_ZLIB -lz"
445                         CPPFLAGS="$CPPFLAGS -I$WITH_ZLIB"
446                 else
447                         AC_CHECK_LIB(z, deflate, [
448                           AC_CHECK_HEADERS([zlib.h],[Z_LIB=-lz])
449                         ])
450                 fi
452   if test x"$Z_LIB" != x; then
453     AC_DEFINE([HAVE_LIBZ], [1], [libz])
454     AC_DEFINE([HAVE_ZLIB_H], [1])
455     AC_SUBST(Z_LIB)
456   else
457     AC_MSG_ERROR([zlib-headers and/or libs were not found, install them or build with --without-zlib])
458   fi
461 AC_MSG_CHECKING(for bzip2 support)
462 AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2],[Enable bzip2 support for mod_compress]),
463     [WITH_BZIP2=$withval],[WITH_BZIP2=yes])
464 AC_MSG_RESULT([$WITH_BZIP2])
466 if test "$WITH_BZIP2" != "no"; then
467                 if test "$WITH_BZIP2" != "yes"; then
468                         BZ_LIB="-L$WITH_BZIP2 -lbz2"
469                         CPPFLAGS="$CPPFLAGS -I$WITH_BZIP2"
470                 else
471                         AC_CHECK_LIB(bz2, BZ2_bzCompress, [
472                           AC_CHECK_HEADERS([bzlib.h],[BZ_LIB=-lbz2])
473                         ])
474                 fi
476   if test x"$BZ_LIB" != x; then
477     AC_DEFINE([HAVE_LIBBZ2], [1], [libbz2])
478     AC_DEFINE([HAVE_BZLIB_H], [1])
479     AC_SUBST(BZ_LIB)
480   else
481     AC_MSG_ERROR([bzip2-headers and/or libs were not found, install them or build with --without-bzip2])
482   fi
485 dnl Check for gamin
486 AC_MSG_CHECKING(for FAM)
487 AC_ARG_WITH(fam, AC_HELP_STRING([--with-fam],[fam/gamin for reducing number of stat() calls]),
488 [WITH_FAM=$withval],[WITH_FAM=no])
489 AC_MSG_RESULT([$WITH_FAM])
491 if test "$WITH_FAM" != "no"; then
492                 if test "$WITH_FAM" != "yes"; then
493                         FAM_LIBS="-L$WITH_FAM -lfam"
494                         CPPFLAGS="$CPPFLAGS -I$WITH_FAM"
495                 else
496                         AC_CHECK_LIB(fam, FAMOpen2, [
497                           AC_CHECK_HEADERS([fam.h],[FAM_LIBS=-lfam])
498                         ])
499                         if test "x$FAM_LIBS" = x; then
500                           PKG_CHECK_MODULES(FAM, gamin >= 0.1.0)
501                         fi
502                 fi
504   if test x"$FAM_LIBS" != x; then
505     OLD_LIBS=$LIBS
506     LIBS=$FAM_LIBS
507     AC_CHECK_FUNCS([FAMNoExists])
508     LIBS=$OLD_LIBS
510     AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
511     AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
512     AC_SUBST(FAM_LIBS)
513   else
514      AC_MSG_ERROR([fam/gamin-headers and/or libs were not found, install them or build with --without-fam])
515   fi
518 AC_MSG_CHECKING(for properties in mod_webdav)
519 AC_ARG_WITH(webdav-props, AC_HELP_STRING([--with-webdav-props],[properties in mod_webdav]),
520 [WITH_WEBDAV_PROPS=$withval],[WITH_WEBDAV_PROPS=no])
521 AC_MSG_RESULT([$WITH_WEBDAV_PROPS])
523 if test "$WITH_WEBDAV_PROPS" != "no"; then
525   AC_MSG_CHECKING(for libxml2)
526   AC_ARG_WITH(libxml, AC_HELP_STRING([--with-libxml],[libxml2 for properties in mod_webdav]),
527   [WITH_LIBXML=$withval],[WITH_LIBXML=yes])
528   AC_MSG_RESULT([$WITH_LIBXML])
530   if test "$WITH_LIBXML" != "no"; then
531                 if test "$WITH_LIBXML" != "yes"; then
532                         XML_LIBS="-L$WITH_LIBXML/.libs -lxml2"
533                         XML_CFLAGS="-I$WITH_LIBXML/include"
534                 else
535                         PKG_CHECK_MODULES(XML, libxml-2.0)
536                 fi
538     if test x"$XML_LIBS" != x; then
539       AC_DEFINE([HAVE_LIBXML2], [1], [libxml2])
540       AC_DEFINE([HAVE_LIBXML_H], [1], [libxml.h])
541       AC_SUBST(XML_LIBS)
542       AC_SUBST(XML_CFLAGS)
543     else
544       AC_MSG_ERROR([libxml2-headers and/or libs were not found, install them or build with --without-webdav-props])
545     fi
546   fi
548   AC_MSG_CHECKING(for sqlite)
549   AC_ARG_WITH(sqlite, AC_HELP_STRING([--with-sqlite],[sqlite for properties in mod_webdav]),
550   [WITH_SQLITE=$withval],[WITH_SQLITE=yes])
551   AC_MSG_RESULT([$WITH_SQLITE])
553   if test "$WITH_SQLITE" != "no"; then
554                 if test "$WITH_SQLITE" != "yes"; then
555                         SQLITE_LIBS="-L$WITH_SQLITE/.libs -lsqlite3"
556                         SQLITE_CFLAGS="-I$WITH_SQLITE"
557                 else
558                         PKG_CHECK_MODULES(SQLITE, sqlite3)
559                 fi
561     if test x"$SQLITE_LIBS" != x; then
562       AC_DEFINE([HAVE_SQLITE3], [1], [libsqlite3])
563       AC_DEFINE([HAVE_SQLITE3_H], [1], [sqlite3.h])
564       AC_SUBST(SQLITE_LIBS)
565       AC_SUBST(SQLITE_CFLAGS)
566     else
567       AC_MSG_ERROR([sqlite-headers and/or libs were not found, install them or build with --without-webdav-props])
568     fi
569   fi
571   AC_MSG_CHECKING(for locks in mod_webdav)
572   AC_ARG_WITH(webdav-locks, AC_HELP_STRING([--with-webdav-locks],[locks in mod_webdav]),
573   [WITH_WEBDAV_LOCKS=$withval],[WITH_WEBDAV_LOCKS=no])
574   AC_MSG_RESULT([$WITH_WEBDAV_LOCKS])
576   if test "$WITH_WEBDAV_LOCKS" != "no"; then
578     AC_MSG_CHECKING(for libuuid)
579     AC_ARG_WITH(uuid, AC_HELP_STRING([--with-uuid],[uuid for locks in mod_webdav]),
580     [WITH_UUID=$withval],[WITH_UUID=yes])
581     AC_MSG_RESULT([$WITH_UUID])
583     if test "$WITH_UUID" != "no"; then
584                 if test "$WITH_UUID" != "yes"; then
585                         UUID_LIBS="-L$WITH_UUID -luuid"
586                         CPPFLAGS="$CPPFLAGS -I$WITH_UUID"
587                 else
588                         AC_CHECK_LIB(uuid, uuid_unparse, [
589                           AC_CHECK_HEADERS([uuid/uuid.h],[UUID_LIBS=-luuid])
590                         ])
591                 fi
593       if test x"$UUID_LIBS" != x; then
594         AC_DEFINE([HAVE_UUID], [1], [libuuid])
595         AC_DEFINE([HAVE_UUID_H], [1], [uuid/uuid.h is available])
596         AC_SUBST(UUID_LIBS)
597       else
598         AC_MSG_ERROR([uuid-headers and/or libs were not found, install them or build with --without-webdav-locks])
599       fi
600     fi
602   fi
606 dnl Check for gdbm
607 AC_MSG_CHECKING(for gdbm)
608 AC_ARG_WITH(gdbm, AC_HELP_STRING([--with-gdbm],[gdbm storage for mod_trigger_b4_dl]),
609 [WITH_GDBM=$withval],[WITH_GDBM=no])
610 AC_MSG_RESULT([$WITH_GDBM])
612 if test "$WITH_GDBM" != "no"; then
613                 if test "$WITH_GDBM" != "yes"; then
614                         GDBM_LIB="-L$WITH_GDBM -lgdbm"
615                         CPPFLAGS="$CPPFLAGS -I$WITH_GDBM"
616                 else
617                         AC_CHECK_LIB(gdbm, gdbm_open, [
618                           AC_CHECK_HEADERS([gdbm.h],[GDBM_LIB=-lgdbm])
619                         ])
620                 fi
622   if test x"$GDBM_LIB" != x; then
623     AC_DEFINE([HAVE_GDBM], [1], [libgdbm])
624     AC_DEFINE([HAVE_GDBM_H], [1])
625     AC_SUBST(GDBM_LIB)
626   else
627     AC_MSG_ERROR([gdbm headers and/or libs were not found, install them or build with --without-gdbm])
628   fi
630 AM_CONDITIONAL(BUILD_WITH_GDBM, test ! $WITH_GDBM = no)
632 dnl Check for GeoIP
633 AC_MSG_CHECKING(for GeoIP)
634 AC_ARG_WITH(geoip, AC_HELP_STRING([--with-geoip],[IP-based geolocation lookup]),
635 [WITH_GEOIP=$withval],[WITH_GEOIP=no])
636 AC_MSG_RESULT([$WITH_GEOIP])
638 if test "$WITH_GEOIP" != "no"; then
639                 if test "$WITH_GEOIP" != "yes"; then
640                         GEOIP_LIB="-L$WITH_GEOIP -lGeoIP"
641                         CPPFLAGS="$CPPFLAGS -I$WITH_GEOIP"
642                 else
643                         AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_addr, [
644                           AC_CHECK_HEADERS([GeoIP.h],[GEOIP_LIB=-lGeoIP])
645                         ])
646                 fi
648   if test x"$GEOIP_LIB" != x; then
649     AC_DEFINE([HAVE_GEOIP], [1], [libGeoIP])
650     AC_DEFINE([HAVE_GEOIP_H], [1])
651     AC_SUBST(GEOIP_LIB)
652   else
653     AC_MSG_ERROR([GeoIP headers and/or libs were not found, install them or build with --without-geoip])
654   fi
656 AM_CONDITIONAL(BUILD_WITH_GEOIP, test ! $WITH_GEOIP = no)
658 dnl Check for memcached
659 AC_MSG_CHECKING(for memcached)
660 AC_ARG_WITH(memcached, AC_HELP_STRING([--with-memcached],[memcached storage for mod_trigger_b4_dl]),
661 [WITH_MEMCACHED=$withval],[WITH_MEMCACHED=no])
662 AC_MSG_RESULT([$WITH_MEMCACHED])
664 if test "$WITH_MEMCACHED" != "no"; then
665                 if test "$WITH_MEMCACHED" != "yes"; then
666                         MEMCACHED_LIB="-L$WITH_MEMCACHED -lMEMCACHED"
667                         CPPFLAGS="$CPPFLAGS -I$WITH_MEMCACHED"
668                 else
669                         AC_CHECK_LIB(memcached, memcached, [
670                           AC_CHECK_HEADERS([libmemcached/memcached.h],[
671                             MEMCACHED_LIB=-lmemcached
672                           ])
673                         ])
674                 fi
676   if test x"$MEMCACHED_LIB" != x; then
677     AC_DEFINE([USE_MEMCACHED], [1], [libmemcached])
678     AC_SUBST(MEMCACHED_LIB)
679   else
680     AC_MSG_ERROR([memcached headers and/or libs were not found, install them or build with --without-memcached])
681   fi
683 AM_CONDITIONAL(BUILD_WITH_MEMCACHED, test ! $WITH_MEMCACHED = no)
685 AM_CONDITIONAL(BUILD_MOD_TRIGGER_B4_DL, test ! $WITH_MEMCACHED = no || test ! $WITH_GDBM = no)
687 dnl Check for lua
688 AC_MSG_CHECKING(if lua-support is requested)
689 AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[lua engine for mod_cml]),
690 [WITH_LUA=$withval],[WITH_LUA=no])
692 AC_MSG_RESULT($WITH_LUA)
693 if test "$WITH_LUA" != "no"; then
694   found_lua=0
695   if test "$WITH_LUA" != "yes"; then
696     PKG_CHECK_MODULES(LUA, $WITH_LUA >= 5.1, [
697       found_lua=1
698     ],[
699       AC_MSG_NOTICE([Couldn't find requested lua pkg-config module $WITH_LUA])
700     ])
701     if test "$found_lua" = "0"; then
702       LUA_LIBS="-L$WITH_LUA -llua"
703       LUA_CFLAGS="-I$WITH_LUA"
704     fi
705   else
706     for luaname in lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua; do
707       if test "$found_lua" = "0"; then
708         PKG_CHECK_MODULES(LUA, $luaname >= 5.1, [
709           found_lua=1
710         ], [
711           AC_MSG_NOTICE([Couldn't find $luaname])
712         ])
713       fi
714     done
715     if test "$found_lua" = "0"; then
716       AC_MSG_ERROR([Couldn't find any lua pkg-config module])
717     fi
718   fi
720   if test x"$LUA_LIBS" != x; then
721     AC_DEFINE([HAVE_LUA], [1], [liblua])
722     AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
723     AC_SUBST(LUA_LIBS)
724     AC_SUBST(LUA_CFLAGS)
725   else
726     AC_MSG_ERROR([lua headers and/or libs were not found, install them or build with --without-lua])
727   fi
729 AM_CONDITIONAL(BUILD_WITH_LUA, test ! $WITH_LUA = no)
731 dnl search for crypt_r and (fallback) for crypt
732 save_LIBS=$LIBS
733 LIBS=
734 AC_SEARCH_LIBS([crypt_r],[crypt],[
735   AC_DEFINE([HAVE_CRYPT_R], [1], [crypt_r])
736   AC_CHECK_HEADERS([crypt.h],[
737     AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
738   ])
740   CRYPT_LIB=$LIBS
742   AC_SEARCH_LIBS([crypt],[crypt],[
743     AC_DEFINE([HAVE_CRYPT], [1], [crypt])
744     AC_CHECK_HEADERS([crypt.h],[
745       AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
746     ])
748     CRYPT_LIB=$LIBS
749   ])
751 LIBS=$save_LIBS
752 AC_SUBST([CRYPT_LIB])
754 save_LIBS=$LIBS
755 AC_SEARCH_LIBS(sendfilev,sendfile,[
756   if test "$ac_cv_search_sendfilev" != no; then
757     test "$ac_cv_search_sendfilev" = "none required" || SENDFILE_LIB="$ac_cv_search_sendfilev"
758     AC_DEFINE([HAVE_SENDFILEV], [1], [solaris sendfilev])
759   fi
761 LIBS=$save_LIBS
762 AC_SUBST(SENDFILE_LIB)
764 case $host_os in
765         *mingw* ) LIBS="$LIBS -lwsock32";;
766         * ) ;;
767 esac
769 AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop inet_pton issetugid memset mmap munmap strchr \
770                   strdup strerror strstr strtol sendfile  getopt socket lstat \
771                   gethostbyname poll epoll_ctl getrlimit chroot \
772                   getuid select signal pathconf madvise posix_fadvise posix_madvise \
773                   writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
774                   memset_s explicit_bzero clock_gettime \
775                   getentropy arc4random jrand48 srandom getloadavg])
776 AC_CHECK_HEADERS([linux/random.h],[
777   AC_CHECK_FUNC([getrandom], AC_DEFINE([HAVE_GETRANDOM], [1], [getrandom]))
780 AC_MSG_CHECKING(if weak symbols are supported)
781 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
782                 __attribute__((weak)) void __dummy(void *x) { }
783                 void f(void *x) { __dummy(x); }
784         ]])],
785         [
786                 AC_MSG_RESULT(yes)
787                 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [weak symbols are supported])
788         ],[AC_MSG_RESULT(no)])
790 AC_MSG_CHECKING(for Large File System support)
791 AC_ARG_ENABLE(lfs,
792  AC_HELP_STRING([--enable-lfs],[Turn on Large File System (default)]),
793  [case "${enableval}" in
794    yes) CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES" ;;
795     no) ;;
796      *) AC_MSG_ERROR(bad value ${enableval} for --enable-lfs) ;;
797   esac],[CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
798          enable_lfs=yes])
799 AC_MSG_RESULT($enableval)
801 AC_CHECK_SIZEOF(long)
802 AC_CHECK_SIZEOF(off_t)
804 if test "x$ac_cv_func_sendfile" = xyes; then
805         dnl check if sendfile works
806         AC_MSG_CHECKING(if sendfile works)
807         if test "x$cross_compiling" = xno; then
808         AC_TRY_RUN([
809                     #ifdef HAVE_SYS_SENDFILE_H
810                     #include <sys/sendfile.h>
811                     #endif /* HAVE_SYS_SENDFILE_H */
812                     #include <errno.h>
813                     int main() {
814                       int o = 0;
815                       if (-1 == sendfile(-1, 0, &o, 0) && errno == ENOSYS) return -1;
816                       return 0;
817                     } ],
818                     AC_MSG_RESULT(yes),
819                     [ AC_MSG_RESULT(no)
820                     AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile]) ] )
821         else
822               AC_MSG_RESULT(no, cross-compiling)
823               AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile])
824         fi
827 dnl Check for IPv6 support
829 AC_ARG_ENABLE(ipv6,
830  AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
831  [case "${enableval}" in
832    yes) ipv6=true ;;
833     no) ipv6=false ;;
834      *) AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
835   esac],[ipv6=true])
837 if test x$ipv6 = xtrue; then
838   AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
839   [AC_TRY_LINK([ #include <sys/types.h>
840 #include <sys/socket.h>
841 #include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ],
842   [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
844   if test "$ac_cv_ipv6_support" = yes; then
845     AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
846   fi
849 # disable mmap by default; if a mmapped file gets truncated, the process gets a SIGBUS signal
850 # on reading the truncated area which we can't handle (yet).
851 # lighttpd may always use mmap with files it owns (created tmp files)
852 AC_ARG_ENABLE(mmap,
853   AC_HELP_STRING([--enable-mmap],[use mmap if available (DANGEROUS, allows local users to trigger SIGBUS crashes)]),
854   [case "${enableval}" in
855    yes) mmap=true ;;
856     no) mmap=false ;;
857      *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmap) ;;
858   esac],[mmap=false])
860 if test x$mmap = xtrue; then
861   AC_DEFINE(ENABLE_MMAP, [1], [Use mmap if available])
865 AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
867 dnl check for fastcgi lib, for the tests only
868 fastcgi_found=no
869 AC_CHECK_LIB(fcgi, FCGI_Accept, [
870  AC_CHECK_HEADERS([fastcgi.h fastcgi/fastcgi.h],[
871    fastcgi_found=yes
872  ])
875 AM_CONDITIONAL(CHECK_WITH_FASTCGI, test "x$fastcgi_found" = xyes)
878 dnl check for extra compiler options (warning options)
879 if test "${GCC}" = "yes"; then
880   TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
881   TRY_CFLAGS([-std=gnu99])
884 AC_ARG_ENABLE(extra-warnings,
885  AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
886  [case "${enableval}" in
887    yes) extrawarnings=true ;;
888     no) extrawarnings=false ;;
889      *) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
890   esac],[extrawarnings=false])
892 if test x$extrawarnings = xtrue; then
893   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])
894   TRY_LDFLAGS([-Wl,--as-needed])
897 dnl build version-id
898 LIGHTTPD_VERSION_ID=`echo $PACKAGE_VERSION | $AWK -F '.' '{print "(" $1 " << 16 | " $2 " << 8 | " $3 ")"}'`
899 AC_DEFINE_UNQUOTED([LIGHTTPD_VERSION_ID], [$LIGHTTPD_VERSION_ID], [lighttpd-version-id])
901 AC_CONFIG_FILES([Makefile src/Makefile
902                  doc/config/conf.d/Makefile \
903                  doc/config/vhosts.d/Makefile \
904                  doc/config/Makefile \
905                  doc/scripts/Makefile \
906                  doc/initscripts/Makefile \
907                  doc/systemd/Makefile \
908                  doc/outdated/Makefile \
909                  doc/Makefile \
910                  tests/Makefile \
911                  tests/docroot/Makefile \
912                  tests/docroot/123/Makefile \
913                  tests/docroot/www/Makefile \
914                  tests/docroot/www/go/Makefile \
915                  tests/docroot/www/indexfile/Makefile \
916                  tests/docroot/www/expire/Makefile \
917                  distribute.sh])
918 AC_OUTPUT
921 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_authn_file mod_status mod_accesslog"
922 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"
924 plugins="mod_rewrite mod_redirect"
925 features="regex-conditionals"
926 if test ! "x$PCRE_LIB" = x; then
927         do_build="$do_build $plugins"
928         enable_feature="$features"
929 else
930         no_build="$no_build $plugins"
931         disable_feature="$features"
934 plugins="mod_trigger_b4_dl"
935 if test ! "x$PCRE_LIB" = x; then
936 if test ! "x$WITH_MEMCACHED" = xno || test ! "x$WITH_GDBM" = xno; then
937         do_build="$do_build $plugins"
938 else
939         no_build="$no_build $plugins"
943 plugins="mod_authn_mysql mod_mysql_vhost"
944 if test ! "x$MYSQL_LIBS" = x; then
945         do_build="$do_build $plugins"
946 else
947         no_build="$no_build $plugins"
950 plugins="mod_cml mod_magnet"
951 if test ! "x$LUA_LIBS" = x; then
952         do_build="$do_build $plugins"
953 else
954         no_build="$no_build $plugins"
957 plugins="mod_geoip"
958 if test ! "x$GEOIP_LIB" = x; then
959         do_build="$do_build $plugins"
960 else
961         no_build="$no_build $plugins"
964 features="storage-gdbm"
965 if test ! "x$GDBM_LIB" = x; then
966         enable_feature="$enable_feature $features"
967 else
968         disable_feature="$disable_feature $features"
971 features="storage-memcached"
972 if test ! "x$MEMCACHED_LIB" = x; then
973         enable_feature="$enable_feature $features"
974 else
975         disable_feature="$disable_feature $features"
978 features="compress-gzip compress-deflate"
979 if test ! "x$Z_LIB" = x; then
980         enable_feature="$enable_feature $features"
981 else
982         disable_feature="$disable_feature $features"
985 features="compress-bzip2"
986 if test ! "x$BZ_LIB" = x; then
987         enable_feature="$enable_feature $features"
988 else
989         disable_feature="$disable_feature $features"
992 plugins="mod_authn_gssapi"
993 if test ! "x$KRB5_LIB" = x; then
994         do_build="$do_build $plugins"
995 else
996         no_build="$no_build $plugins"
999 plugins="mod_authn_ldap"
1000 if test ! "x$LDAP_LIB" = x; then
1001         do_build="$do_build $plugins"
1002 else
1003         no_build="$no_build $plugins"
1006 features="network-openssl"
1007 if test ! "x$SSL_LIB" = x; then
1008         enable_feature="$enable_feature $features"
1009 else
1010         disable_feature="$disable_feature $features"
1013 dnl no crypt call
1014 features="auth-crypt"
1015 if test "$ac_cv_search_crypt" = no; then
1016         disable_feature="$disable_feature $features"
1017 else
1018         enable_feature="$enable_feature $features"
1021 features="network-ipv6"
1022 if test "$ac_cv_ipv6_support" = yes; then
1023         enable_feature="$enable_feature $features"
1024 else
1025         disable_feature="$disable_feature $features"
1028 features="large-files"
1029 if test "$enable_lfs" = yes; then
1030         enable_feature="$enable_feature $features"
1031 else
1032         disable_feature="$disable_feature $features"
1035 features="stat-cache-fam"
1036 if test ! "x$FAM_LIBS" = x; then
1037         enable_feature="$enable_feature $features"
1038 else
1039         disable_feature="$disable_feature $features"
1042 features="webdav-properties"
1043 if test "x$XML_LIBS" \!= x -a "x$SQLITE_LIBS" \!= x; then
1044         enable_feature="$enable_feature $features"
1045 else
1046         disable_feature="$disable_feature $features"
1049 features="webdav-locks"
1050 if test "x$UUID_LIBS" \!= x; then
1051         enable_feature="$enable_feature $features"
1052 else
1053         disable_feature="$disable_feature $features"
1057 dnl output
1059 $ECHO
1060 $ECHO "Plugins:"
1061 $ECHO
1063 $ECHO "enabled: "
1064 for p in $do_build; do
1065         $ECHO "  $p"
1066 done | sort
1068 $ECHO "disabled: "
1069 for p in $no_build; do
1070         $ECHO "  $p"
1071 done | sort
1073 $ECHO
1074 $ECHO "Features:"
1075 $ECHO
1077 $ECHO "enabled: "
1078 for p in $enable_feature; do
1079         $ECHO "  $p"
1080 done | sort
1082 $ECHO "disabled: "
1083 for p in $disable_feature; do
1084         $ECHO "  $p"
1085 done | sort
1087 $ECHO