summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2017-10-22 21:07:16 +0200
committerStefan Bühler <stbuehler@web.de>2017-11-07 10:30:51 +0100
commitebf8b11abb4a219ffc4ab93599e99fefa46d9539 (patch)
tree4c3b119cb271a12018e3a5ff8bfe0b23602dae07
parentc383ff562ce53ed86ba6c0d6bb3d5a1bbfef2dba (diff)
downloadlighttpd1.4-personal/stbuehler/cleanup-build.tar.gz
lighttpd1.4-personal/stbuehler/cleanup-build.zip
[WIP] build systems cleanuppersonal/stbuehler/cleanup-build
-rw-r--r--INSTALL4
-rw-r--r--SConstruct134
-rw-r--r--configure.ac129
-rw-r--r--meson_options.txt6
-rw-r--r--src/SConscript2
-rw-r--r--src/algo_sha1.c6
-rw-r--r--src/algo_sha1.h2
-rw-r--r--src/array.h4
-rw-r--r--src/base.h4
-rw-r--r--src/buffer.c2
-rw-r--r--src/configfile-glue.c2
-rw-r--r--src/configfile.c18
-rw-r--r--src/configparser.y2
-rw-r--r--src/data_config.c2
-rw-r--r--src/fdevent.h27
-rw-r--r--src/fdevent_libev.c2
-rw-r--r--src/keyvalue.c6
-rw-r--r--src/keyvalue.h4
-rw-r--r--src/md5.c42
-rw-r--r--src/meson.build448
-rw-r--r--src/mod_accesslog.c16
-rw-r--r--src/mod_authn_file.c8
-rw-r--r--src/mod_authn_ldap.c3
-rw-r--r--src/mod_cml.c10
-rw-r--r--src/mod_cml.h4
-rw-r--r--src/mod_cml_funcs.c2
-rw-r--r--src/mod_cml_lua.c2
-rw-r--r--src/mod_compress.c27
-rw-r--r--src/mod_deflate.c56
-rw-r--r--src/mod_dirlisting.c32
-rw-r--r--src/mod_fastcgi.c11
-rw-r--r--src/mod_openssl.c4
-rw-r--r--src/mod_redirect.c4
-rw-r--r--src/mod_rewrite.c12
-rw-r--r--src/mod_secdownload.c12
-rw-r--r--src/mod_status.c4
-rw-r--r--src/mod_trigger_b4_dl.c60
-rw-r--r--src/mod_vhostdb_ldap.c2
-rw-r--r--src/mod_webdav.c51
-rw-r--r--src/network_backends.h55
-rw-r--r--src/plugin.c4
-rw-r--r--src/rand.c13
-rw-r--r--src/server.c60
-rw-r--r--src/settings.h86
-rw-r--r--src/stat_cache.c50
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/fcgi-auth.c14
-rw-r--r--tests/fcgi-responder.c14
-rw-r--r--tests/meson.build25
-rw-r--r--tests/scgi-responder.c2
50 files changed, 743 insertions, 749 deletions
diff --git a/INSTALL b/INSTALL
index 883bfd4b..04b34114 100644
--- a/INSTALL
+++ b/INSTALL
@@ -42,6 +42,10 @@ configurable variables that might be set in a customized build. build_static=1
can be replaced with build_fullstatic=1 to perform lighttpd static build with
modules *and* to link statically against external dependencies.
+full-static build using SCons
+-----------------------------
+
+ $ scons with_all=1 with_pgsql=0 with_ldap=0 with_krb5=0 with_geoip=0 with_memcached=0 build_fullstatic=1 build_dynamic=0
static build using make
-----------------------
diff --git a/SConstruct b/SConstruct
index dfb2e496..97d0b711 100644
--- a/SConstruct
+++ b/SConstruct
@@ -333,16 +333,10 @@ if 1:
)
autoconf.haveCHeaders([
- 'arpa/inet.h',
- 'crypt.h',
- 'fcntl.h',
'getopt.h',
- 'inttypes.h',
- 'linux/random.h',
- 'netinet/in.h',
'poll.h',
+ 'port.h',
'pwd.h',
- 'stdint.h',
'stdlib.h',
'string.h',
'strings.h',
@@ -352,47 +346,42 @@ if 1:
'sys/filio.h',
'sys/mman.h',
'sys/poll.h',
- 'sys/port.h',
'sys/prctl.h',
'sys/resource.h',
'sys/select.h',
'sys/sendfile.h',
- 'sys/socket.h',
'sys/time.h',
'sys/uio.h',
'sys/un.h',
- 'sys/wait.h',
'syslog.h',
- 'unistd.h',
- 'winsock2.h',
# "have" the last header if we include others before?
['sys/time.h', 'sys/types.h', 'sys/resource.h'],
- ['sys/types.h', 'netinet/in.h'],
['sys/types.h', 'sys/event.h'],
['sys/types.h', 'sys/mman.h'],
['sys/types.h', 'sys/select.h'],
- ['sys/types.h', 'sys/socket.h'],
['sys/types.h', 'sys/uio.h'],
['sys/types.h', 'sys/un.h'],
])
+ # headers checked in special autoconf macros
+ autoconf.haveCHeaders([
+ 'inttypes.h',
+ 'stdint.h',
+ 'sys/wait.h',
+ ])
+
autoconf.haveFuncs([
'arc4random_buf',
'chroot',
'clock_gettime',
- 'dup2',
'epoll_ctl',
'explicit_bzero',
'fork',
- 'getcwd',
- 'gethostbyname',
'getloadavg',
- 'getopt',
'getrlimit',
'getuid',
- 'inet_ntoa',
- 'inet_ntop',
+ 'gmtime_r',
'inet_pton',
'issetugid',
'jrand48',
@@ -401,60 +390,48 @@ if 1:
'lstat',
'madvise',
'memset_s',
- 'memset',
'mmap',
- 'munmap',
'pathconf',
'pipe2',
'poll',
'port_create',
- 'posix_fadvise',
- 'prctl',
'select',
'send_file',
'sendfile',
'sendfile64',
'sigaction',
'signal',
- 'socket',
'srandom',
- 'stat',
- 'strchr',
- 'strdup',
- 'strerror',
- 'strftime',
- 'strstr',
- 'strtol',
'writev',
])
- autoconf.haveFunc('getentropy', 'sys/random.h')
- autoconf.haveFunc('getrandom', 'linux/random.h')
-
- autoconf.haveTypes(Split('pid_t size_t off_t'))
# have crypt_r/crypt, and is -lcrypt needed?
- if autoconf.CheckLib('crypt'):
- autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_LIBCRYPT' ],
- LIBCRYPT = 'crypt',
- )
- with autoconf.restoreEnvLibs():
- autoconf.env['LIBS'] = ['crypt']
- autoconf.haveFuncs(['crypt', 'crypt_r'])
- else:
- autoconf.haveFuncs(['crypt', 'crypt_r'])
-
- if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'):
+ if autoconf.haveCHeader('crypt.h'):
+ if autoconf.haveFunc('crypt_r'):
+ pass
+ elif autoconf.haveFuncInLib('crypt_r', 'crypt'):
+ autoconf.env.Append(LIBCRYPT = [ 'crypt' ])
+ if autoconf.haveFunc('crypt'):
+ pass
+ elif autoconf.haveFuncInLib('crypt', 'crypt'):
+ autoconf.env.Append(LIBCRYPT = [ 'crypt' ])
+
+ if autoconf.CheckType('socklen_t', '#include <sys/types.h>\n#include <sys/socket.h>'):
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ])
- if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'):
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ])
+ if autoconf.CheckCHeader('sys/random.h'):
+ autoconf.haveFunc('getentropy', 'sys/random.h')
- if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'):
- autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ],
- LIBS = [ 'rt' ],
- )
+ if autoconf.haveCHeader('linux/random.h'):
+ autoconf.haveFunc('getrandom', 'linux/random.h')
+
+ if not autoconf.CheckFunc('clock_gettime'):
+ # maybe we need -lrt for clock_gettime
+ if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'):
+ autoconf.env.Append(
+ CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ],
+ LIBS = [ 'rt' ],
+ )
if autoconf.CheckIPv6():
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ])
@@ -463,20 +440,21 @@ if 1:
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ])
if autoconf.CheckGmtOffInStructTm():
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ])
+ autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_TM_GMTOFF' ])
if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'):
autoconf.env.Append(LIBDL = 'dl')
# used in tests if present
- if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'):
- autoconf.env.Append(LIBFCGI = 'fcgi')
+ if autoconf.CheckLib('fcgi'):
+ if autoconf.haveCHeader('fcgi_stdio.h') or autoconf.haveCHeader('fastcgi/fcgi_stdio.h'):
+ autoconf.env.Append(LIBFCGI = 'fcgi')
if env['with_bzip2']:
if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'):
fail("Couldn't find bz2")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ],
+ CPPFLAGS = [ '-DWITH_BZIP' ],
LIBBZ2 = 'bz2',
)
@@ -484,7 +462,7 @@ if 1:
if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'):
fail("Couldn't find dbi")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ],
+ CPPFLAGS = [ '-DWITH_DBI' ],
LIBDBI = 'dbi',
)
@@ -492,16 +470,16 @@ if 1:
if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'):
fail("Couldn't find fam")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ],
+ CPPFLAGS = [ '-DWITH_FAM' ],
LIBS = [ 'fam' ],
)
- autoconf.haveFunc('FAMNoExists')
+ autoconf.haveFunc('FAMNoExists');
if env['with_gdbm']:
if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'):
fail("Couldn't find gdbm")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ],
+ CPPFLAGS = [ '-DWITH_GDBM' ],
LIBGDBM = 'gdbm',
)
@@ -509,7 +487,7 @@ if 1:
if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'):
fail("Couldn't find geoip")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_GEOIP' ],
+ CPPFLAGS = [ '-DWITH_GEOIP' ],
LIBGEOIP = 'GeoIP',
)
@@ -519,7 +497,7 @@ if 1:
if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'):
fail("Couldn't find gssapi_krb5")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_KRB5' ],
+ CPPFLAGS = [ '-DWITH_KRB5' ],
LIBKRB5 = 'krb5',
LIBGSSAPI_KRB5 = 'gssapi_krb5',
)
@@ -530,11 +508,7 @@ if 1:
if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'):
fail("Couldn't find lber")
autoconf.env.Append(
- CPPFLAGS = [
- '-DLDAP_DEPRECATED=1',
- '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP',
- '-DHAVE_LBER_H', '-DHAVE_LIBLBER',
- ],
+ CPPFLAGS = [ '-DWITH_LDAP' ],
LIBLDAP = 'ldap',
LIBLBER = 'lber',
)
@@ -544,7 +518,7 @@ if 1:
for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']:
print("Searching for lua: " + lua_name + " >= 5.0")
if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"):
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ])
+ autoconf.env.Append(CPPFLAGS = [ '-DWITH_LUA' ])
found_lua = True
break
if not found_lua:
@@ -554,7 +528,7 @@ if 1:
if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'):
fail("Couldn't find memcached")
autoconf.env.Append(
- CPPFLAGS = [ '-DUSE_MEMCACHED' ],
+ CPPFLAGS = [ '-DWITH_MEMCACHED' ],
LIBMEMCACHED = 'memcached',
)
@@ -562,13 +536,13 @@ if 1:
mysql_config = autoconf.checkProgram('mysql', 'mysql_config')
if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'):
fail("Couldn't find mysql")
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ])
+ autoconf.env.Append(CPPFLAGS = [ '-DWITH_MYSQL' ])
if env['with_openssl']:
if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'):
fail("Couldn't find openssl")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'],
+ CPPFLAGS = [ '-DWITH_OPENSSL' ] ,
LIBSSL = 'ssl',
LIBCRYPTO = 'crypto',
)
@@ -577,18 +551,18 @@ if 1:
pcre_config = autoconf.checkProgram('pcre', 'pcre-config')
if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'):
fail("Couldn't find pcre")
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ])
+ autoconf.env.Append(CPPFLAGS = [ '-DWITH_PCRE' ])
if env['with_pgsql']:
if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'):
fail("Couldn't find libpq")
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ])
+ autoconf.env.Append(CPPFLAGS = [ '-DWITH_PGSQL' ])
if env['with_sqlite3']:
if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'):
fail("Couldn't find sqlite3")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ],
+ CPPFLAGS = [ '-DWITH_SQLITE3' ],
LIBSQLITE3 = 'sqlite3',
)
@@ -596,7 +570,7 @@ if 1:
if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'):
fail("Couldn't find uuid")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ],
+ CPPFLAGS = [ '-DWITH_UUID' ],
LIBUUID = 'uuid',
)
@@ -604,13 +578,13 @@ if 1:
xml2_config = autoconf.checkProgram('xml', 'xml2-config')
if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'):
fail("Couldn't find xml2")
- autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ])
+ autoconf.env.Append(CPPFLAGS = [ '-DWITH_XML' ])
if env['with_zlib']:
if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'):
fail("Couldn't find zlib")
autoconf.env.Append(
- CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ],
+ CPPFLAGS = [ '-DWITH_ZLIB' ],
LIBZ = 'z',
)
diff --git a/configure.ac b/configure.ac
index f49f7b34..6d730003 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,18 +122,16 @@ AC_CHECK_HEADERS([\
sys/uio.h \
sys/un.h \
syslog.h \
- uuid/uuid.h \
])
dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
-AC_CHECK_MEMBER([struct tm.tm_gmtoff],
- [AC_DEFINE([HAVE_STRUCT_TM_GMTOFF], [1], [gmtoff in struct tm])],
+AC_CHECK_MEMBERS([struct tm.tm_gmtoff],
+ [], dnl defines HAVE_STRUCT_TM_TM_GMTOFF
[],
[#include <time.h>]
)
@@ -160,11 +158,7 @@ dnl need dlopen/-ldl to load plugins (when not on windows)
save_LIBS=$LIBS
LIBS=
AC_SEARCH_LIBS([dlopen], [dl], [
- AC_CHECK_HEADERS([dlfcn.h], [
- DL_LIB=$LIBS
- AC_DEFINE([HAVE_LIBDL], [1], [libdl])
- AC_DEFINE([HAVE_DLFCN_H], [1])
- ])
+ AC_CHECK_HEADERS([dlfcn.h], [DL_LIB=$LIBS])
])
LIBS=$save_LIBS
AC_SUBST([DL_LIB])
@@ -198,7 +192,7 @@ if test "$WITH_LIBEV" != no; then
LIBEV_CFLAGS="-I$WITH_LIBEV/include"
LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
else
- AC_CHECK_HEADERS([ev.h],
+ AC_CHECK_HEADER([ev.h],
[AC_CHECK_LIB([ev], [ev_time],
[
LIBEV_CFLAGS=
@@ -211,7 +205,7 @@ if test "$WITH_LIBEV" != no; then
fi
])
- AC_DEFINE([HAVE_LIBEV], [1], [libev support])
+ AC_DEFINE([WITH_LIBEV], [1], [libev])
fi
AC_SUBST([LIBEV_CFLAGS])
@@ -259,7 +253,7 @@ if test "$WITH_MYSQL" != no; then
AC_MSG_CHECKING([for MySQL libraries at])
AC_MSG_RESULT([$MYSQL_LIBS])
- AC_DEFINE([HAVE_MYSQL], [1], [mysql support])
+ AC_DEFINE([WITH_MYSQL], [1], [mysql])
fi
AM_CONDITIONAL([BUILD_WITH_MYSQL], [test "$WITH_MYSQL" != no])
@@ -304,7 +298,7 @@ if test "$WITH_PGSQL" != no; then
AC_MSG_CHECKING([for PgSQL libraries at])
AC_MSG_RESULT([$PGSQL_LIBS])
- AC_DEFINE([HAVE_PGSQL], [1], [pgsql support])
+ AC_DEFINE([WITH_PGSQL], [1], [pgsql])
fi
AM_CONDITIONAL([BUILD_WITH_PGSQL], [test "$WITH_PGSQL" != no])
@@ -331,7 +325,7 @@ if test "$WITH_DBI" != no; then
DBI_CFLAGS="-I$WITH_LIBDBI/include"
DBI_LIBS="-L$WITH_LIBDBI/lib -ldbi"
else
- AC_CHECK_HEADERS([dbi/dbi.h],
+ AC_CHECK_HEADER([dbi/dbi.h],
[AC_CHECK_LIB([dbi], [dbi_version],
[
DBI_CFLAGS=
@@ -343,7 +337,7 @@ if test "$WITH_DBI" != no; then
)
fi
- AC_DEFINE([HAVE_DBI], [1], [LibDBI support])
+ AC_DEFINE([WITH_DBI], [1], [LibDBI support])
fi
AM_CONDITIONAL([BUILD_WITH_DBI], [test "$WITH_DBI" != no])
@@ -363,30 +357,20 @@ AC_MSG_RESULT([$WITH_LDAP])
if test "$WITH_LDAP" != no; then
AC_CHECK_LIB([ldap], [ldap_bind],
- [AC_CHECK_HEADERS([ldap.h],
- [
- LDAP_LIB=-lldap
- AC_DEFINE([HAVE_LIBLDAP], [1], [libldap])
- AC_DEFINE([HAVE_LDAP_H], [1])
- AC_DEFINE([LDAP_DEPRECATED], [1], [Using deprecated ldap api])
- ],
+ [AC_CHECK_HEADER([ldap.h], [LDAP_LIB=-lldap],
[AC_MSG_ERROR([ldap headers not found, install them or build without --with-ldap])]
)],
[AC_MSG_ERROR([ldap library not found, install it or build without --with-ldap])]
)
AC_SUBST([LDAP_LIB])
AC_CHECK_LIB([lber], [ber_printf],
- [AC_CHECK_HEADERS([lber.h],
- [
- LBER_LIB=-llber
- AC_DEFINE([HAVE_LIBLBER], [1], [liblber])
- AC_DEFINE([HAVE_LBER_H], [1])
- ],
+ [AC_CHECK_HEADER([lber.h], [LBER_LIB=-llber],
[AC_MSG_ERROR([lber headers not found, install them or build without --with-ldap])]
)],
[AC_MSG_ERROR([lber library not found, install it or build without --with-ldap])]
)
AC_SUBST([LBER_LIB])
+ AC_DEFINE([WITH_LDAP], [1], [LDAP])
fi
AM_CONDITIONAL([BUILD_WITH_LDAP], [test "$WITH_LDAP" != no])
@@ -404,10 +388,9 @@ if test "$WITH_ATTR" != no; then
have_xattr=no
# libattr (linux only?)
AC_CHECK_LIB([attr], [attr_get], [
- AC_CHECK_HEADERS([attr/attributes.h], [
+ AC_CHECK_HEADER([attr/attributes.h], [
ATTR_LIB=-lattr
- AC_DEFINE([HAVE_XATTR], [1], [libattr])
- AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
+ AC_DEFINE([HAVE_LIBATTR], [1], [libattr])
have_xattr=yes
])
])
@@ -415,9 +398,8 @@ if test "$WITH_ATTR" != no; then
# (Free)BSD extattr
AC_CHECK_FUNC([extattr_get_file], [
- AC_CHECK_HEADERS([sys/extattr.h], [
+ AC_CHECK_HEADER([sys/extattr.h], [
AC_DEFINE([HAVE_EXTATTR], [1], [BSD extended attributes])
- AC_DEFINE([HAVE_SYS_EXTATTR_H], [1])
have_xattr=yes
])
])
@@ -425,6 +407,7 @@ if test "$WITH_ATTR" != no; then
if test "$have_xattr" = no; then
AC_MSG_ERROR([no backend found implementing extended attributes])
fi
+ AC_DEFINE([WITH_XATTR], [1], [xattr])
fi
dnl Check for valgrind
@@ -440,9 +423,10 @@ AC_ARG_WITH([valgrind],
AC_MSG_RESULT([$WITH_VALGRIND])
if test "$WITH_VALGRIND" != no; then
- AC_CHECK_HEADERS([valgrind/valgrind.h], [], [
+ AC_CHECK_HEADER([valgrind/valgrind.h], [], [
AC_MSG_ERROR([valgrind headers not found. install them or build without --with-valgrind])
])
+ AC_DEFINE([WITH_VALGRIND], [1], [valgrind])
fi
dnl Checking for libunwind
@@ -461,7 +445,7 @@ if test "$WITH_LIBUNWIND" != no; then
PKG_CHECK_MODULES([LIBUNWIND], [libunwind], [], [
AC_MSG_ERROR([libunwind not found. install it or build without --with-libunwind])
])
- AC_DEFINE([HAVE_LIBUNWIND], [1], [Have libunwind support])
+ AC_DEFINE([WITH_LIBUNWIND], [1], [libunwind])
fi
dnl Checking for kerberos5
@@ -512,10 +496,9 @@ if test "$WITH_KRB5" != no; then
LDFLAGS="${LDFLAGS}${krb5_append_LDFLAGS}"
AC_CHECK_LIB([gssapi_krb5], [gss_acquire_cred],
- [AC_CHECK_HEADERS([gssapi/gssapi_krb5.h],
+ [AC_CHECK_HEADER([gssapi/gssapi_krb5.h],
[
KRB5_LIB="-lkrb5 -lgssapi_krb5"
- AC_DEFINE([HAVE_KRB5], [1], [libgssapi_krb5])
],
[AC_MSG_ERROR([gssapi_krb5 headers were not found, install them or build without --with-krb5])]
)],
@@ -525,6 +508,8 @@ if test "$WITH_KRB5" != no; then
*darwin*|*cygwin* ) KRB5_LIB="$KRB5_LIB -lcom_err" ;;
* ) ;;
esac
+
+ AC_DEFINE([WITH_KRB5], [1], [krb5])
fi
AM_CONDITIONAL([BUILD_WITH_KRB5], [test "$WITH_KRB5" != no])
@@ -578,27 +563,24 @@ AC_ARG_WITH([openssl-libs],
AM_CONDITIONAL([BUILD_WITH_OPENSSL], [test "$WITH_OPENSSL" != no])
if test "$WITH_OPENSSL" != no; then
- if test "$WITH_KRB5" != no; then
- AC_DEFINE([USE_OPENSSL_KERBEROS], [1], [with kerberos])
- fi
-
CPPFLAGS="${CPPFLAGS}${openssl_append_CPPFLAGS}"
LDFLAGS="${LDFLAGS}${openssl_append_LDFLAGS}"
- AC_CHECK_HEADERS([openssl/ssl.h], [], [
+ AC_CHECK_HEADER([openssl/ssl.h], [], [
AC_MSG_ERROR([openssl headers not found. install them or build without --with-openssl])
])
+
AC_CHECK_LIB([crypto], [BIO_f_base64],
[CRYPTO_LIB="-lcrypto"],
[AC_MSG_ERROR([openssl crypto library not found. install it or build without --with-openssl])]
)
AC_CHECK_LIB([ssl], [SSL_new],
[SSL_LIB="-lssl -lcrypto"],
- [AC_MSG_ERROR([openssl ssl library not found. install it or build without --with-openssl])],
+ [AC_MSG_ERROR([openssl ssl library not found. install it or build without --with-openssl])]
[ -lcrypto "$DL_LIB" ]
)
- AC_DEFINE([HAVE_LIBSSL], [], [Have libssl])
+ AC_DEFINE([WITH_OPENSSL], [], [openssl])
AC_SUBST([SSL_LIB])
AC_SUBST([CRYPTO_LIB])
fi
@@ -629,8 +611,7 @@ if test "$WITH_PCRE" != no; then
AC_MSG_ERROR([pcre-config not found, install the pcre-devel package or build with --without-pcre])
fi
- AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre])
- AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h])
+ AC_DEFINE([WITH_PCRE], [1], [pcre])
AC_SUBST([PCRE_LIB])
fi
@@ -651,7 +632,7 @@ if test "$WITH_ZLIB" != no; then
Z_LIB="-L$WITH_ZLIB -lz"
CPPFLAGS="$CPPFLAGS -I$WITH_ZLIB"
else
- AC_CHECK_HEADERS([zlib.h], [],
+ AC_CHECK_HEADER([zlib.h], [],
[AC_MSG_ERROR([zlib headers not found, install them or build without --with-zlib])]
)
AC_CHECK_LIB([z], [deflate],
@@ -660,8 +641,7 @@ if test "$WITH_ZLIB" != no; then
)
fi
- AC_DEFINE([HAVE_LIBZ], [1], [libz])
- AC_DEFINE([HAVE_ZLIB_H], [1])
+ AC_DEFINE([WITH_ZLIB], [1], [zlib])
AC_SUBST([Z_LIB])
fi
@@ -682,7 +662,7 @@ if test "$WITH_BZIP2" != no; then
BZ_LIB="-L$WITH_BZIP2 -lbz2"
CPPFLAGS="$CPPFLAGS -I$WITH_BZIP2"
else
- AC_CHECK_HEADERS([bzlib.h], [], [
+ AC_CHECK_HEADER([bzlib.h], [], [
AC_MSG_ERROR([bzip2 headers not found, install them or build without --with-bzip2])
])
AC_CHECK_LIB([bz2], [BZ2_bzCompress],
@@ -691,8 +671,7 @@ if test "$WITH_BZIP2" != no; then
)
fi
- AC_DEFINE([HAVE_LIBBZ2], [1], [libbz2])
- AC_DEFINE([HAVE_BZLIB_H], [1])
+ AC_DEFINE([WITH_BZIP], [1], [bzip2])
AC_SUBST([BZ_LIB])
fi
@@ -714,7 +693,7 @@ if test "$WITH_FAM" != no; then
CPPFLAGS="$CPPFLAGS -I$WITH_FAM"
else
AC_CHECK_LIB([fam], [FAMOpen2], [
- AC_CHECK_HEADERS([fam.h], [FAM_LIBS=-lfam])
+ AC_CHECK_HEADER([fam.h], [FAM_LIBS=-lfam])
])
dnl fam has no pkg-config so far, so just search for gamin as fallback
if test -z "$FAM_LIBS"; then
@@ -731,8 +710,7 @@ if test "$WITH_FAM" != no; then
AC_CHECK_FUNCS([FAMNoExists])
LIBS=$OLD_LIBS
- AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
- AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
+ AC_DEFINE([WITH_FAM], [1], [fam])
AC_SUBST([FAM_LIBS])
fi
@@ -770,9 +748,7 @@ if test "$WITH_WEBDAV_PROPS" != no; then
AC_MSG_ERROR([libxml2 not found, install it or build without --with-webdav-props])
])
fi
-
- AC_DEFINE([HAVE_LIBXML2], [1], [libxml2])
- AC_DEFINE([HAVE_LIBXML_H], [1], [libxml.h])
+ AC_DEFINE([WITH_XML], [1], [libxml2])
AC_SUBST([XML_LIBS])
AC_SUBST([XML_CFLAGS])
@@ -799,8 +775,7 @@ if test "$WITH_WEBDAV_PROPS" != no; then
])
fi
- AC_DEFINE([HAVE_SQLITE3], [1], [libsqlite3])
- AC_DEFINE([HAVE_SQLITE3_H], [1], [sqlite3.h])
+ AC_DEFINE([WITH_SQLITE3], [1], [sqlite3])
AC_SUBST([SQLITE_LIBS])
AC_SUBST([SQLITE_CFLAGS])
fi
@@ -843,13 +818,12 @@ if test "$WITH_WEBDAV_LOCKS" != no; then
[UUID_LIBS=-luuid],
[AC_MSG_ERROR([uuid lib not found, install it or build without --with-webdav-locks])]
)
- AC_CHECK_HEADERS([uuid/uuid.h], [],
+ AC_CHECK_HEADER([uuid/uuid.h], [],
[AC_MSG_ERROR([uuid headers not found, install them or build without --with-webdav-locks])]
)
fi
- AC_DEFINE([HAVE_UUID], [1], [libuuid])
- AC_DEFINE([HAVE_UUID_H], [1], [uuid/uuid.h is available])
+ AC_DEFINE([WITH_UUID], [1], [uuid])
AC_SUBST([UUID_LIBS])
fi
@@ -872,13 +846,12 @@ if test "$WITH_GDBM" != no; then
[GDBM_LIB=-lgdbm],
[AC_MSG_ERROR([gdbm lib not found, install it or build without --with-gdbm])]
)
- AC_CHECK_HEADERS([gdbm.h], [],
+ AC_CHECK_HEADER([gdbm.h], [],
[AC_MSG_ERROR([gdbm headers not found, install them or build without --with-gdbm])]
)
fi
- AC_DEFINE([HAVE_GDBM], [1], [libgdbm])
- AC_DEFINE([HAVE_GDBM_H], [1])
+ AC_DEFINE([WITH_GDBM], [1], [gdbm])
AC_SUBST([GDBM_LIB])
fi
AM_CONDITIONAL([BUILD_WITH_GDBM], [test "$WITH_GDBM" != no])
@@ -902,13 +875,12 @@ if test "$WITH_GEOIP" != no; then
[GEOIP_LIB=-lGeoIP],
[AC_MSG_ERROR([GeoIP lib not found, install it or build without --with-geoip])]
)
- AC_CHECK_HEADERS([GeoIP.h], [],
+ AC_CHECK_HEADER([GeoIP.h], [],
[AC_MSG_ERROR([GeoIP headers not found, install them or build without --with-geoip])]
)
fi
- AC_DEFINE([HAVE_GEOIP], [1], [libGeoIP])
- AC_DEFINE([HAVE_GEOIP_H], [1])
+ AC_DEFINE([WITH_GEOIP], [1], [GeoIP])
AC_SUBST([GEOIP_LIB])
fi
AM_CONDITIONAL([BUILD_WITH_GEOIP], [test "$WITH_GEOIP" != no])
@@ -934,12 +906,12 @@ if test "$WITH_MEMCACHED" != no; then
[ MEMCACHED_LIB=-lmemcached ],
[AC_MSG_ERROR([memcached lib not found, install it or build without --with-memcached])]
)
- AC_CHECK_HEADERS([libmemcached/memcached.h], [],
+ AC_CHECK_HEADER([libmemcached/memcached.h], [],
[AC_MSG_ERROR([memcached headers not found, install them or build without --with-memcached])]
)
fi
- AC_DEFINE([USE_MEMCACHED], [1], [libmemcached])
+ AC_DEFINE([WITH_MEMCACHED], [1], [memcached])
AC_SUBST([MEMCACHED_LIB])
fi
AM_CONDITIONAL([BUILD_WITH_MEMCACHED], [test "$WITH_MEMCACHED" != no])
@@ -986,8 +958,7 @@ if test "$WITH_LUA" != no; then
fi
fi
- AC_DEFINE([HAVE_LUA], [1], [liblua])
- AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
+ AC_DEFINE([WITH_LUA], [1], [lua])
AC_SUBST([LUA_LIBS])
AC_SUBST([LUA_CFLAGS])
fi
@@ -1065,7 +1036,6 @@ AC_CHECK_FUNCS([\
localtime_r \
lstat \
madvise \
- memset \
memset_s \
mmap \
pathconf \
@@ -1081,7 +1051,7 @@ AC_CHECK_FUNCS([\
srandom \
writev \
])
-AC_CHECK_HEADERS([sys/random.h], [AC_CHECK_FUNCS([getentropy])])
+AC_CHECK_HEADER([sys/random.h], [AC_CHECK_FUNCS([getentropy])])
AC_CHECK_HEADERS([linux/random.h], [AC_CHECK_FUNCS([getrandom])])
AC_MSG_NOTICE([----------------------------------------])
@@ -1211,9 +1181,12 @@ dnl check for fastcgi lib, for the tests only
AC_MSG_NOTICE([----------------------------------------])
fastcgi_found=no
AC_CHECK_LIB([fcgi], [FCGI_Accept], [
- AC_CHECK_HEADERS([fastcgi.h fastcgi/fastcgi.h], [
- fastcgi_found=yes
- ])
+ AC_CHECK_HEADERS([fcgi_stdio.h fastcgi/fcgi_stdio.h],
+ [
+ fastcgi_found=yes
+ break # only need one header
+ ]
+ )
])
AM_CONDITIONAL([CHECK_WITH_FASTCGI], [test "$fastcgi_found" = yes])
diff --git a/meson_options.txt b/meson_options.txt
index 6fde5ea2..53147ed0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -116,6 +116,12 @@ option('build_static',
description: 'build a static lighttpd with all modules added',
)
+option('link_static',
+ type: 'boolean',
+ value: false,
+ description: 'try to link dependencies statically',
+)
+
option('moduledir',
type: 'string',
value: 'lib/lighttpd',
diff --git a/src/SConscript b/src/SConscript
index 4c2ba11a..ba6676fe 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -47,7 +47,7 @@ def WorkaroundFreeBSDLibOrder(libs):
return libs
def GatherLibs(env, *libs):
- libs = RemoveDuplicateLibs(env['LIBS'] + list(libs) + [env['APPEND_LIBS']])
+ libs = RemoveDuplicateLibs(list(env['LIBS']) + list(libs) + [env['APPEND_LIBS']])
return WorkaroundFreeBSDLibOrder(libs)
common_src = Split("base64.c buffer.c log.c \
diff --git a/src/algo_sha1.c b/src/algo_sha1.c
index dbf646b8..4346a0a6 100644
--- a/src/algo_sha1.c
+++ b/src/algo_sha1.c
@@ -1,11 +1,7 @@
#include "first.h"
typedef int innocuous_typedef_to_quiet_empty_translation_unit_compiler_warning;
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
-#define USE_OPENSSL_CRYPTO
-#endif
-
-#ifndef USE_OPENSSL_CRYPTO
+#if !defined(WITH_OPENSSL)
#include "sys-endian.h"
#include "algo_sha1.h"
diff --git a/src/algo_sha1.h b/src/algo_sha1.h
index d8b44379..44dd95e2 100644
--- a/src/algo_sha1.h
+++ b/src/algo_sha1.h
@@ -2,7 +2,7 @@
#define INCLUDED_ALGO_SHA1_H
#include "first.h"
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
+#if defined(WITH_OPENSSL)
#include <openssl/sha.h>
diff --git a/src/array.h b/src/array.h
index 16e1b011..e80e9e15 100644
--- a/src/array.h
+++ b/src/array.h
@@ -2,7 +2,7 @@
#define ARRAY_H
#include "first.h"
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
# include <pcre.h>
#endif
@@ -118,7 +118,7 @@ struct data_config {
data_config *next;
buffer *string;
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
pcre *regex;
pcre_extra *regex_study;
#endif
diff --git a/src/base.h b/src/base.h
index 0ddae6ea..71cdb37f 100644
--- a/src/base.h
+++ b/src/base.h
@@ -204,7 +204,7 @@ typedef struct {
char is_symlink;
#endif
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
int dir_version;
#endif
@@ -474,7 +474,7 @@ typedef struct {
enum { STAT_CACHE_ENGINE_UNSET,
STAT_CACHE_ENGINE_NONE,
STAT_CACHE_ENGINE_SIMPLE
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
, STAT_CACHE_ENGINE_FAM
#endif
} stat_cache_engine;
diff --git a/src/buffer.c b/src/buffer.c
index d4caae47..253b2c67 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1017,7 +1017,7 @@ void buffer_to_upper(buffer *b) {
#include <stdio.h>
-#ifdef HAVE_LIBUNWIND
+#if defined(WITH_LIBUNWIND)
# define UNW_LOCAL_ONLY
# include <libunwind.h>
diff --git a/src/configfile-glue.c b/src/configfile-glue.c
index cacf1f9a..851829cb 100644
--- a/src/configfile-glue.c
+++ b/src/configfile-glue.c
@@ -540,7 +540,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat
return (dc->cond == CONFIG_COND_EQ) ? COND_RESULT_FALSE : COND_RESULT_TRUE;
}
break;
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
case CONFIG_COND_NOMATCH:
case CONFIG_COND_MATCH: {
int n;
diff --git a/src/configfile.c b/src/configfile.c
index 5333e0a3..c658d5b8 100644
--- a/src/configfile.c
+++ b/src/configfile.c
@@ -24,7 +24,7 @@
#include <glob.h>
-#if defined(HAVE_MYSQL) || (defined(HAVE_LDAP_H) && defined(HAVE_LBER_H) && defined(HAVE_LIBLDAP) && defined(HAVE_LIBLBER))
+#if defined(WITH_MYSQL) || defined(WITH_LDAP)
static void config_warn_authn_module (server *srv, const char *module) {
size_t len = strlen(module);
for (size_t i = 0; i < srv->config_context->used; ++i) {
@@ -45,7 +45,7 @@ static void config_warn_authn_module (server *srv, const char *module) {
}
#endif
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
+#if defined(WITH_OPENSSL)
static void config_warn_openssl_module (server *srv) {
for (size_t i = 0; i < srv->config_context->used; ++i) {
const data_config *config = (data_config const*)srv->config_context->data[i];
@@ -347,7 +347,7 @@ static int config_insert(server *srv) {
"unexpected value for mimetype.assign; expected list of \"ext\" => \"mimetype\"");
}
-#if !(defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H)
+#if defined(WITH_OPENSSL)
if (s->ssl_enabled) {
log_error_write(srv, __FILE__, __LINE__, "s",
"ssl support is missing, recompile with --with-openssl");
@@ -370,7 +370,7 @@ static int config_insert(server *srv) {
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_SIMPLE;
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("simple"))) {
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_SIMPLE;
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("fam"))) {
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_FAM;
#endif
@@ -379,7 +379,7 @@ static int config_insert(server *srv) {
} else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"server.stat-cache-engine can be one of \"disable\", \"simple\","
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
" \"fam\","
#endif
" but not:", stat_cache_string);
@@ -488,7 +488,7 @@ static int config_insert(server *srv) {
}
if (append_mod_openssl) {
- #if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
+ #if defined(WITH_OPENSSL)
config_warn_openssl_module(srv);
#endif
}
@@ -503,12 +503,12 @@ static int config_insert(server *srv) {
array_insert_unique(srv->srvconf.modules, (data_unset *)ds);
}
if (append_mod_authn_ldap) {
- #if defined(HAVE_LDAP_H) && defined(HAVE_LBER_H) && defined(HAVE_LIBLDAP) && defined(HAVE_LIBLBER)
+ #if defined(WITH_LDAP)
config_warn_authn_module(srv, "ldap");
#endif
}
if (append_mod_authn_mysql) {
- #if defined(HAVE_MYSQL)
+ #if defined(WITH_MYSQL)
config_warn_authn_module(srv, "mysql");
#endif
}
@@ -1400,7 +1400,7 @@ int config_set_defaults(server *srv) {
#ifdef USE_SELECT
{ FDEVENT_HANDLER_SELECT, "select" },
#endif
-#ifdef USE_LIBEV
+#if defined(WITH_LIBEV)
{ FDEVENT_HANDLER_LIBEV, "libev" },
#endif
#ifdef USE_SOLARIS_DEVPOLL
diff --git a/src/configparser.y b/src/configparser.y
index 7a065a58..d1c190d6 100644
--- a/src/configparser.y
+++ b/src/configparser.y
@@ -696,7 +696,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
break;
case CONFIG_COND_NOMATCH:
case CONFIG_COND_MATCH: {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
const char *errptr;
int erroff, captures;
diff --git a/src/data_config.c b/src/data_config.c
index 3fcd2685..be49d6cc 100644
--- a/src/data_config.c
+++ b/src/data_config.c
@@ -31,7 +31,7 @@ static void data_config_free(data_unset *d) {
vector_config_weak_clear(&ds->children);
if (ds->string) buffer_free(ds->string);
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
if (ds->regex) pcre_free(ds->regex);
if (ds->regex_study) pcre_free(ds->regex_study);
#endif
diff --git a/src/fdevent.h b/src/fdevent.h
index b69d2f8c..9349ac9c 100644
--- a/src/fdevent.h
+++ b/src/fdevent.h
@@ -12,47 +12,36 @@
#include <sys/types.h>
-/* select event-system */
-
-#if defined(HAVE_EPOLL_CTL) && defined(HAVE_SYS_EPOLL_H)
-# define USE_LINUX_EPOLL
+#if defined(USE_LINUX_EPOLL)
struct epoll_event; /* declaration */
#endif
-/* MacOS 10.3.x has poll.h under /usr/include/, all other unixes
- * under /usr/include/sys/ */
-#if defined HAVE_POLL && (defined(HAVE_SYS_POLL_H) || defined(HAVE_POLL_H))
-# define USE_POLL
+#if defined(USE_POLL)
struct pollfd; /* declaration */
#endif
-#if defined HAVE_SELECT
+#if defined(USE_SELECT)
# ifdef __WIN32
# include <winsock2.h>
# endif
-# define USE_SELECT
# ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
# endif
#endif
-#if defined HAVE_SYS_DEVPOLL_H && defined(__sun)
-# define USE_SOLARIS_DEVPOLL
+#if defined(USE_SOLARIS_DEVPOLL)
struct pollfd; /* declaration */
#endif
-#if defined HAVE_PORT_H && defined HAVE_PORT_CREATE && defined(__sun)
-# define USE_SOLARIS_PORT
+#if defined(USE_SOLARIS_PORT)
# include <port.h>
#endif
-#if defined HAVE_SYS_EVENT_H && defined HAVE_KQUEUE
-# define USE_FREEBSD_KQUEUE
+#if defined(USE_FREEBSD_KQUEUE)
struct kevent; /* declaration */
#endif
-#if defined HAVE_LIBEV
-# define USE_LIBEV
+#if defined(WITH_LIBEV)
struct ev_loop; /* declaration */
#endif
@@ -164,7 +153,7 @@ typedef struct fdevents {
#ifdef USE_SOLARIS_PORT
int port_fd;
#endif
-#ifdef USE_LIBEV
+#if defined(WITH_LIBEV)
struct ev_loop *libev_loop;
#endif
int (*reset)(struct fdevents *ev);
diff --git a/src/fdevent_libev.c b/src/fdevent_libev.c
index 87dbf0c3..ead142ae 100644
--- a/src/fdevent_libev.c
+++ b/src/fdevent_libev.c
@@ -6,7 +6,7 @@
#include "buffer.h"
#include "log.h"
-#ifdef USE_LIBEV
+#if defined(WITH_LIBEV)
# include <ev.h>
diff --git a/src/keyvalue.c b/src/keyvalue.c
index 81edf8e9..da80697c 100644
--- a/src/keyvalue.c
+++ b/src/keyvalue.c
@@ -180,7 +180,7 @@ pcre_keyvalue_buffer *pcre_keyvalue_buffer_init(void) {
}
int pcre_keyvalue_buffer_append(server *srv, pcre_keyvalue_buffer *kvb, const char *key, const char *value) {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
size_t i;
const char *errptr;
int erroff;
@@ -189,7 +189,7 @@ int pcre_keyvalue_buffer_append(server *srv, pcre_keyvalue_buffer *kvb, const ch
if (!key) return -1;
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
if (kvb->size == 0) {
kvb->size = 4;
kvb->used = 0;
@@ -241,7 +241,7 @@ int pcre_keyvalue_buffer_append(server *srv, pcre_keyvalue_buffer *kvb, const ch
}
void pcre_keyvalue_buffer_free(pcre_keyvalue_buffer *kvb) {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
size_t i;
pcre_keyvalue *kv;
diff --git a/src/keyvalue.h b/src/keyvalue.h
index 9fc2bc7f..cdd073d1 100644
--- a/src/keyvalue.h
+++ b/src/keyvalue.h
@@ -2,7 +2,7 @@
#define _KEY_VALUE_H_
#include "first.h"
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
# include <pcre.h>
#endif
@@ -69,7 +69,7 @@ typedef struct {
} keyvalue;
typedef struct {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
pcre *key;
pcre_extra *key_extra;
#endif
diff --git a/src/md5.c b/src/md5.c
index 1a43e214..1971c754 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -28,13 +28,8 @@ documentation and/or software.
#include "md5.h"
-#if 0 /* Note: not defined here or in lighttpd local "md5.h" */
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
-#define USE_OPENSSL_CRYPTO
-#endif
-#endif
-
-#ifndef USE_OPENSSL_CRYPTO
+/* Note: not defined here or in lighttpd local "md5.h" */
+/* #if !defined(WITH_OPENSSL) */
#include <string.h>
/* Constants for MD5Transform routine.
@@ -61,16 +56,8 @@ static void li_MD5Transform (UINT4 [4], const unsigned char [64]);
static void Encode (unsigned char *, UINT4 *, unsigned int);
static void Decode (UINT4 *, const unsigned char *, unsigned int);
-#ifdef HAVE_MEMCPY
#define MD5_memcpy(output, input, len) memcpy((output), (input), (len))
-#else
-static void MD5_memcpy (POINTER, POINTER, unsigned int);
-#endif
-#ifdef HAVE_MEMSET
#define MD5_memset(output, value, len) memset((output), (value), (len))
-#else
-static void MD5_memset (POINTER, int, unsigned int);
-#endif
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -315,27 +302,4 @@ static void Decode (UINT4 *output, const unsigned char *input, unsigned int len)
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
-#ifndef HAVE_MEMCPY
-static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
-
- output[i] = input[i];
-}
-#endif
-/* Note: Replace "for loop" with standard memset if possible.
- */
-#ifndef HAVE_MEMSET
-static void MD5_memset (POINTER output, int value, unsigned int len)
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *)output)[i] = (char)value;
-}
-#endif
-#endif
+/* #endif */
diff --git a/src/meson.build b/src/meson.build
index e3c91d2f..e63c5198 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,7 @@
sbinddir = join_paths(get_option('prefix'), get_option('sbindir'))
moduledir = join_paths(get_option('prefix'), get_option('moduledir'))
+# doesn't do much so far :(
+link_static = get_option('link_static')
include_base_paths = [
'/usr/include',
@@ -26,71 +28,75 @@ endif
compiler = meson.get_compiler('c')
conf_data = configuration_data()
-conf_data.set('HAVE_SYS_DEVPOLL_H', compiler.has_header('sys/devpoll.h'))
-conf_data.set('HAVE_SYS_EPOLL_H', compiler.has_header('sys/epoll.h'))
-conf_data.set('HAVE_SYS_EVENT_H', compiler.has_header('sys/event.h'))
-conf_data.set('HAVE_SYS_MMAN_H', compiler.has_header('sys/mman.h'))
-conf_data.set('HAVE_SYS_POLL_H', compiler.has_header('sys/poll.h'))
-conf_data.set('HAVE_SYS_PORT_H', compiler.has_header('sys/port.h'))
-conf_data.set('HAVE_SYS_PRCTL_H', compiler.has_header('sys/prctl.h'))
-conf_data.set('HAVE_SYS_RESOURCE_H', compiler.has_header('sys/resource.h'))
-conf_data.set('HAVE_SYS_SENDFILE_H', compiler.has_header('sys/sendfile.h'))
-conf_data.set('HAVE_SYS_SELECT_H', compiler.has_header('sys/select.h'))
-conf_data.set('HAVE_SYS_TYPES_H', compiler.has_header('sys/types.h'))
-conf_data.set('HAVE_SYS_UIO_H', compiler.has_header('sys/uio.h'))
-conf_data.set('HAVE_SYS_UN_H', compiler.has_header('sys/un.h'))
-conf_data.set('HAVE_SYS_WAIT_H', compiler.has_header('sys/wait.h'))
-conf_data.set('HAVE_SYS_TIME_H', compiler.has_header('sys/time.h'))
-conf_data.set('HAVE_UNISTD_H', compiler.has_header('unistd.h'))
-conf_data.set('HAVE_PTHREAD_H', compiler.has_header('pthread.h'))
-conf_data.set('HAVE_GETOPT_H', compiler.has_header('getopt.h'))
-conf_data.set('HAVE_INTTYPES_H', compiler.has_header('inttypes.h'))
-conf_data.set('HAVE_POLL_H', compiler.has_header('poll.h'))
-conf_data.set('HAVE_PWD_H', compiler.has_header('pwd.h'))
-conf_data.set('HAVE_STDDEF_H', compiler.has_header('stddef.h'))
-conf_data.set('HAVE_STDINT_H', compiler.has_header('stdint.h'))
-conf_data.set('HAVE_STRINGS_H', compiler.has_header('strings.h'))
-conf_data.set('HAVE_SYSLOG_H', compiler.has_header('syslog.h'))
-
-# check for fastcgi lib, for the tests only
-conf_data.set('HAVE_FASTCGI_H', compiler.has_header('fastcgi.h'))
-if not(conf_data.get('HAVE_FASTCGI_H'))
- conf_data.set('HAVE_FASTCGI_FASTCGI_H', compiler.has_header('fastcgi/fastcgi.h'))
-endif
+check_headers = [
+ 'getopt.h',
+ 'poll.h',
+ 'port.h',
+ 'pwd.h',
+ 'stdlib.h',
+ 'string.h',
+ 'strings.h',
+ 'sys/devpoll.h',
+ 'sys/epoll.h',
+ 'sys/event.h',
+ 'sys/filio.h',
+ 'sys/mman.h',
+ 'sys/poll.h',
+ 'sys/prctl.h',
+ 'sys/resource.h',
+ 'sys/select.h',
+ 'sys/sendfile.h',
+ 'sys/time.h',
+ 'sys/uio.h',
+ 'sys/un.h',
+ 'syslog.h',
+]
+
+# headers checked in special autoconf macros
+check_headers += [
+ 'inttypes.h',
+ 'stdint.h',
+ 'sys/wait.h',
+]
+
+foreach h: check_headers
+ conf_data.set('HAVE_' + h.to_upper().underscorify(), compiler.has_header(h))
+endforeach
# will be needed for auth
conf_data.set('HAVE_CRYPT_H', compiler.has_header('crypt.h'))
if conf_data.get('HAVE_CRYPT_H')
# check if we need libcrypt for crypt_r / crypt
+ libcrypt = compiler.find_library('crypt', required: false)
# crypt_r in default libs?
if compiler.has_function('crypt_r', args: defs, prefix: '#include <crypt.h>')
libcrypt = []
conf_data.set('HAVE_CRYPT_R', 1)
# crypt_r in -lcrypt ?
- elif compiler.has_function('crypt_r', args: defs + ['-lcrypt'], prefix: '#include <crypt.h>')
- libcrypt = [ compiler.find_library('crypt') ]
+ elif libcrypt.found() and compiler.has_function('crypt_r', args: defs, dependencies: libcrypt, prefix: '#include <crypt.h>')
+ libcrypt = [ libcrypt ]
conf_data.set('HAVE_CRYPT_R', 1)
# crypt in default libs?
elif compiler.has_function('crypt', args: defs, prefix: '#include <crypt.h>')
libcrypt = []
conf_data.set('HAVE_CRYPT', 1)
# crypt in -lcrypt ?
- elif compiler.has_function('crypt', args: defs + ['-lcrypt'], prefix: '#include <crypt.h>')
- libcrypt = [ compiler.find_library('crypt') ]
+ elif libcrypt.found() and compiler.has_function('crypt', args: defs, dependencies: libcrypt, prefix: '#include <crypt.h>')
+ libcrypt = [ libcrypt ]
conf_data.set('HAVE_CRYPT', 1)
endif
endif
-conf_data.set('HAVE_SYS_INOTIFY_H', compiler.has_header('sys/inotify.h'))
-if conf_data.get('HAVE_SYS_INOTIFY_H')
- conf_data.set('HAVE_INOTIFY_INIT', compiler.has_function('inotify_init', args: defs))
-endif
-
-conf_data.set('HAVE_SOCKLEN_T', compiler.has_type('socklen_t', args: defs, prefix: '#include <sys/socket.h>'))
+conf_data.set('HAVE_SOCKLEN_T', compiler.has_type('socklen_t',
+ args: defs,
+ prefix: '''
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ '''
+))
-conf_data.set('HAVE_SYS_RANDOM_H', compiler.has_header('sys/random.h'))
-if conf_data.get('HAVE_SYS_RANDOM_H')
+if compiler.has_header('sys/random.h')
conf_data.set('HAVE_GETENTROPY', compiler.has_function(
'getentropy',
args: defs,
@@ -107,52 +113,45 @@ if conf_data.get('HAVE_LINUX_RANDOM_H')
))
endif
-conf_data.set('SIZEOF_LONG', compiler.sizeof('long', args: defs))
-conf_data.set('SIZEOF_OFF_T', compiler.sizeof('off_t', args: defs))
-
-conf_data.set('HAVE_ARC4RANDOM_BUF', compiler.has_function('arc4random_buf', args: defs))
-conf_data.set('HAVE_CHROOT', compiler.has_function('chroot', args: defs))
-conf_data.set('HAVE_EPOLL_CTL', compiler.has_function('epoll_ctl', args: defs))
-conf_data.set('HAVE_FORK', compiler.has_function('fork', args: defs))
-conf_data.set('HAVE_GETLOADAVG', compiler.has_function('getloadavg', args: defs))
-conf_data.set('HAVE_GETRLIMIT', compiler.has_function('getrlimit', args: defs))
-conf_data.set('HAVE_GETUID', compiler.has_function('getuid', args: defs))
-conf_data.set('HAVE_GMTIME_R', compiler.has_function('gmtime_r', args: defs))
-conf_data.set('HAVE_INET_NTOP', compiler.has_function('inet_ntop', args: defs))
-conf_data.set('HAVE_JRAND48', compiler.has_function('jrand48', args: defs))
-conf_data.set('HAVE_KQUEUE', compiler.has_function('kqueue', args: defs))
-conf_data.set('HAVE_LOCALTIME_R', compiler.has_function('localtime_r', args: defs))
-conf_data.set('HAVE_LSTAT', compiler.has_function('lstat', args: defs))
-conf_data.set('HAVE_MADVISE', compiler.has_function('madvise', args: defs))
-conf_data.set('HAVE_MEMCPY', compiler.has_function('memcpy', args: defs))
-conf_data.set('HAVE_MEMSET', compiler.has_function('memset', args: defs))
-conf_data.set('HAVE_MMAP', compiler.has_function('mmap', args: defs))
-conf_data.set('HAVE_PATHCONF', compiler.has_function('pathconf', args: defs))
-conf_data.set('HAVE_PIPE2', compiler.has_function('pipe2', args: defs))
-conf_data.set('HAVE_POLL', compiler.has_function('poll', args: defs))
-conf_data.set('HAVE_PORT_CREATE', compiler.has_function('port_create', args: defs))
-conf_data.set('HAVE_PRCTL', compiler.has_function('prctl', args: defs))
-conf_data.set('HAVE_PREAD', compiler.has_function('pread', args: defs))
-conf_data.set('HAVE_POSIX_FADVISE', compiler.has_function('posix_fadvise', args: defs))
-conf_data.set('HAVE_SELECT', compiler.has_function('select', args: defs))
-conf_data.set('HAVE_SENDFILE', compiler.has_function('sendfile', args: defs))
-conf_data.set('HAVE_SEND_FILE', compiler.has_function('send_file', args: defs))
-conf_data.set('HAVE_SENDFILE64', compiler.has_function('sendfile64', args: defs))
-conf_data.set('HAVE_SENDFILEV', compiler.has_function('sendfilev', args: defs))
-conf_data.set('HAVE_SIGACTION', compiler.has_function('sigaction', args: defs))
-conf_data.set('HAVE_SIGNAL', compiler.has_function('signal', args: defs))
-conf_data.set('HAVE_SIGTIMEDWAIT', compiler.has_function('sigtimedwait', args: defs))
-conf_data.set('HAVE_SRANDOM', compiler.has_function('srandom', args: defs))
-conf_data.set('HAVE_STRPTIME', compiler.has_function('strptime', args: defs))
-conf_data.set('HAVE_SYSLOG', compiler.has_function('syslog', args: defs))
-conf_data.set('HAVE_WRITEV', compiler.has_function('writev', args: defs))
-conf_data.set('HAVE_INET_ATON', compiler.has_function('inet_aton', args: defs))
-conf_data.set('HAVE_ISSETUGID', compiler.has_function('issetugid', args: defs))
-conf_data.set('HAVE_INET_PTON', compiler.has_function('inet_pton', args: defs))
-conf_data.set('HAVE_MEMSET_S', compiler.has_function('memset_s', args: defs))
-conf_data.set('HAVE_EXPLICIT_BZERO', compiler.has_function('explicit_bzero', args: defs))
-
-conf_data.set('HAVE_CLOCK_GETTIME', compiler.has_header_symbol('time.h', 'clock_gettime'))
+check_funcs = [
+ 'arc4random_buf',
+ 'chroot',
+ 'clock_gettime',
+ 'epoll_ctl',
+ 'explicit_bzero',
+ 'fork',
+ 'getloadavg',
+ 'getrlimit',
+ 'getuid',
+ 'gmtime_r',
+ 'inet_pton',
+ 'issetugid',
+ 'jrand48',
+ 'kqueue',
+ 'localtime_r',
+ 'lstat',
+ 'madvise',
+ 'memset_s',
+ 'mmap',
+ 'pathconf',
+ 'pipe2',
+ 'poll',
+ 'port_create',
+ 'select',
+ 'send_file',
+ 'sendfile',
+ 'sendfile64',
+ 'sigaction',
+ 'signal',
+ 'srandom',
+ 'writev',
+]
+
+foreach f: check_funcs
+ conf_data.set('HAVE_' + f.to_upper(), compiler.has_function(f, args: defs))
+endforeach
+
+# check whether clock_gettime needs -lrt
clock_lib = []
if not(conf_data.get('HAVE_CLOCK_GETTIME'))
if compiler.has_function('clock_gettime', args: defs + ['-lrt'], prefix: '#include <time.h>')
@@ -186,7 +185,7 @@ conf_data.set('HAVE_WEAK_SYMBOLS', compiler.compiles('''
args: defs
))
-conf_data.set('HAVE_STRUCT_TM_GMTOFF', compiler.compiles('''
+conf_data.set('HAVE_STRUCT_TM_TM_GMTOFF', compiler.compiles('''
#include <time.h>
int main(void) {
struct tm t;
@@ -218,15 +217,14 @@ libbz2 = []
if get_option('with_bzip')
libbz2 = [ compiler.find_library('bz2') ]
if compiler.has_function('BZ2_bzCompress', args: defs, dependencies: libbz2, prefix: '#include <bzlib.h>')
- conf_data.set('HAVE_BZLIB_H', true)
- conf_data.set('HAVE_LIBBZ2', true)
+ conf_data.set('WITH_BZIP', true)
else
error('Couldn\'t find bz2 header / library')
endif
endif
if get_option('with_dbi')
- libdbi = dependency('dbi', required: false)
+ libdbi = dependency('dbi', required: false, static: link_static)
if libdbi.found()
libdbi = [ libdbi ]
else
@@ -235,7 +233,7 @@ if get_option('with_dbi')
error('Couldn\'t find dbi/dbi.h or dbi_conn_connect in lib dbi')
endif
endif
- conf_data.set('HAVE_DBI', true)
+ conf_data.set('WITH_DBI', true)
endif
libfam = []
@@ -244,12 +242,13 @@ if get_option('with_fam')
if not(compiler.has_function('FAMOpen2', args: defs, dependencies: libfam, prefix: '#include <fam.h>'))
error('Couldn\'t find fam.h or FAMOpen2 in lib fam')
endif
- conf_data.set('HAVE_FAM_H', true)
+ conf_data.set('HAVE_FAMNOEXISTS', compiler.has_function('FAMNoExists', args: defs, dependencies: libfam, prefix: '#include <fam.h>'))
+ conf_data.set('WITH_FAM', true)
endif
libgeoip = []
if get_option('with_geoip')
- libgeoip = dependency('geoip', required: false)
+ libgeoip = dependency('geoip', required: false, static: link_static)
if libgeoip.found()
libgeoip = [ libgeoip ]
else
@@ -258,6 +257,7 @@ if get_option('with_geoip')
error('Couldn\'t find GeoIP_country_name_by_addr in lib GeoIP')
endif
endif
+ conf_data.set('WITH_GEOIP', true)
endif
libgdbm = []
@@ -266,14 +266,13 @@ if get_option('with_gdbm')
if not(compiler.has_function('gdbm_open', args: defs, dependencies: libgdbm, prefix: '#include <gdbm.h>'))
error('Couldn\'t find gdbm.h or gdbm_open in lib gdbm')
endif
- conf_data.set('HAVE_GDBM_H', true)
- conf_data.set('HAVE_GDBM', true)
+ conf_data.set('WITH_GDBM', true)
endif
libkrb5 = []
libgssapi_krb5 = []
if get_option('with_krb5')
- libkrb5 = dependency('krb5', required: false)
+ libkrb5 = dependency('krb5', required: false, static: link_static)
if libkrb5.found()
libkrb5 = [ libkrb5 ]
else
@@ -283,14 +282,14 @@ if get_option('with_krb5')
endif
endif
- libgssapi_krb5 = dependency('krb5-gssapi', required: false)
+ libgssapi_krb5 = dependency('krb5-gssapi', required: false, static: link_static)
if libgssapi_krb5.found()
libgssapi_krb5 = [ libgssapi_krb5 ]
else
libgssapi_krb5 = [ compiler.find_library('gssapi_krb5') ]
endif
- conf_data.set('HAVE_KRB5', true)
+ conf_data.set('WITH_KRB5', true)
endif
libldap = []
@@ -301,26 +300,23 @@ if get_option('with_ldap')
args: defs,
dependencies: libldap,
prefix: '''
+ /* ldap_bind is part of the deprecated api */
#define LDAP_DEPRECATED 1
#include <ldap.h>
'''
))
error('Couldn\'t find ldap.h or ldap_bind in lib libldap')
endif
- conf_data.set('HAVE_LDAP_H', true)
- conf_data.set('HAVE_LIBLDAP', true)
liblber = [ compiler.find_library('lber') ]
if not(compiler.has_function('ber_printf', args: defs, dependencies: liblber, prefix: '#include <lber.h>'))
error('Couldn\'t find lber.h or ber_printf in lib liblber')
endif
- conf_data.set('HAVE_LBER_H', true)
- conf_data.set('HAVE_LIBLBER', true)
- conf_data.set('LDAP_DEPRECATED', 1, comment: 'Using deprecated ldap api')
+ conf_data.set('WITH_LDAP', true)
endif
libev = []
if get_option('with_libev')
- libev = dependency('ev', required: false)
+ libev = dependency('ev', required: false, static: link_static)
if libev.found()
libev = [ libev ]
elif compiler.has_header('ev.h') and compiler.has_function('ev_time', args: defs + ['-lev'])
@@ -328,12 +324,13 @@ if get_option('with_libev')
else
error('Couldn\'t find libev header / library')
endif
- conf_data.set('HAVE_LIBEV', true)
+ conf_data.set('WITH_LIBEV', true)
endif
libunwind = []
if get_option('with_libunwind')
- libunwind = [ dependency('libunwind') ]
+ libunwind = [ dependency('libunwind', static: link_static) ]
+ conf_data.set('WITH_LIBUNWIND', true)
endif
liblua = []
@@ -341,7 +338,7 @@ if get_option('with_lua')
found_lua = false
foreach l: ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']
if not(found_lua)
- liblua = dependency(l, required: false)
+ liblua = dependency(l, required: false, static: link_static)
found_lua = liblua.found()
endif
endforeach
@@ -349,7 +346,7 @@ if get_option('with_lua')
error('Couldn\'t find any lua library')
endif
liblua = [ liblua ]
- conf_data.set('HAVE_LUA_H', true)
+ conf_data.set('WITH_LUA', true)
endif
libmemcached = []
@@ -357,8 +354,8 @@ if get_option('with_memcached')
# manual search:
# header: libmemcached/memcached.h
# function: memcached (-lmemcached)
- libmemcached = [ dependency('libmemcached') ]
- conf_data.set('USE_MEMCACHED', true)
+ libmemcached = [ dependency('libmemcached', static: link_static) ]
+ conf_data.set('WITH_MEMCACHED', true)
endif
libmysqlclient = []
@@ -366,8 +363,8 @@ if get_option('with_mysql')
# manual search: extend include path with 'mysql/'
# header: mysql.h
# function: mysql_real_connect (-lmysqlclient)
- libmysqlclient = [ dependency('mysqlclient') ]
- conf_data.set('HAVE_MYSQL', true)
+ libmysqlclient = [ dependency('mysqlclient', static: link_static) ]
+ conf_data.set('WITH_MYSQL', true)
endif
libssl = []
@@ -377,10 +374,9 @@ if get_option('with_openssl')
# header: openssl/ssl.h
# function: SSL_new (-lssl)
# function: BIO_f_base64 (-lcrypto)
- libssl = [ dependency('libssl') ]
- libcrypto = [ dependency('libcrypto') ]
- conf_data.set('HAVE_OPENSSL_SSL_H', true)
- conf_data.set('HAVE_LIBSSL', true)
+ libssl = [ dependency('libssl', static: link_static) ]
+ libcrypto = [ dependency('libcrypto', static: link_static) ]
+ conf_data.set('WITH_OPENSSL', true)
endif
libpcre = []
@@ -388,9 +384,8 @@ if get_option('with_pcre')
# manual search:
# header: pcre.h
# function: pcre_exec (-lpcre)
- libpcre = [ dependency('libpcre') ]
- conf_data.set('HAVE_PCRE_H', true)
- conf_data.set('HAVE_LIBPCRE', true)
+ libpcre = [ dependency('libpcre', static: link_static) ]
+ conf_data.set('WITH_PCRE', true)
endif
libpq = []
@@ -398,8 +393,8 @@ if get_option('with_pgsql')
# manual search:
# header: libpq-fe.h
# function: PQsetdbLogin (-lpq)
- libpq = [ dependency('libpq') ]
- conf_data.set('HAVE_PGSQL', true)
+ libpq = [ dependency('libpq', static: link_static) ]
+ conf_data.set('WITH_PGSQL', true)
endif
#if get_option('with_valgrind')
@@ -407,7 +402,11 @@ endif
libuuid = []
if get_option('with_webdav_locks')
- libuuid = dependency('uuid', required: false)
+ if not(get_option('with_webdav_props'))
+ error('webdav locks requires webdav props')
+ endif
+
+ libuuid = dependency('uuid', required: false, static: link_static)
if libuuid.found()
libuuid = [ libuuid ]
elif compiler.has_function('uuid_generate', args: defs, prefix: '#include <uuid/uuid.h>')
@@ -423,14 +422,13 @@ if get_option('with_webdav_locks')
error('Couldn\'t find uuid/uuid.h or uuid_generate in lib c and uuid')
endif
endif
- conf_data.set('HAVE_UUID', true)
- conf_data.set('HAVE_UUID_UUID_H', true)
+ conf_data.set('WITH_UUID', true)
endif
libxml2 = []
libsqlite3 = []
if get_option('with_webdav_props')
- libxml2 = dependency('libxml-2.0', required: false)
+ libxml2 = dependency('libxml-2.0', required: false, static: link_static)
if libxml2.found()
libxml2 = [ libxml2 ]
else
@@ -465,9 +463,9 @@ if get_option('with_webdav_props')
# has_function doesn't like "internal dependencies"
libxml2 += libxml2_includes_dep
endif
- conf_data.set('HAVE_LIBXML_H', true)
+ conf_data.set('WITH_XML', true)
- libsqlite3 = dependency('sqlite31', required: false)
+ libsqlite3 = dependency('sqlite31', required: false, static: link_static)
if libsqlite3.found()
libsqlite3 = [ libsqlite3 ]
else
@@ -482,29 +480,36 @@ if get_option('with_webdav_props')
error('Couldn\'t find sqlite3.h or sqlite3_reset in lib sqlite3')
endif
endif
- conf_data.set('HAVE_SQLITE3_H', true)
+ conf_data.set('WITH_SQLITE3', true)
endif
libattr = []
if get_option('with_xattr')
- libattr = [ compiler.find_library('attr') ]
- if not(compiler.has_function('attr_get',
- args: defs,
- dependencies: libattr,
- prefix: '''
- #include <sys/types.h>
- #include <attr/attributes.h>
- '''
- ))
- error('Couldn\'t find attr/attributes.h or attr_get in lib attr')
+ libattr = compiler.find_library('attr')
+ if libattr.found()
+ libattr = [ libattr ]
+ if not(compiler.has_function('attr_get',
+ args: defs,
+ dependencies: libattr,
+ prefix: '''
+ #include <sys/types.h>
+ #include <attr/attributes.h>
+ '''
+ ))
+ error('Couldn\'t find attr/attributes.h or attr_get in lib attr')
+ endif
+ conf_data.set('HAVE_LIBATTR', true)
+ elif compiler.has_function('extattr_get_file', args: defs, prefix: '#include <sys/extattr.h>')
+ # BSD extended attributes, no lib needed
+ libattr = []
+ conf_data.set('HAVE_EXTATTR', true)
endif
- conf_data.set('HAVE_ATTR_ATTRIBUTES_H', true)
- conf_data.set('HAVE_XATTR', true)
+ conf_data.set('WITH_XATTR', true)
endif
libz = []
if get_option('with_zlib')
- libz = dependency('zlib', required: false)
+ libz = dependency('zlib', required: false, static: link_static)
if libz.found()
libz = [ libz ]
else
@@ -514,8 +519,7 @@ if get_option('with_zlib')
error('Couldn\'t find z header / library')
endif
endif
- conf_data.set('HAVE_ZLIB_H', true)
- conf_data.set('HAVE_LIBZ', true)
+ conf_data.set('WITH_ZLIB', true)
endif
configure_file(
@@ -624,62 +628,8 @@ common_flags = [ declare_dependency(
# tests also use common_flags, and need this
include_directories: include_directories('.'),
) ]
-
lighttpd_flags = []
lighttpd_angel_flags = []
-if target_machine.system() == 'windows'
- lighttpd_flags += [ declare_dependency(
- compile_args: [
- '-DLI_DECLARE_EXPORTS',
- ],
- ) ]
- if compiler.get_id() == 'gcc'
- libmsvcr70 = [ compiler.find_library('msvcr70') ]
- lighttpd_flags += libmsvcr70 + [ declare_dependency(
- link_args: [
- '-Wl,-subsystem,console',
- ],
- ) ]
- lighttpd_angel_flags += libmsvcr70 + [ declare_dependency(
- link_args: [
- '-Wl,-subsystem,console',
- ],
- ) ]
- endif
-endif
-
-if compiler.get_id() == 'gcc' or target_machine.system() != 'darwin'
- lighttpd_flags += [ declare_dependency(
- link_args: [
- '-Wl,-export-dynamic',
- ],
- ) ]
-endif
-
-executable('lighttpd-angel',
- sources: 'lighttpd-angel.c',
- dependencies: common_flags + lighttpd_angel_flags,
- c_args: ['-DSBIN_DIR="' + sbinddir + '"'],
- install: true,
- install_dir: sbinddir,
-)
-
-executable('lighttpd', configparser,
- sources: common_src + main_src,
- # libssl needed?
- dependencies: common_flags + lighttpd_flags
- + libattr
- + libcrypto
- + libdl
- + libev
- + libfam
- + libpcre
- + libunwind
- + libws2_32
- ,
- install: true,
- install_dir: sbinddir,
-)
test('test_buffer', executable('test_buffer',
sources: ['test_buffer.c', 'buffer.c'],
@@ -806,15 +756,91 @@ if get_option('with_openssl')
]
endif
-foreach mod: modules
- mod_name = mod.get(0)
- mod_sources = mod.get(1)
- mod_deps = mod.length() > 2 ? mod.get(2) : []
- shared_module(mod_name,
- sources: mod_sources,
- dependencies: common_flags + mod_deps,
- name_prefix: '',
- install: true,
- install_dir: moduledir,
+if get_option('build_static')
+ sh = find_program('sh')
+ plugin_names = []
+ foreach mod: modules
+ mod_name = mod.get(0)
+ mod_sources = mod.get(1)
+ mod_deps = mod.length() > 2 ? mod.get(2) : []
+ plugin_names += [ mod_name ]
+ lighttpd_flags += mod_deps + [ declare_dependency(
+ sources: mod_sources,
+ ) ]
+ endforeach
+ # printf repeats the format string until all arguments are handled;
+ # the plugin names should be "sane" ([a-zA-Z0-9_]+)
+ plugin_static_h = custom_target('plugin-static.h',
+ command: [ sh, '-c', 'printf \'PLUGIN_INIT(%s)\n\' ' + ' '.join(plugin_names) ],
+ capture: true,
+ output: [ 'plugin-static.h' ],
)
-endforeach
+ main_src += [ plugin_static_h ]
+else
+ foreach mod: modules
+ mod_name = mod.get(0)
+ mod_sources = mod.get(1)
+ mod_deps = mod.length() > 2 ? mod.get(2) : []
+ shared_module(mod_name,
+ sources: mod_sources,
+ dependencies: common_flags + mod_deps,
+ name_prefix: '',
+ install: true,
+ install_dir: moduledir,
+ )
+ endforeach
+endif
+
+if target_machine.system() == 'windows'
+ lighttpd_flags += [ declare_dependency(
+ compile_args: [
+ '-DLI_DECLARE_EXPORTS',
+ ],
+ ) ]
+ if compiler.get_id() == 'gcc'
+ libmsvcr70 = [ compiler.find_library('msvcr70') ]
+ lighttpd_flags += libmsvcr70 + [ declare_dependency(
+ link_args: [
+ '-Wl,-subsystem,console',
+ ],
+ ) ]
+ lighttpd_angel_flags += libmsvcr70 + [ declare_dependency(
+ link_args: [
+ '-Wl,-subsystem,console',
+ ],
+ ) ]
+ endif
+endif
+
+if compiler.get_id() == 'gcc' or target_machine.system() != 'darwin'
+ lighttpd_flags += [ declare_dependency(
+ link_args: [
+ '-Wl,-export-dynamic',
+ ],
+ ) ]
+endif
+
+executable('lighttpd-angel',
+ sources: 'lighttpd-angel.c',
+ dependencies: common_flags + lighttpd_angel_flags,
+ c_args: ['-DSBIN_DIR="' + sbinddir + '"'],
+ install: true,
+ install_dir: sbinddir,
+)
+
+executable('lighttpd',
+ sources: common_src + main_src + [ configparser ],
+ # libssl needed?
+ dependencies: common_flags + lighttpd_flags
+ + libattr
+ + libcrypto
+ + libdl
+ + libev
+ + libfam
+ + libpcre
+ + libunwind
+ + libws2_32
+ ,
+ install: true,
+ install_dir: sbinddir,
+)
diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c
index 3e6773ce..79ac33fe 100644
--- a/src/mod_accesslog.c
+++ b/src/mod_accesslog.c
@@ -833,15 +833,15 @@ REQUESTDONE_FUNC(log_access_write) {
/* cache the generated timestamp (only if ! FORMAT_FLAG_TIME_BEGIN) */
struct tm *tmptr;
time_t t;
- #if defined(HAVE_STRUCT_TM_GMTOFF)
+ #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
# ifdef HAVE_LOCALTIME_R
struct tm tm;
# endif /* HAVE_LOCALTIME_R */
- #else /* HAVE_STRUCT_TM_GMTOFF */
+ #else /* HAVE_STRUCT_TM_TM_GMTOFF */
# ifdef HAVE_GMTIME_R
struct tm tm;
# endif /* HAVE_GMTIME_R */
- #endif /* HAVE_STRUCT_TM_GMTOFF */
+ #endif /* HAVE_STRUCT_TM_TM_GMTOFF */
if (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) {
t = *(p->conf.last_generated_accesslog_ts_ptr) = srv->cur_ts;
@@ -850,24 +850,24 @@ REQUESTDONE_FUNC(log_access_write) {
t = con->request_start;
}
- #if defined(HAVE_STRUCT_TM_GMTOFF)
+ #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
# ifdef HAVE_LOCALTIME_R
tmptr = localtime_r(&t, &tm);
# else /* HAVE_LOCALTIME_R */
tmptr = localtime(&t);
# endif /* HAVE_LOCALTIME_R */
- #else /* HAVE_STRUCT_TM_GMTOFF */
+ #else /* HAVE_STRUCT_TM_TM_GMTOFF */
# ifdef HAVE_GMTIME_R
tmptr = gmtime_r(&t, &tm);
# else /* HAVE_GMTIME_R */
tmptr = gmtime(&t);
# endif /* HAVE_GMTIME_R */
- #endif /* HAVE_STRUCT_TM_GMTOFF */
+ #endif /* HAVE_STRUCT_TM_TM_GMTOFF */
buffer_string_prepare_copy(p->conf.ts_accesslog_str, 255);
if (buffer_string_is_empty(f->string)) {
- #if defined(HAVE_STRUCT_TM_GMTOFF)
+ #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
long scd, hrs, min;
buffer_append_strftime(p->conf.ts_accesslog_str, "[%d/%b/%Y:%H:%M:%S ", tmptr);
buffer_append_string_len(p->conf.ts_accesslog_str, tmptr->tm_gmtoff >= 0 ? "+" : "-", 1);
@@ -885,7 +885,7 @@ REQUESTDONE_FUNC(log_access_write) {
buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("]"));
#else
buffer_append_strftime(p->conf.ts_accesslog_str, "[%d/%b/%Y:%H:%M:%S +0000]", tmptr);
- #endif /* HAVE_STRUCT_TM_GMTOFF */
+ #endif /* HAVE_STRUCT_TM_TM_GMTOFF */
} else {
buffer_append_strftime(p->conf.ts_accesslog_str, f->string->ptr, tmptr);
}
diff --git a/src/mod_authn_file.c b/src/mod_authn_file.c
index c7cff52e..2e342a5c 100644
--- a/src/mod_authn_file.c
+++ b/src/mod_authn_file.c
@@ -14,11 +14,7 @@
# define HAVE_CRYPT
#endif
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
-#define USE_OPENSSL_CRYPTO
-#endif
-
-#ifdef USE_OPENSSL_CRYPTO
+#if defined(WITH_OPENSSL)
#include <openssl/md4.h>
#endif
@@ -645,7 +641,7 @@ static handler_t mod_authn_file_htpasswd_basic(server *srv, connection *con, voi
crypt_tmp_data.initialized = 0;
#endif
#endif
- #ifdef USE_OPENSSL_CRYPTO /* (for MD4_*() (e.g. MD4_Update())) */
+ #if defined(WITH_OPENSSL) /* (for MD4_*() (e.g. MD4_Update())) */
if (0 == memcmp(password->ptr, CONST_STR_LEN("$1+ntlm$"))) {
/* CRYPT-MD5-NTLM algorithm
* This algorithm allows for the construction of (slight more)
diff --git a/src/mod_authn_ldap.c b/src/mod_authn_ldap.c
index d8be4f5f..d4ccc0e2 100644
--- a/src/mod_authn_ldap.c
+++ b/src/mod_authn_ldap.c
@@ -1,6 +1,7 @@
#include "first.h"
-#define USE_LDAP
+/* Using deprecated ldap api */
+#define LDAP_DEPRECATED 1
#include <ldap.h>
#include "server.h"
diff --git a/src/mod_cml.c b/src/mod_cml.c
index 16abd589..cd231ded 100644
--- a/src/mod_cml.c
+++ b/src/mod_cml.c
@@ -49,7 +49,7 @@ FREE_FUNC(mod_cml_free) {
buffer_free(s->power_magnet);
array_free(s->mc_hosts);
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
if (s->memc) memcached_free(s->memc);
#endif
@@ -94,7 +94,7 @@ SETDEFAULTS_FUNC(mod_cml_set_defaults) {
s->mc_hosts = array_init();
s->mc_namespace = buffer_init();
s->power_magnet = buffer_init();
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
s->memc = NULL;
#endif
@@ -116,7 +116,7 @@ SETDEFAULTS_FUNC(mod_cml_set_defaults) {
}
if (s->mc_hosts->used) {
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
buffer *option_string = buffer_init();
size_t k;
@@ -162,7 +162,7 @@ static int mod_cml_patch_connection(server *srv, connection *con, plugin_data *p
plugin_config *s = p->config_storage[0];
PATCH(ext);
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
PATCH(memc);
#endif
PATCH(mc_namespace);
@@ -183,7 +183,7 @@ static int mod_cml_patch_connection(server *srv, connection *con, plugin_data *p
if (buffer_is_equal_string(du->key, CONST_STR_LEN("cml.extension"))) {
PATCH(ext);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("cml.memcache-hosts"))) {
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
PATCH(memc);
#endif
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("cml.memcache-namespace"))) {
diff --git a/src/mod_cml.h b/src/mod_cml.h
index f47210c9..581b6b77 100644
--- a/src/mod_cml.h
+++ b/src/mod_cml.h
@@ -8,7 +8,7 @@
#include "plugin.h"
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
#include <libmemcached/memcached.h>
#endif
@@ -19,7 +19,7 @@ typedef struct {
array *mc_hosts;
buffer *mc_namespace;
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
memcached_st *memc;
#endif
buffer *power_magnet;
diff --git a/src/mod_cml_funcs.c b/src/mod_cml_funcs.c
index d582b52b..08b16061 100644
--- a/src/mod_cml_funcs.c
+++ b/src/mod_cml_funcs.c
@@ -176,7 +176,7 @@ int f_file_isdir(lua_State *L) {
-#ifdef USE_MEMCACHED
+#if defined(WITH_MEMCACHED)
int f_memcache_exists(lua_State *L) {
size_t key_len;
const char *key;
diff --git a/src/mod_cml_lua.c b/src/mod_cml_lua.c
index de344fd1..60eb1976 100644
--- a/src/mod_cml_lua.c
+++ b/src/mod_cml_lua.c
@@ -119,7 +119,7 @@ int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) {
lua_register(L, "file_isdir", f_file_isreg);
lua_register(L, "dir_files", f_dir_files);
-#ifdef USE_MEMCACHED
+#if defined(WITH_MEMCACHED)
lua_pushlightuserdata(L, p->conf.memc);
lua_pushcclosure(L, f_memcache_get_long, 1);
lua_setglobal(L, "memcache_get_long");
diff --git a/src/mod_compress.c b/src/mod_compress.c
index 41ad68d1..279645b2 100644
--- a/src/mod_compress.c
+++ b/src/mod_compress.c
@@ -22,20 +22,18 @@
#include <errno.h>
#include <time.h>
-#if defined HAVE_ZLIB_H && defined HAVE_LIBZ
-# define USE_ZLIB
+
+#if defined WITH_ZLIB
# include <zlib.h>
#endif
-#if defined HAVE_BZLIB_H && defined HAVE_LIBBZ2
-# define USE_BZ2LIB
+#if defined WITH_BZIP
/* we don't need stdio interface */
# define BZ_NO_STDIO
# include <bzlib.h>
#endif
-#if defined HAVE_SYS_MMAN_H && defined HAVE_MMAP && defined ENABLE_MMAP
-#define USE_MMAP
+#if defined(USE_MMAP)
#include "sys-mmap.h"
#include <setjmp.h>
@@ -49,7 +47,8 @@ static void sigbus_handler(int sig) {
if (sigbus_jmp_valid) siglongjmp(sigbus_jmp, 1);
log_failed_assert(__FILE__, __LINE__, "SIGBUS");
}
-#endif
+
+#endif /* USE_MMAP */
/* request: accept-encoding */
#define HTTP_ACCEPT_ENCODING_IDENTITY BV(0)
@@ -226,10 +225,10 @@ SETDEFAULTS_FUNC(mod_compress_setdefaults) {
if (encodings_arr->used) {
size_t j = 0;
for (j = 0; j < encodings_arr->used; j++) {
-#if defined(USE_ZLIB) || defined(USE_BZ2LIB)
+#if defined(WITH_ZLIB) || defined(USE_BZ2LIB)
data_string *ds = (data_string *)encodings_arr->data[j];
#endif
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
if (NULL != strstr(ds->value->ptr, "gzip"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP | HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(ds->value->ptr, "x-gzip"))
@@ -251,7 +250,7 @@ SETDEFAULTS_FUNC(mod_compress_setdefaults) {
} else {
/* default encodings */
s->allowed_encodings = 0
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
| HTTP_ACCEPT_ENCODING_GZIP | HTTP_ACCEPT_ENCODING_X_GZIP | HTTP_ACCEPT_ENCODING_DEFLATE
#endif
#ifdef USE_BZ2LIB
@@ -279,7 +278,7 @@ SETDEFAULTS_FUNC(mod_compress_setdefaults) {
}
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
static int deflate_file_to_buffer_gzip(server *srv, connection *con, plugin_data *p, char *start, off_t st_size, time_t mtime) {
unsigned char *c;
unsigned long crc;
@@ -603,7 +602,7 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, bu
ret = -1;
switch(type) {
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
case HTTP_ACCEPT_ENCODING_GZIP:
case HTTP_ACCEPT_ENCODING_X_GZIP:
ret = deflate_file_to_buffer_gzip(srv, con, p, start, sce->st.st_size, sce->st.st_mtime);
@@ -715,7 +714,7 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p,
}
switch(type) {
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
case HTTP_ACCEPT_ENCODING_GZIP:
case HTTP_ACCEPT_ENCODING_X_GZIP:
ret = deflate_file_to_buffer_gzip(srv, con, p, start, sce->st.st_size, sce->st.st_mtime);
@@ -907,7 +906,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
int use_etag = sce->etag != NULL && sce->etag->ptr != NULL;
/* get client side support encodings */
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
if (mod_compress_contains_encoding(value, CONST_STR_LEN("gzip"))) accept_encoding |= HTTP_ACCEPT_ENCODING_GZIP;
if (mod_compress_contains_encoding(value, CONST_STR_LEN("x-gzip"))) accept_encoding |= HTTP_ACCEPT_ENCODING_X_GZIP;
if (mod_compress_contains_encoding(value, CONST_STR_LEN("deflate"))) accept_encoding |= HTTP_ACCEPT_ENCODING_DEFLATE;
diff --git a/src/mod_deflate.c b/src/mod_deflate.c
index 0640ec0b..27a29cd7 100644
--- a/src/mod_deflate.c
+++ b/src/mod_deflate.c
@@ -119,8 +119,7 @@
#include "plugin.h"
-#if defined HAVE_ZLIB_H && defined HAVE_LIBZ
-# define USE_ZLIB
+#if defined WITH_ZLIB
# include <zlib.h>
#endif
#ifndef Z_DEFAULT_COMPRESSION
@@ -130,15 +129,13 @@
#define MAX_WBITS 15
#endif
-#if defined HAVE_BZLIB_H && defined HAVE_LIBBZ2
-# define USE_BZ2LIB
+#if defined WITH_BZIP
/* we don't need stdio interface */
# define BZ_NO_STDIO
# include <bzlib.h>
#endif
-#if defined HAVE_SYS_MMAN_H && defined HAVE_MMAP && defined ENABLE_MMAP
-#define USE_MMAP
+#if defined(USE_MMAP)
#include "sys-mmap.h"
#include <setjmp.h>
@@ -152,7 +149,8 @@ static void sigbus_handler(int sig) {
if (sigbus_jmp_valid) siglongjmp(sigbus_jmp, 1);
log_failed_assert(__FILE__, __LINE__, "SIGBUS");
}
-#endif
+
+#endif /* USE_MMAP */
/* request: accept-encoding */
#define HTTP_ACCEPT_ENCODING_IDENTITY BV(0)
@@ -190,10 +188,10 @@ typedef struct {
typedef struct {
union {
- #ifdef USE_ZLIB
+ #ifdef WITH_ZLIB
z_stream z;
#endif
- #ifdef USE_BZ2LIB
+ #ifdef WITH_BZIP
bz_stream bz;
#endif
int dummy;
@@ -341,10 +339,10 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
if (p->encodings->used) {
size_t j = 0;
for (j = 0; j < p->encodings->used; j++) {
-#if defined(USE_ZLIB) || defined(USE_BZ2LIB)
+#if defined(WITH_ZLIB) || defined(WITH_BZIP)
data_string *ds = (data_string *)p->encodings->data[j];
#endif
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
if (NULL != strstr(ds->value->ptr, "gzip"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP | HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(ds->value->ptr, "x-gzip"))
@@ -356,7 +354,7 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_COMPRESS;
*/
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
if (NULL != strstr(ds->value->ptr, "bzip2"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_BZIP2 | HTTP_ACCEPT_ENCODING_X_BZIP2;
if (NULL != strstr(ds->value->ptr, "x-bzip2"))
@@ -365,12 +363,12 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
}
} else {
/* default encodings */
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP
| HTTP_ACCEPT_ENCODING_X_GZIP
| HTTP_ACCEPT_ENCODING_DEFLATE;
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_BZIP2
| HTTP_ACCEPT_ENCODING_X_BZIP2;
#endif
@@ -393,7 +391,7 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
}
-#if defined(USE_ZLIB) || defined(USE_BZ2LIB)
+#if defined(WITH_ZLIB) || defined(WITH_BZIP)
static int stream_http_chunk_append_mem(server *srv, connection *con, handler_ctx *hctx, size_t len) {
/* future: might also write stream to hctx temporary file in compressed file cache */
return http_chunk_append_mem(srv, con, hctx->output->ptr, len);
@@ -401,7 +399,7 @@ static int stream_http_chunk_append_mem(server *srv, connection *con, handler_ct
#endif
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
static int stream_deflate_init(handler_ctx *hctx) {
z_stream * const z = &hctx->u.z;
@@ -511,7 +509,7 @@ static int stream_deflate_end(server *srv, handler_ctx *hctx) {
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
static int stream_bzip2_init(handler_ctx *hctx) {
bz_stream * const bz = &hctx->u.bz;
@@ -616,12 +614,12 @@ static int stream_bzip2_end(server *srv, handler_ctx *hctx) {
static int mod_deflate_stream_init(handler_ctx *hctx) {
switch(hctx->compression_type) {
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
case HTTP_ACCEPT_ENCODING_GZIP:
case HTTP_ACCEPT_ENCODING_DEFLATE:
return stream_deflate_init(hctx);
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
case HTTP_ACCEPT_ENCODING_BZIP2:
return stream_bzip2_init(hctx);
#endif
@@ -633,12 +631,12 @@ static int mod_deflate_stream_init(handler_ctx *hctx) {
static int mod_deflate_compress(server *srv, connection *con, handler_ctx *hctx, unsigned char *start, off_t st_size) {
if (0 == st_size) return 0;
switch(hctx->compression_type) {
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
case HTTP_ACCEPT_ENCODING_GZIP:
case HTTP_ACCEPT_ENCODING_DEFLATE:
return stream_deflate_compress(srv, con, hctx, start, st_size);
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
case HTTP_ACCEPT_ENCODING_BZIP2:
return stream_bzip2_compress(srv, con, hctx, start, st_size);
#endif
@@ -653,12 +651,12 @@ static int mod_deflate_compress(server *srv, connection *con, handler_ctx *hctx,
static int mod_deflate_stream_flush(server *srv, connection *con, handler_ctx *hctx, int end) {
if (0 == hctx->bytes_in) return 0;
switch(hctx->compression_type) {
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
case HTTP_ACCEPT_ENCODING_GZIP:
case HTTP_ACCEPT_ENCODING_DEFLATE:
return stream_deflate_flush(srv, con, hctx, end);
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
case HTTP_ACCEPT_ENCODING_BZIP2:
return stream_bzip2_flush(srv, con, hctx, end);
#endif
@@ -686,12 +684,12 @@ static void mod_deflate_note_ratio(server *srv, connection *con, handler_ctx *hc
static int mod_deflate_stream_end(server *srv, handler_ctx *hctx) {
switch(hctx->compression_type) {
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
case HTTP_ACCEPT_ENCODING_GZIP:
case HTTP_ACCEPT_ENCODING_DEFLATE:
return stream_deflate_end(srv, hctx);
#endif
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
case HTTP_ACCEPT_ENCODING_BZIP2:
return stream_bzip2_end(srv, hctx);
#endif
@@ -993,16 +991,16 @@ static int mod_deflate_patch_connection(server *srv, connection *con, plugin_dat
static int mod_deflate_choose_encoding (const char *value, plugin_data *p, const char **label) {
/* get client side support encodings */
int accept_encoding = 0;
-#if !defined(USE_ZLIB) && !defined(USE_BZ2LIB)
+#if !defined(WITH_ZLIB) && !defined(WITH_BZIP)
UNUSED(value);
#endif
-#ifdef USE_ZLIB
+#ifdef WITH_ZLIB
if (NULL != strstr(value, "gzip")) accept_encoding |= HTTP_ACCEPT_ENCODING_GZIP;
else if (NULL != strstr(value, "x-gzip")) accept_encoding |= HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(value, "deflate")) accept_encoding |= HTTP_ACCEPT_ENCODING_DEFLATE;
#endif
/* if (NULL != strstr(value, "compress")) accept_encoding |= HTTP_ACCEPT_ENCODING_COMPRESS; */
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
if (p->conf.allowed_encodings & (HTTP_ACCEPT_ENCODING_BZIP2 | HTTP_ACCEPT_ENCODING_X_BZIP2)) {
if (NULL != strstr(value, "bzip2")) accept_encoding |= HTTP_ACCEPT_ENCODING_BZIP2;
else if (NULL != strstr(value, "x-bzip2")) accept_encoding |= HTTP_ACCEPT_ENCODING_X_BZIP2;
@@ -1014,7 +1012,7 @@ static int mod_deflate_choose_encoding (const char *value, plugin_data *p, const
accept_encoding &= p->conf.allowed_encodings;
/* select best matching encoding */
-#ifdef USE_BZ2LIB
+#ifdef WITH_BZIP
if (accept_encoding & HTTP_ACCEPT_ENCODING_BZIP2) {
*label = "bzip2";
return HTTP_ACCEPT_ENCODING_BZIP2;
diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c
index 597ec3b7..032e0443 100644
--- a/src/mod_dirlisting.c
+++ b/src/mod_dirlisting.c
@@ -21,18 +21,22 @@
* this is a dirlisting for a lighttpd plugin
*/
-#ifdef HAVE_ATTR_ATTRIBUTES_H
-#include <attr/attributes.h>
-#endif
-
-#ifdef HAVE_SYS_EXTATTR_H
-#include <sys/extattr.h>
+#if defined(WITH_XATTR)
+# if defined(HAVE_LIBATTR)
+/* linux */
+# include <attr/attributes.h>
+# elif defined(HAVE_EXTATTR)
+/* BSD */
+# include <sys/extattr.h>
+# else
+# error Unknown extended attribute support
+# endif
#endif
/* plugin config for all request/connections */
typedef struct {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
pcre *regex;
#endif
buffer *string;
@@ -84,7 +88,7 @@ static excludes_buffer *excludes_buffer_init(void) {
}
static int excludes_buffer_append(excludes_buffer *exb, buffer *string) {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
size_t i;
const char *errptr;
int erroff;
@@ -131,7 +135,7 @@ static int excludes_buffer_append(excludes_buffer *exb, buffer *string) {
}
static void excludes_buffer_free(excludes_buffer *exb) {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
size_t i;
for (i = 0; i < exb->size; i++) {
@@ -297,7 +301,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
return HANDLER_ERROR;
}
-#ifndef HAVE_PCRE_H
+#if !defined(WITH_PCRE)
if (excludes_list->used > 0) {
log_error_write(srv, __FILE__, __LINE__, "sss",
"pcre support is missing for: ", CONFIG_EXCLUDE, ", please install libpcre and the headers");
@@ -913,7 +917,7 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
char datebuf[sizeof("2005-Jan-01 22:23:24")];
const char *content_type;
long name_max;
-#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
+#if defined(WITH_XATTR)
char attrval[128];
int attrlen;
#endif
@@ -986,7 +990,7 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
/* compare d_name against excludes array
* elements, skipping any that match.
*/
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
for(i = 0; i < p->conf.excludes->used; i++) {
int n;
#define N 10
@@ -1082,7 +1086,8 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
tmp = files.ent[i];
content_type = NULL;
-#if defined(HAVE_XATTR)
+#if defined(WITH_XATTR)
+#if defined(HAVE_LIBATTR)
if (con->conf.use_xattr) {
memcpy(path_file, DIRLIST_ENT_NAME(tmp), tmp->namelen + 1);
attrlen = sizeof(attrval) - 1;
@@ -1100,6 +1105,7 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
}
}
#endif
+#endif
if (content_type == NULL) {
const buffer *type = stat_cache_mimetype_by_ext(con, DIRLIST_ENT_NAME(tmp), tmp->namelen);
diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c
index 4ad4f83d..ddb7450f 100644
--- a/src/mod_fastcgi.c
+++ b/src/mod_fastcgi.c
@@ -17,15 +17,8 @@ typedef gw_handler_ctx handler_ctx;
#include "plugin.h"
#include "status_counter.h"
-#ifdef HAVE_FASTCGI_FASTCGI_H
-# include <fastcgi/fastcgi.h>
-#else
-# ifdef HAVE_FASTCGI_H
-# include <fastcgi.h>
-# else
-# include "fastcgi.h"
-# endif
-#endif /* HAVE_FASTCGI_FASTCGI_H */
+/* protocol definitions */
+#include "fastcgi.h"
#if GW_RESPONDER != FCGI_RESPONDER
#error "mismatched defines: (GW_RESPONDER != FCGI_RESPONDER)"
diff --git a/src/mod_openssl.c b/src/mod_openssl.c
index adc9ad94..1eceda6e 100644
--- a/src/mod_openssl.c
+++ b/src/mod_openssl.c
@@ -4,8 +4,8 @@
#include <string.h>
#include <unistd.h>
-#ifndef USE_OPENSSL_KERBEROS
-#ifndef OPENSSL_NO_KRB5
+#if !defined(WITH_KRB5)
+#if !defined(OPENSSL_NO_KRB5)
#define OPENSSL_NO_KRB5
#endif
#endif
diff --git a/src/mod_redirect.c b/src/mod_redirect.c
index 4812e90d..6e264751 100644
--- a/src/mod_redirect.c
+++ b/src/mod_redirect.c
@@ -129,7 +129,7 @@ SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
return HANDLER_GO_ON;
}
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
static int mod_redirect_patch_connection(server *srv, connection *con, plugin_data *p) {
size_t i, j;
plugin_config *s = p->config_storage[0];
@@ -163,7 +163,7 @@ static int mod_redirect_patch_connection(server *srv, connection *con, plugin_da
}
#endif
static handler_t mod_redirect_uri_handler(server *srv, connection *con, void *p_data) {
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
plugin_data *p = p_data;
size_t i;
diff --git a/src/mod_rewrite.c b/src/mod_rewrite.c
index 70b25845..9945bfcf 100644
--- a/src/mod_rewrite.c
+++ b/src/mod_rewrite.c
@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
typedef struct {
pcre *key;
@@ -232,7 +232,7 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
plugin_data *p = p_d;
if (!p) return HANDLER_ERROR;
@@ -245,7 +245,7 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
for (i = 0; i < srv->config_context->used; i++) {
data_config const* config = (data_config const*)srv->config_context->data[i];
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
plugin_config *s;
s = calloc(1, sizeof(plugin_config));
@@ -258,7 +258,7 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
return HANDLER_ERROR;
}
-#ifndef HAVE_PCRE_H
+#if !defined(WITH_PCRE)
# define parse_config_entry(srv, ca, x, option, y) parse_config_entry(srv, ca, option)
#endif
parse_config_entry(srv, config->value, s->rewrite, CONST_STR_LEN("url.rewrite-once"), 1);
@@ -272,7 +272,7 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
return HANDLER_GO_ON;
}
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
#define PATCH(x) \
p->conf.x = s->x;
@@ -488,7 +488,7 @@ int mod_rewrite_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = buffer_init_string("rewrite");
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
p->init = mod_rewrite_init;
/* it has to stay _raw as we are matching on uri + querystring
*/
diff --git a/src/mod_secdownload.c b/src/mod_secdownload.c
index ce233cba..806a7ceb 100644
--- a/src/mod_secdownload.c
+++ b/src/mod_secdownload.c
@@ -10,11 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
-#define USE_OPENSSL_CRYPTO
-#endif
-
-#ifdef USE_OPENSSL_CRYPTO
+#if defined(WITH_OPENSSL)
#include <openssl/evp.h>
#include <openssl/hmac.h>
#endif
@@ -186,7 +182,7 @@ static int secdl_verify_mac(server *srv, plugin_config *config, const char* prot
return (32 == maclen) && const_time_memeq(mac, hexmd5, 32);
}
case SECDL_HMAC_SHA1:
-#ifdef USE_OPENSSL_CRYPTO
+#if defined(WITH_OPENSSL)
{
unsigned char digest[20];
char base64_digest[27];
@@ -208,7 +204,7 @@ static int secdl_verify_mac(server *srv, plugin_config *config, const char* prot
#endif
break;
case SECDL_HMAC_SHA256:
-#ifdef USE_OPENSSL_CRYPTO
+#if defined(WITH_OPENSSL)
{
unsigned char digest[32];
char base64_digest[43];
@@ -329,7 +325,7 @@ SETDEFAULTS_FUNC(mod_secdownload_set_defaults) {
algorithm);
buffer_free(algorithm);
return HANDLER_ERROR;
-#ifndef USE_OPENSSL_CRYPTO
+#ifndef WITH_OPENSSL
case SECDL_HMAC_SHA1:
case SECDL_HMAC_SHA256:
log_error_write(srv, __FILE__, __LINE__, "sb",
diff --git a/src/mod_status.c b/src/mod_status.c
index 5ed25e1f..0d72fefe 100644
--- a/src/mod_status.c
+++ b/src/mod_status.c
@@ -817,7 +817,7 @@ static handler_t mod_status_handle_server_config(server *srv, connection *con, v
#ifdef USE_SELECT
{ FDEVENT_HANDLER_SELECT, "select" },
#endif
-#ifdef USE_LIBEV
+#if defined(WITH_LIBEV)
{ FDEVENT_HANDLER_LIBEV, "libev" },
#endif
#ifdef USE_SOLARIS_DEVPOLL
@@ -848,7 +848,7 @@ static handler_t mod_status_handle_server_config(server *srv, connection *con, v
" <table summary=\"status\" border=\"1\">\n"));
mod_status_header_append(b, "Server-Features");
-#ifdef HAVE_PCRE_H
+#if defined(WITH_PCRE)
mod_status_row_append(b, "RegEx Conditionals", "enabled");
#else
mod_status_row_append(b, "RegEx Conditionals", "disabled - pcre missing");
diff --git a/src/mod_trigger_b4_dl.c b/src/mod_trigger_b4_dl.c
index 399116d8..0c463945 100644
--- a/src/mod_trigger_b4_dl.c
+++ b/src/mod_trigger_b4_dl.c
@@ -11,15 +11,15 @@
#include <stdlib.h>
#include <string.h>
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
# include <gdbm.h>
#endif
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
# include <pcre.h>
#endif
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
# include <libmemcached/memcached.h>
#endif
@@ -39,15 +39,15 @@ typedef struct {
array *mc_hosts;
buffer *mc_namespace;
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
pcre *trigger_regex;
pcre *download_regex;
#endif
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
GDBM_FILE db;
#endif
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
memcached_st *memc;
#endif
@@ -99,14 +99,14 @@ FREE_FUNC(mod_trigger_b4_dl_free) {
buffer_free(s->mc_namespace);
array_free(s->mc_hosts);
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
if (s->trigger_regex) pcre_free(s->trigger_regex);
if (s->download_regex) pcre_free(s->download_regex);
#endif
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
if (s->db) gdbm_close(s->db);
#endif
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
if (s->memc) memcached_free(s->memc);
#endif
@@ -148,7 +148,7 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) {
for (i = 0; i < srv->config_context->used; i++) {
data_config const* config = (data_config const*)srv->config_context->data[i];
plugin_config *s;
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
const char *errptr;
int erroff;
#endif
@@ -175,7 +175,7 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) {
if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) {
return HANDLER_ERROR;
}
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
if (!buffer_string_is_empty(s->db_filename)) {
if (NULL == (s->db = gdbm_open(s->db_filename->ptr, 4096, GDBM_WRCREAT | GDBM_NOLOCK, S_IRUSR | S_IWUSR, 0))) {
log_error_write(srv, __FILE__, __LINE__, "s",
@@ -185,7 +185,7 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) {
fdevent_setfd_cloexec(gdbm_fdesc(s->db));
}
#endif
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
if (!buffer_string_is_empty(s->download_url)) {
if (NULL == (s->download_regex = pcre_compile(s->download_url->ptr,
0, &errptr, &erroff, NULL))) {
@@ -217,7 +217,7 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) {
}
if (s->mc_hosts->used) {
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
buffer *option_string = buffer_init();
size_t k;
@@ -262,10 +262,10 @@ static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plug
size_t i, j;
plugin_config *s = p->config_storage[0];
-#if defined(HAVE_GDBM)
+#if defined(WITH_GDBM)
PATCH(db);
#endif
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
PATCH(download_regex);
PATCH(trigger_regex);
#endif
@@ -273,7 +273,7 @@ static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plug
PATCH(deny_url);
PATCH(mc_namespace);
PATCH(debug);
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
PATCH(memc);
#endif
@@ -290,15 +290,15 @@ static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plug
data_unset *du = dc->value->data[j];
if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.download-url"))) {
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
PATCH(download_regex);
#endif
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.trigger-url"))) {
-# if defined(HAVE_PCRE_H)
+# if defined(WITH_PCRE)
PATCH(trigger_regex);
# endif
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.gdbm-filename"))) {
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
PATCH(db);
#endif
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.trigger-timeout"))) {
@@ -310,7 +310,7 @@ static int mod_trigger_b4_dl_patch_connection(server *srv, connection *con, plug
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.memcache-namespace"))) {
PATCH(mc_namespace);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.memcache-hosts"))) {
-#if defined(USE_MEMCACHED)
+#if defined(WITH_MEMCACHED)
PATCH(memc);
#endif
}
@@ -326,7 +326,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
const char *remote_ip;
data_string *ds;
-#if defined(HAVE_PCRE_H)
+#if defined(WITH_PCRE)
int n;
# define N 10
int ovec[N * 3];
@@ -339,16 +339,16 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
if (!p->conf.trigger_regex || !p->conf.download_regex) return HANDLER_GO_ON;
-# if !defined(HAVE_GDBM_H) && !defined(USE_MEMCACHED)
+# if !defined(WITH_GDBM) && !defined(WITH_MEMCACHED)
return HANDLER_GO_ON;
-# elif defined(HAVE_GDBM_H) && defined(USE_MEMCACHED)
+# elif defined(WITH_GDBM) && defined(WITH_MEMCACHED)
if (!p->conf.db && !p->conf.memc) return HANDLER_GO_ON;
if (p->conf.db && p->conf.memc) {
/* can't decide which one */
return HANDLER_GO_ON;
}
-# elif defined(HAVE_GDBM_H)
+# elif defined(WITH_GDBM)
if (!p->conf.db) return HANDLER_GO_ON;
# else
if (!p->conf.memc) return HANDLER_GO_ON;
@@ -377,7 +377,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
return HANDLER_ERROR;
}
} else {
-# if defined(HAVE_GDBM_H)
+# if defined(WITH_GDBM)
if (p->conf.db) {
/* the trigger matched */
datum key, val;
@@ -394,7 +394,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
}
}
# endif
-# if defined(USE_MEMCACHED)
+# if defined(WITH_MEMCACHED)
if (p->conf.memc) {
size_t i, len;
buffer_copy_buffer(p->tmp_buf, p->conf.mc_namespace);
@@ -429,7 +429,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
}
} else {
/* the download uri matched */
-# if defined(HAVE_GDBM_H)
+# if defined(WITH_GDBM)
if (p->conf.db) {
datum key, val;
time_t last_hit;
@@ -480,7 +480,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
}
# endif
-# if defined(USE_MEMCACHED)
+# if defined(WITH_MEMCACHED)
if (p->conf.memc) {
size_t i, len;
@@ -532,7 +532,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
return HANDLER_GO_ON;
}
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
TRIGGER_FUNC(mod_trigger_b4_dl_handle_trigger) {
plugin_data *p = p_d;
size_t i;
@@ -591,7 +591,7 @@ int mod_trigger_b4_dl_plugin_init(plugin *p) {
p->init = mod_trigger_b4_dl_init;
p->handle_uri_clean = mod_trigger_b4_dl_uri_handler;
p->set_defaults = mod_trigger_b4_dl_set_defaults;
-#if defined(HAVE_GDBM_H)
+#if defined(WITH_GDBM)
p->handle_trigger = mod_trigger_b4_dl_handle_trigger;
#endif
p->cleanup = mod_trigger_b4_dl_free;
diff --git a/src/mod_vhostdb_ldap.c b/src/mod_vhostdb_ldap.c
index 98f7c072..4f506aa9 100644
--- a/src/mod_vhostdb_ldap.c
+++ b/src/mod_vhostdb_ldap.c
@@ -1,5 +1,7 @@
#include "first.h"
+/* Using deprecated ldap api */
+#define LDAP_DEPRECATED 1
#include <ldap.h>
#include <errno.h>
diff --git a/src/mod_webdav.c b/src/mod_webdav.c
index e5799aa5..9efee4b5 100644
--- a/src/mod_webdav.c
+++ b/src/mod_webdav.c
@@ -23,17 +23,16 @@
#include <unistd.h>
#include <dirent.h>
-#if defined(HAVE_LIBXML_H) && defined(HAVE_SQLITE3_H)
-#define USE_PROPPATCH
+#if defined(WITH_XML) && defined(WITH_SQLITE3)
+#define WEBDAV_USE_PROPPATCH
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <sqlite3.h>
#endif
-#if defined(HAVE_LIBXML_H) && defined(HAVE_SQLITE3_H) \
- && defined(HAVE_UUID) && defined(HAVE_UUID_UUID_H)
-#define USE_LOCKS
+#if defined(WITH_XML) && defined(WITH_SQLITE3) && defined(WITH_UUID)
+#define WEBDAV_USE_LOCKS
#include <uuid/uuid.h>
#endif
@@ -56,7 +55,7 @@ typedef struct {
unsigned short log_xml;
buffer *sqlite_db_name;
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
sqlite3 *sql;
sqlite3_stmt *stmt_update_prop;
sqlite3_stmt *stmt_delete_prop;
@@ -128,7 +127,7 @@ FREE_FUNC(mod_webdav_free) {
if (NULL == s) continue;
buffer_free(s->sqlite_db_name);
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
if (s->sql) {
sqlite3_finalize(s->stmt_delete_prop);
sqlite3_finalize(s->stmt_delete_uri);
@@ -205,7 +204,7 @@ SETDEFAULTS_FUNC(mod_webdav_set_defaults) {
}
if (!buffer_string_is_empty(s->sqlite_db_name)) {
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
const char *next_stmt;
char *err;
@@ -387,7 +386,7 @@ static int mod_webdav_patch_connection(server *srv, connection *con, plugin_data
PATCH_OPTION(is_readonly);
PATCH_OPTION(log_xml);
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
PATCH_OPTION(sql);
PATCH_OPTION(stmt_update_prop);
PATCH_OPTION(stmt_delete_prop);
@@ -423,7 +422,7 @@ static int mod_webdav_patch_connection(server *srv, connection *con, plugin_data
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.log-xml"))) {
PATCH_OPTION(log_xml);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.sqlite-db-name"))) {
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
PATCH_OPTION(sql);
PATCH_OPTION(stmt_update_prop);
PATCH_OPTION(stmt_delete_prop);
@@ -552,7 +551,7 @@ static int webdav_delete_file(server *srv, connection *con, handler_ctx *hctx, p
}
webdav_gen_response_status_tag(srv, con, dst, status, b);
} else {
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
sqlite3_stmt *stmt = hctx->conf.stmt_delete_uri;
if (!stmt) {
@@ -630,7 +629,7 @@ static int webdav_delete_dir(server *srv, connection *con, handler_ctx *hctx, ph
webdav_gen_response_status_tag(srv, con, &d, status, b);
} else {
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
sqlite3_stmt *stmt = hctx->conf.stmt_delete_uri;
if (stmt) {
@@ -728,7 +727,7 @@ static int webdav_copy_file(server *srv, connection *con, handler_ctx *hctx, phy
"close ", dst->path, "failed: ", strerror(errno));
}
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
if (0 == status) {
/* copy worked fine, copy connected properties */
sqlite3_stmt *stmt = hctx->conf.stmt_copy_uri;
@@ -802,7 +801,7 @@ static int webdav_copy_dir(server *srv, connection *con, handler_ctx *hctx, phys
errno != EEXIST) {
/* WTH ? */
} else {
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
sqlite3_stmt *stmt = hctx->conf.stmt_copy_uri;
if (0 != (status = webdav_copy_dir(srv, con, hctx, &s, &d, overwrite))) {
@@ -847,7 +846,7 @@ static int webdav_copy_dir(server *srv, connection *con, handler_ctx *hctx, phys
return status;
}
-#ifdef USE_LOCKS
+#ifdef WEBDAV_USE_LOCKS
static void webdav_activelock(buffer *b,
const buffer *locktoken, const char *lockscope, const char *locktype, int depth, int timeout) {
buffer_append_string_len(b, CONST_STR_LEN("<D:activelock>\n"));
@@ -985,7 +984,7 @@ static int webdav_get_live_property(server *srv, connection *con, handler_ctx *h
buffer_append_string_len(b, CONST_STR_LEN("</D:getetag>"));
buffer_reset(con->physical.etag);
found = 1;
- #ifdef USE_LOCKS
+ #ifdef WEBDAV_USE_LOCKS
} else if (0 == strcmp(prop_name, "lockdiscovery")) {
webdav_get_live_property_lockdiscovery(srv, con, hctx, dst, b);
found = 1;
@@ -1010,7 +1009,7 @@ static int webdav_get_property(server *srv, connection *con, handler_ctx *hctx,
return webdav_get_live_property(srv, con, hctx, dst, prop_name, b);
} else {
int found = 0;
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
sqlite3_stmt *stmt = hctx->conf.stmt_select_prop;
if (stmt) {
@@ -1061,7 +1060,7 @@ static webdav_property live_properties[] = {
{ "DAV:", "getlastmodified" },
{ "DAV:", "resourcetype" },
/*{ "DAV:", "source" },*//*(not implemented)*/
- #ifdef USE_LOCKS
+ #ifdef WEBDAV_USE_LOCKS
{ "DAV:", "lockdiscovery" },
{ "DAV:", "supportedlock" },
#endif
@@ -1100,7 +1099,7 @@ static int webdav_get_props(server *srv, connection *con, handler_ctx *hctx, phy
return 0;
}
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
static int webdav_parse_chunkqueue(server *srv, connection *con, handler_ctx *hctx, chunkqueue *cq, xmlDoc **ret_xml) {
xmlParserCtxtPtr ctxt;
xmlDoc *xml;
@@ -1210,7 +1209,7 @@ static int webdav_parse_chunkqueue(server *srv, connection *con, handler_ctx *hc
}
#endif
-#ifdef USE_LOCKS
+#ifdef WEBDAV_USE_LOCKS
static int webdav_lockdiscovery(server *srv, connection *con,
buffer *locktoken, const char *lockscope, const char *locktype, int depth) {
@@ -1246,7 +1245,7 @@ static int webdav_lockdiscovery(server *srv, connection *con,
static int webdav_has_lock(server *srv, connection *con, handler_ctx *hctx, buffer *uri) {
int has_lock = 1;
-#ifdef USE_LOCKS
+#ifdef WEBDAV_USE_LOCKS
data_string *ds;
UNUSED(srv);
@@ -1357,7 +1356,7 @@ SUBREQUEST_FUNC(mod_webdav_subrequest_handler_huge) {
return HANDLER_FINISHED;
}
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
/* any special requests or just allprop ? */
if (con->request.content_length) {
xmlDocPtr xml;
@@ -2182,7 +2181,7 @@ SUBREQUEST_FUNC(mod_webdav_subrequest_handler_huge) {
/* try a rename */
if (0 == rename(con->physical.path->ptr, p->physical.path->ptr)) {
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
sqlite3_stmt *stmt;
stmt = p->conf.stmt_move_uri;
@@ -2250,7 +2249,7 @@ SUBREQUEST_FUNC(mod_webdav_subrequest_handler_huge) {
return HANDLER_FINISHED;
}
-#ifdef USE_PROPPATCH
+#ifdef WEBDAV_USE_PROPPATCH
if (con->request.content_length) {
xmlDocPtr xml;
@@ -2418,7 +2417,7 @@ propmatch_cleanup:
return HANDLER_FINISHED;
}
-#ifdef USE_LOCKS
+#ifdef WEBDAV_USE_LOCKS
if (con->request.content_length) {
xmlDocPtr xml;
buffer *hdr_if = NULL;
@@ -2650,7 +2649,7 @@ propmatch_cleanup:
return HANDLER_FINISHED;
#endif
case HTTP_METHOD_UNLOCK:
-#ifdef USE_LOCKS
+#ifdef WEBDAV_USE_LOCKS
if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "Lock-Token"))) {
buffer *locktoken = ds->value;
sqlite3_stmt *stmt = p->conf.stmt_remove_lock;
diff --git a/src/network_backends.h b/src/network_backends.h
index db03a589..96a1373b 100644
--- a/src/network_backends.h
+++ b/src/network_backends.h
@@ -4,61 +4,10 @@
#include "settings.h"
-#include <sys/types.h>
-
-/* on linux 2.4.x you get either sendfile or LFS */
-#if defined HAVE_SYS_SENDFILE_H && defined HAVE_SENDFILE && (!defined _LARGEFILE_SOURCE || defined HAVE_SENDFILE64) && defined(__linux__) && !defined HAVE_SENDFILE_BROKEN
-# ifdef USE_SENDFILE
-# error "can't have more than one sendfile implementation"
-# endif
-# define USE_SENDFILE "linux-sendfile"
-# define USE_LINUX_SENDFILE
-#endif
-
-#if defined HAVE_SENDFILE && (defined(__FreeBSD__) || defined(__DragonFly__))
-# ifdef USE_SENDFILE
-# error "can't have more than one sendfile implementation"
-# endif
-# define USE_SENDFILE "freebsd-sendfile"
-# define USE_FREEBSD_SENDFILE
-#endif
-
-#if defined HAVE_SENDFILE && defined(__APPLE__)
-# ifdef USE_SENDFILE
-# error "can't have more than one sendfile implementation"
-# endif
-# define USE_SENDFILE "darwin-sendfile"
-# define USE_DARWIN_SENDFILE
-#endif
-
-#if defined HAVE_SYS_SENDFILE_H && defined HAVE_SENDFILEV && defined(__sun)
-# ifdef USE_SENDFILE
-# error "can't have more than one sendfile implementation"
-# endif
-# define USE_SENDFILE "solaris-sendfilev"
-# define USE_SOLARIS_SENDFILEV
-#endif
-
-/* not supported so far
-#if defined HAVE_SEND_FILE && defined(__aix)
-# ifdef USE_SENDFILE
-# error "can't have more than one sendfile implementation"
-# endif
-# define USE_SENDFILE "aix-sendfile"
-# define USE_AIX_SENDFILE
-#endif
-*/
-
-#if defined HAVE_SYS_UIO_H && defined HAVE_WRITEV
-# define USE_WRITEV
-#endif
-
-#if defined HAVE_SYS_MMAN_H && defined HAVE_MMAP && defined ENABLE_MMAP
-# define USE_MMAP
-#endif
-
#include "base.h"
+#include <sys/types.h>
+
/* return values:
* >= 0 : no error
* -1 : error (on our side)
diff --git a/src/plugin.c b/src/plugin.c
index 20aec918..73f31328 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <stdlib.h>
-#ifdef HAVE_VALGRIND_VALGRIND_H
+#if defined(WITH_VALGRIND)
# include <valgrind/valgrind.h>
#endif
@@ -68,7 +68,7 @@ static void plugin_free(plugin *p) {
#endif
if (p->name) buffer_free(p->name);
-#if defined(HAVE_VALGRIND_VALGRIND_H) && !defined(LIGHTTPD_STATIC)
+#if defined(WITH_VALGRIND) && !defined(LIGHTTPD_STATIC)
/*if (RUNNING_ON_VALGRIND) use_dlclose = 0;*/
#endif
diff --git a/src/rand.c b/src/rand.c
index 10cd0252..fad9697b 100644
--- a/src/rand.c
+++ b/src/rand.c
@@ -14,10 +14,7 @@
#include <time.h>
#include <unistd.h>
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
-#define USE_OPENSSL_CRYPTO
-#endif
-#ifdef USE_OPENSSL_CRYPTO
+#if defined(WITH_OPENSSL)
#include <openssl/opensslv.h> /* OPENSSL_VERSION_NUMBER */
#include <openssl/rand.h>
#endif
@@ -161,7 +158,7 @@ static void li_rand_init (void)
#ifdef HAVE_SRANDOM
srandom(u); /*(initialize just in case random() used elsewhere)*/
#endif
- #ifdef USE_OPENSSL_CRYPTO
+ #if defined(WITH_OPENSSL)
RAND_poll();
RAND_seed(xsubi, (int)sizeof(xsubi));
#endif
@@ -176,7 +173,7 @@ int li_rand_pseudo (void)
{
/* randomness *is not* cryptographically strong */
/* (attempt to use better mechanisms to replace the more portable rand()) */
- #ifdef USE_OPENSSL_CRYPTO /* (openssl 1.1.0 deprecates RAND_pseudo_bytes()) */
+ #if defined(WITH_OPENSSL) /* (openssl 1.1.0 deprecates RAND_pseudo_bytes()) */
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
int i;
if (-1 != RAND_pseudo_bytes((unsigned char *)&i, sizeof(i))) return i;
@@ -206,7 +203,7 @@ void li_rand_pseudo_bytes (unsigned char *buf, int num)
int li_rand_bytes (unsigned char *buf, int num)
{
- #ifdef USE_OPENSSL_CRYPTO
+ #if defined(WITH_OPENSSL)
int rc = RAND_bytes(buf, num);
if (-1 != rc) {
return rc;
@@ -225,7 +222,7 @@ int li_rand_bytes (unsigned char *buf, int num)
void li_rand_cleanup (void)
{
- #ifdef USE_OPENSSL_CRYPTO
+ #if defined(WITH_OPENSSL)
RAND_cleanup();
#endif
safe_memclear(xsubi, sizeof(xsubi));
diff --git a/src/server.c b/src/server.c
index de4b0a3a..36dcc8ab 100644
--- a/src/server.c
+++ b/src/server.c
@@ -44,10 +44,11 @@
#include <stdio.h>
#ifdef HAVE_GETOPT_H
+/* posix says getopt() should be in <unistd.h>... */
# include <getopt.h>
#endif
-#ifdef HAVE_VALGRIND_VALGRIND_H
+#if defined(WITH_VALGRIND)
# include <valgrind/valgrind.h>
#endif
@@ -72,18 +73,12 @@
# include <sys/prctl.h>
#endif
-#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
-#define USE_SSL
+#if defined(WITH_OPENSSL)
#define TEXT_SSL " (ssl)"
#else
#define TEXT_SSL
#endif
-#ifndef __sgi
-/* IRIX doesn't like the alarm based time() optimization */
-/* #define USE_ALARM */
-#endif
-
static int oneshot_fd = 0;
static volatile int pid_fd = -2;
static server_socket_array graceful_sockets;
@@ -578,7 +573,7 @@ static void show_features (void) {
#else
"\t- kqueue (FreeBSD)\n"
#endif
-#ifdef USE_LIBEV
+#if defined(WITH_LIBEV)
"\t+ libev (generic)\n"
#else
"\t- libev (generic)\n"
@@ -621,12 +616,12 @@ static void show_features (void) {
#else
"\t- IPv6 support\n"
#endif
-#if defined HAVE_ZLIB_H && defined HAVE_LIBZ
+#if defined(WITH_ZLIB)
"\t+ zlib support\n"
#else
"\t- zlib support\n"
#endif
-#if defined HAVE_BZLIB_H && defined HAVE_LIBBZ2
+#if defined(WITH_BZIP)
"\t+ bzip2 support\n"
#else
"\t- bzip2 support\n"
@@ -636,71 +631,86 @@ static void show_features (void) {
#else
"\t- crypt support\n"
#endif
-#ifdef USE_SSL
+#if defined(WITH_OPENSSL)
"\t+ SSL support\n"
#else
"\t- SSL support\n"
#endif
-#ifdef HAVE_LIBPCRE
+#if defined(WITH_PCRE)
"\t+ PCRE support\n"
#else
"\t- PCRE support\n"
#endif
-#ifdef HAVE_MYSQL
+#if defined(WITH_MYSQL)
"\t+ MySQL support\n"
#else
"\t- MySQL support\n"
#endif
-#ifdef HAVE_PGSQL
+#if defined(WITH_PGSQL)
"\t+ PgSQL support\n"
#else
"\t- PgSQL support\n"
#endif
-#ifdef HAVE_DBI
+#if defined(WITH_DBI)
"\t+ DBI support\n"
#else
"\t- DBI support\n"
#endif
-#ifdef HAVE_KRB5
+#if defined(WITH_KRB5)
"\t+ Kerberos support\n"
#else
"\t- Kerberos support\n"
#endif
-#if defined(HAVE_LDAP_H) && defined(HAVE_LBER_H) && defined(HAVE_LIBLDAP) && defined(HAVE_LIBLBER)
+#if defined(WITH_LDAP)
"\t+ LDAP support\n"
#else
"\t- LDAP support\n"
#endif
-#ifdef USE_MEMCACHED
+#if defined(WITH_MEMCACHED)
"\t+ memcached support\n"
#else
"\t- memcached support\n"
#endif
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
"\t+ FAM support\n"
#else
"\t- FAM support\n"
#endif
-#ifdef HAVE_LUA_H
+#if defined(WITH_LUA)
"\t+ LUA support\n"
#else
"\t- LUA support\n"
#endif
-#ifdef HAVE_LIBXML_H
+#if defined(WITH_XML)
"\t+ xml support\n"
#else
"\t- xml support\n"
#endif
-#ifdef HAVE_SQLITE3_H
+#if defined(WITH_SQLITE3)
"\t+ SQLite support\n"
#else
"\t- SQLite support\n"
#endif
-#ifdef HAVE_GDBM_H
+#if defined(WITH_GDBM)
"\t+ GDBM support\n"
#else
"\t- GDBM support\n"
#endif
+#if defined(WITH_GEOIP)
+ "\t+ GeoIP support\n"
+#else
+ "\t- GeoIP support\n"
+#endif
+#if defined(WITH_XATTR)
+ "\t+ Extended attribute support\n"
+#else
+ "\t- Extended attribute support\n"
+#endif
+#if defined(WITH_VALGRIND)
+ "\t+ valgrind support\n"
+#else
+ "\t- valgrind support\n"
+#endif
"\n";
show_version();
printf("\nEvent Handlers:\n\n%s", features);
@@ -1282,7 +1292,7 @@ static int server_main (server * const srv, int argc, char **argv) {
#ifdef HAVE_GETRLIMIT
struct rlimit rlim;
int use_rlimit = 1;
-#ifdef HAVE_VALGRIND_VALGRIND_H
+#if defined(WITH_VALGRIND)
if (RUNNING_ON_VALGRIND) use_rlimit = 0;
#endif
diff --git a/src/settings.h b/src/settings.h
index 65d1c1c6..8db7f93c 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -45,4 +45,90 @@ typedef enum { HANDLER_UNSET,
#define HTTP_LINGER_TIMEOUT 5
+#ifndef __sgi
+/* IRIX doesn't like the alarm based time() optimization */
+/* #define USE_ALARM */
+#endif
+
+/* select event-systems */
+
+#if defined(HAVE_EPOLL_CTL) && defined(HAVE_SYS_EPOLL_H)
+# define USE_LINUX_EPOLL
+#endif
+
+/* MacOS 10.3.x has poll.h under /usr/include/, all other unixes
+ * under /usr/include/sys/ */
+#if defined(HAVE_POLL) && (defined(HAVE_SYS_POLL_H) || defined(HAVE_POLL_H))
+# define USE_POLL
+#endif
+
+#if defined(HAVE_SELECT)
+# define USE_SELECT
+#endif
+
+#if defined(HAVE_SYS_DEVPOLL_H) && defined(__sun)
+# define USE_SOLARIS_DEVPOLL
+#endif
+
+#if defined(HAVE_PORT_H) && defined(HAVE_PORT_CREATE) && defined(__sun)
+# define USE_SOLARIS_PORT
+#endif
+
+#if defined(HAVE_SYS_EVENT_H) && defined(HAVE_KQUEUE)
+# define USE_FREEBSD_KQUEUE
+#endif
+
+/* sendfile/writev/mmap */
+
+/* on linux 2.4.x you get either sendfile or LFS */
+#if defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILE) && (!defined(_LARGEFILE_SOURCE) || defined(HAVE_SENDFILE64)) && defined(__linux__) && !defined(HAVE_SENDFILE_BROKEN)
+# if defined(USE_SENDFILE)
+# error "can't have more than one sendfile implementation"
+# endif
+# define USE_SENDFILE "linux-sendfile"
+# define USE_LINUX_SENDFILE
+#endif
+
+#if defined(HAVE_SENDFILE) && (defined(__FreeBSD__) || defined(__DragonFly__))
+# if defined(USE_SENDFILE)
+# error "can't have more than one sendfile implementation"
+# endif
+# define USE_SENDFILE "freebsd-sendfile"
+# define USE_FREEBSD_SENDFILE
+#endif
+
+#if defined(HAVE_SENDFILE) && defined(__APPLE__)
+# if defined(USE_SENDFILE)
+# error "can't have more than one sendfile implementation"
+# endif
+# define USE_SENDFILE "darwin-sendfile"
+# define USE_DARWIN_SENDFILE
+#endif
+
+#if defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILEV) && defined(__sun)
+# if defined(USE_SENDFILE)
+# error "can't have more than one sendfile implementation"
+# endif
+# define USE_SENDFILE "solaris-sendfilev"
+# define USE_SOLARIS_SENDFILEV
+#endif
+
+/* not supported so far
+#if defined(HAVE_SEND_FILE) && defined(__aix)
+# if defined(USE_SENDFILE)
+# error "can't have more than one sendfile implementation"
+# endif
+# define USE_SENDFILE "aix-sendfile"
+# define USE_AIX_SENDFILE
+#endif
+*/
+
+#if defined(HAVE_SYS_UIO_H) && defined(HAVE_WRITEV)
+# define USE_WRITEV
+#endif
+
+#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP) && defined(ENABLE_MMAP)
+# define USE_MMAP
+#endif
+
#endif
diff --git a/src/stat_cache.c b/src/stat_cache.c
index f82e351f..2c873f5c 100644
--- a/src/stat_cache.c
+++ b/src/stat_cache.c
@@ -15,15 +15,19 @@
#include <unistd.h>
#include <fcntl.h>
-#ifdef HAVE_ATTR_ATTRIBUTES_H
-# include <attr/attributes.h>
-#endif
-
-#ifdef HAVE_SYS_EXTATTR_H
-# include <sys/extattr.h>
-#endif
-
-#ifdef HAVE_FAM_H
+#if defined(WITH_XATTR)
+# if defined(HAVE_LIBATTR)
+/* linux */
+# include <attr/attributes.h>
+# elif defined(HAVE_EXTATTR)
+/* BSD */
+# include <sys/extattr.h>
+# else
+# error Unknown extended attribute support
+# endif
+#endif
+
+#if defined(WITH_FAM)
# include <fam.h>
#endif
@@ -60,7 +64,7 @@
*
* */
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
typedef struct {
FAMRequest *req;
@@ -98,7 +102,7 @@ typedef struct stat_cache {
splay_tree *files; /* the nodes of the tree are stat_cache_entry's */
buffer *dir_name; /* for building the dirname from the filename */
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
splay_tree *dirs; /* the nodes of the tree are fam_dir_entry */
FAMConnection fam;
@@ -107,7 +111,7 @@ typedef struct stat_cache {
buffer *hash_key; /* temp-store for the hash-key */
} stat_cache;
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
static handler_t stat_cache_handle_fdevent(server *srv, void *_fce, int revent);
#endif
@@ -121,7 +125,7 @@ stat_cache *stat_cache_init(server *srv) {
sc->dir_name = buffer_init();
sc->hash_key = buffer_init();
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
sc->fam_fcce_ndx = -1;
#endif
@@ -129,7 +133,7 @@ stat_cache *stat_cache_init(server *srv) {
ctrl.size = 0;
#endif
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
/* setup FAM */
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
if (0 != FAMOpen2(&sc->fam, "lighttpd")) {
@@ -175,7 +179,7 @@ static void stat_cache_entry_free(void *data) {
free(sce);
}
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
static fam_dir_entry * fam_dir_entry_init(void) {
fam_dir_entry *fam_dir = NULL;
@@ -217,7 +221,7 @@ void stat_cache_free(stat_cache *sc) {
buffer_free(sc->dir_name);
buffer_free(sc->hash_key);
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
while (sc->dirs) {
int osize;
splay_tree *node = sc->dirs;
@@ -244,7 +248,8 @@ void stat_cache_free(stat_cache *sc) {
free(sc);
}
-#if defined(HAVE_XATTR)
+#if defined(WITH_XATTR)
+#if defined(HAVE_LIBATTR)
static int stat_cache_attr_get(buffer *buf, char *name, char *xattrname) {
int attrlen;
int ret;
@@ -270,6 +275,7 @@ static int stat_cache_attr_get(buffer *buf, char *name, char *xattrname) {
return -1;
}
#endif
+#endif /* WITH_XATTR */
const buffer * stat_cache_mimetype_by_ext(const connection *con, const char *name, size_t nlen)
{
@@ -332,7 +338,7 @@ static uint32_t hashme(buffer *str) {
return hash;
}
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
static handler_t stat_cache_handle_fdevent(server *srv, void *_fce, int revent) {
size_t i;
stat_cache *sc = srv->stat_cache;
@@ -444,7 +450,7 @@ static int stat_cache_lstat(server *srv, buffer *dname, struct stat *lst) {
*/
handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_cache_entry **ret_sce) {
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
fam_dir_entry *fam_dir = NULL;
int dir_ndx = -1;
#endif
@@ -513,7 +519,7 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
#endif
}
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
/* dir-check */
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
if (0 != buffer_copy_dirname(sc->dir_name, name)) {
@@ -678,7 +684,7 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
if (S_ISREG(st.st_mode)) {
/* determine mimetype */
buffer_reset(sce->content_type);
-#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
+#if defined(WITH_XATTR)
if (con->conf.use_xattr) {
stat_cache_attr_get(sce->content_type, name->ptr, srv->srvconf.xattr_name->ptr);
}
@@ -695,7 +701,7 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
etag_create(sce->etag, &(sce->st), con->etag_flags);
}
-#ifdef HAVE_FAM_H
+#if defined(WITH_FAM)
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
/* is this directory already registered ? */
if (NULL == fam_dir) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 24454963..cef181ea 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,9 @@
# lighttpd.conf and conformance.pl expect this directory
testdir=$(srcdir)/tmp/lighttpd/
+# first.h
+AM_CFLAGS = -I$(srcdir)/../src
+
if CHECK_WITH_FASTCGI
check_PROGRAMS=fcgi-auth fcgi-responder scgi-responder
diff --git a/tests/fcgi-auth.c b/tests/fcgi-auth.c
index 3c7cdfdc..456b71dc 100644
--- a/tests/fcgi-auth.c
+++ b/tests/fcgi-auth.c
@@ -1,11 +1,13 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#ifdef HAVE_FASTCGI_FASTCGI_H
-#include <fastcgi/fcgi_stdio.h>
+#include "first.h"
+
+#if defined(HAVE_FASTCGI_FCGI_STDIO_H)
+# include <fastcgi/fcgi_stdio.h>
+#elif defined(HAVE_FCGI_STDIO_H)
+# include <fcgi_stdio.h>
#else
-#include <fcgi_stdio.h>
+# error Missing fcgi_stdio.h
#endif
+
#include <stdlib.h>
#include <string.h>
diff --git a/tests/fcgi-responder.c b/tests/fcgi-responder.c
index d04bc32e..64075fbc 100644
--- a/tests/fcgi-responder.c
+++ b/tests/fcgi-responder.c
@@ -1,11 +1,13 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#ifdef HAVE_FASTCGI_FASTCGI_H
-#include <fastcgi/fcgi_stdio.h>
+#include "first.h"
+
+#if defined(HAVE_FASTCGI_FCGI_STDIO_H)
+# include <fastcgi/fcgi_stdio.h>
+#elif defined(HAVE_FCGI_STDIO_H)
+# include <fcgi_stdio.h>
#else
-#include <fcgi_stdio.h>
+# error Missing fcgi_stdio.h
#endif
+
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
diff --git a/tests/meson.build b/tests/meson.build
index 0ac68a68..0692f7ef 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,13 +1,28 @@
-if conf_data.get('HAVE_FASTCGI_H') or conf_data.get('HAVE_FASTCGI_FASTCGI_H')
- libfcgi = compiler.find_library('fcgi', required: false)
- if libfcgi.found()
+libfcgi = compiler.find_library('fcgi', required: false)
+if libfcgi.found()
+ found_fcgi_header = false
+ libfcgi = [ libfcgi ]
+
+ if compiler.has_header('fcgi_stdio.h')
+ found_fcgi_header = true
+ libfcgi += [ declare_dependency(
+ compile_args: '-DHAVE_FCGI_STDIO_H'
+ ) ]
+ elif compiler.has_header('fastcgi/fcgi_stdio.h')
+ found_fcgi_header = true
+ libfcgi += [ declare_dependency(
+ compile_args: '-DHAVE_FASTCGI_FCGI_STDIO_H'
+ ) ]
+ endif
+
+ if found_fcgi_header
executable('fcgi-auth',
sources: 'fcgi-auth.c',
- dependencies: common_flags + [ libfcgi ],
+ dependencies: common_flags + libfcgi,
)
executable('fcgi-responder',
sources: 'fcgi-responder.c',
- dependencies: common_flags + [ libfcgi ],
+ dependencies: common_flags + libfcgi,
)
endif
endif
diff --git a/tests/scgi-responder.c b/tests/scgi-responder.c
index 0c4244b7..b882bf02 100644
--- a/tests/scgi-responder.c
+++ b/tests/scgi-responder.c
@@ -8,6 +8,8 @@
* - no write timeouts; might block writing response
*/
+#include "first.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <assert.h>