[mod_auth] LDAP escape username in DN and filters
[lighttpd.git] / configure.ac
blob640671fd1d8a3a13fe73f5fc6802cd7f93db31ec
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.46], [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 AX_PROG_CC_FOR_BUILD
66 AM_PROG_CC_C_O
67 AC_PROG_LD
68 AC_PROG_INSTALL
69 AC_PROG_AWK
70 AC_PROG_CPP
71 dnl AC_PROG_CXX
72 AC_PROG_LN_S
73 AC_PROG_MAKE_SET
75 dnl AM_PROG_AR is needed for some linker stuff
76 dnl AC_USE_SYSTEM_EXTENSIONS requires autoconf 2.60
77 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_USE_SYSTEM_EXTENSIONS])
78 dnl AM_PROG_AR requires automake 1.11 (and uses AC_COMPILE_IFELSE which wants AC_USE_SYSTEM_EXTENSIONS)
79 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
81 dnl check environment
82 AC_AIX
83 AC_ISC_POSIX
84 AC_MINIX
86 dnl AC_CANONICAL_HOST
87 case $host_os in
88         *darwin*|*cygwin*|*aix*|*mingw*|*midipix* ) NO_RDYNAMIC=yes;;
89         * ) NO_RDYNAMIC=no;;
90 esac
91 AM_CONDITIONAL(NO_RDYNAMIC, test x$NO_RDYNAMIC = xyes)
93 if test -z "$LIGHTTPD_STATIC"; then
94   LIGHTTPD_STATIC=no
96 AM_CONDITIONAL(LIGHTTPD_STATIC, test x$LIGHTTPD_STATIC = xyes)
98 AC_EXEEXT
100 dnl libtool
101 AC_DISABLE_STATIC
102 AC_ENABLE_SHARED
104 AC_LIBTOOL_DLOPEN
105 AC_PROG_LIBTOOL
107 dnl for solaris
108 CPPFLAGS="${CPPFLAGS} -D_REENTRANT -D__EXTENSIONS__"
110 dnl Checks for header files.
111 AC_HEADER_STDC
112 AC_HEADER_SYS_WAIT
113 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h \
114 sys/socket.h sys/time.h unistd.h sys/sendfile.h sys/uio.h \
115 getopt.h sys/epoll.h sys/select.h poll.h sys/poll.h sys/devpoll.h sys/filio.h \
116 sys/mman.h sys/event.h port.h pwd.h \
117 sys/resource.h sys/un.h syslog.h sys/prctl.h uuid/uuid.h])
119 dnl Checks for typedefs, structures, and compiler characteristics.
120 AC_C_CONST
121 AC_C_INLINE
122 AC_C_CHAR_UNSIGNED
123 AC_TYPE_OFF_T
124 AC_TYPE_PID_T
125 AC_TYPE_SIZE_T
127 AC_CHECK_MEMBER(struct tm.tm_gmtoff,[AC_DEFINE([HAVE_STRUCT_TM_GMTOFF],[1],[gmtoff in struct tm])],,[#include <time.h>])
128 AC_CHECK_TYPES(struct sockaddr_storage,,,[#include <sys/socket.h>])
129 AC_CHECK_TYPES(socklen_t,,,[#include <sys/types.h>
130 #include <sys/socket.h>])
132 dnl Checks for library functions.
133 AC_FUNC_FORK
134 dnl AC_FUNC_MALLOC
135 dnl AC_FUNC_MMAP
136 dnl AC_FUNC_REALLOC
137 AC_TYPE_SIGNAL
138 AC_FUNC_STAT
139 AC_FUNC_STRFTIME
141 if test -z "$PKG_CONFIG"; then
142   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
145 dnl checking for libev
146 AC_MSG_CHECKING(for libev support)
147 AC_ARG_WITH(libev,
148     AC_HELP_STRING([--with-libev@<:@=PATH@:>@],[Include libev support for fdevent handlers in PATH/include and PATH/lib]),
149     [WITH_LIBEV=$withval],[WITH_LIBEV=no])
151 LIBEV_CFLAGS=""
152 LIBEV_LIBS=""
154 if test "$WITH_LIBEV" != "no"; then
155         PKG_CHECK_MODULES(LIBEV, libev, [], [
156                 dnl no pkg-config for libev, searching manually:
158                 if test "$WITH_LIBEV" != "yes"; then
159                         LIBEV_CFLAGS="-I$WITH_LIBEV/include"
160                         LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
161                 else
162                         AC_CHECK_HEADERS([ev.h],[
163                                 AC_CHECK_LIB([ev], [ev_time], [
164                                                 LIBEV_CFLAGS=""
165                                                 LIBEV_LIBS="-lev"
166                                         ],[
167                                         AC_MSG_ERROR([libev not found])
168                                         ]
169                                 )],[
170                                         AC_MSG_ERROR([libev not found])
171                                 ]
172                         )
173                 fi
174         ])
176         AC_DEFINE([HAVE_LIBEV], [1], [libev support])
179 AC_SUBST(LIBEV_CFLAGS)
180 AC_SUBST(LIBEV_LIBS)
181 AC_MSG_RESULT([$WITH_LIBEV])
183 dnl Checks for database.
184 MYSQL_INCLUDE=""
185 MYSQL_LIBS=""
187 AC_MSG_CHECKING(for MySQL support)
188 AC_ARG_WITH(mysql,
189     AC_HELP_STRING([--with-mysql@<:@=PATH@:>@],[Include MySQL support. PATH is the path to 'mysql_config']),
190     [WITH_MYSQL=$withval],[WITH_MYSQL=no])
192 if test "$WITH_MYSQL" != "no"; then
193   AC_MSG_RESULT(yes)
194   if test "$WITH_MYSQL" = "yes"; then
195     AC_PATH_PROG(MYSQL_CONFIG, mysql_config)
196   else
197     MYSQL_CONFIG=$WITH_MYSQL
198   fi
200   if test "$MYSQL_CONFIG" = ""; then
201     AC_MSG_ERROR(mysql_config is not found)
202   fi
203   if test \! -x $MYSQL_CONFIG; then
204     AC_MSG_ERROR(mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config)
205   fi
207   if $MYSQL_CONFIG | grep -- '--include' > /dev/null ; then
208     MYSQL_INCLUDE="`$MYSQL_CONFIG --include | sed s/\'//g`"
209   else
210     MYSQL_INCLUDE="`$MYSQL_CONFIG --cflags | sed s/\'//g`"
211   fi
212   MYSQL_LIBS="`$MYSQL_CONFIG --libs | sed s/\'//g`"
214   AC_MSG_CHECKING(for MySQL includes at)
215   AC_MSG_RESULT($MYSQL_INCLUDE)
217   AC_MSG_CHECKING(for MySQL libraries at)
218   AC_MSG_RESULT($MYSQL_LIBS)
219 dnl check for errmsg.h, which isn't installed by some versions of 3.21
220   old_CPPFLAGS="$CPPFLAGS"
221   CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
222   AC_CHECK_HEADERS(errmsg.h mysql.h)
223   CPPFLAGS="$old_CPPFLAGS"
225   AC_DEFINE([HAVE_MYSQL], [1], [mysql support])
226 else
227   AC_MSG_RESULT(no)
229 AM_CONDITIONAL(BUILD_WITH_MYSQL, test ! $WITH_MYSQL = no)
231 AC_SUBST(MYSQL_LIBS)
232 AC_SUBST(MYSQL_INCLUDE)
234 dnl Check for LDAP
235 AC_MSG_CHECKING(for LDAP support)
236 AC_ARG_WITH(ldap, AC_HELP_STRING([--with-ldap],[enable LDAP support]),
237 [WITH_LDAP=$withval], [WITH_LDAP=no])
238 AC_MSG_RESULT([$withval])
239 if test "$WITH_LDAP" != "no"; then
240  AC_CHECK_LIB(ldap, ldap_bind, [
241   AC_CHECK_HEADERS([ldap.h],[
242     LDAP_LIB=-lldap
243     AC_DEFINE([HAVE_LIBLDAP], [1], [libldap])
244     AC_DEFINE([HAVE_LDAP_H], [1])
245     AC_DEFINE([LDAP_DEPRECATED], [1], [Using deprecated ldap api])
246   ])
247  ])
248  AC_SUBST(LDAP_LIB)
249  AC_CHECK_LIB(lber, ber_printf, [
250   AC_CHECK_HEADERS([lber.h],[
251     LBER_LIB=-llber
252     AC_DEFINE([HAVE_LIBLBER], [1], [liblber])
253     AC_DEFINE([HAVE_LBER_H], [1])
254   ])
255  ])
256  AC_SUBST(LBER_LIB)
258 AM_CONDITIONAL(BUILD_WITH_LDAP, test ! $WITH_LDAP = no)
260 dnl Check for xattr
261 AC_MSG_CHECKING(for extended attributes support)
262 AC_ARG_WITH(attr, AC_HELP_STRING([--with-attr],[enable extended attribute support]),
263 [WITH_ATTR=$withval],[WITH_ATTR=no])
264 AC_MSG_RESULT($withval)
265 if test "$WITH_ATTR" != "no"; then
266   # libattr (linux only?)
267   AC_CHECK_LIB(attr, attr_get, [
268     AC_CHECK_HEADERS([attr/attributes.h],[
269       ATTR_LIB=-lattr
270       AC_DEFINE([HAVE_XATTR], [1], [libattr])
271       AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
272     ])
273   ])
274   AC_SUBST(ATTR_LIB)
276   # (Free)BSD extattr
277   AC_CHECK_FUNC([extattr_get_file], [
278     AC_CHECK_HEADERS([sys/extattr.h],[
279       AC_DEFINE([HAVE_EXTATTR], [1], [BSD extended attributes])
280       AC_DEFINE([HAVE_SYS_EXTATTR_H], [1])
281     ])
282   ])
285 dnl openssl on solaris needs -lsocket -lnsl
286 AC_SEARCH_LIBS(socket,socket)
287 AC_SEARCH_LIBS(gethostbyname,nsl socket)
289 dnl On Haiku accept() and friends are in libnetwork
290 AC_SEARCH_LIBS(accept,network)
292 dnl clock_gettime() needs -lrt with glibc < 2.17, and possibly other platforms
293 AC_SEARCH_LIBS([clock_gettime],[rt])
295 save_LIBS=$LIBS
296 AC_SEARCH_LIBS(dlopen,dl,[
297   AC_CHECK_HEADERS([dlfcn.h],[
298     if test "$ac_cv_search_dlopen" != no; then
299       test "$ac_cv_search_dlopen" = "none required" || DL_LIB="$ac_cv_search_dlopen"
300     fi
302     AC_DEFINE([HAVE_LIBDL], [1], [libdl])
303     AC_DEFINE([HAVE_DLFCN_H], [1])
304   ])
306 LIBS=$save_LIBS
307 AC_SUBST(DL_LIB)
309 dnl Check for valgrind
310 AC_MSG_CHECKING(for valgrind)
311 AC_ARG_WITH(valgrind, AC_HELP_STRING([--with-valgrind],[enable internal support for valgrind]),
312 [WITH_VALGRIND=$withval],[WITH_VALGRIND=no])
313 AC_MSG_RESULT([$WITH_VALGRIND])
314 if test "$WITH_VALGRIND" != "no"; then
315  AC_CHECK_HEADERS([valgrind/valgrind.h])
318 dnl Checking for libunwind
319 AC_MSG_CHECKING(for libunwind)
320 AC_ARG_WITH(libunwind,
321     AC_HELP_STRING([--with-libunwind],[Include libunwind support for backtraces on assert failures]),
322     [WITH_LIBUNWIND=$withval],[WITH_LIBUNWIND=no])
324 if test "$WITH_LIBUNWIND" != "no"; then
325   PKG_CHECK_MODULES(LIBUNWIND, libunwind)
326   AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
328 AC_MSG_RESULT([$WITH_LIBUNWIND])
330 dnl Checking for kerberos5
331 AC_MSG_CHECKING(for kerberos5)
332 AC_ARG_WITH(krb5,
333         AC_HELP_STRING([--with-krb5@<:@=DIR@:>@],[Use Kerberos 5]),
334         [WITH_KRB5=$withval],[WITH_KRB5=no])
335 if test "$WITH_KRB5" != "no"; then
336         use_krb5=yes
337         if test "x$WITH_KRB5" != "xyes"; then
338                 CPPFLAGS="$CPPFLAGS -I$WITH_KRB5/include"
339                 LDFLAGS="$LDFLAGS -L$WITH_KRB5/lib"
340         fi
341 else
342         use_krb5=no
344 AC_MSG_RESULT([$use_krb5])
345 AM_CONDITIONAL(BUILD_WITH_KRB5, test ! $WITH_KRB5 = no)
347 AC_ARG_WITH(krb5-includes,
348         AC_HELP_STRING([--with-krb5-includes=DIR],[Kerberos includes]),
349         [ use_krb5=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
352 AC_ARG_WITH(krb5-libs,
353         AC_HELP_STRING([--with-krb5-libs=DIR],[Kerberos libraries]),
354         [ use_krb5=yes LDFLAGS="$LDFLAGS -L$withval" ]
357 if test "x$use_krb5" = "xyes"; then
358         AC_CHECK_LIB(gssapi_krb5, gss_acquire_cred, [
359                 AC_CHECK_HEADERS([gssapi/gssapi_krb5.h],[
360                         KRB5_LIB="-lkrb5 -lgssapi_krb5"
361                         AC_DEFINE(HAVE_KRB5, [1], [libgssapi_krb5])
362                 ])
363         ])
364         if test "x$KRB5_LIB" = x; then
365                 AC_MSG_ERROR([gssapi_krb5 headers and/or libs where not found, install them or build with --without-krb5])
366         fi
368 AC_SUBST(KRB5_LIB)
370 dnl Check for openssl
371 AC_MSG_CHECKING(for OpenSSL)
372 AC_ARG_WITH(openssl,
373     AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[Include openssl support (default no)]),
374     [WITH_OPENSSL=$withval],[WITH_OPENSSL=no])
376 if test "$WITH_OPENSSL" != "no"; then
377     use_openssl=yes
378     if test "$WITH_OPENSSL" != "yes"; then
379         CPPFLAGS="$CPPFLAGS -I$WITH_OPENSSL/include"
380         LDFLAGS="$LDFLAGS -L$WITH_OPENSSL/lib"
381     fi
382 else
383     use_openssl=no
385 AC_MSG_RESULT([$use_openssl])
386 AM_CONDITIONAL(BUILD_WITH_OPENSSL, test ! $WITH_OPENSSL = no)
388 AC_ARG_WITH(openssl-includes,
389     AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
390     [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
393 AC_ARG_WITH(openssl-libs,
394     AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
395     [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
398 if test "x$use_openssl" = "xyes"; then
399     if test "x$use_krb5" = "xyes"; then
400         AC_DEFINE([USE_OPENSSL_KERBEROS], [1], [with kerberos])
401     fi
403     AC_CHECK_HEADERS([openssl/ssl.h])
404     OLDLIBS="$LIBS"
405     AC_CHECK_LIB(crypto, BIO_f_base64, [
406       AC_CHECK_LIB(ssl, SSL_new, [ SSL_LIB="-lssl -lcrypto"
407                                  CRYPTO_LIB="-lcrypto"
408                                  AC_DEFINE(HAVE_LIBSSL, [], [Have libssl]) ], [], [ -lcrypto "$DL_LIB" ])
409     ], [], [])
410     LIBS="$OLDLIBS"
411     AC_SUBST(SSL_LIB)
412     AC_SUBST(CRYPTO_LIB)
415 AC_MSG_CHECKING(for perl regular expressions support)
416 AC_ARG_WITH(pcre, AC_HELP_STRING([--with-pcre],[Enable pcre support (default yes)]),
417     [WITH_PCRE=$withval],[WITH_PCRE=yes])
418 AC_MSG_RESULT([$WITH_PCRE])
420 if test "$WITH_PCRE" != "no"; then
421                 if test "$WITH_PCRE" != "yes"; then
422                         PCRE_LIB="-L$WITH_PCRE/lib -lpcre"
423                         CPPFLAGS="$CPPFLAGS -I$WITH_PCRE/include"
424                 else
425                         AC_PATH_PROG(PCRECONFIG, pcre-config)
426                         if test x"$PCRECONFIG" != x; then
427                                 PCRE_LIB=`$PCRECONFIG --libs`
428                                 CPPFLAGS="$CPPFLAGS `$PCRECONFIG --cflags`"
429                         fi
430                 fi
432   if test x"$PCRE_LIB" != x; then
433     AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre])
434     AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h])
435     AC_SUBST(PCRE_LIB)
436   else
437     AC_MSG_ERROR([pcre-config not found, install the pcre-devel package or build with --without-pcre])
438   fi
441 AC_MSG_CHECKING(for zlib support)
442 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],[Enable zlib support for mod_compress]),
443     [WITH_ZLIB=$withval],[WITH_ZLIB=yes])
444 AC_MSG_RESULT([$WITH_ZLIB])
446 if test "$WITH_ZLIB" != "no"; then
447                 if test "$WITH_ZLIB" != "yes"; then
448                         Z_LIB="-L$WITH_ZLIB -lz"
449                         CPPFLAGS="$CPPFLAGS -I$WITH_ZLIB"
450                 else
451                         AC_CHECK_LIB(z, deflate, [
452                           AC_CHECK_HEADERS([zlib.h],[Z_LIB=-lz])
453                         ])
454                 fi
456   if test x"$Z_LIB" != x; then
457     AC_DEFINE([HAVE_LIBZ], [1], [libz])
458     AC_DEFINE([HAVE_ZLIB_H], [1])
459     AC_SUBST(Z_LIB)
460   else
461     AC_MSG_ERROR([zlib-headers and/or libs were not found, install them or build with --without-zlib])
462   fi
465 AC_MSG_CHECKING(for bzip2 support)
466 AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2],[Enable bzip2 support for mod_compress]),
467     [WITH_BZIP2=$withval],[WITH_BZIP2=yes])
468 AC_MSG_RESULT([$WITH_BZIP2])
470 if test "$WITH_BZIP2" != "no"; then
471                 if test "$WITH_BZIP2" != "yes"; then
472                         BZ_LIB="-L$WITH_BZIP2 -lbz2"
473                         CPPFLAGS="$CPPFLAGS -I$WITH_BZIP2"
474                 else
475                         AC_CHECK_LIB(bz2, BZ2_bzCompress, [
476                           AC_CHECK_HEADERS([bzlib.h],[BZ_LIB=-lbz2])
477                         ])
478                 fi
480   if test x"$BZ_LIB" != x; then
481     AC_DEFINE([HAVE_LIBBZ2], [1], [libbz2])
482     AC_DEFINE([HAVE_BZLIB_H], [1])
483     AC_SUBST(BZ_LIB)
484   else
485     AC_MSG_ERROR([bzip2-headers and/or libs were not found, install them or build with --without-bzip2])
486   fi
489 dnl Check for gamin
490 AC_MSG_CHECKING(for FAM)
491 AC_ARG_WITH(fam, AC_HELP_STRING([--with-fam],[fam/gamin for reducing number of stat() calls]),
492 [WITH_FAM=$withval],[WITH_FAM=no])
493 AC_MSG_RESULT([$WITH_FAM])
495 if test "$WITH_FAM" != "no"; then
496                 if test "$WITH_FAM" != "yes"; then
497                         FAM_LIBS="-L$WITH_FAM -lfam"
498                         CPPFLAGS="$CPPFLAGS -I$WITH_FAM"
499                 else
500                         AC_CHECK_LIB(fam, FAMOpen2, [
501                           AC_CHECK_HEADERS([fam.h],[FAM_LIBS=-lfam])
502                         ])
503                         if test "x$FAM_LIBS" = x; then
504                           PKG_CHECK_MODULES(FAM, gamin >= 0.1.0)
505                         fi
506                 fi
508   if test x"$FAM_LIBS" != x; then
509     OLD_LIBS=$LIBS
510     LIBS=$FAM_LIBS
511     AC_CHECK_FUNCS([FAMNoExists])
512     LIBS=$OLD_LIBS
514     AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
515     AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
516     AC_SUBST(FAM_LIBS)
517   else
518      AC_MSG_ERROR([fam/gamin-headers and/or libs were not found, install them or build with --without-fam])
519   fi
522 AC_MSG_CHECKING(for properties in mod_webdav)
523 AC_ARG_WITH(webdav-props, AC_HELP_STRING([--with-webdav-props],[properties in mod_webdav]),
524 [WITH_WEBDAV_PROPS=$withval],[WITH_WEBDAV_PROPS=no])
525 AC_MSG_RESULT([$WITH_WEBDAV_PROPS])
527 if test "$WITH_WEBDAV_PROPS" != "no"; then
529   AC_MSG_CHECKING(for libxml2)
530   AC_ARG_WITH(libxml, AC_HELP_STRING([--with-libxml],[libxml2 for properties in mod_webdav]),
531   [WITH_LIBXML=$withval],[WITH_LIBXML=yes])
532   AC_MSG_RESULT([$WITH_LIBXML])
534   if test "$WITH_LIBXML" != "no"; then
535                 if test "$WITH_LIBXML" != "yes"; then
536                         XML_LIBS="-L$WITH_LIBXML/.libs -lxml2"
537                         XML_CFLAGS="-I$WITH_LIBXML/include"
538                 else
539                         PKG_CHECK_MODULES(XML, libxml-2.0)
540                 fi
542     if test x"$XML_LIBS" != x; then
543       AC_DEFINE([HAVE_LIBXML2], [1], [libxml2])
544       AC_DEFINE([HAVE_LIBXML_H], [1], [libxml.h])
545       AC_SUBST(XML_LIBS)
546       AC_SUBST(XML_CFLAGS)
547     else
548       AC_MSG_ERROR([libxml2-headers and/or libs were not found, install them or build with --without-webdav-props])
549     fi
550   fi
552   AC_MSG_CHECKING(for sqlite)
553   AC_ARG_WITH(sqlite, AC_HELP_STRING([--with-sqlite],[sqlite for properties in mod_webdav]),
554   [WITH_SQLITE=$withval],[WITH_SQLITE=yes])
555   AC_MSG_RESULT([$WITH_SQLITE])
557   if test "$WITH_SQLITE" != "no"; then
558                 if test "$WITH_SQLITE" != "yes"; then
559                         SQLITE_LIBS="-L$WITH_SQLITE/.libs -lsqlite3"
560                         SQLITE_CFLAGS="-I$WITH_SQLITE"
561                 else
562                         PKG_CHECK_MODULES(SQLITE, sqlite3)
563                 fi
565     if test x"$SQLITE_LIBS" != x; then
566       AC_DEFINE([HAVE_SQLITE3], [1], [libsqlite3])
567       AC_DEFINE([HAVE_SQLITE3_H], [1], [sqlite3.h])
568       AC_SUBST(SQLITE_LIBS)
569       AC_SUBST(SQLITE_CFLAGS)
570     else
571       AC_MSG_ERROR([sqlite-headers and/or libs were not found, install them or build with --without-webdav-props])
572     fi
573   fi
575   AC_MSG_CHECKING(for locks in mod_webdav)
576   AC_ARG_WITH(webdav-locks, AC_HELP_STRING([--with-webdav-locks],[locks in mod_webdav]),
577   [WITH_WEBDAV_LOCKS=$withval],[WITH_WEBDAV_LOCKS=no])
578   AC_MSG_RESULT([$WITH_WEBDAV_LOCKS])
580   if test "$WITH_WEBDAV_LOCKS" != "no"; then
582     AC_MSG_CHECKING(for libuuid)
583     AC_ARG_WITH(uuid, AC_HELP_STRING([--with-uuid],[uuid for locks in mod_webdav]),
584     [WITH_UUID=$withval],[WITH_UUID=yes])
585     AC_MSG_RESULT([$WITH_UUID])
587     if test "$WITH_UUID" != "no"; then
588                 if test "$WITH_UUID" != "yes"; then
589                         UUID_LIBS="-L$WITH_UUID -luuid"
590                         CPPFLAGS="$CPPFLAGS -I$WITH_UUID"
591                 else
592                         AC_CHECK_LIB(uuid, uuid_unparse, [
593                           AC_CHECK_HEADERS([uuid/uuid.h],[UUID_LIBS=-luuid])
594                         ])
595                 fi
597       if test x"$UUID_LIBS" != x; then
598         AC_DEFINE([HAVE_UUID], [1], [libuuid])
599         AC_DEFINE([HAVE_UUID_H], [1], [uuid/uuid.h is available])
600         AC_SUBST(UUID_LIBS)
601       else
602         AC_MSG_ERROR([uuid-headers and/or libs were not found, install them or build with --without-webdav-locks])
603       fi
604     fi
606   fi
610 dnl Check for gdbm
611 AC_MSG_CHECKING(for gdbm)
612 AC_ARG_WITH(gdbm, AC_HELP_STRING([--with-gdbm],[gdbm storage for mod_trigger_b4_dl]),
613 [WITH_GDBM=$withval],[WITH_GDBM=no])
614 AC_MSG_RESULT([$WITH_GDBM])
616 if test "$WITH_GDBM" != "no"; then
617                 if test "$WITH_GDBM" != "yes"; then
618                         GDBM_LIB="-L$WITH_GDBM -lgdbm"
619                         CPPFLAGS="$CPPFLAGS -I$WITH_GDBM"
620                 else
621                         AC_CHECK_LIB(gdbm, gdbm_open, [
622                           AC_CHECK_HEADERS([gdbm.h],[GDBM_LIB=-lgdbm])
623                         ])
624                 fi
626   if test x"$GDBM_LIB" != x; then
627     AC_DEFINE([HAVE_GDBM], [1], [libgdbm])
628     AC_DEFINE([HAVE_GDBM_H], [1])
629     AC_SUBST(GDBM_LIB)
630   else
631     AC_MSG_ERROR([gdbm headers and/or libs were not found, install them or build with --without-gdbm])
632   fi
634 AM_CONDITIONAL(BUILD_WITH_GDBM, test ! $WITH_GDBM = no)
636 dnl Check for GeoIP
637 AC_MSG_CHECKING(for GeoIP)
638 AC_ARG_WITH(geoip, AC_HELP_STRING([--with-geoip],[IP-based geolocation lookup]),
639 [WITH_GEOIP=$withval],[WITH_GEOIP=no])
640 AC_MSG_RESULT([$WITH_GEOIP])
642 if test "$WITH_GEOIP" != "no"; then
643                 if test "$WITH_GEOIP" != "yes"; then
644                         GEOIP_LIB="-L$WITH_GEOIP -lGeoIP"
645                         CPPFLAGS="$CPPFLAGS -I$WITH_GEOIP"
646                 else
647                         AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_addr, [
648                           AC_CHECK_HEADERS([GeoIP.h],[GEOIP_LIB=-lGeoIP])
649                         ])
650                 fi
652   if test x"$GEOIP_LIB" != x; then
653     AC_DEFINE([HAVE_GEOIP], [1], [libGeoIP])
654     AC_DEFINE([HAVE_GEOIP_H], [1])
655     AC_SUBST(GEOIP_LIB)
656   else
657     AC_MSG_ERROR([GeoIP headers and/or libs were not found, install them or build with --without-geoip])
658   fi
660 AM_CONDITIONAL(BUILD_WITH_GEOIP, test ! $WITH_GEOIP = no)
662 dnl Check for memcached
663 AC_MSG_CHECKING(for memcached)
664 AC_ARG_WITH(memcached, AC_HELP_STRING([--with-memcached],[memcached storage for mod_trigger_b4_dl]),
665 [WITH_MEMCACHED=$withval],[WITH_MEMCACHED=no])
666 AC_MSG_RESULT([$WITH_MEMCACHED])
668 if test "$WITH_MEMCACHED" != "no"; then
669                 if test "$WITH_MEMCACHED" != "yes"; then
670                         MEMCACHED_LIB="-L$WITH_MEMCACHED -lMEMCACHED"
671                         CPPFLAGS="$CPPFLAGS -I$WITH_MEMCACHED"
672                 else
673                         AC_CHECK_LIB(memcached, memcached, [
674                           AC_CHECK_HEADERS([libmemcached/memcached.h],[
675                             MEMCACHED_LIB=-lmemcached
676                           ])
677                         ])
678                 fi
680   if test x"$MEMCACHED_LIB" != x; then
681     AC_DEFINE([USE_MEMCACHED], [1], [libmemcached])
682     AC_SUBST(MEMCACHED_LIB)
683   else
684     AC_MSG_ERROR([memcached headers and/or libs were not found, install them or build with --without-memcached])
685   fi
687 AM_CONDITIONAL(BUILD_WITH_MEMCACHED, test ! $WITH_MEMCACHED = no)
689 AM_CONDITIONAL(BUILD_MOD_TRIGGER_B4_DL, test ! $WITH_MEMCACHED = no || test ! $WITH_GDBM = no)
691 dnl Check for lua
692 AC_MSG_CHECKING(if lua-support is requested)
693 AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[lua engine for mod_cml]),
694 [WITH_LUA=$withval],[WITH_LUA=no])
696 AC_MSG_RESULT($WITH_LUA)
697 if test "$WITH_LUA" != "no"; then
698   found_lua=0
699   if test "$WITH_LUA" != "yes"; then
700     PKG_CHECK_MODULES(LUA, $WITH_LUA >= 5.1, [
701       found_lua=1
702     ],[
703       AC_MSG_NOTICE([Couldn't find requested lua pkg-config module $WITH_LUA])
704     ])
705     if test "$found_lua" = "0"; then
706       LUA_LIBS="-L$WITH_LUA -llua"
707       LUA_CFLAGS="-I$WITH_LUA"
708     fi
709   else
710     for luaname in lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua; do
711       if test "$found_lua" = "0"; then
712         PKG_CHECK_MODULES(LUA, $luaname >= 5.1, [
713           found_lua=1
714         ], [
715           AC_MSG_NOTICE([Couldn't find $luaname])
716         ])
717       fi
718     done
719     if test "$found_lua" = "0"; then
720       AC_MSG_ERROR([Couldn't find any lua pkg-config module])
721     fi
722   fi
724   if test x"$LUA_LIBS" != x; then
725     AC_DEFINE([HAVE_LUA], [1], [liblua])
726     AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
727     AC_SUBST(LUA_LIBS)
728     AC_SUBST(LUA_CFLAGS)
729   else
730     AC_MSG_ERROR([lua headers and/or libs were not found, install them or build with --without-lua])
731   fi
733 AM_CONDITIONAL(BUILD_WITH_LUA, test ! $WITH_LUA = no)
735 dnl search for crypt_r and (fallback) for crypt
736 save_LIBS=$LIBS
737 LIBS=
738 AC_SEARCH_LIBS([crypt_r],[crypt],[
739   AC_DEFINE([HAVE_CRYPT_R], [1], [crypt_r])
740   AC_CHECK_HEADERS([crypt.h],[
741     AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
742   ])
744   CRYPT_LIB=$LIBS
746   AC_SEARCH_LIBS([crypt],[crypt],[
747     AC_DEFINE([HAVE_CRYPT], [1], [crypt])
748     AC_CHECK_HEADERS([crypt.h],[
749       AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
750     ])
752     CRYPT_LIB=$LIBS
753   ])
755 LIBS=$save_LIBS
756 AC_SUBST([CRYPT_LIB])
758 save_LIBS=$LIBS
759 AC_SEARCH_LIBS(sendfilev,sendfile,[
760   if test "$ac_cv_search_sendfilev" != no; then
761     test "$ac_cv_search_sendfilev" = "none required" || SENDFILE_LIB="$ac_cv_search_sendfilev"
762     AC_DEFINE([HAVE_SENDFILEV], [1], [solaris sendfilev])
763   fi
765 LIBS=$save_LIBS
766 AC_SUBST(SENDFILE_LIB)
768 case $host_os in
769         *mingw* ) LIBS="$LIBS -lwsock32";;
770         * ) ;;
771 esac
773 AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop inet_pton issetugid memset mmap munmap strchr \
774                   strdup strerror strstr strtol sendfile  getopt socket lstat \
775                   gethostbyname poll epoll_ctl getrlimit chroot \
776                   getuid select signal pathconf madvise posix_fadvise posix_madvise \
777                   writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
778                   memset_s explicit_bzero clock_gettime pipe2 \
779                   getentropy arc4random_buf jrand48 srandom getloadavg])
780 AC_CHECK_HEADERS([linux/random.h],[
781   AC_CHECK_FUNC([getrandom], AC_DEFINE([HAVE_GETRANDOM], [1], [getrandom]))
784 AC_MSG_CHECKING(if weak symbols are supported)
785 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
786                 __attribute__((weak)) void __dummy(void *x) { }
787                 void f(void *x) { __dummy(x); }
788         ]])],
789         [
790                 AC_MSG_RESULT(yes)
791                 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [weak symbols are supported])
792         ],[AC_MSG_RESULT(no)])
794 AC_MSG_CHECKING(for Large File System support)
795 AC_ARG_ENABLE(lfs,
796  AC_HELP_STRING([--enable-lfs],[Turn on Large File System (default)]),
797  [case "${enableval}" in
798    yes) CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES" ;;
799     no) ;;
800      *) AC_MSG_ERROR(bad value ${enableval} for --enable-lfs) ;;
801   esac],[CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
802          enable_lfs=yes])
803 AC_MSG_RESULT($enableval)
805 AC_CHECK_SIZEOF(long)
806 AC_CHECK_SIZEOF(off_t)
808 if test "x$ac_cv_func_sendfile" = xyes; then
809         dnl check if sendfile works
810         AC_MSG_CHECKING(if sendfile works)
811         if test "x$cross_compiling" = xno; then
812         AC_TRY_RUN([
813                     #ifdef HAVE_SYS_SENDFILE_H
814                     #include <sys/sendfile.h>
815                     #endif /* HAVE_SYS_SENDFILE_H */
816                     #include <errno.h>
817                     int main() {
818                       int o = 0;
819                       if (-1 == sendfile(-1, 0, &o, 0) && errno == ENOSYS) return -1;
820                       return 0;
821                     } ],
822                     AC_MSG_RESULT(yes),
823                     [ AC_MSG_RESULT(no)
824                     AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile]) ] )
825         else
826               AC_MSG_RESULT(no, cross-compiling)
827               AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile])
828         fi
831 dnl Check for IPv6 support
833 AC_ARG_ENABLE(ipv6,
834  AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
835  [case "${enableval}" in
836    yes) ipv6=true ;;
837     no) ipv6=false ;;
838      *) AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
839   esac],[ipv6=true])
841 if test x$ipv6 = xtrue; then
842   AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
843   [AC_TRY_LINK([ #include <sys/types.h>
844 #include <sys/socket.h>
845 #include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ],
846   [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
848   if test "$ac_cv_ipv6_support" = yes; then
849     AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
850   fi
853 # disable mmap by default; if a mmapped file gets truncated, the process gets a SIGBUS signal
854 # on reading the truncated area which we can't handle (yet).
855 # lighttpd may always use mmap with files it owns (created tmp files)
856 AC_ARG_ENABLE(mmap,
857   AC_HELP_STRING([--enable-mmap],[use mmap if available (DANGEROUS, allows local users to trigger SIGBUS crashes)]),
858   [case "${enableval}" in
859    yes) mmap=true ;;
860     no) mmap=false ;;
861      *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmap) ;;
862   esac],[mmap=false])
864 if test x$mmap = xtrue; then
865   AC_DEFINE(ENABLE_MMAP, [1], [Use mmap if available])
868 dnl check for fastcgi lib, for the tests only
869 fastcgi_found=no
870 AC_CHECK_LIB(fcgi, FCGI_Accept, [
871  AC_CHECK_HEADERS([fastcgi.h fastcgi/fastcgi.h],[
872    fastcgi_found=yes
873  ])
876 AM_CONDITIONAL(CHECK_WITH_FASTCGI, test "x$fastcgi_found" = xyes)
879 dnl check for extra compiler options (warning options)
880 if test "${GCC}" = "yes"; then
881   TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
882   TRY_CFLAGS([-std=gnu99])
885 AC_ARG_ENABLE(extra-warnings,
886  AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
887  [case "${enableval}" in
888    yes) extrawarnings=true ;;
889     no) extrawarnings=false ;;
890      *) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
891   esac],[extrawarnings=false])
893 if test x$extrawarnings = xtrue; then
894   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])
895   TRY_LDFLAGS([-Wl,--as-needed])
898 dnl build version-id
899 LIGHTTPD_VERSION_ID=`echo $PACKAGE_VERSION | $AWK -F '.' '{print "(" $1 " << 16 | " $2 " << 8 | " $3 ")"}'`
900 AC_DEFINE_UNQUOTED([LIGHTTPD_VERSION_ID], [$LIGHTTPD_VERSION_ID], [lighttpd-version-id])
902 AC_CONFIG_FILES([Makefile src/Makefile
903                  doc/config/conf.d/Makefile \
904                  doc/config/vhosts.d/Makefile \
905                  doc/config/Makefile \
906                  doc/scripts/Makefile \
907                  doc/initscripts/Makefile \
908                  doc/systemd/Makefile \
909                  doc/outdated/Makefile \
910                  doc/Makefile \
911                  tests/Makefile \
912                  tests/docroot/Makefile \
913                  tests/docroot/123/Makefile \
914                  tests/docroot/www/Makefile \
915                  tests/docroot/www/go/Makefile \
916                  tests/docroot/www/indexfile/Makefile \
917                  tests/docroot/www/expire/Makefile \
918                  distribute.sh])
919 AC_OUTPUT
922 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"
923 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"
925 plugins="mod_rewrite mod_redirect"
926 features="regex-conditionals"
927 if test ! "x$PCRE_LIB" = x; then
928         do_build="$do_build $plugins"
929         enable_feature="$features"
930 else
931         no_build="$no_build $plugins"
932         disable_feature="$features"
935 plugins="mod_trigger_b4_dl"
936 if test ! "x$PCRE_LIB" = x; then
937 if test ! "x$WITH_MEMCACHED" = xno || test ! "x$WITH_GDBM" = xno; then
938         do_build="$do_build $plugins"
939 else
940         no_build="$no_build $plugins"
944 plugins="mod_authn_mysql mod_mysql_vhost"
945 if test ! "x$MYSQL_LIBS" = x; then
946         do_build="$do_build $plugins"
947 else
948         no_build="$no_build $plugins"
951 plugins="mod_cml mod_magnet"
952 if test ! "x$LUA_LIBS" = x; then
953         do_build="$do_build $plugins"
954 else
955         no_build="$no_build $plugins"
958 plugins="mod_geoip"
959 if test ! "x$GEOIP_LIB" = x; then
960         do_build="$do_build $plugins"
961 else
962         no_build="$no_build $plugins"
965 features="storage-gdbm"
966 if test ! "x$GDBM_LIB" = x; then
967         enable_feature="$enable_feature $features"
968 else
969         disable_feature="$disable_feature $features"
972 features="storage-memcached"
973 if test ! "x$MEMCACHED_LIB" = x; then
974         enable_feature="$enable_feature $features"
975 else
976         disable_feature="$disable_feature $features"
979 features="compress-gzip compress-deflate"
980 if test ! "x$Z_LIB" = x; then
981         enable_feature="$enable_feature $features"
982 else
983         disable_feature="$disable_feature $features"
986 features="compress-bzip2"
987 if test ! "x$BZ_LIB" = x; then
988         enable_feature="$enable_feature $features"
989 else
990         disable_feature="$disable_feature $features"
993 plugins="mod_authn_gssapi"
994 if test ! "x$KRB5_LIB" = x; then
995         do_build="$do_build $plugins"
996 else
997         no_build="$no_build $plugins"
1000 plugins="mod_authn_ldap"
1001 if test ! "x$LDAP_LIB" = x; then
1002         do_build="$do_build $plugins"
1003 else
1004         no_build="$no_build $plugins"
1007 features="network-openssl"
1008 if test ! "x$SSL_LIB" = x; then
1009         enable_feature="$enable_feature $features"
1010 else
1011         disable_feature="$disable_feature $features"
1014 dnl no crypt call
1015 features="auth-crypt"
1016 if test "$ac_cv_search_crypt" = no; then
1017         disable_feature="$disable_feature $features"
1018 else
1019         enable_feature="$enable_feature $features"
1022 features="network-ipv6"
1023 if test "$ac_cv_ipv6_support" = yes; then
1024         enable_feature="$enable_feature $features"
1025 else
1026         disable_feature="$disable_feature $features"
1029 features="large-files"
1030 if test "$enable_lfs" = yes; then
1031         enable_feature="$enable_feature $features"
1032 else
1033         disable_feature="$disable_feature $features"
1036 features="stat-cache-fam"
1037 if test ! "x$FAM_LIBS" = x; then
1038         enable_feature="$enable_feature $features"
1039 else
1040         disable_feature="$disable_feature $features"
1043 features="webdav-properties"
1044 if test "x$XML_LIBS" \!= x -a "x$SQLITE_LIBS" \!= x; then
1045         enable_feature="$enable_feature $features"
1046 else
1047         disable_feature="$disable_feature $features"
1050 features="webdav-locks"
1051 if test "x$UUID_LIBS" \!= x; then
1052         enable_feature="$enable_feature $features"
1053 else
1054         disable_feature="$disable_feature $features"
1058 dnl output
1060 $ECHO
1061 $ECHO "Plugins:"
1062 $ECHO
1064 $ECHO "enabled: "
1065 for p in $do_build; do
1066         $ECHO "  $p"
1067 done | sort
1069 $ECHO "disabled: "
1070 for p in $no_build; do
1071         $ECHO "  $p"
1072 done | sort
1074 $ECHO
1075 $ECHO "Features:"
1076 $ECHO
1078 $ECHO "enabled: "
1079 for p in $enable_feature; do
1080         $ECHO "  $p"
1081 done | sort
1083 $ECHO "disabled: "
1084 for p in $disable_feature; do
1085         $ECHO "  $p"
1086 done | sort
1088 $ECHO