[core] use buffer_eq_icase* funcs
[lighttpd.git] / configure.ac
blob7eee7203f8cce2351b4ae0bba6c4df58fbb9ff38
1 dnl                                               -*- Autoconf -*-
2 dnl Process this file with autoconf to produce a configure script.
3 dnl
4 dnl Indentation rules:
5 dnl - closing braces not at the beginning of a line must match opening
6 dnl   braces earlier on that line
7 dnl - closing braces at the beginning of a line:
8 dnl   - must not be followed by anything else apart from "," or comments
9 dnl   - must match opening braces from another line and indented the
10 dnl     same as that other line
11 dnl - if one argument was put on a new line, all following arguments
12 dnl   must be on their own line too
13 dnl - if an argument uses more than one line and is not a single
14 dnl   function call, the argument should be on different lines than the
15 dnl   wrapping braces
16 AC_PREREQ(2.60)
17 AC_INIT([lighttpd], [1.4.55], [contact@lighttpd.net])
18 AC_CONFIG_SRCDIR([src/server.c])
19 AC_CONFIG_HEADER([config.h])
20 AC_CONFIG_MACRO_DIR([m4])
22 AC_CANONICAL_HOST
24 AM_INIT_AUTOMAKE([1.13 -Wall -Wno-portability -Wno-override foreign dist-xz tar-ustar serial-tests silent-rules subdir-objects])
26 dnl @synopsis TRY_CFLAGS [compiler flags]
27 dnl @summary check whether compiler supports given flags and adds them to CFLAGS
28 AC_DEFUN([TRY_CFLAGS],
29 [dnl
30   AC_MSG_CHECKING([if $CC supports $1])
31   AC_LANG_PUSH([C])
32   ac_try_cflags_saved_cflags="${CFLAGS}"
33   CFLAGS="${CFLAGS} $1"
34   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
35     [AC_MSG_RESULT([yes])],
36     [
37       AC_MSG_ERROR([no])
38       CFLAGS="${ac_try_cflags_saved_cflags}"
39     ]
40   )
41   AC_LANG_POP([C])
44 dnl @synopsis TRY_LDFLAGS [linker flags]
45 dnl @summary check whether linker supports given flags and adds them to LDFLAGS
46 AC_DEFUN([TRY_LDFLAGS],
47 [dnl
48   AC_MSG_CHECKING([if $LD supports $1])
49   AC_LANG_PUSH([C])
50   ac_try_ldflags_saved_ldflags="${LDFLAGS}"
51   LDFLAGS="${LDFLAGS} $1"
52   AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
53     [AC_MSG_RESULT([yes])],
54     [
55       AC_MSG_ERROR([no])
56       LDFLAGS="${ac_try_ldflags_saved_cflags}"
57     ]
58   )
59   AC_LANG_POP([C])
62 dnl Checks for programs.
63 AC_PROG_CC
64 AC_PROG_CC_STDC
65 AX_PROG_CC_FOR_BUILD
66 AC_PROG_LD
67 AC_PROG_INSTALL
68 AC_PROG_CPP
69 AC_PROG_MAKE_SET
71 AC_USE_SYSTEM_EXTENSIONS
72 AM_PROG_AR
74 dnl AC_CANONICAL_HOST
75 case "$host_os" in
76 *darwin*|*cygwin*|*aix*|*mingw*|*midipix* ) NO_RDYNAMIC=yes ;;
77 * ) NO_RDYNAMIC=no ;;
78 esac
79 AM_CONDITIONAL([NO_RDYNAMIC], [test "$NO_RDYNAMIC" = yes])
81 AM_CONDITIONAL([LIGHTTPD_STATIC], [test "$LIGHTTPD_STATIC" = yes])
83 AC_EXEEXT
85 dnl libtool
86 AC_DISABLE_STATIC
87 AC_ENABLE_SHARED
89 AC_LIBTOOL_DLOPEN
90 AC_PROG_LIBTOOL
92 dnl for solaris
93 CPPFLAGS="${CPPFLAGS} -D_REENTRANT"
95 dnl Checks for header files.
97 dnl check for:
98 dnl   inttypes.h => HAVE_INTTYPES_H
99 dnl   stdint.h => HAVE_STDINT_H
100 dnl and maybe more (which shouldn't be relied on)
101 AC_HEADER_STDC
102 dnl checks for sys/wait.h => HAVE_SYS_WAIT_H
103 AC_HEADER_SYS_WAIT
104 AC_CHECK_HEADERS([\
105   getopt.h \
106   poll.h \
107   port.h \
108   pwd.h \
109   stdlib.h \
110   strings.h \
111   sys/devpoll.h \
112   sys/epoll.h \
113   sys/event.h \
114   sys/filio.h \
115   sys/mman.h \
116   sys/poll.h \
117   sys/prctl.h \
118   sys/resource.h \
119   sys/select.h \
120   sys/sendfile.h \
121   sys/time.h \
122   sys/uio.h \
123   sys/un.h \
124   syslog.h \
125   uuid/uuid.h \
128 dnl Checks for typedefs, structures, and compiler characteristics.
129 AC_C_CONST
130 AC_C_INLINE
131 AC_TYPE_OFF_T
132 AC_TYPE_PID_T
133 AC_TYPE_SIZE_T
135 AC_CHECK_MEMBER([struct tm.tm_gmtoff],
136   [AC_DEFINE([HAVE_STRUCT_TM_GMTOFF], [1], [gmtoff in struct tm])],
137   [],
138   [#include <time.h>]
140 AC_CHECK_TYPES([socklen_t],
141   [], dnl defines HAVE_SOCKLEN_T
142   [],
143   [
144     #include <sys/types.h>
145     #include <sys/socket.h>
146   ]
149 dnl openssl on solaris needs -lsocket -lnsl
150 AC_SEARCH_LIBS([socket], [socket])
151 AC_SEARCH_LIBS([gethostbyname], [nsl socket])
153 dnl On Haiku accept() and friends are in libnetwork
154 AC_SEARCH_LIBS([accept], [network])
156 dnl clock_gettime() needs -lrt with glibc < 2.17, and possibly other platforms
157 AC_SEARCH_LIBS([clock_gettime], [rt])
159 dnl FreeBSD elftc_copyfile()
160 save_LIBS=$LIBS
161 LIBS=
162 AC_SEARCH_LIBS([elftc_copyfile], [elftc], [
163   AC_CHECK_HEADERS([libelftc.h], [
164     ELFTC_LIB=$LIBS
165     AC_DEFINE([HAVE_LIBELFTC], [1], [libelftc])
166     AC_DEFINE([HAVE_ELFTC_COPYFILE], [1], [elftc_copyfile])
167   ])
169 LIBS=$save_LIBS
170 AC_SUBST([ELFTC_LIB])
172 dnl need dlopen/-ldl to load plugins (when not on windows)
173 save_LIBS=$LIBS
174 LIBS=
175 AC_SEARCH_LIBS([dlopen], [dl], [
176   AC_CHECK_HEADERS([dlfcn.h], [
177     DL_LIB=$LIBS
178     AC_DEFINE([HAVE_LIBDL], [1], [libdl])
179     AC_DEFINE([HAVE_DLFCN_H], [1])
180   ])
182 LIBS=$save_LIBS
183 AC_SUBST([DL_LIB])
185 dnl prepare pkg-config usage below
186 PKG_PROG_PKG_CONFIG
188 dnl checking for libev
189 AC_MSG_NOTICE([----------------------------------------])
190 AC_MSG_CHECKING([for libev support])
191 AC_ARG_WITH([libev],
192   [AC_HELP_STRING([--with-libev@<:@=PATH@:>@],
193     [Include libev support for fdevent handlers in PATH/include and PATH/lib]
194   )],
195   [WITH_LIBEV=$withval],
196   [WITH_LIBEV=no]
198 AC_MSG_RESULT([$WITH_LIBEV])
200 LIBEV_CFLAGS=
201 LIBEV_LIBS=
203 if test "$WITH_LIBEV" != no; then
204   PKG_CHECK_MODULES([LIBEV], [libev], [], [
205     dnl no pkg-config for libev, searching manually:
207     if test "$WITH_LIBEV" != yes; then
208       LIBEV_CFLAGS="-I$WITH_LIBEV/include"
209       LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
210     else
211       AC_CHECK_HEADERS([ev.h],
212         [AC_CHECK_LIB([ev], [ev_time],
213           [
214             LIBEV_CFLAGS=
215             LIBEV_LIBS="-lev"
216           ],
217           [AC_MSG_ERROR([libev not found])]
218         )],
219         [AC_MSG_ERROR([libev header not found])]
220       )
221     fi
222   ])
224   AC_DEFINE([HAVE_LIBEV], [1], [libev support])
227 AC_SUBST([LIBEV_CFLAGS])
228 AC_SUBST([LIBEV_LIBS])
230 dnl Checks for mysql
231 AC_MSG_NOTICE([----------------------------------------])
232 AC_MSG_CHECKING([for MySQL support])
233 AC_ARG_WITH([mysql],
234   [AC_HELP_STRING([--with-mysql@<:@=PATH@:>@],
235     [Include MySQL support. PATH is the path to 'mysql_config']
236   )],
237   [WITH_MYSQL=$withval],
238   [WITH_MYSQL=no]
240 AC_MSG_RESULT([$WITH_MYSQL])
242 MYSQL_CFLAGS=
243 MYSQL_LIBS=
245 if test "$WITH_MYSQL" != no; then
246   if test "$WITH_MYSQL" = yes; then
247     PKG_CHECK_MODULES([MYSQL],[mariadb],[
248       MYSQL_CONFIG=$PKG_CONFIG
249     ],[
250       PKG_CHECK_MODULES([MYSQL],[mysqlclient],[
251         MYSQL_CONFIG=$PKG_CONFIG
252       ],[
253         AC_PATH_PROG([MYSQL_CONFIG], [mysql_config])
254       ])
255     ])
256   else
257     MYSQL_CONFIG=$WITH_MYSQL
258   fi
260   if test "$MYSQL_CONFIG" != "$PKG_CONFIG"; then
261     if test -z "$MYSQL_CONFIG"; then
262       AC_MSG_ERROR([mysql_config is not found])
263     fi
264     if test ! -x "$MYSQL_CONFIG"; then
265       AC_MSG_ERROR([mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config])
266     fi
268     if "$MYSQL_CONFIG" | grep -- '--include' > /dev/null ; then
269       MYSQL_CFLAGS=`"$MYSQL_CONFIG" --include | sed s/\'//g`
270     else
271       MYSQL_CFLAGS=`"$MYSQL_CONFIG" --cflags | sed s/\'//g`
272     fi
273     MYSQL_LIBS=`"$MYSQL_CONFIG" --libs | sed s/\'//g`
274   fi
276   AC_MSG_CHECKING([for MySQL includes at])
277   AC_MSG_RESULT([$MYSQL_CFLAGS])
279   AC_MSG_CHECKING([for MySQL libraries at])
280   AC_MSG_RESULT([$MYSQL_LIBS])
282   AC_DEFINE([HAVE_MYSQL], [1], [mysql support])
284 AM_CONDITIONAL([BUILD_WITH_MYSQL], [test "$WITH_MYSQL" != no])
286 AC_SUBST([MYSQL_LIBS])
287 AC_SUBST([MYSQL_CFLAGS])
289 dnl Checks for pgsql
290 AC_MSG_NOTICE([----------------------------------------])
291 AC_MSG_CHECKING([for PgSQL support])
292 AC_ARG_WITH([pgsql],
293   [AC_HELP_STRING([--with-pgsql@<:@=PATH@:>@],
294     [Include PgSQL support. PATH is the path to 'pg_config']
295   )],
296   [WITH_PGSQL=$withval],
297   [WITH_PGSQL=no]
299 AC_MSG_RESULT([$WITH_PGSQL])
301 PGSQL_INCLUDE=
302 PGSQL_LIBS=
304 if test "$WITH_PGSQL" != no; then
305   if test "$WITH_PGSQL" = yes; then
306     AC_PATH_PROG([PGSQL_CONFIG], [pg_config])
307   else
308     PGSQL_CONFIG=$WITH_PGSQL
309   fi
311   if test -z "$PGSQL_CONFIG"; then
312     AC_MSG_ERROR([pg_config is not found])
313   fi
314   if test ! -x "$PGSQL_CONFIG"; then
315     AC_MSG_ERROR([pg_config not exists or not executable, use --with-pgsql=path-to-pg_config])
316   fi
318   PGSQL_INCLUDE="-I`"$PGSQL_CONFIG" --includedir`"
319   PGSQL_LIBS="-L`"$PGSQL_CONFIG" --libdir` -lpq"
321   AC_MSG_CHECKING([for PgSQL includes at])
322   AC_MSG_RESULT([$PGSQL_INCLUDE])
324   AC_MSG_CHECKING([for PgSQL libraries at])
325   AC_MSG_RESULT([$PGSQL_LIBS])
327   AC_DEFINE([HAVE_PGSQL], [1], [pgsql support])
329 AM_CONDITIONAL([BUILD_WITH_PGSQL], [test "$WITH_PGSQL" != no])
331 AC_SUBST([PGSQL_LIBS])
332 AC_SUBST([PGSQL_INCLUDE])
334 dnl Checks for libdbi library
335 AC_MSG_NOTICE([----------------------------------------])
336 AC_MSG_CHECKING([for LibDBI support])
337 AC_ARG_WITH([dbi],
338   [AC_HELP_STRING([--with-dbi@<:@=PATH@:>@],
339     [Include DBI support in PATH/include/dbi.h and PATH/lib]
340   )],
341   [WITH_DBI=$withval],
342   [WITH_DBI=no]
344 AC_MSG_RESULT([$WITH_DBI])
346 DBI_INCLUDE=
347 DBI_LIBS=
349 if test "$WITH_DBI" != no; then
350   if test "$WITH_DBI" != yes; then
351     DBI_CFLAGS="-I$WITH_DBI/include"
352     DBI_LIBS="-L$WITH_DBI/lib -ldbi"
353   else
354     AC_CHECK_HEADERS([dbi/dbi.h],
355       [AC_CHECK_LIB([dbi], [dbi_version],
356         [
357           DBI_CFLAGS=
358           DBI_LIBS="-ldbi"
359         ],
360         [AC_MSG_ERROR([LibDBI not found])]
361       )],
362       [AC_MSG_ERROR([LibDBI header not found])]
363     )
364   fi
366   AC_DEFINE([HAVE_DBI], [1], [LibDBI support])
368 AM_CONDITIONAL([BUILD_WITH_DBI], [test "$WITH_DBI" != no])
370 AC_SUBST([DBI_LIBS])
371 AC_SUBST([DBI_CFLAGS])
373 dnl Checks for libsasl2 library
374 AC_MSG_NOTICE([----------------------------------------])
375 AC_MSG_CHECKING([for LibSASL support])
376 AC_ARG_WITH([sasl],
377   [AC_HELP_STRING([--with-sasl@<:@=PATH@:>@],
378     [Include SASL support in PATH/include/sasl/sasl.h and PATH/lib]
379   )],
380   [WITH_SASL=$withval],
381   [WITH_SASL=no]
383 AC_MSG_RESULT([$WITH_SASL])
385 SASL_INCLUDE=
386 SASL_LIBS=
388 if test "$WITH_SASL" != no; then
389   if test "$WITH_SASL" != yes; then
390     SASL_CFLAGS="-I$WITH_SASL/include"
391     SASL_LIBS="-L$WITH_SASL/lib -lsasl2"
392   else
393     AC_CHECK_HEADERS([sasl/sasl.h],
394       [AC_CHECK_LIB([sasl2], [sasl_server_init],
395         [
396           SASL_CFLAGS=
397           SASL_LIBS="-lsasl2"
398         ],
399         [AC_MSG_ERROR([libsasl2 not found])]
400       )],
401       [AC_MSG_ERROR([SASL header not found])]
402     )
403   fi
405   AC_DEFINE([HAVE_SASL], [1], [LibSASL support])
407 AM_CONDITIONAL([BUILD_WITH_SASL], [test "$WITH_SASL" != no])
409 AC_SUBST([SASL_LIBS])
410 AC_SUBST([SASL_CFLAGS])
413 dnl Check for LDAP
414 AC_MSG_NOTICE([----------------------------------------])
415 AC_MSG_CHECKING([for LDAP support])
416 AC_ARG_WITH([ldap],
417   [AC_HELP_STRING([--with-ldap], [enable LDAP support])],
418   [WITH_LDAP=$withval],
419   [WITH_LDAP=no]
421 AC_MSG_RESULT([$WITH_LDAP])
423 if test "$WITH_LDAP" != no; then
424   AC_CHECK_LIB([ldap], [ldap_sasl_bind_s],
425     [AC_CHECK_HEADERS([ldap.h],
426       [
427         LDAP_LIB=-lldap
428         AC_DEFINE([HAVE_LIBLDAP], [1], [libldap])
429         AC_DEFINE([HAVE_LDAP_H], [1])
430       ],
431       [AC_MSG_ERROR([ldap headers not found, install them or build without --with-ldap])]
432     )],
433     [AC_MSG_ERROR([ldap library not found, install it or build without --with-ldap])]
434   )
435   AC_SUBST([LDAP_LIB])
436   AC_CHECK_LIB([lber], [ber_printf],
437     [AC_CHECK_HEADERS([lber.h],
438       [
439         LBER_LIB=-llber
440         AC_DEFINE([HAVE_LIBLBER], [1], [liblber])
441         AC_DEFINE([HAVE_LBER_H], [1])
442       ],
443       [AC_MSG_ERROR([lber headers not found, install them or build without --with-ldap])]
444     )],
445     [AC_MSG_ERROR([lber library not found, install it or build without --with-ldap])]
446   )
447   AC_SUBST([LBER_LIB])
449 AM_CONDITIONAL([BUILD_WITH_LDAP], [test "$WITH_LDAP" != no])
451 dnl Check for PAM
452 AC_MSG_NOTICE([----------------------------------------])
453 AC_MSG_CHECKING(for PAM support)
454 AC_ARG_WITH([pam],
455   [AC_HELP_STRING([--with-pam],[enable PAM support])],
456   [WITH_PAM=$withval],
457   [WITH_PAM=no]
459 AC_MSG_RESULT([$withval])
461 if test "$WITH_PAM" != "no"; then
462   AC_CHECK_LIB([pam], [pam_start],
463     [AC_CHECK_HEADERS([security/pam_appl.h],[
464       PAM_LIB=-lpam
465       AC_DEFINE([HAVE_PAM], [1], [libpam])
466       AC_DEFINE([HAVE_SECURITY_PAM_APPL_H], [1])
467       ],
468       [AC_MSG_ERROR([pam headers not found, install them or build without --with-pam])]
469     )],
470     [AC_MSG_ERROR([pam library not found, install it or build without --with-pam])]
471   )
472   AC_SUBST(PAM_LIB)
474 AM_CONDITIONAL([BUILD_WITH_PAM], [test "$WITH_PAM" != no])
476 dnl Check for xattr
477 AC_MSG_NOTICE([----------------------------------------])
478 AC_MSG_CHECKING([for extended attributes support])
479 AC_ARG_WITH([attr],
480   [AC_HELP_STRING([--with-attr], [enable extended attribute support])],
481   [WITH_ATTR=$withval],
482   [WITH_ATTR=no]
484 AC_MSG_RESULT([$WITH_ATTR])
486 if test "$WITH_ATTR" != no; then
487   have_xattr=no
488   # libattr (linux only?)
489   AC_CHECK_LIB([attr], [attr_get], [
490     AC_CHECK_HEADERS([attr/attributes.h], [
491       ATTR_LIB=-lattr
492       AC_DEFINE([HAVE_XATTR], [1], [libattr])
493       AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
494       have_xattr=yes
495     ])
496   ])
497   AC_SUBST([ATTR_LIB])
499   # (Free)BSD extattr
500   AC_CHECK_FUNC([extattr_get_file], [
501     AC_CHECK_HEADERS([sys/extattr.h], [
502       AC_DEFINE([HAVE_EXTATTR], [1], [BSD extended attributes])
503       AC_DEFINE([HAVE_SYS_EXTATTR_H], [1])
504       have_xattr=yes
505     ])
506   ])
508   if test "$have_xattr" = no; then
509     AC_MSG_ERROR([no backend found implementing extended attributes])
510   fi
513 dnl Check for valgrind
514 AC_MSG_NOTICE([----------------------------------------])
515 AC_MSG_CHECKING([for valgrind])
516 AC_ARG_WITH([valgrind],
517   [AC_HELP_STRING([--with-valgrind],
518     [enable internal support for valgrind]
519   )],
520   [WITH_VALGRIND=$withval],
521   [WITH_VALGRIND=no]
523 AC_MSG_RESULT([$WITH_VALGRIND])
525 if test "$WITH_VALGRIND" != no; then
526   AC_CHECK_HEADERS([valgrind/valgrind.h], [], [
527     AC_MSG_ERROR([valgrind headers not found. install them or build without --with-valgrind])
528   ])
531 dnl Checking for libunwind
532 AC_MSG_NOTICE([----------------------------------------])
533 AC_MSG_CHECKING([for libunwind])
534 AC_ARG_WITH([libunwind],
535   [AC_HELP_STRING([--with-libunwind],
536     [Include libunwind support for backtraces on assert failures]
537   )],
538   [WITH_LIBUNWIND=$withval],
539   [WITH_LIBUNWIND=no]
541 AC_MSG_RESULT([$WITH_LIBUNWIND])
543 if test "$WITH_LIBUNWIND" != no; then
544   PKG_CHECK_MODULES([LIBUNWIND], [libunwind], [], [
545     AC_MSG_ERROR([libunwind not found. install it or build without --with-libunwind])
546   ])
547   AC_DEFINE([HAVE_LIBUNWIND], [1], [Have libunwind support])
550 dnl Checking for kerberos5
551 AC_MSG_NOTICE([----------------------------------------])
552 AC_MSG_CHECKING([for kerberos5])
553 AC_ARG_WITH([krb5],
554   [AC_HELP_STRING([--with-krb5@<:@=DIR@:>@], [Use Kerberos 5])],
555   [WITH_KRB5=$withval],
556   [WITH_KRB5=no]
558 AC_MSG_RESULT([$WITH_KRB5])
560 if test "$WITH_KRB5" != no; then
561   if test "$WITH_KRB5" != yes; then
562     krb5_append_CPPFLAGS=" -I$WITH_KRB5/include"
563     krb5_append_LDFLAGS=" -L$WITH_KRB5/lib"
564   fi
567 AC_MSG_CHECKING([custom include directory for kerberos5])
568 AC_ARG_WITH([krb5-includes],
569   [AC_HELP_STRING([--with-krb5-includes=DIR], [Kerberos includes])],
570   [
571     if test "$WITH_KRB5" = no; then
572       AC_MSG_ERROR([build --with-krb5 to use --with-krb5-includes])
573     fi
574     krb5_append_CPPFLAGS=" -I$withval"
575     AC_MSG_RESULT([$withval])
576   ],
577   [AC_MSG_RESULT([no])]
580 AC_MSG_CHECKING([custom lib directory for kerberos5])
581 AC_ARG_WITH([krb5-libs],
582   [AC_HELP_STRING([--with-krb5-libs=DIR], [Kerberos libraries])],
583   [
584     if test "$WITH_KRB5" = no; then
585       AC_MSG_ERROR([build --with-krb5 to use --with-krb5-libs])
586     fi
587     krb5_append_LDFLAGS=" -L$withval"
588     AC_MSG_RESULT([$withval])
589   ],
590   [AC_MSG_RESULT([no])]
593 if test "$WITH_KRB5" != no; then
594   CPPFLAGS="${CPPFLAGS}${krb5_append_CPPFLAGS}"
595   LDFLAGS="${LDFLAGS}${krb5_append_LDFLAGS}"
597   AC_CHECK_LIB([gssapi_krb5], [gss_acquire_cred],
598     [AC_CHECK_HEADERS([gssapi/gssapi_krb5.h],
599       [
600         KRB5_LIB="-lkrb5 -lgssapi_krb5"
601         AC_DEFINE([HAVE_KRB5], [1], [libgssapi_krb5])
602       ],
603       [AC_MSG_ERROR([gssapi_krb5 headers were not found, install them or build without --with-krb5])]
604     )],
605     [AC_MSG_ERROR([gssapi_krb5 libs were not found, install them or build without --with-krb5])]
606   )
607   case "$host_os" in
608   *darwin*|*cygwin* ) KRB5_LIB="$KRB5_LIB -lcom_err" ;;
609   * ) ;;
610   esac
613 AM_CONDITIONAL([BUILD_WITH_KRB5], [test "$WITH_KRB5" != no])
614 AC_SUBST([KRB5_LIB])
616 dnl Check for openssl
617 AC_MSG_NOTICE([----------------------------------------])
618 AC_MSG_CHECKING([for OpenSSL])
619 AC_ARG_WITH([openssl],
620   [AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],
621     [Include openssl support (default no)]
622   )],
623   [WITH_OPENSSL=$withval],
624   [WITH_OPENSSL=no]
626 AC_MSG_RESULT([$WITH_OPENSSL])
628 if test "$WITH_OPENSSL" != no; then
629   if test "$WITH_OPENSSL" != yes; then
630     openssl_append_CPPFLAGS=" -I$WITH_OPENSSL/include"
631     openssl_append_LDFLAGS=" -L$WITH_OPENSSL/lib"
632   fi
635 AC_MSG_CHECKING([custom include directory for openssl])
636 AC_ARG_WITH([openssl-includes],
637   [AC_HELP_STRING([--with-openssl-includes=DIR], [OpenSSL includes])],
638   [
639     if test "$WITH_OPENSSL" = no; then
640       AC_MSG_ERROR([build --with-openssl to use --with-openssl-includes])
641     fi
642     openssl_append_CPPFLAGS=" -I$withval"
643     AC_MSG_RESULT([$withval])
644   ],
645   [AC_MSG_RESULT([no])]
648 AC_MSG_CHECKING([custom lib directory for openssl])
649 AC_ARG_WITH([openssl-libs],
650   [AC_HELP_STRING([--with-openssl-libs=DIR], [OpenSSL libraries])],
651   [
652     if test "$WITH_OPENSSL" = no; then
653       AC_MSG_ERROR([build --with-openssl to use --with-openssl-libs])
654     fi
655     openssl_append_LDFLAGS=" -L$withval"
656     AC_MSG_RESULT([$withval])
657   ],
658   [AC_MSG_RESULT([no])]
661 if test "$WITH_OPENSSL" != no; then
662   if test "$WITH_KRB5" != no; then
663     AC_DEFINE([USE_OPENSSL_KERBEROS], [1], [with kerberos])
664   fi
666   CPPFLAGS="${CPPFLAGS}${openssl_append_CPPFLAGS}"
667   LDFLAGS="${LDFLAGS}${openssl_append_LDFLAGS}"
669   AC_CHECK_HEADERS([openssl/ssl.h], [], [
670     AC_MSG_ERROR([openssl headers not found. install them or build without --with-openssl])
671   ])
672   AC_CHECK_LIB([crypto], [BIO_f_base64],
673     [CRYPTO_LIB="-lcrypto"],
674     [AC_MSG_ERROR([openssl crypto library not found. install it or build without --with-openssl])]
675   )
676   AC_CHECK_LIB([ssl], [SSL_new],
677     [SSL_LIB="-lssl -lcrypto"],
678     [AC_MSG_ERROR([openssl ssl library not found. install it or build without --with-openssl])],
679     [ -lcrypto "$DL_LIB" ]
680   )
682   AC_DEFINE([HAVE_LIBSSL], [], [Have libssl])
683   AC_SUBST([SSL_LIB])
684   AC_SUBST([CRYPTO_LIB])
687 dnl Check for wolfSSL
688 AC_MSG_NOTICE([----------------------------------------])
689 AC_MSG_CHECKING([for wolfSSL])
690 AC_ARG_WITH([wolfssl],
691   [AC_HELP_STRING([--with-wolfssl@<:@=DIR@:>@],
692     [Include openssl support (default no)]
693   )],
694   [WITH_WOLFSSL=$withval],
695   [WITH_WOLFSSL=no]
697 AC_MSG_RESULT([$WITH_WOLFSSL])
699 if test "$WITH_WOLFSSL" != no; then
700   if test "$WITH_WOLFSSL" = yes; then
701     WITH_WOLFSSL="/usr/local"
702   fi
704   CPPFLAGS="${CPPFLAGS} -I$WITH_WOLFSSL/include -I$WITH_WOLFSSL/include/wolfssl"
705   LDFLAGS="${LDFLAGS} -L$WITH_WOLFSSL/lib"
707   AC_CHECK_HEADERS([wolfssl/ssl.h], [], [
708     AC_MSG_ERROR([wolfssl headers not found. install them or build without --with-wolfssl])
709   ])
710   AC_CHECK_LIB([wolfssl], [wolfSSL_Init],
711     [CRYPTO_LIB="-lwolfssl"],
712     [AC_MSG_ERROR([wolfssl crypto library not found. install it or build without --with-wolfssl])]
713   )
714   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
715     #include <wolfssl/options.h>
716     #if !defined(HAVE_LIGHTY) && !defined(OPENSSL_ALL)
717     #error HAVE_LIGHTY macro not defined
718     #endif
719   ]])], [], [AC_MSG_ERROR([wolfssl must be built with ./configure --enable-lighty])])
720   SSL_LIB="-lwolfssl"
722   AC_SUBST([SSL_LIB])
723   AC_SUBST([CRYPTO_LIB])
726 AM_CONDITIONAL([BUILD_WITH_OPENSSL],
727                [test "$WITH_OPENSSL" != no || test "$WITH_WOLFSSL" != no])
729 if test "$WITH_OPENSSL" != no && test "$WITH_WOLFSSL" != no; then
730   AC_MSG_ERROR([lighttpd should not be built with both --with-openssl and --with-wolfssl])
734 dnl pcre support
735 AC_MSG_NOTICE([----------------------------------------])
736 AC_MSG_CHECKING([for perl regular expressions support])
737 AC_ARG_WITH([pcre],
738   [AC_HELP_STRING([--with-pcre], [Enable pcre support (default yes)])],
739   [WITH_PCRE=$withval],
740   [WITH_PCRE=yes]
742 AC_MSG_RESULT([$WITH_PCRE])
744 if test "$WITH_PCRE" != no; then
745   if test "$WITH_PCRE" != yes; then
746     PCRE_LIB="-L$WITH_PCRE/lib -lpcre"
747     CPPFLAGS="$CPPFLAGS -I$WITH_PCRE/include"
748   else
749     AC_PATH_PROG([PCRECONFIG], [pcre-config])
750     if test -n "$PCRECONFIG"; then
751       PCRE_LIB=`"$PCRECONFIG" --libs`
752       CPPFLAGS="$CPPFLAGS `"$PCRECONFIG" --cflags`"
753     fi
754   fi
756   if test -z "$PCRE_LIB"; then
757     AC_MSG_ERROR([pcre-config not found, install the pcre-devel package or build with --without-pcre])
758   fi
760   AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre])
761   AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h])
762   AC_SUBST([PCRE_LIB])
765 dnl zlib
766 AC_MSG_NOTICE([----------------------------------------])
767 AC_MSG_CHECKING([for zlib support])
768 AC_ARG_WITH([zlib],
769   [AC_HELP_STRING([--with-zlib],
770     [Enable zlib support for mod_compress]
771   )],
772   [WITH_ZLIB=$withval],
773   [WITH_ZLIB=yes]
775 AC_MSG_RESULT([$WITH_ZLIB])
777 if test "$WITH_ZLIB" != no; then
778   if test "$WITH_ZLIB" != yes; then
779     Z_LIB="-L$WITH_ZLIB -lz"
780     CPPFLAGS="$CPPFLAGS -I$WITH_ZLIB"
781   else
782     AC_CHECK_HEADERS([zlib.h], [],
783       [AC_MSG_ERROR([zlib headers not found, install them or build without --with-zlib])]
784     )
785     AC_CHECK_LIB([z], [deflate],
786       [Z_LIB=-lz],
787       [AC_MSG_ERROR([zlib library not found, install it or build without --with-zlib])]
788     )
789   fi
791   AC_DEFINE([HAVE_LIBZ], [1], [libz])
792   AC_DEFINE([HAVE_ZLIB_H], [1])
793   AC_SUBST([Z_LIB])
796 dnl bzip2
797 AC_MSG_NOTICE([----------------------------------------])
798 AC_MSG_CHECKING([for bzip2 support])
799 AC_ARG_WITH([bzip2],
800   [AC_HELP_STRING([--with-bzip2],
801     [Enable bzip2 support for mod_compress]
802   )],
803   [WITH_BZIP2=$withval],
804   [WITH_BZIP2=yes]
806 AC_MSG_RESULT([$WITH_BZIP2])
808 if test "$WITH_BZIP2" != no; then
809   if test "$WITH_BZIP2" != yes; then
810     BZ_LIB="-L$WITH_BZIP2 -lbz2"
811     CPPFLAGS="$CPPFLAGS -I$WITH_BZIP2"
812   else
813     AC_CHECK_HEADERS([bzlib.h], [], [
814       AC_MSG_ERROR([bzip2 headers not found, install them or build without --with-bzip2])
815     ])
816     AC_CHECK_LIB([bz2], [BZ2_bzCompress],
817       [BZ_LIB=-lbz2],
818       [AC_MSG_ERROR([bzip2 library not found, install it or build without --with-bzip2])]
819     )
820   fi
822   AC_DEFINE([HAVE_LIBBZ2], [1], [libbz2])
823   AC_DEFINE([HAVE_BZLIB_H], [1])
824   AC_SUBST([BZ_LIB])
827 dnl Check for fam/gamin
828 AC_MSG_NOTICE([----------------------------------------])
829 AC_MSG_CHECKING([for FAM])
830 AC_ARG_WITH([fam],
831   [AC_HELP_STRING([--with-fam],
832     [fam/gamin for reducing number of stat() calls]
833   )],
834   [WITH_FAM=$withval],
835   [WITH_FAM=no]
837 AC_MSG_RESULT([$WITH_FAM])
839 if test "$WITH_FAM" != no; then
840   if test "$WITH_FAM" != yes; then
841     FAM_LIBS="-L$WITH_FAM -lfam"
842     CPPFLAGS="$CPPFLAGS -I$WITH_FAM"
843   else
844     AC_CHECK_LIB([fam], [FAMOpen2], [
845       AC_CHECK_HEADERS([fam.h], [FAM_LIBS=-lfam])
846     ])
847     dnl fam has no pkg-config so far, so just search for gamin as fallback
848     if test -z "$FAM_LIBS"; then
849       PKG_CHECK_MODULES([FAM], [gamin >= 0.1.0])
850     fi
851   fi
853   if test -z "$FAM_LIBS"; then
854     AC_MSG_ERROR([fam/gamin headers and/or libs were not found, install them or build without --with-fam])
855   fi
857   OLD_LIBS=$LIBS
858   LIBS=$FAM_LIBS
859   AC_CHECK_FUNCS([FAMNoExists])
860   LIBS=$OLD_LIBS
862   AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
863   AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
864   AC_SUBST([FAM_LIBS])
868 dnl webdav props (xml2 and sqlite3)
869 AC_MSG_NOTICE([----------------------------------------])
870 AC_MSG_CHECKING([for properties in mod_webdav])
871 AC_ARG_WITH([webdav-props],
872   [AC_HELP_STRING([--with-webdav-props], [properties in mod_webdav])],
873   [WITH_WEBDAV_PROPS=$withval],
874   [WITH_WEBDAV_PROPS=no]
876 AC_MSG_RESULT([$WITH_WEBDAV_PROPS])
878 if test "$WITH_WEBDAV_PROPS" != no; then
879   AC_MSG_CHECKING([for libxml2])
880   AC_ARG_WITH([libxml],
881     [AC_HELP_STRING([--with-libxml],
882       [libxml2 for properties in mod_webdav]
883     )],
884     [WITH_LIBXML=$withval],
885     [WITH_LIBXML=yes]
886   )
887   AC_MSG_RESULT([$WITH_LIBXML])
889   if test "$WITH_LIBXML" = no; then
890     AC_MSG_ERROR([--with-webdav-props requires libxml])
891   fi
893   if test "$WITH_LIBXML" != yes; then
894     XML_LIBS="-L$WITH_LIBXML/.libs -lxml2"
895     XML_CFLAGS="-I$WITH_LIBXML/include"
896   else
897     PKG_CHECK_MODULES([XML], [libxml-2.0], [], [
898       AC_MSG_ERROR([libxml2 not found, install it or build without --with-webdav-props])
899     ])
900   fi
902   AC_DEFINE([HAVE_LIBXML2], [1], [libxml2])
903   AC_DEFINE([HAVE_LIBXML_H], [1], [libxml.h])
904   AC_SUBST([XML_LIBS])
905   AC_SUBST([XML_CFLAGS])
907   AC_MSG_CHECKING([for sqlite])
908   AC_ARG_WITH([sqlite],
909     [AC_HELP_STRING([--with-sqlite],
910       [sqlite for properties in mod_webdav]
911     )],
912     [WITH_SQLITE=$withval],
913     [WITH_SQLITE=yes]
914   )
915   AC_MSG_RESULT([$WITH_SQLITE])
917   if test "$WITH_SQLITE" = no; then
918     AC_MSG_ERROR([--with-webdav-props requires sqlite])
919   fi
921   if test "$WITH_SQLITE" != yes; then
922     SQLITE_LIBS="-L$WITH_SQLITE/.libs -lsqlite3"
923     SQLITE_CFLAGS="-I$WITH_SQLITE"
924   else
925     PKG_CHECK_MODULES([SQLITE], [sqlite3], [], [
926       AC_MSG_ERROR([sqlite3 not found, install it or build without --with-webdav-props])
927     ])
928   fi
930   AC_DEFINE([HAVE_SQLITE3], [1], [libsqlite3])
931   AC_DEFINE([HAVE_SQLITE3_H], [1], [sqlite3.h])
932   AC_SUBST([SQLITE_LIBS])
933   AC_SUBST([SQLITE_CFLAGS])
937 dnl webdav locks (uuid)
938 AC_MSG_NOTICE([----------------------------------------])
939 AC_MSG_CHECKING([for locks in mod_webdav])
940 AC_ARG_WITH([webdav-locks],
941   [AC_HELP_STRING([--with-webdav-locks],
942     [locks in mod_webdav (requires webdav properties)]
943   )],
944   [WITH_WEBDAV_LOCKS=$withval],
945   [WITH_WEBDAV_LOCKS=no]
947 AC_MSG_RESULT([$WITH_WEBDAV_LOCKS])
949 if test "$WITH_WEBDAV_LOCKS" != no; then
950   if test "$WITH_WEBDAV_PROPS" = no; then
951     AC_MSG_ERROR([--with-webdav-locks requires --with-webdav-props])
952   fi
954   AC_MSG_CHECKING([for libuuid])
955   AC_ARG_WITH([uuid],
956     [AC_HELP_STRING([--with-uuid], [uuid for locks in mod_webdav])],
957     [WITH_UUID=$withval],
958     [WITH_UUID=yes]
959   )
960   AC_MSG_RESULT([$WITH_UUID])
962   if test "$WITH_UUID" = no; then
963     AC_MSG_ERROR([--with-webdav-locks requires uuid])
964   fi
966   if test "$WITH_UUID" != yes; then
967     UUID_LIBS="-L$WITH_UUID -luuid"
968     CPPFLAGS="$CPPFLAGS -I$WITH_UUID"
969   else
970     AC_CHECK_LIB([uuid], [uuid_unparse],
971       [UUID_LIBS=-luuid],
972       [AC_MSG_ERROR([uuid lib not found, install it or build without --with-webdav-locks])]
973     )
974     AC_CHECK_HEADERS([uuid/uuid.h], [],
975       [AC_MSG_ERROR([uuid headers not found, install them or build without --with-webdav-locks])]
976     )
977   fi
979   AC_DEFINE([HAVE_LIBUUID], [1], [libuuid])
980   AC_DEFINE([HAVE_UUID_UUID_H], [1], [uuid/uuid.h is available])
981   AC_SUBST([UUID_LIBS])
984 dnl Check for gdbm
985 AC_MSG_NOTICE([----------------------------------------])
986 AC_MSG_CHECKING([for gdbm])
987 AC_ARG_WITH([gdbm],
988   [AC_HELP_STRING([--with-gdbm], [gdbm storage for mod_trigger_b4_dl])],
989   [WITH_GDBM=$withval],
990   [WITH_GDBM=no]
992 AC_MSG_RESULT([$WITH_GDBM])
994 if test "$WITH_GDBM" != no; then
995   if test "$WITH_GDBM" != yes; then
996     GDBM_LIB="-L$WITH_GDBM -lgdbm"
997     CPPFLAGS="$CPPFLAGS -I$WITH_GDBM"
998   else
999     AC_CHECK_LIB([gdbm], [gdbm_open],
1000       [GDBM_LIB=-lgdbm],
1001       [AC_MSG_ERROR([gdbm lib not found, install it or build without --with-gdbm])]
1002     )
1003     AC_CHECK_HEADERS([gdbm.h], [],
1004       [AC_MSG_ERROR([gdbm headers not found, install them or build without --with-gdbm])]
1005     )
1006   fi
1008   AC_DEFINE([HAVE_GDBM], [1], [libgdbm])
1009   AC_DEFINE([HAVE_GDBM_H], [1])
1010   AC_SUBST([GDBM_LIB])
1012 AM_CONDITIONAL([BUILD_WITH_GDBM], [test "$WITH_GDBM" != no])
1014 dnl Check for GeoIP
1015 AC_MSG_NOTICE([----------------------------------------])
1016 AC_MSG_CHECKING([for GeoIP])
1017 AC_ARG_WITH([geoip],
1018   [AC_HELP_STRING([--with-geoip], [IP-based geolocation lookup])],
1019   [WITH_GEOIP=$withval],
1020   [WITH_GEOIP=no]
1022 AC_MSG_RESULT([$WITH_GEOIP])
1024 if test "$WITH_GEOIP" != no; then
1025   if test "$WITH_GEOIP" != yes; then
1026     GEOIP_LIB="-L$WITH_GEOIP -lGeoIP"
1027     CPPFLAGS="$CPPFLAGS -I$WITH_GEOIP"
1028   else
1029     AC_CHECK_LIB([GeoIP], [GeoIP_country_name_by_addr],
1030       [GEOIP_LIB=-lGeoIP],
1031       [AC_MSG_ERROR([GeoIP lib not found, install it or build without --with-geoip])]
1032     )
1033     AC_CHECK_HEADERS([GeoIP.h], [],
1034       [AC_MSG_ERROR([GeoIP headers not found, install them or build without --with-geoip])]
1035     )
1036   fi
1038   AC_DEFINE([HAVE_GEOIP], [1], [libGeoIP])
1039   AC_DEFINE([HAVE_GEOIP_H], [1])
1040   AC_SUBST([GEOIP_LIB])
1042 AM_CONDITIONAL([BUILD_WITH_GEOIP], [test "$WITH_GEOIP" != no])
1044 dnl Check for maxminddb
1045 AC_MSG_NOTICE([----------------------------------------])
1046 AC_MSG_CHECKING([for maxminddb])
1047 AC_ARG_WITH([maxminddb],
1048   [AC_HELP_STRING([--with-maxminddb], [IP-based geolocation lookup])],
1049   [WITH_MAXMINDDB=$withval],
1050   [WITH_MAXMINDDB=no]
1052 AC_MSG_RESULT([$WITH_MAXMINDDB])
1054 if test "$WITH_MAXMINDDB" != no; then
1055   if test "$WITH_MAXMINDDB" != yes; then
1056     MAXMINDDB_LIB="-L$WITH_MAXMINDDB -lmaxminddb"
1057     CPPFLAGS="$CPPFLAGS -I$WITH_MAXMINDDB"
1058   else
1059     AC_CHECK_LIB([maxminddb], [MMDB_open],
1060       [MAXMINDDB_LIB=-lmaxminddb],
1061       [AC_MSG_ERROR([maxminddb lib not found, install it or build without --with-maxminddb])]
1062     )
1063     AC_CHECK_HEADERS([maxminddb.h], [],
1064       [AC_MSG_ERROR([maxminddb headers not found, install them or build without --with-maxminddb])]
1065     )
1066   fi
1068   AC_DEFINE([HAVE_MAXMINDDB], [1], [libmaxminddb])
1069   AC_DEFINE([HAVE_MAXMINDDB_H], [1])
1070   AC_SUBST([MAXMINDDB_LIB])
1072 AM_CONDITIONAL([BUILD_WITH_MAXMINDDB], [test "$WITH_MAXMINDDB" != no])
1074 dnl Check for memcached
1075 AC_MSG_NOTICE([----------------------------------------])
1076 AC_MSG_CHECKING([for memcached])
1077 AC_ARG_WITH([memcached],
1078   [AC_HELP_STRING([--with-memcached],
1079     [memcached storage for mod_trigger_b4_dl/mod_cml]
1080   )],
1081   [WITH_MEMCACHED=$withval],
1082   [WITH_MEMCACHED=no]
1084 AC_MSG_RESULT([$WITH_MEMCACHED])
1086 if test "$WITH_MEMCACHED" != no; then
1087   if test "$WITH_MEMCACHED" != yes; then
1088     MEMCACHED_LIB="-L$WITH_MEMCACHED -lMEMCACHED"
1089     CPPFLAGS="$CPPFLAGS -I$WITH_MEMCACHED"
1090   else
1091     AC_CHECK_LIB([memcached], [memcached],
1092       [ MEMCACHED_LIB=-lmemcached ],
1093       [AC_MSG_ERROR([memcached lib not found, install it or build without --with-memcached])]
1094     )
1095     AC_CHECK_HEADERS([libmemcached/memcached.h], [],
1096       [AC_MSG_ERROR([memcached headers not found, install them or build without --with-memcached])]
1097     )
1098   fi
1100   AC_DEFINE([USE_MEMCACHED], [1], [libmemcached])
1101   AC_SUBST([MEMCACHED_LIB])
1103 AM_CONDITIONAL([BUILD_WITH_MEMCACHED], [test "$WITH_MEMCACHED" != no])
1105 BUILD_MOD_TRIGGER_B4_DL=no
1106 if test "$WITH_MEMCACHED" != no || test "$WITH_GDBM" != no ; then
1107   BUILD_MOD_TRIGGER_B4_DL=yes
1110 AM_CONDITIONAL([BUILD_MOD_TRIGGER_B4_DL], [test "$BUILD_MOD_TRIGGER_B4_DL" != no])
1112 dnl Check for lua
1113 AC_MSG_NOTICE([----------------------------------------])
1114 AC_MSG_CHECKING([if lua-support is requested])
1115 AC_ARG_WITH([lua],
1116   [AC_HELP_STRING([--with-lua], [lua engine for mod_magnet/mod_cml])],
1117   [WITH_LUA=$withval],
1118   [WITH_LUA=no]
1120 AC_MSG_RESULT([$WITH_LUA])
1122 if test "$WITH_LUA" != no; then
1123   found_lua=0
1124   if test "$WITH_LUA" != yes; then
1125     PKG_CHECK_MODULES([LUA], [$WITH_LUA >= 5.1],
1126       [found_lua=1],
1127       [AC_MSG_NOTICE([Couldn\'t find requested lua pkg-config module $WITH_LUA])]
1128     )
1129     if test "$found_lua" = "0"; then
1130       LUA_LIBS="-L$WITH_LUA -llua"
1131       LUA_CFLAGS="-I$WITH_LUA"
1132     fi
1133   else
1134     for luaname in lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua; do
1135       if test "$found_lua" = "0"; then
1136         PKG_CHECK_MODULES([LUA], [$luaname >= 5.1],
1137           [found_lua=1],
1138           [AC_MSG_NOTICE([Couldn\'t find $luaname])]
1139         )
1140       fi
1141     done
1142     if test "$found_lua" = "0"; then
1143       AC_MSG_ERROR([Couldn\'t find any lua pkg-config module])
1144     fi
1145   fi
1147   AC_DEFINE([HAVE_LUA], [1], [liblua])
1148   AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
1149   AC_SUBST([LUA_LIBS])
1150   AC_SUBST([LUA_CFLAGS])
1152 AM_CONDITIONAL([BUILD_WITH_LUA], [test "$WITH_LUA" != no])
1154 dnl "--with-FEATURE" blocks end
1155 AC_MSG_NOTICE([----------------------------------------])
1157 dnl search for crypt_r and (fallback) for crypt
1158 save_LIBS=$LIBS
1159 LIBS=
1160 found_crypt=no
1161 AC_SEARCH_LIBS([crypt_r], [crypt],
1162   [
1163     AC_DEFINE([HAVE_CRYPT_R], [1], [crypt_r])
1164     AC_CHECK_HEADERS([crypt.h])
1165     CRYPT_LIB=$LIBS
1166     found_crypt=crypt_r
1167   ],
1168   [AC_SEARCH_LIBS([crypt], [crypt], [
1169     AC_DEFINE([HAVE_CRYPT], [1], [crypt])
1170     AC_CHECK_HEADERS([crypt.h])
1171     CRYPT_LIB=$LIBS
1172     found_crypt=crypt
1173   ])]
1175 LIBS=$save_LIBS
1176 AC_SUBST([CRYPT_LIB])
1178 AC_MSG_CHECKING([crypt_r/crypt support])
1179 AC_MSG_RESULT([$found_crypt])
1181 dnl check whether sendfilev needs -lsendfile
1182 AC_MSG_NOTICE([----------------------------------------])
1183 save_LIBS=$LIBS
1184 LIBS=
1185 have_sendfilev=no
1186 AC_SEARCH_LIBS([sendfilev], [sendfile], [
1187   if test -z "$LIBS"; then
1188     have_sendfilev=yes
1189   else
1190     have_sendfilev=$LIBS
1191   fi
1192   SENDFILE_LIB=$LIBS
1193   AC_DEFINE([HAVE_SENDFILEV], [1], [solaris sendfilev])
1195 LIBS=$save_LIBS
1196 AC_SUBST([SENDFILE_LIB])
1198 AC_MSG_CHECKING([solaris sendfilev present])
1199 AC_MSG_RESULT([$have_sendfilev])
1201 AC_MSG_NOTICE([----------------------------------------])
1203 case "$host_os" in
1204 *mingw* ) LIBS="$LIBS -lwsock32" ;;
1205 * ) ;;
1206 esac
1208 AC_CHECK_FUNCS([\
1209   arc4random_buf \
1210   chroot \
1211   clock_gettime \
1212   epoll_ctl \
1213   explicit_bzero \
1214   fork \
1215   getloadavg \
1216   getrlimit \
1217   getuid \
1218   gmtime_r \
1219   inet_pton \
1220   issetugid \
1221   jrand48 \
1222   kqueue \
1223   localtime_r \
1224   lstat \
1225   madvise \
1226   memset \
1227   memset_s \
1228   mmap \
1229   pathconf \
1230   pipe2 \
1231   poll \
1232   port_create \
1233   select \
1234   send_file \
1235   sendfile \
1236   sendfile64 \
1237   sigaction \
1238   signal \
1239   srandom \
1240   writev \
1242 AC_CHECK_HEADERS([sys/random.h], [AC_CHECK_FUNCS([getentropy])])
1243 AC_CHECK_HEADERS([linux/random.h], [AC_CHECK_FUNCS([getrandom])])
1245 AC_MSG_NOTICE([----------------------------------------])
1246 AC_MSG_CHECKING([if weak symbols are supported])
1247 AC_LINK_IFELSE(
1248   [AC_LANG_PROGRAM([[
1249     __attribute__((weak)) void __dummy(void *x) { }
1250     void f(void *x) { __dummy(x); }
1251   ]])],
1252   [
1253     AC_MSG_RESULT([yes])
1254     AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [weak symbols are supported])
1255   ],
1256   [AC_MSG_RESULT([no])]
1259 AC_MSG_NOTICE([----------------------------------------])
1260 AC_MSG_CHECKING([for Large File System support])
1261 AC_ARG_ENABLE([lfs],
1262   [AC_HELP_STRING([--enable-lfs],
1263     [Turn on Large File System (default)]
1264   )],
1265   [
1266     case "${enableval}" in
1267     yes) ENABLE_LFS=yes ;;
1268     no) ENABLE_LFS=no ;;
1269     *) AC_MSG_ERROR([bad value ${enableval} for --enable-lfs]) ;;
1270     esac
1271   ],
1272   [ ENABLE_LFS=yes ]
1274 AC_MSG_RESULT([$ENABLE_LFS])
1275 if test "$ENABLE_LFS" = yes; then
1276   CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
1279 dnl check if sendfile works
1280 if test "$ac_cv_func_sendfile" = yes; then
1281   AC_MSG_NOTICE([----------------------------------------])
1282   AC_MSG_CHECKING([if sendfile works])
1283   if test "$cross_compiling" = no; then
1284     AC_TRY_RUN(
1285       [
1286         #ifdef HAVE_SYS_SENDFILE_H
1287         #include <sys/sendfile.h>
1288         #endif /* HAVE_SYS_SENDFILE_H */
1289         #include <errno.h>
1290         int main() {
1291           int o = 0;
1292           if (-1 == sendfile(-1, 0, &o, 0) && errno == ENOSYS) return -1;
1293           return 0;
1294         }
1295       ],
1296       [AC_MSG_RESULT([yes])],
1297       [
1298         AC_MSG_RESULT([no])
1299         AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile])
1300       ]
1301     )
1302   fi
1305 dnl Check for IPv6 support
1306 AC_MSG_NOTICE([----------------------------------------])
1307 AC_ARG_ENABLE([ipv6],
1308   [AC_HELP_STRING([--disable-ipv6], [disable IPv6 support])],
1309   [
1310     case "${enableval}" in
1311     yes) ipv6=true ;;
1312     no) ipv6=false ;;
1313     *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
1314     esac
1315   ],
1316   [ipv6=true]
1319 if test "$ipv6" = true; then
1320   AC_CACHE_CHECK([for IPv6 support], [ac_cv_ipv6_support], [
1321     AC_TRY_LINK(
1322       [
1323         #include <sys/types.h>
1324         #include <sys/socket.h>
1325         #include <netinet/in.h>
1326       ],
1327       [
1328         struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
1329       ],
1330       [ac_cv_ipv6_support=yes],
1331       [ac_cv_ipv6_support=no]
1332     )
1333   ])
1335   if test "$ac_cv_ipv6_support" = yes; then
1336     AC_DEFINE([HAVE_IPV6], [1], [Whether to enable IPv6 support])
1337   else
1338     AC_MSG_ERROR([IPv6 seems broken.  Fix it or build with --disable-ipv6])
1339   fi
1342 # disable mmap by default
1343 # lighttpd may always use mmap with files it owns (created tmp files)
1344 AC_MSG_NOTICE([----------------------------------------])
1345 AC_MSG_CHECKING([use mmap if available])
1346 AC_ARG_ENABLE([mmap],
1347   [AC_HELP_STRING([--enable-mmap],
1348     [use mmap if available]
1349   )],
1350   [
1351     case "${enableval}" in
1352     yes) mmap=true ;;
1353     no) mmap=false ;;
1354     *) AC_MSG_ERROR([bad value ${enableval} for --enable-mmap]) ;;
1355     esac
1356   ],
1357   [mmap=false]
1359 AC_MSG_RESULT([$mmap])
1361 if test "$mmap" = true; then
1362   AC_DEFINE([ENABLE_MMAP], [1], [Use mmap if available])
1365 dnl check for fastcgi lib, for the tests only
1366 AC_MSG_NOTICE([----------------------------------------])
1367 fastcgi_found=no
1368 AC_CHECK_LIB([fcgi], [FCGI_Accept], [
1369   AC_CHECK_HEADERS([fastcgi.h fastcgi/fastcgi.h], [
1370     fastcgi_found=yes
1371   ])
1374 AM_CONDITIONAL([CHECK_WITH_FASTCGI], [test "$fastcgi_found" = yes])
1377 AC_MSG_NOTICE([----------------------------------------])
1378 dnl check for extra compiler options (warning options)
1379 if test "${GCC}" = yes; then
1380   TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
1383 AC_ARG_ENABLE([extra-warnings],
1384   [AC_HELP_STRING([--enable-extra-warnings],
1385     [enable extra warnings (gcc specific)]
1386   )],
1387   [
1388     case "${enableval}" in
1389     error) extrawarnings=error ;;
1390     yes) extrawarnings=true ;;
1391     no) extrawarnings=false ;;
1392     *) AC_MSG_ERROR([bad value ${enableval} for --enable-extra-warnings]) ;;
1393     esac
1394   ],
1395   [extrawarnings=false]
1398 if test "$extrawarnings" = true || test "$extrawarnings" = error; then
1399   TRY_CFLAGS([-g -O2 -g2 -Wall -Wmissing-declarations -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security])
1400   TRY_LDFLAGS([-Wl,--as-needed])
1401   if test "$extrawarnings" = error; then
1402     AS_VAR_APPEND([CFLAGS], [" -Werror"])
1403     AS_VAR_APPEND([LDFLAGS], [" -Wl,--fatal-warnings"])
1404   fi
1407 dnl build version-id
1408 LIGHTTPD_VERSION_ID=m4_format([0x%x%02x%02x], m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))
1409 AC_DEFINE_UNQUOTED([LIGHTTPD_VERSION_ID], [$LIGHTTPD_VERSION_ID], [lighttpd-version-id])
1411 AC_CONFIG_FILES([\
1412   distribute.sh \
1413   doc/config/conf.d/Makefile \
1414   doc/config/Makefile \
1415   doc/config/vhosts.d/Makefile \
1416   doc/Makefile \
1417   doc/outdated/Makefile \
1418   doc/scripts/Makefile \
1419   doc/systemd/Makefile \
1420   Makefile \
1421   src/Makefile \
1422   tests/docroot/123/Makefile \
1423   tests/docroot/Makefile \
1424   tests/docroot/www/expire/Makefile \
1425   tests/docroot/www/go/Makefile \
1426   tests/docroot/www/indexfile/Makefile \
1427   tests/docroot/www/Makefile \
1428   tests/Makefile \
1430 AC_OUTPUT
1432 do_build="\
1433   mod_access \
1434   mod_accesslog \
1435   mod_alias \
1436   mod_auth \
1437   mod_authn_file \
1438   mod_cgi \
1439   mod_compress \
1440   mod_deflate \
1441   mod_dirlisting \
1442   mod_evhost \
1443   mod_expire \
1444   mod_extforward \
1445   mod_fastcgi \
1446   mod_flv_streaming \
1447   mod_indexfile \
1448   mod_proxy \
1449   mod_redirect \
1450   mod_rewrite \
1451   mod_rrdtool \
1452   mod_scgi \
1453   mod_secdownload \
1454   mod_setenv \
1455   mod_simple_vhost \
1456   mod_sockproxy \
1457   mod_ssi \
1458   mod_staticfile \
1459   mod_status \
1460   mod_userdir \
1461   mod_usertrack \
1462   mod_vhostdb \
1463   mod_webdav \
1464   mod_wstunnel \
1467 lighty_track_feature() {
1468   if eval "$3"; then
1469     enable_feature="$enable_feature $1"
1470     do_build="$do_build $2"
1471   else
1472     disable_feature="$disable_feature $1"
1473     no_build="$no_build $2"
1474   fi
1477 lighty_track_feature "regex-conditionals" "" \
1478   'test "$WITH_PCRE" != no'
1480 lighty_track_feature "storage-gdbm" "" \
1481   'test "$WITH_GDBM" != no'
1483 lighty_track_feature "storage-memcached" "" \
1484   'test "$WITH_MEMCACHED" != no'
1486 lighty_track_feature "" "mod_trigger_b4_dl" \
1487   'test "$BUILD_MOD_TRIGGER_B4_DL" != no'
1489 lighty_track_feature "mysql" "mod_authn_mysql mod_mysql_vhost mod_vhostdb_mysql" \
1490   'test "$WITH_MYSQL" != no'
1492 lighty_track_feature "postgresql" "mod_vhostdb_pgsql" \
1493   'test "$WITH_PGSQL" != no'
1495 lighty_track_feature "dbi" "mod_vhostdb_dbi" \
1496   'test "$WITH_DBI" != no'
1498 lighty_track_feature "lua" "mod_cml mod_magnet" \
1499   'test "$WITH_LUA" != no'
1501 lighty_track_feature "geoip" "mod_geoip" \
1502   'test "$WITH_GEOIP" != no'
1504 lighty_track_feature "maxminddb" "mod_maxminddb" \
1505   'test "$WITH_MAXMINDDB" != no'
1507 lighty_track_feature "compress-gzip compress-deflate" "" \
1508   'test "$WITH_ZLIB" != no'
1510 lighty_track_feature "compress-bzip2" "" \
1511   'test "$WITH_BZIP2" != no'
1513 lighty_track_feature "kerberos" "mod_authn_gssapi" \
1514   'test "$WITH_KRB5" != no'
1516 lighty_track_feature "ldap" "mod_authn_ldap mod_vhostdb_ldap" \
1517   'test "$WITH_LDAP" != no'
1519 lighty_track_feature "pam" "mod_authn_pam" \
1520   'test "$WITH_PAM" != no'
1522 lighty_track_feature "network-openssl" "mod_openssl" \
1523   'test "$WITH_OPENSSL" != no || test "$WITH_WOLFSSL" != no'
1525 lighty_track_feature "auth-crypt" "" \
1526   'test "$found_crypt" != no'
1528 lighty_track_feature "network-ipv6" "" \
1529   'test "$ac_cv_ipv6_support" != no'
1531 lighty_track_feature "large-files" "" \
1532   'test "$ENABLE_LFS" = yes'
1534 lighty_track_feature "stat-cache-fam" "" \
1535   'test "$WITH_FAM" != no'
1537 lighty_track_feature "webdav-properties" "" \
1538   'test "$WITH_WEBDAV_PROPS" != no'
1540 lighty_track_feature "webdav-locks" "" \
1541   'test "$WITH_WEBDAV_LOCKS" != no'
1543 dnl output
1545 $ECHO
1546 $ECHO "Plugins:"
1547 $ECHO
1549 $ECHO "enabled: "
1550 for p in $do_build; do
1551   $ECHO "  $p"
1552 done | sort
1554 $ECHO "disabled: "
1555 for p in $no_build; do
1556   $ECHO "  $p"
1557 done | sort
1559 $ECHO
1560 $ECHO "Features:"
1561 $ECHO
1563 $ECHO "enabled: "
1564 for p in $enable_feature; do
1565   $ECHO "  $p"
1566 done | sort
1568 $ECHO "disabled: "
1569 for p in $disable_feature; do
1570   $ECHO "  $p"
1571 done | sort
1573 $ECHO