1dnl                                               -*- Autoconf -*-
2dnl Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.57)
4AC_INIT([lighttpd], [1.4.39], [contact@lighttpd.net])
5AC_CONFIG_SRCDIR([src/server.c])
6AC_CONFIG_HEADER([config.h])
7AC_CONFIG_MACRO_DIR([m4])
8
9AC_CANONICAL_TARGET
10
11dnl HOW FUCKING BROKEN IS AUTOMAKE...
12dnl serial-tests is not recognized before 1.12, and required for serial tests with 1.13, sane version checks "impossible"
13dnl if you don't use the default (symlinked) automake on your box, set AUTOMAKE to the path you're using
14m4_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])
19])
20
21AM_INIT_AUTOMAKE([-Wall -Wno-portability -Wno-override foreign dist-xz tar-ustar] serial_tests)
22
23dnl enable with --enable-silent-rules or make V=0 (needs automake >= 1.11)
24m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
25
26
27dnl @synopsis TRY_CFLAGS [compiler flags]
28dnl @summary check whether compiler supports given flags and adds them to CFLAGS
29AC_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])
43])
44
45dnl @synopsis TRY_LDFLAGS [linker flags]
46dnl @summary check whether linker supports given flags and adds them to LDFLAGS
47AC_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])
61])
62
63dnl Checks for programs.
64AC_PROG_CC
65AM_PROG_CC_C_O
66AC_PROG_LD
67AC_PROG_INSTALL
68AC_PROG_AWK
69AC_PROG_CPP
70dnl AC_PROG_CXX
71AC_PROG_LN_S
72AC_PROG_MAKE_SET
73
74dnl AM_PROG_AR is needed for some linker stuff
75dnl AC_USE_SYSTEM_EXTENSIONS requires autoconf 2.60
76m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_USE_SYSTEM_EXTENSIONS])
77dnl AM_PROG_AR requires automake 1.11 (and uses AC_COMPILE_IFELSE which wants AC_USE_SYSTEM_EXTENSIONS)
78m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
79
80dnl check environment
81AC_AIX
82AC_ISC_POSIX
83AC_MINIX
84
85dnl AC_CANONICAL_HOST
86case $host_os in
87	*darwin*|*cygwin*|*aix*|*mingw* ) NO_RDYNAMIC=yes;;
88	* ) NO_RDYNAMIC=no;;
89esac
90AM_CONDITIONAL(NO_RDYNAMIC, test x$NO_RDYNAMIC = xyes)
91
92AC_EXEEXT
93
94dnl libtool
95AC_DISABLE_STATIC
96AC_ENABLE_SHARED
97
98AC_LIBTOOL_DLOPEN
99AC_PROG_LIBTOOL
100
101dnl for solaris
102CPPFLAGS="${CPPFLAGS} -D_REENTRANT -D__EXTENSIONS__"
103
104dnl Checks for header files.
105AC_HEADER_STDC
106AC_HEADER_SYS_WAIT
107AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h \
108sys/socket.h sys/time.h unistd.h sys/sendfile.h sys/uio.h \
109getopt.h sys/epoll.h sys/select.h poll.h sys/poll.h sys/devpoll.h sys/filio.h \
110sys/mman.h sys/event.h port.h pwd.h \
111sys/resource.h sys/un.h syslog.h sys/prctl.h uuid/uuid.h])
112
113dnl Checks for typedefs, structures, and compiler characteristics.
114AC_C_CONST
115AC_C_INLINE
116AC_C_CHAR_UNSIGNED
117AC_TYPE_OFF_T
118AC_TYPE_PID_T
119AC_TYPE_SIZE_T
120
121AC_CHECK_MEMBER(struct tm.tm_gmtoff,[AC_DEFINE([HAVE_STRUCT_TM_GMTOFF],[1],[gmtoff in struct tm])],,[#include <time.h>])
122AC_CHECK_TYPES(struct sockaddr_storage,,,[#include <sys/socket.h>])
123AC_CHECK_TYPES(socklen_t,,,[#include <sys/types.h>
124#include <sys/socket.h>])
125
126dnl Checks for library functions.
127AC_FUNC_FORK
128dnl AC_FUNC_MALLOC
129dnl AC_FUNC_MMAP
130dnl AC_FUNC_REALLOC
131AC_TYPE_SIGNAL
132AC_FUNC_STAT
133AC_FUNC_STRFTIME
134AC_CHECK_FUNCS([issetugid inet_pton])
135
136if test -z "$PKG_CONFIG"; then
137  AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
138fi
139
140dnl checking for libev
141AC_MSG_CHECKING(for libev support)
142AC_ARG_WITH(libev,
143    AC_HELP_STRING([--with-libev@<:@=PATH@:>@],[Include libev support for fdevent handlers in PATH/include and PATH/lib]),
144    [WITH_LIBEV=$withval],[WITH_LIBEV=no])
145
146LIBEV_CFLAGS=""
147LIBEV_LIBS=""
148
149if test "$WITH_LIBEV" != "no"; then
150	PKG_CHECK_MODULES(LIBEV, libev, [], [
151		dnl no pkg-config for libev, searching manually:
152
153		if test "$WITH_LIBEV" != "yes"; then
154			LIBEV_CFLAGS="-I$WITH_LIBEV/include"
155			LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
156		else
157			AC_CHECK_HEADERS([ev.h],[
158				AC_CHECK_LIB([ev], [ev_time], [
159						LIBEV_CFLAGS=""
160						LIBEV_LIBS="-lev"
161					],[
162					AC_MSG_ERROR([libev not found])
163					]
164				)],[
165					AC_MSG_ERROR([libev not found])
166				]
167			)
168		fi
169	])
170
171	AC_DEFINE([HAVE_LIBEV], [1], [libev support])
172fi
173
174AC_SUBST(LIBEV_CFLAGS)
175AC_SUBST(LIBEV_LIBS)
176
177dnl Checks for database.
178MYSQL_INCLUDE=""
179MYSQL_LIBS=""
180
181AC_MSG_CHECKING(for MySQL support)
182AC_ARG_WITH(mysql,
183    AC_HELP_STRING([--with-mysql@<:@=PATH@:>@],[Include MySQL support. PATH is the path to 'mysql_config']),
184    [WITH_MYSQL=$withval],[WITH_MYSQL=no])
185
186if test "$WITH_MYSQL" != "no"; then
187  AC_MSG_RESULT(yes)
188  if test "$WITH_MYSQL" = "yes"; then
189    AC_PATH_PROG(MYSQL_CONFIG, mysql_config)
190  else
191    MYSQL_CONFIG=$WITH_MYSQL
192  fi
193
194  if test "$MYSQL_CONFIG" = ""; then
195    AC_MSG_ERROR(mysql_config is not found)
196  fi
197  if test \! -x $MYSQL_CONFIG; then
198    AC_MSG_ERROR(mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config)
199  fi
200
201  if $MYSQL_CONFIG | grep -- '--include' > /dev/null ; then
202    MYSQL_INCLUDE="`$MYSQL_CONFIG --include | sed s/\'//g`"
203  else
204    MYSQL_INCLUDE="`$MYSQL_CONFIG --cflags | sed s/\'//g`"
205  fi
206  MYSQL_LIBS="`$MYSQL_CONFIG --libs | sed s/\'//g`"
207
208  AC_MSG_CHECKING(for MySQL includes at)
209  AC_MSG_RESULT($MYSQL_INCLUDE)
210
211  AC_MSG_CHECKING(for MySQL libraries at)
212  AC_MSG_RESULT($MYSQL_LIBS)
213dnl check for errmsg.h, which isn't installed by some versions of 3.21
214  old_CPPFLAGS="$CPPFLAGS"
215  CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
216  AC_CHECK_HEADERS(errmsg.h mysql.h)
217  CPPFLAGS="$old_CPPFLAGS"
218
219  AC_DEFINE([HAVE_MYSQL], [1], [mysql support])
220else
221  AC_MSG_RESULT(no)
222fi
223
224AC_SUBST(MYSQL_LIBS)
225AC_SUBST(MYSQL_INCLUDE)
226
227dnl Check for LDAP
228AC_MSG_CHECKING(for LDAP support)
229AC_ARG_WITH(ldap, AC_HELP_STRING([--with-ldap],[enable LDAP support]),
230[WITH_LDAP=$withval], [WITH_LDAP=no])
231AC_MSG_RESULT([$withval])
232if test "$WITH_LDAP" != "no"; then
233 AC_CHECK_LIB(ldap, ldap_bind, [
234  AC_CHECK_HEADERS([ldap.h],[
235    LDAP_LIB=-lldap
236    AC_DEFINE([HAVE_LIBLDAP], [1], [libldap])
237    AC_DEFINE([HAVE_LDAP_H], [1])
238    AC_DEFINE([LDAP_DEPRECATED], [1], [Using deprecated ldap api])
239  ])
240 ])
241 AC_SUBST(LDAP_LIB)
242 AC_CHECK_LIB(lber, ber_printf, [
243  AC_CHECK_HEADERS([lber.h],[
244    LBER_LIB=-llber
245    AC_DEFINE([HAVE_LIBLBER], [1], [liblber])
246    AC_DEFINE([HAVE_LBER_H], [1])
247  ])
248 ])
249 AC_SUBST(LBER_LIB)
250fi
251
252dnl Check for xattr
253AC_MSG_CHECKING(for extended attributes support)
254AC_ARG_WITH(attr, AC_HELP_STRING([--with-attr],[enable extended attribute support]),
255[WITH_ATTR=$withval],[WITH_ATTR=no])
256AC_MSG_RESULT($withval)
257if test "$WITH_ATTR" != "no"; then
258  # libattr (linux only?)
259  AC_CHECK_LIB(attr, attr_get, [
260    AC_CHECK_HEADERS([attr/attributes.h],[
261      ATTR_LIB=-lattr
262      AC_DEFINE([HAVE_XATTR], [1], [libattr])
263      AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
264    ])
265  ])
266  AC_SUBST(ATTR_LIB)
267
268  # (Free)BSD extattr
269  AC_CHECK_FUNC([extattr_get_file], [
270    AC_CHECK_HEADERS([sys/extattr.h],[
271      AC_DEFINE([HAVE_EXTATTR], [1], [BSD extended attributes])
272      AC_DEFINE([HAVE_SYS_EXTATTR_H], [1])
273    ])
274  ])
275fi
276
277dnl openssl on solaris needs -lsocket -lnsl
278AC_SEARCH_LIBS(socket,socket)
279AC_SEARCH_LIBS(gethostbyname,nsl socket)
280AC_SEARCH_LIBS(hstrerror,resolv)
281
282save_LIBS=$LIBS
283AC_SEARCH_LIBS(dlopen,dl,[
284  AC_CHECK_HEADERS([dlfcn.h],[
285    if test "$ac_cv_search_dlopen" != no; then
286      test "$ac_cv_search_dlopen" = "none required" || DL_LIB="$ac_cv_search_dlopen"
287    fi
288
289    AC_DEFINE([HAVE_LIBDL], [1], [libdl])
290    AC_DEFINE([HAVE_DLFCN_H], [1])
291  ])
292])
293LIBS=$save_LIBS
294AC_SUBST(DL_LIB)
295
296dnl Check for valgrind
297AC_MSG_CHECKING(for valgrind)
298AC_ARG_WITH(valgrind, AC_HELP_STRING([--with-valgrind],[enable internal support for valgrind]),
299[WITH_VALGRIND=$withval],[WITH_VALGRIND=no])
300AC_MSG_RESULT([$WITH_VALGRIND])
301if test "$WITH_VALGRIND" != "no"; then
302 AC_CHECK_HEADERS([valgrind/valgrind.h])
303fi
304
305dnl Checking for libunwind
306AC_MSG_CHECKING(for libunwind)
307AC_ARG_WITH(libunwind,
308    AC_HELP_STRING([--with-libunwind],[Include libunwind support for backtraces on assert failures]),
309    [WITH_LIBUNWIND=$withval],[WITH_LIBUNWIND=no])
310
311if test "$WITH_LIBUNWIND" != "no"; then
312  PKG_CHECK_MODULES(LIBUNWIND, libunwind)
313  AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
314fi
315
316dnl Check for openssl
317AC_MSG_CHECKING(for OpenSSL)
318AC_ARG_WITH(openssl,
319    AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[Include openssl support (default no)]),
320    [WITH_OPENSSL=$withval],[WITH_OPENSSL=no])
321
322if test "$WITH_OPENSSL" != "no"; then
323    use_openssl=yes
324    if test "$WITH_OPENSSL" != "yes"; then
325	CPPFLAGS="$CPPFLAGS -I$WITH_OPENSSL/include"
326	LDFLAGS="$LDFLAGS -L$WITH_OPENSSL/lib"
327    fi
328else
329    use_openssl=no
330fi
331AC_MSG_RESULT([$use_openssl])
332
333AC_ARG_WITH(openssl-includes,
334    AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
335    [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
336)
337
338AC_ARG_WITH(openssl-libs,
339    AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
340    [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
341)
342
343AC_ARG_WITH(kerberos5,
344    AC_HELP_STRING([--with-kerberos5],[use Kerberos5 support with OpenSSL]),
345    [ use_kerberos=yes ], [use_kerberos=no]
346)
347
348if test "x$use_openssl" = "xyes"; then
349    if test "x$use_kerberos" != "xyes"; then
350        CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
351    fi
352
353    AC_CHECK_HEADERS([openssl/ssl.h])
354    OLDLIBS="$LIBS"
355    AC_CHECK_LIB(crypto, BIO_f_base64, [
356      AC_CHECK_LIB(ssl, SSL_new, [ SSL_LIB="-lssl -lcrypto"
357				 AC_DEFINE(HAVE_LIBSSL, [], [Have libssl]) ], [], [ -lcrypto "$DL_LIB" ])
358    ], [], [])
359    LIBS="$OLDLIBS"
360    AC_SUBST(SSL_LIB)
361fi
362
363AC_MSG_CHECKING(for perl regular expressions support)
364AC_ARG_WITH(pcre, AC_HELP_STRING([--with-pcre],[Enable pcre support (default yes)]),
365    [WITH_PCRE=$withval],[WITH_PCRE=yes])
366AC_MSG_RESULT([$WITH_PCRE])
367
368if test "$WITH_PCRE" != "no"; then
369  AC_PATH_PROG(PCRECONFIG, pcre-config)
370
371  if test x"$PCRECONFIG" != x; then
372    PCRE_LIB=`$PCRECONFIG --libs`
373    CPPFLAGS="$CPPFLAGS `$PCRECONFIG --cflags`"
374    AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre])
375    AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h])
376  else
377     AC_MSG_ERROR([pcre-config not found, install the pcre-devel package or build with --without-pcre])
378  fi
379fi
380
381AC_SUBST(PCRE_LIB)
382
383AC_MSG_CHECKING(for zlib support)
384AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],[Enable zlib support for mod_compress]),
385    [WITH_ZLIB=$withval],[WITH_ZLIB=yes])
386AC_MSG_RESULT([$WITH_ZLIB])
387
388if test "$WITH_ZLIB" != "no"; then
389  AC_CHECK_LIB(z, deflate, [
390    AC_CHECK_HEADERS([zlib.h],[
391      Z_LIB=-lz
392      AC_DEFINE([HAVE_LIBZ], [1], [libz])
393      AC_DEFINE([HAVE_ZLIB_H], [1])
394    ])
395  ])
396  if test x$Z_LIB = x; then
397     AC_MSG_ERROR([zlib-headers and/or libs where not found, install them or build with --without-zlib])
398  fi
399fi
400AC_SUBST(Z_LIB)
401
402AC_MSG_CHECKING(for bzip2 support)
403AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2],[Enable bzip2 support for mod_compress]),
404    [WITH_BZIP2=$withval],[WITH_BZIP2=yes])
405AC_MSG_RESULT([$WITH_BZIP2])
406
407if test "$WITH_BZIP2" != "no"; then
408  AC_CHECK_LIB(bz2, BZ2_bzCompress, [
409    AC_CHECK_HEADERS([bzlib.h],[
410      BZ_LIB=-lbz2
411      AC_DEFINE([HAVE_LIBBZ2], [1], [libbz2])
412      AC_DEFINE([HAVE_BZLIB_H], [1])
413    ])
414  ])
415  if test x$BZ_LIB = x; then
416     AC_MSG_ERROR([bzip2-headers and/or libs where not found, install them or build with --without-bzip2])
417  fi
418fi
419AC_SUBST(BZ_LIB)
420
421dnl Check for gamin
422AC_MSG_CHECKING(for FAM)
423AC_ARG_WITH(fam, AC_HELP_STRING([--with-fam],[fam/gamin for reducing number of stat() calls]),
424[WITH_FAM=$withval],[WITH_FAM=no])
425AC_MSG_RESULT([$WITH_FAM])
426
427if test "$WITH_FAM" != "no"; then
428  AC_CHECK_LIB(fam, FAMOpen2, [
429    AC_CHECK_HEADERS([fam.h],[
430      FAM_LIBS=-lfam
431      AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
432      AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
433    ])
434  ])
435  if test "x$FAM_LIBS" = x; then
436    PKG_CHECK_MODULES(FAM, gamin >= 0.1.0, [
437      AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
438      AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
439    ])
440  fi
441  OLD_LIBS=$LIBS
442  LIBS=$FAM_LIBS
443  AC_CHECK_FUNCS([FAMNoExists])
444  LIBS=$OLD_LIBS
445
446  if test x$FAM_LIBS = x; then
447     AC_MSG_ERROR([fam/gamin-headers and/or libs where not found, install them or build with --without-fam])
448  fi
449fi
450
451AC_MSG_CHECKING(for properties in mod_webdav)
452AC_ARG_WITH(webdav-props, AC_HELP_STRING([--with-webdav-props],[properties in mod_webdav]),
453[WITH_WEBDAV_PROPS=$withval],[WITH_WEBDAV_PROPS=no])
454AC_MSG_RESULT([$WITH_WEBDAV_PROPS])
455
456if test "$WITH_WEBDAV_PROPS" != "no"; then
457  PKG_CHECK_MODULES(XML, libxml-2.0, [
458    AC_DEFINE([HAVE_LIBXML2], [1], [libxml2])
459    AC_DEFINE([HAVE_LIBXML_H], [1], [libxml.h])
460  ])
461  PKG_CHECK_MODULES(SQLITE, sqlite3, [
462    AC_DEFINE([HAVE_SQLITE3], [1], [libsqlite3])
463    AC_DEFINE([HAVE_SQLITE3_H], [1], [sqlite3.h])
464  ])
465
466  AC_MSG_CHECKING(for locks in mod_webdav)
467  AC_ARG_WITH(webdav-locks, AC_HELP_STRING([--with-webdav-locks],[locks in mod_webdav]),
468  [WITH_WEBDAV_LOCKS=$withval],[WITH_WEBDAV_LOCKS=no])
469  AC_MSG_RESULT([$WITH_WEBDAV_LOCKS])
470
471  if test "$WITH_WEBDAV_LOCKS" != "no"; then
472    AC_CHECK_LIB(uuid, uuid_unparse, [
473      AC_CHECK_HEADERS([uuid/uuid.h],[
474        UUID_LIBS=-luuid
475        AC_DEFINE([HAVE_UUID], [1], [libuuid])
476        AC_DEFINE([HAVE_UUID_H], [1], [uuid/uuid.h is available])
477      ])
478    ])
479  fi
480fi
481AC_SUBST(UUID_LIBS)
482
483dnl Check for gdbm
484AC_MSG_CHECKING(for gdbm)
485AC_ARG_WITH(gdbm, AC_HELP_STRING([--with-gdbm],[gdbm storage for mod_trigger_b4_dl]),
486[WITH_GDBM=$withval],[WITH_GDBM=no])
487AC_MSG_RESULT([$WITH_GDBM])
488
489if test "$WITH_GDBM" != "no"; then
490 AC_CHECK_LIB(gdbm, gdbm_open, [
491         AC_CHECK_HEADERS([gdbm.h],[
492                 GDBM_LIB=-lgdbm
493                 AC_DEFINE([HAVE_GDBM], [1], [libgdbm])
494		 AC_DEFINE([HAVE_GDBM_H], [1])
495         ])
496 ])
497 AC_SUBST(GDBM_LIB)
498fi
499
500dnl Check for memcache
501AC_MSG_CHECKING(for memcache)
502AC_ARG_WITH(memcache, AC_HELP_STRING([--with-memcache],[memcached storage for mod_trigger_b4_dl]),
503[WITH_MEMCACHE=$withval],[WITH_MEMCACHE=no])
504AC_MSG_RESULT([$WITH_MEMCACHE])
505if test "$WITH_MEMCACHE" != "no"; then
506 AC_CHECK_LIB(memcache, mc_new, [
507         AC_CHECK_HEADERS([memcache.h],[
508                 MEMCACHE_LIB=-lmemcache
509                 AC_DEFINE([HAVE_MEMCACHE], [1], [libmemcache])
510		 AC_DEFINE([HAVE_MEMCACHE_H], [1], [memcache.h])
511         ])
512 ])
513 AC_SUBST(MEMCACHE_LIB)
514fi
515
516dnl Check for lua
517AC_MSG_CHECKING(if lua-support is requested)
518AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[lua engine for mod_cml]),
519[WITH_LUA=$withval],[WITH_LUA=no])
520
521AC_MSG_RESULT($WITH_LUA)
522if test "$WITH_LUA" != "no"; then
523 if test "$WITH_LUA" = "yes"; then
524  WITH_LUA=lua
525 fi
526 dnl first check for lua5.1 (debian and others), then lua-5.1 (freebsd), then $WITH_LUA (defaults to lua)
527 dnl check "lua" last now that lua5.2 is out
528 PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [
529  AC_DEFINE([HAVE_LUA], [1], [liblua])
530  AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
531 ],[
532  PKG_CHECK_MODULES(LUA, lua-5.1 >= 5.1, [
533   AC_DEFINE([HAVE_LUA], [1], [liblua])
534   AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
535  ],[
536   PKG_CHECK_MODULES(LUA, $WITH_LUA >= 5.1, [
537    AC_DEFINE([HAVE_LUA], [1], [liblua])
538    AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
539   ])
540  ])
541 ])
542
543 AC_SUBST(LUA_CFLAGS)
544 AC_SUBST(LUA_LIBS)
545fi
546
547dnl search for crypt_r and (fallback) for crypt
548save_LIBS=$LIBS
549LIBS=
550AC_SEARCH_LIBS([crypt_r],[crypt],[
551  AC_DEFINE([HAVE_CRYPT_R], [1], [crypt_r])
552  AC_CHECK_HEADERS([crypt.h],[
553    AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
554  ])
555
556  CRYPT_LIB=$LIBS
557],[
558  AC_SEARCH_LIBS([crypt],[crypt],[
559    AC_DEFINE([HAVE_CRYPT], [1], [crypt])
560    AC_CHECK_HEADERS([crypt.h],[
561      AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
562    ])
563
564    CRYPT_LIB=$LIBS
565  ])
566])
567LIBS=$save_LIBS
568AC_SUBST([CRYPT_LIB])
569
570save_LIBS=$LIBS
571AC_SEARCH_LIBS(sendfilev,sendfile,[
572  if test "$ac_cv_search_sendfilev" != no; then
573    test "$ac_cv_search_sendfilev" = "none required" || SENDFILE_LIB="$ac_cv_search_sendfilev"
574    AC_DEFINE([HAVE_SENDFILEV], [1], [solaris sendfilev])
575  fi
576])
577LIBS=$save_LIBS
578AC_SUBST(SENDFILE_LIB)
579
580case $host_os in
581	*mingw* ) LIBS="$LIBS -lwsock32";;
582        * ) ;;
583esac
584
585AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \
586		  strdup strerror strstr strtol sendfile  getopt socket lstat \
587		  gethostbyname poll epoll_ctl getrlimit chroot \
588		  getuid select signal pathconf madvise posix_fadvise posix_madvise \
589		  writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
590		  memset_s explicit_bzero])
591
592AC_MSG_CHECKING(if weak symbols are supported)
593AC_LINK_IFELSE([AC_LANG_PROGRAM([[
594		__attribute__((weak)) void __dummy(void *x) { }
595		void f(void *x) { __dummy(x); }
596	]])],
597	[
598		AC_MSG_RESULT(yes)
599		AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [weak symbols are supported])
600	],[AC_MSG_RESULT(no)])
601
602AC_MSG_CHECKING(for Large File System support)
603AC_ARG_ENABLE(lfs,
604 AC_HELP_STRING([--enable-lfs],[Turn on Large File System (default)]),
605 [case "${enableval}" in
606   yes) CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES" ;;
607    no) ;;
608     *) AC_MSG_ERROR(bad value ${enableval} for --enable-lfs) ;;
609  esac],[CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
610	 enable_lfs=yes])
611AC_MSG_RESULT($enableval)
612
613AC_CHECK_SIZEOF(long)
614AC_CHECK_SIZEOF(off_t)
615
616if test "x$ac_cv_func_sendfile" = xyes; then
617	dnl check if sendfile works
618        AC_MSG_CHECKING(if sendfile works)
619	if test "x$cross_compiling" = xno; then
620	AC_TRY_RUN([
621		    #ifdef HAVE_SYS_SENDFILE_H
622		    #include <sys/sendfile.h>
623		    #endif /* HAVE_SYS_SENDFILE_H */
624		    #include <errno.h>
625		    int main() {
626		      int o = 0;
627		      if (-1 == sendfile(-1, 0, &o, 0) && errno == ENOSYS) return -1;
628		      return 0;
629		    } ],
630		    AC_MSG_RESULT(yes),
631		    [ AC_MSG_RESULT(no)
632		    AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile]) ] )
633	else
634	      AC_MSG_RESULT(no, cross-compiling)
635	      AC_DEFINE([HAVE_SENDFILE_BROKEN], [1], [broken sendfile])
636	fi
637fi
638
639dnl Check for IPv6 support
640
641AC_ARG_ENABLE(ipv6,
642 AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
643 [case "${enableval}" in
644   yes) ipv6=true ;;
645    no) ipv6=false ;;
646     *) AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
647  esac],[ipv6=true])
648
649if test x$ipv6 = xtrue; then
650  AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
651  [AC_TRY_LINK([ #include <sys/types.h>
652#include <sys/socket.h>
653#include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ],
654  [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
655
656  if test "$ac_cv_ipv6_support" = yes; then
657    AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
658  fi
659fi
660
661# disable mmap by default; if a mmapped file gets truncated, the process gets a SIGBUS signal
662# on reading the truncated area which we can't handle (yet).
663# lighttpd may always use mmap with files it owns (created tmp files)
664AC_ARG_ENABLE(mmap,
665  AC_HELP_STRING([--enable-mmap],[use mmap if available (DANGEROUS, allows local users to trigger SIGBUS crashes)]),
666  [case "${enableval}" in
667   yes) mmap=true ;;
668    no) mmap=false ;;
669     *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmap) ;;
670  esac],[mmap=false])
671
672if test x$mmap = xtrue; then
673  AC_DEFINE(ENABLE_MMAP, [1], [Use mmap if available])
674fi
675
676
677AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
678
679dnl check for fastcgi lib, for the tests only
680fastcgi_found=no
681AC_CHECK_LIB(fcgi, FCGI_Accept, [
682 AC_CHECK_HEADERS([fastcgi.h fastcgi/fastcgi.h],[
683   fastcgi_found=yes
684 ])
685])
686
687AM_CONDITIONAL(CHECK_WITH_FASTCGI, test "x$fastcgi_found" = xyes)
688
689
690dnl check for extra compiler options (warning options)
691if test "${GCC}" = "yes"; then
692  TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
693  TRY_CFLAGS([-std=gnu99])
694fi
695
696AC_ARG_ENABLE(extra-warnings,
697 AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
698 [case "${enableval}" in
699   yes) extrawarnings=true ;;
700    no) extrawarnings=false ;;
701     *) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
702  esac],[extrawarnings=false])
703
704if test x$extrawarnings = xtrue; then
705  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])
706  TRY_LDFLAGS([-Wl,--as-needed])
707fi
708
709dnl build version-id
710LIGHTTPD_VERSION_ID=`echo $PACKAGE_VERSION | $AWK -F '.' '{print "(" $1 " << 16 | " $2 " << 8 | " $3 ")"}'`
711AC_DEFINE_UNQUOTED([LIGHTTPD_VERSION_ID], [$LIGHTTPD_VERSION_ID], [lighttpd-version-id])
712
713AC_CONFIG_FILES([Makefile src/Makefile
714		 doc/config/conf.d/Makefile \
715		 doc/config/vhosts.d/Makefile \
716		 doc/config/Makefile \
717		 doc/scripts/Makefile \
718		 doc/initscripts/Makefile \
719		 doc/systemd/Makefile \
720		 doc/outdated/Makefile \
721		 doc/Makefile \
722		 tests/Makefile \
723		 tests/docroot/Makefile \
724		 tests/docroot/123/Makefile \
725		 tests/docroot/www/Makefile \
726		 tests/docroot/www/go/Makefile \
727		 tests/docroot/www/indexfile/Makefile \
728		 tests/docroot/www/expire/Makefile \
729		 distribute.sh])
730AC_OUTPUT
731
732
733do_build="mod_cgi mod_fastcgi mod_extforward mod_proxy mod_evhost mod_simple_vhost mod_access mod_alias mod_setenv mod_usertrack mod_auth mod_status mod_accesslog"
734do_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"
735
736plugins="mod_rewrite mod_redirect mod_ssi mod_trigger_b4_dl"
737features="regex-conditionals"
738if test ! "x$PCRE_LIB" = x; then
739	do_build="$do_build $plugins"
740	enable_feature="$features"
741else
742	no_build="$no_build $plugins"
743	disable_feature="$features"
744fi
745
746plugins="mod_mysql_vhost"
747if test ! "x$MYSQL_LIBS" = x; then
748	do_build="$do_build $plugins"
749else
750	no_build="$no_build $plugins"
751fi
752
753plugins="mod_cml mod_magnet"
754if test ! "x$LUA_LIBS" = x; then
755	do_build="$do_build $plugins"
756else
757	no_build="$no_build $plugins"
758fi
759
760features="storage-gdbm"
761if test ! "x$GDBM_LIB" = x; then
762	enable_feature="$enable_feature $features"
763else
764	disable_feature="$disable_feature $features"
765fi
766
767features="storage-memcache"
768if test ! "x$MEMCACHE_LIB" = x; then
769	enable_feature="$enable_feature $features"
770else
771	disable_feature="$disable_feature $features"
772fi
773
774features="compress-gzip compress-deflate"
775if test ! "x$Z_LIB" = x; then
776	enable_feature="$enable_feature $features"
777else
778	disable_feature="$disable_feature $features"
779fi
780
781features="compress-bzip2"
782if test ! "x$BZ_LIB" = x; then
783	enable_feature="$enable_feature $features"
784else
785	disable_feature="$disable_feature $features"
786fi
787
788features="auth-ldap"
789if test ! "x$LDAP_LIB" = x; then
790	enable_feature="$enable_feature $features"
791else
792	disable_feature="$disable_feature $features"
793fi
794
795features="network-openssl"
796if test ! "x$SSL_LIB" = x; then
797	enable_feature="$enable_feature $features"
798else
799	disable_feature="$disable_feature $features"
800fi
801
802dnl no crypt call
803features="auth-crypt"
804if test "$ac_cv_search_crypt" = no; then
805	disable_feature="$disable_feature $features"
806else
807	enable_feature="$enable_feature $features"
808fi
809
810features="network-ipv6"
811if test "$ac_cv_ipv6_support" = yes; then
812	enable_feature="$enable_feature $features"
813else
814	disable_feature="$disable_feature $features"
815fi
816
817features="large-files"
818if test "$enable_lfs" = yes; then
819	enable_feature="$enable_feature $features"
820else
821	disable_feature="$disable_feature $features"
822fi
823
824features="stat-cache-fam"
825if test ! "x$FAM_LIBS" = x; then
826	enable_feature="$enable_feature $features"
827else
828	disable_feature="$disable_feature $features"
829fi
830
831features="webdav-properties"
832if test "x$XML_LIBS" \!= x -a "x$SQLITE_LIBS" \!= x; then
833	enable_feature="$enable_feature $features"
834else
835	disable_feature="$disable_feature $features"
836fi
837
838features="webdav-locks"
839if test "x$UUID_LIBS" \!= x; then
840	enable_feature="$enable_feature $features"
841else
842	disable_feature="$disable_feature $features"
843fi
844
845
846dnl output
847
848$ECHO
849$ECHO "Plugins:"
850$ECHO
851
852$ECHO "enabled: "
853for p in $do_build; do
854	$ECHO "  $p"
855done | sort
856
857$ECHO "disabled: "
858for p in $no_build; do
859	$ECHO "  $p"
860done | sort
861
862$ECHO
863$ECHO "Features:"
864$ECHO
865
866$ECHO "enabled: "
867for p in $enable_feature; do
868	$ECHO "  $p"
869done | sort
870
871$ECHO "disabled: "
872for p in $disable_feature; do
873	$ECHO "  $p"
874done | sort
875
876$ECHO
877