1sbinddir = join_paths(get_option('prefix'), get_option('sbindir')) 2moduledir = join_paths(get_option('prefix'), get_option('moduledir')) 3 4include_base_paths = [ 5 '/usr/include', 6 '/usr/local/include', 7# '/opt/local/include', 8] 9 10defs = [ 11 '-D_FILE_OFFSET_BITS=64', 12 '-D_LARGEFILE_SOURCE', 13 '-D_LARGE_FILES', 14 '-D_GNU_SOURCE', 15] 16 17libws2_32 = [] 18if target_machine.system() == 'windows' 19 libws2_32 = [ compiler.find_library('ws2_32') ] 20 defs += [ 21 '-DNVALGRIND', 22 ] 23endif 24 25 26compiler = meson.get_compiler('c') 27conf_data = configuration_data() 28 29conf_data.set('HAVE_SYS_DEVPOLL_H', compiler.has_header('sys/devpoll.h')) 30conf_data.set('HAVE_SYS_EPOLL_H', compiler.has_header('sys/epoll.h')) 31conf_data.set('HAVE_SYS_EVENT_H', compiler.has_header('sys/event.h')) 32conf_data.set('HAVE_SYS_INOTIFY_H', compiler.has_header('sys/inotify.h')) 33conf_data.set('HAVE_SYS_LOADAVG_H', compiler.has_header('sys/loadavg.h')) 34conf_data.set('HAVE_SYS_MMAN_H', compiler.has_header('sys/mman.h')) 35conf_data.set('HAVE_SYS_POLL_H', compiler.has_header('sys/poll.h')) 36conf_data.set('HAVE_SYS_PORT_H', compiler.has_header('sys/port.h')) 37conf_data.set('HAVE_SYS_PRCTL_H', compiler.has_header('sys/prctl.h')) 38conf_data.set('HAVE_SYS_RESOURCE_H', compiler.has_header('sys/resource.h')) 39conf_data.set('HAVE_SYS_SENDFILE_H', compiler.has_header('sys/sendfile.h')) 40conf_data.set('HAVE_SYS_SELECT_H', compiler.has_header('sys/select.h')) 41conf_data.set('HAVE_SYS_TYPES_H', compiler.has_header('sys/types.h')) 42conf_data.set('HAVE_SYS_UIO_H', compiler.has_header('sys/uio.h')) 43conf_data.set('HAVE_SYS_UN_H', compiler.has_header('sys/un.h')) 44conf_data.set('HAVE_SYS_WAIT_H', compiler.has_header('sys/wait.h')) 45conf_data.set('HAVE_SYS_TIME_H', compiler.has_header('sys/time.h')) 46conf_data.set('HAVE_UNISTD_H', compiler.has_header('unistd.h')) 47conf_data.set('HAVE_PTHREAD_H', compiler.has_header('pthread.h')) 48conf_data.set('HAVE_GETOPT_H', compiler.has_header('getopt.h')) 49conf_data.set('HAVE_INTTYPES_H', compiler.has_header('inttypes.h')) 50conf_data.set('HAVE_POLL_H', compiler.has_header('poll.h')) 51conf_data.set('HAVE_PWD_H', compiler.has_header('pwd.h')) 52conf_data.set('HAVE_STDDEF_H', compiler.has_header('stddef.h')) 53conf_data.set('HAVE_STDINT_H', compiler.has_header('stdint.h')) 54conf_data.set('HAVE_STRINGS_H', compiler.has_header('strings.h')) 55conf_data.set('HAVE_SYSLOG_H', compiler.has_header('syslog.h')) 56 57# check for fastcgi lib, for the tests only 58conf_data.set('HAVE_FASTCGI_H', compiler.has_header('fastcgi.h')) 59if not(conf_data.get('HAVE_FASTCGI_H')) 60 conf_data.set('HAVE_FASTCGI_FASTCGI_H', compiler.has_header('fastcgi/fastcgi.h')) 61endif 62 63# will be needed for auth 64conf_data.set('HAVE_CRYPT_H', compiler.has_header('crypt.h')) 65if conf_data.get('HAVE_CRYPT_H') 66 # check if we need libcrypt for crypt_r / crypt 67 68 # crypt_r in default libs? 69 if compiler.has_function('crypt_r', args: defs, prefix: '#include <crypt.h>') 70 libcrypt = [] 71 conf_data.set('HAVE_CRYPT_R', 1) 72 # crypt_r in -lcrypt ? 73 elif compiler.has_function('crypt_r', args: defs + ['-lcrypt'], prefix: '#include <crypt.h>') 74 libcrypt = [ compiler.find_library('crypt') ] 75 conf_data.set('HAVE_CRYPT_R', 1) 76 # crypt in default libs? 77 elif compiler.has_function('crypt', args: defs, prefix: '#include <crypt.h>') 78 libcrypt = [] 79 conf_data.set('HAVE_CRYPT', 1) 80 # crypt in -lcrypt ? 81 elif compiler.has_function('crypt', args: defs + ['-lcrypt'], prefix: '#include <crypt.h>') 82 libcrypt = [ compiler.find_library('crypt') ] 83 conf_data.set('HAVE_CRYPT', 1) 84 endif 85endif 86 87conf_data.set('HAVE_SYS_INOTIFY_H', compiler.has_header('sys/inotify.h')) 88if conf_data.get('HAVE_SYS_INOTIFY_H') 89 conf_data.set('HAVE_INOTIFY_INIT', compiler.has_function('inotify_init', args: defs)) 90endif 91 92conf_data.set('HAVE_SOCKLEN_T', compiler.has_type('socklen_t', args: defs, prefix: '#include <sys/socket.h>')) 93 94conf_data.set('HAVE_SYS_RANDOM_H', compiler.has_header('sys/random.h')) 95if conf_data.get('HAVE_SYS_RANDOM_H') 96 conf_data.set('HAVE_GETENTROPY', compiler.has_function( 97 'getentropy', 98 args: defs, 99 prefix: '#include <sys/random.h>' 100 )) 101endif 102 103conf_data.set('HAVE_LINUX_RANDOM_H', compiler.has_header('linux/random.h')) 104if conf_data.get('HAVE_LINUX_RANDOM_H') 105 conf_data.set('HAVE_GETRANDOM', compiler.has_function( 106 'getrandom', 107 args: defs, 108 prefix: '#include <linux/random.h>' 109 )) 110endif 111 112conf_data.set('SIZEOF_LONG', compiler.sizeof('long', args: defs)) 113conf_data.set('SIZEOF_OFF_T', compiler.sizeof('off_t', args: defs)) 114 115conf_data.set('HAVE_ARC4RANDOM_BUF', compiler.has_function('arc4random_buf', args: defs)) 116conf_data.set('HAVE_CHROOT', compiler.has_function('chroot', args: defs)) 117conf_data.set('HAVE_COPY_FILE_RANGE', compiler.has_function('copy_file_range', args: defs)) 118conf_data.set('HAVE_EPOLL_CTL', compiler.has_function('epoll_ctl', args: defs)) 119conf_data.set('HAVE_FORK', compiler.has_function('fork', args: defs)) 120conf_data.set('HAVE_GETLOADAVG', compiler.has_function('getloadavg', args: defs)) 121conf_data.set('HAVE_GETRLIMIT', compiler.has_function('getrlimit', args: defs)) 122conf_data.set('HAVE_GETUID', compiler.has_function('getuid', args: defs)) 123conf_data.set('HAVE_GMTIME_R', compiler.has_function('gmtime_r', args: defs)) 124conf_data.set('HAVE_INET_ATON', compiler.has_function('inet_aton', args: defs)) 125conf_data.set('HAVE_INET_NTOP', compiler.has_function('inet_ntop', args: defs)) 126conf_data.set('HAVE_JRAND48', compiler.has_function('jrand48', args: defs)) 127conf_data.set('HAVE_KQUEUE', compiler.has_function('kqueue', args: defs)) 128conf_data.set('HAVE_LOCALTIME_R', compiler.has_function('localtime_r', args: defs)) 129conf_data.set('HAVE_LSTAT', compiler.has_function('lstat', args: defs)) 130conf_data.set('HAVE_MADVISE', compiler.has_function('madvise', args: defs)) 131conf_data.set('HAVE_MEMCPY', compiler.has_function('memcpy', args: defs)) 132conf_data.set('HAVE_MEMSET', compiler.has_function('memset', args: defs)) 133conf_data.set('HAVE_MMAP', compiler.has_function('mmap', args: defs)) 134conf_data.set('HAVE_PATHCONF', compiler.has_function('pathconf', args: defs)) 135conf_data.set('HAVE_PIPE2', compiler.has_function('pipe2', args: defs)) 136conf_data.set('HAVE_POLL', compiler.has_function('poll', args: defs)) 137conf_data.set('HAVE_PORT_CREATE', compiler.has_function('port_create', args: defs)) 138conf_data.set('HAVE_PRCTL', compiler.has_function('prctl', args: defs)) 139conf_data.set('HAVE_PREAD', compiler.has_function('pread', args: defs)) 140conf_data.set('HAVE_POSIX_FADVISE', compiler.has_function('posix_fadvise', args: defs)) 141conf_data.set('HAVE_SELECT', compiler.has_function('select', args: defs)) 142conf_data.set('HAVE_SENDFILE', compiler.has_function('sendfile', args: defs)) 143conf_data.set('HAVE_SEND_FILE', compiler.has_function('send_file', args: defs)) 144conf_data.set('HAVE_SENDFILE64', compiler.has_function('sendfile64', args: defs)) 145conf_data.set('HAVE_SENDFILEV', compiler.has_function('sendfilev', args: defs)) 146conf_data.set('HAVE_SIGACTION', compiler.has_function('sigaction', args: defs)) 147conf_data.set('HAVE_SIGNAL', compiler.has_function('signal', args: defs)) 148conf_data.set('HAVE_SIGTIMEDWAIT', compiler.has_function('sigtimedwait', args: defs)) 149conf_data.set('HAVE_SRANDOM', compiler.has_function('srandom', args: defs)) 150conf_data.set('HAVE_STRPTIME', compiler.has_function('strptime', args: defs)) 151conf_data.set('HAVE_SYSLOG', compiler.has_function('syslog', args: defs)) 152conf_data.set('HAVE_WRITEV', compiler.has_function('writev', args: defs)) 153conf_data.set('HAVE_INET_ATON', compiler.has_function('inet_aton', args: defs)) 154conf_data.set('HAVE_ISSETUGID', compiler.has_function('issetugid', args: defs)) 155conf_data.set('HAVE_INET_PTON', compiler.has_function('inet_pton', args: defs)) 156conf_data.set('HAVE_MEMSET_S', compiler.has_function('memset_s', args: defs)) 157conf_data.set('HAVE_EXPLICIT_BZERO', compiler.has_function('explicit_bzero', args: defs)) 158conf_data.set('HAVE_EXPLICIT_MEMSET', compiler.has_function('explicit_memset', args: defs)) 159 160conf_data.set('HAVE_CLOCK_GETTIME', compiler.has_header_symbol('time.h', 'clock_gettime')) 161clock_lib = [] 162if not(conf_data.get('HAVE_CLOCK_GETTIME')) 163 if compiler.has_function('clock_gettime', args: defs + ['-lrt'], prefix: '#include <time.h>') 164 conf_data.set('HAVE_CLOCK_GETTIME', true) 165 clock_lib = [ compiler.find_library('rt') ] 166 endif 167endif 168 169libelftc = [] 170if compiler.has_function('elftc_copyfile', args: defs + ['-lelftc'], prefix: '#include <libelftc.h>') 171 conf_data.set('HAVE_ELFTC_COPYFILE', true) 172 libelftc = [ compiler.find_library('elftc') ] 173endif 174 175conf_data.set('HAVE_IPV6', compiler.compiles(''' 176 #include <sys/types.h> 177 #include <sys/socket.h> 178 #include <netinet/in.h> 179 180 int main() { 181 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; 182 return 0; 183 } 184''', 185 name: 'IPv6 support', 186 args: defs 187)) 188 189conf_data.set('HAVE_WEAK_SYMBOLS', compiler.compiles(''' 190 __attribute__((weak)) void __dummy(void *x) { } 191 int main() { 192 void *x; 193 __dummy(x); 194 } 195''', 196 name: 'weak symbols', 197 args: defs 198)) 199 200conf_data.set('HAVE_STRUCT_TM_GMTOFF', compiler.compiles(''' 201 #include <time.h> 202 int main(void) { 203 struct tm t; 204 t.tm_gmtoff = 0; 205 return 0; 206 } 207''', 208 name: 'struct tm gmt offset', 209 args: defs 210)) 211 212conf_data.set('LIGHTTPD_VERSION_ID', 10400) 213conf_data.set_quoted('PACKAGE_NAME', meson.project_name()) 214conf_data.set_quoted('PACKAGE_VERSION', meson.project_version()) 215conf_data.set_quoted('LIBRARY_DIR', moduledir) 216 217conf_data.set('LIGHTTPD_STATIC', get_option('build_static')) 218libdl = [] 219if not(get_option('build_static')) 220 if target_machine.system() != 'windows' 221 libdl = [ compiler.find_library('dl') ] 222 if not(compiler.has_function('dlopen', args: defs, dependencies: libdl, prefix: '#include <dlfcn.h>')) 223 error('Couldn\'t find dlfcn.h or dlopen in lib dl') 224 endif 225 endif 226endif 227 228libbrotli = [] 229if get_option('with_brotli') 230 libbrotli = [ compiler.find_library('brotlienc') ] 231 if compiler.has_function('BrotliEncoderCreateInstance', args: defs, dependencies: libbrotlienc, prefix: '#include <brotli/encode.h>') 232 conf_data.set('HAVE_BROTLI_ENCODE_H', true) 233 conf_data.set('HAVE_BROTLI', true) 234 else 235 error('Couldn\'t find brotli header / library') 236 endif 237endif 238 239libbz2 = [] 240if get_option('with_bzip') 241 libbz2 = [ compiler.find_library('bz2') ] 242 if compiler.has_function('BZ2_bzCompress', args: defs, dependencies: libbz2, prefix: '#include <bzlib.h>') 243 conf_data.set('HAVE_BZLIB_H', true) 244 conf_data.set('HAVE_LIBBZ2', true) 245 else 246 error('Couldn\'t find bz2 header / library') 247 endif 248endif 249 250if get_option('with_dbi') 251 libdbi = dependency('dbi', required: false) 252 if libdbi.found() 253 libdbi = [ libdbi ] 254 else 255 libdbi = [ compiler.find_library('dbi') ] 256 if not(compiler.has_function('dbi_conn_connect', args: defs, dependencies: libdbi, prefix: '#include <dbi/dbi.h>')) 257 error('Couldn\'t find dbi/dbi.h or dbi_conn_connect in lib dbi') 258 endif 259 endif 260 conf_data.set('HAVE_DBI', true) 261endif 262 263libfam = [] 264if get_option('with_fam') and not(conf_data.get('HAVE_SYS_INOTIFY_H')) 265 libfam = [ compiler.find_library('fam') ] 266 if not(compiler.has_function('FAMOpen2', args: defs, dependencies: libfam, prefix: '#include <fam.h>')) 267 error('Couldn\'t find fam.h or FAMOpen2 in lib fam') 268 endif 269 conf_data.set('HAVE_FAM_H', true) 270endif 271 272libmaxminddb = [] 273if get_option('with_maxminddb') 274 libmaxminddb = [ compiler.find_library('maxminddb') ] 275 if not(compiler.has_function('MMDB_open', args: defs, dependencies: libmaxminddb, prefix: '#include <maxminddb.h>')) 276 error('Couldn\'t find maxminddb.h or MMDB_open in lib maxminddb') 277 endif 278endif 279 280libgeoip = [] 281if get_option('with_geoip') 282 libgeoip = dependency('geoip', required: false) 283 if libgeoip.found() 284 libgeoip = [ libgeoip ] 285 else 286 libgeoip = [ compiler.find_library('GeoIP') ] 287 if not(compiler.has_function('GeoIP_country_name_by_addr', args: defs, dependencies: libgeoip)) 288 error('Couldn\'t find GeoIP_country_name_by_addr in lib GeoIP') 289 endif 290 endif 291endif 292 293libgdbm = [] 294if get_option('with_gdbm') 295 libgdbm = [ compiler.find_library('gdbm') ] 296 if not(compiler.has_function('gdbm_open', args: defs, dependencies: libgdbm, prefix: '#include <gdbm.h>')) 297 error('Couldn\'t find gdbm.h or gdbm_open in lib gdbm') 298 endif 299 conf_data.set('HAVE_GDBM_H', true) 300 conf_data.set('HAVE_GDBM', true) 301endif 302 303libkrb5 = [] 304libgssapi_krb5 = [] 305if get_option('with_krb5') 306 libkrb5 = dependency('krb5', required: false) 307 if libkrb5.found() 308 libkrb5 = [ libkrb5 ] 309 else 310 libkrb5 = [ compiler.find_library('krb5') ] 311 if not(compiler.has_function('krb5_init_context', args: defs, dependencies: libkrb5)) 312 error('Couldn\'t find krb5_init_context in lib krb5') 313 endif 314 endif 315 316 libgssapi_krb5 = dependency('krb5-gssapi', required: false) 317 if libgssapi_krb5.found() 318 libgssapi_krb5 = [ libgssapi_krb5 ] 319 else 320 libgssapi_krb5 = [ compiler.find_library('gssapi_krb5') ] 321 endif 322 323 conf_data.set('HAVE_KRB5', true) 324endif 325 326libldap = [] 327liblber = [] 328if get_option('with_ldap') 329 libldap = [ compiler.find_library('ldap') ] 330 if not(compiler.has_function('ldap_sasl_bind_s', 331 args: defs, 332 dependencies: libldap, 333 prefix: ''' 334 #include <ldap.h> 335 ''' 336 )) 337 error('Couldn\'t find ldap.h or ldap_bind in lib libldap') 338 endif 339 conf_data.set('HAVE_LDAP_H', true) 340 conf_data.set('HAVE_LIBLDAP', true) 341 liblber = [ compiler.find_library('lber') ] 342 if not(compiler.has_function('ber_printf', args: defs, dependencies: liblber, prefix: '#include <lber.h>')) 343 error('Couldn\'t find lber.h or ber_printf in lib liblber') 344 endif 345 conf_data.set('HAVE_LBER_H', true) 346 conf_data.set('HAVE_LIBLBER', true) 347endif 348 349libpam = [] 350if get_option('with_pam') 351 libpam = [ compiler.find_library('pam') ] 352 if not(compiler.has_function('pam_start', 353 args: defs, 354 dependencies: libpam, 355 prefix: ''' 356 #include <security/pam_appl.h> 357 ''' 358 )) 359 error('Couldn\'t find security/pam_appl.h or pam_start in lib libpam') 360 endif 361 conf_data.set('HAVE_PAM', true) 362endif 363 364libev = [] 365if get_option('with_libev') 366 libev = dependency('ev', required: false) 367 if libev.found() 368 libev = [ libev ] 369 elif compiler.has_header('ev.h') and compiler.has_function('ev_time', args: defs + ['-lev']) 370 libev = [ compiler.find_library('ev') ] 371 else 372 error('Couldn\'t find libev header / library') 373 endif 374 conf_data.set('HAVE_LIBEV', true) 375endif 376 377libunwind = [] 378if get_option('with_libunwind') 379 libunwind = [ dependency('libunwind') ] 380endif 381 382liblua = [] 383if get_option('with_lua') 384 found_lua = false 385 foreach l: ['lua5.4', 'lua-5.4', 'lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua'] 386 if not(found_lua) 387 liblua = dependency(l, required: false) 388 if (liblua.found()) 389 found_lua = true 390 else 391 liblua = compiler.find_library(l, required: false) 392 if (liblua.found()) 393 found_lua = true 394 liblua_found_header = false 395 foreach ib: include_base_paths 396 if not(liblua_found_header) 397 i = join_paths(ib, l) 398 if compiler.has_header(join_paths(i, 'lua.h')) 399 liblua_found_header = true 400 liblua += [ declare_dependency(include_directories: include_directories(i)) ] 401 endif 402 endif 403 endforeach 404 endif 405 endif 406 endif 407 endforeach 408 if not(found_lua) 409 error('Couldn\'t find any lua library') 410 endif 411 liblua = [ liblua ] 412 conf_data.set('HAVE_LUA_H', true) 413endif 414 415libmemcached = [] 416if get_option('with_memcached') 417 # manual search: 418 # header: libmemcached/memcached.h 419 # function: memcached (-lmemcached) 420 libmemcached = [ dependency('libmemcached') ] 421 conf_data.set('USE_MEMCACHED', true) 422endif 423 424libmysqlclient = [] 425if get_option('with_mysql') 426 # manual search: extend include path with 'mysql/' 427 # header: mysql.h 428 # function: mysql_real_connect (-lmariadb) 429 libmysqlclient = [ dependency('libmariadb') ] 430 #-# function: mysql_real_connect (-lmysqlclient) 431 #-libmysqlclient = [ dependency('mysqlclient') ] 432 conf_data.set('HAVE_MYSQL', true) 433endif 434 435libssl = [] 436libcrypto = [] 437libsslcrypto = [] 438libgnutls = [] 439libmbedtls = [] 440libmbedcrypto = [] 441libmbedx509 = [] 442libwolfssl = [] 443if get_option('with_openssl') 444 # manual search: 445 # header: openssl/ssl.h 446 # function: SSL_new (-lssl) 447 # function: BIO_f_base64 (-lcrypto) 448 libssl = [ dependency('libssl') ] 449 libsslcrypto = [ dependency('libcrypto') ] 450 libcrypto = [ dependency('libcrypto') ] 451 conf_data.set('HAVE_OPENSSL_SSL_H', true) 452 conf_data.set('HAVE_LIBSSL', true) 453endif 454if get_option('with_wolfssl') 455 # manual search: 456 # header: wolfssl/ssl.h 457 # function: wolfSSL_Init (-lwolfssl) 458 libwolfssl = [ dependency('wolfssl') ] 459 libcrypto = [ dependency('wolfssl') ] 460 conf_data.set('HAVE_WOLFSSL_SSL_H', true) 461endif 462if get_option('with_mbedtls') 463 # manual search: 464 # header: mbedtls/ssl.h 465 # function: mbedtls_cipher_info_from_type (-lmbedtls) 466 # function: mbedtls_x509_get_name (-lmbedx509) 467 # function: mbedtls_base64_encode (-lmbedcrypto) 468 libmbedtls = [ compiler.find_library('mbedtls') ] 469 libmbedx509 = [ compiler.find_library('mbedx509') ] 470 libmbedcrypto = [ compiler.find_library('mbedcrypto') ] 471 libcrypto = [ compiler.find_library('mbedcrypto') ] 472 conf_data.set('HAVE_LIBMBEDCRYPTO', true) 473endif 474if get_option('with_nettle') 475 # manual search: 476 # header: nettle/nettle-types.h 477 # function: nettle_md5_init (-lnettle) 478 libcrypto = [ dependency('nettle') ] 479 conf_data.set('HAVE_NETTLE_NETTLE_TYPES_H', true) 480endif 481if get_option('with_gnutls') 482 # manual search: 483 # header: gnutls/gnutls.h 484 # function: gnutls_check_version (-lgnutls) 485 libgnutls = [ dependency('gnutls') ] 486 conf_data.set('HAVE_GNUTLS_CRYPTO_H', true) 487 if not(get_option('with_openssl')) and not(get_option('with_wolfssl')) and not(get_option('with_mbedtls')) and not(getoption('with_nettle')) 488 libcrypto = [ dependency('gnutls') ] 489 endif 490endif 491libssl3 = [] 492libsmime3 = [] 493libnss3 = [] 494libnssutil3 = [] 495if get_option('with_nss') 496 # manual search: 497 # header: nss3/nss.h 498 # function: NSSSSL_GetVersion (-lssl3) 499 # function: NSSSMIME_GetVersion (-lsmime3) 500 # function: NSS_GetVersion (-lnss3) 501 # function: NSSUTIL_GetVersion (-lnssutil3) 502 libnss3 = [ dependency('nss') ] 503 #libssl3 = [ compiler.find_library('libssl3') ] 504 #libsmime3 = [ compiler.find_library('libsmime3') ] 505 #libnss3 = [ compiler.find_library('libnss3') ] 506 #libnssutil3 = [ compiler.find_library('libnssutil3') ] 507 conf_data.set('HAVE_NSS3_NSS_H', true) 508 if not(get_option('with_openssl')) and not(get_option('with_wolfssl')) and not(get_option('with_mbedtls')) and not(getoption('with_nettle')) and not(getoption('with_gnutls')) 509 libcrypto = [ dependency('nss') ] 510 endif 511endif 512if get_option('with_nss') 513 # manual search: 514 # header: nss/nss.h 515 conf_data.set('HAVE_NSS_NSS_H', true) 516endif 517 518libpcre = [] 519if get_option('with_pcre') 520 # manual search: 521 # header: pcre.h 522 # function: pcre_exec (-lpcre) 523 libpcre = [ dependency('libpcre') ] 524 conf_data.set('HAVE_PCRE_H', true) 525 conf_data.set('HAVE_LIBPCRE', true) 526endif 527 528libpq = [] 529if get_option('with_pgsql') 530 # manual search: 531 # header: libpq-fe.h 532 # function: PQsetdbLogin (-lpq) 533 libpq = [ dependency('libpq') ] 534 conf_data.set('HAVE_PGSQL', true) 535endif 536 537if get_option('with_sasl') 538 libsasl = dependency('sasl2', required: false) 539 if libsasl.found() 540 libsasl = [ libsasl2 ] 541 else 542 libsasl = [ compiler.find_library('sasl2') ] 543 if not(compiler.has_function('sasl_server_init', args: defs, dependencies: libsasl, prefix: '#include <sasl/sasl.h>')) 544 error('Couldn\'t find sasl/sasl.h or sasl_server_init in libsasl2') 545 endif 546 endif 547 conf_data.set('HAVE_SASL', true) 548endif 549 550#if get_option('with_valgrind') 551#endif 552 553libuuid = [] 554if get_option('with_webdav_locks') 555 libuuid = dependency('uuid', required: false) 556 if libuuid.found() 557 libuuid = [ libuuid ] 558 elif compiler.has_function('uuid_generate', args: defs, prefix: '#include <uuid/uuid.h>') 559 # uuid_generate in libc, everything is fine, no lib needed 560 libuuid = [] 561 else 562 libuuid = compiler.find_library('uuid') 563 if not(compiler.has_function('uuid_generate', 564 args: defs, 565 dependencies: libuuid, 566 prefix: '#include <uuid/uuid.h>' 567 )) 568 error('Couldn\'t find uuid/uuid.h or uuid_generate in lib c and uuid') 569 endif 570 endif 571 conf_data.set('HAVE_LIBUUID', true) 572 conf_data.set('HAVE_UUID_UUID_H', true) 573endif 574 575libxml2 = [] 576libsqlite3 = [] 577if get_option('with_webdav_props') 578 libxml2 = dependency('libxml-2.0', required: false) 579 if libxml2.found() 580 libxml2 = [ libxml2 ] 581 else 582 libxml2_includes = [] 583 libxml2_includes_dep = [] 584 libxml2_found_header = compiler.has_header('libxml/tree.h') 585 foreach i: include_base_paths 586 if not(libxml2_found_header) 587 message('Searching in ' + join_paths(i, 'libxml2')) 588 i = include_directories(join_paths(i, 'libxml2')) 589 if compiler.has_header('libxml/tree.h', include_directories: i) 590 libxml2_found_header = true 591 libxml2_includes = [ i ] 592 libxml2_includes_dep = [ declare_dependency(include_directories: i) ] 593 endif 594 endif 595 endforeach 596 if not(libxml2_found_header) 597 error('Couldn\'t find libxml/tree.h') 598 endif 599 libxml2 = [ compiler.find_library('xml2') ] 600 if not(compiler.has_function('xmlParseChunk', 601 args: defs, 602 dependencies: libxml2, 603 include_directories: libxml2_includes, 604 prefix: ''' 605 #include <libxml/tree.h> 606 ''' 607 )) 608 error('Couldn\'t find xmlParseChunk in lib xml2') 609 endif 610 # has_function doesn't like "internal dependencies" 611 libxml2 += libxml2_includes_dep 612 endif 613 conf_data.set('HAVE_LIBXML_H', true) 614 615 libsqlite3 = dependency('sqlite31', required: false) 616 if libsqlite3.found() 617 libsqlite3 = [ libsqlite3 ] 618 else 619 libsqlite3 = [ compiler.find_library('sqlite3') ] 620 if not(compiler.has_function('sqlite3_reset', 621 args: defs, 622 dependencies: libsqlite3, 623 prefix: ''' 624 #include <sqlite3.h> 625 ''' 626 )) 627 error('Couldn\'t find sqlite3.h or sqlite3_reset in lib sqlite3') 628 endif 629 endif 630 conf_data.set('HAVE_SQLITE3_H', true) 631endif 632 633libattr = [] 634if get_option('with_xattr') 635 if compiler.has_function('getxattr', 636 args: defs, 637 prefix: ''' 638 #include <sys/types.h> 639 #include <sys/xattr.h> 640 ''' 641 ) 642 conf_data.set('HAVE_SYS_XATTR_H', true) 643 conf_data.set('HAVE_XATTR', true) 644 else 645 libattr = [ compiler.find_library('attr') ] 646 if not(compiler.has_function('attr_get', 647 args: defs, 648 dependencies: libattr, 649 prefix: ''' 650 #include <sys/types.h> 651 #include <attr/attributes.h> 652 ''' 653 )) 654 error('Couldn\'t find attr/attributes.h or attr_get in lib attr') 655 endif 656 conf_data.set('HAVE_ATTR_ATTRIBUTES_H', true) 657 conf_data.set('HAVE_XATTR', true) 658 endif 659endif 660 661libxxhash = [] 662if get_option('with_xxhash') 663 libxxhash = dependency('libxxhash', required: false) 664 if libxxhash.found() 665 libxxhash = [ libxxhash ] 666 else 667 libxxhash = [ compiler.find_library('xxhash') ] 668 if not(compiler.has_function('XXH_versionNumber', args: defs, dependencies: libxxhash, prefix: '#include <xxhash.h>')) 669 error('Couldn\'t find xxhash/xxhash.h or XXH_versionNumber in lib xxhash') 670 endif 671 endif 672 conf_data.set('HAVE_XXHASH_H', true) 673endif 674 675libz = [] 676if get_option('with_zlib') 677 libz = dependency('zlib', required: false) 678 if libz.found() 679 libz = [ libz ] 680 else 681 # windows alternative names? 'zlib', 'zdll' 682 libz = [ compiler.find_library('z') ] 683 if not(compiler.has_function('deflate', args: defs, dependencies: libz, prefix: '#include <zlib.h>')) 684 error('Couldn\'t find z header / library') 685 endif 686 endif 687 conf_data.set('HAVE_ZLIB_H', true) 688 conf_data.set('HAVE_LIBZ', true) 689endif 690 691configure_file( 692 output : 'config.h', 693 configuration : conf_data, 694) 695 696common_src = [ 697 'algo_md5.c', 698 'algo_sha1.c', 699 'algo_splaytree.c', 700 'array.c', 701 'base64.c', 702 'buffer.c', 703 'burl.c', 704 'chunk.c', 705 'configfile-glue.c', 706 'connections-glue.c', 707 'data_array.c', 708 'data_integer.c', 709 'data_string.c', 710 'etag.c', 711 'fdevent_freebsd_kqueue.c', 712 'fdevent_libev.c', 713 'fdevent_linux_sysepoll.c', 714 'fdevent_poll.c', 715 'fdevent_select.c', 716 'fdevent_solaris_devpoll.c', 717 'fdevent_solaris_port.c', 718 'fdevent.c', 719 'gw_backend.c', 720 'http_auth.c', 721 'http_chunk.c', 722 'http_header.c', 723 'http_kv.c', 724 'http_vhostdb.c', 725 'http-header-glue.c', 726 'keyvalue.c', 727 'log.c', 728 'plugin.c', 729 'rand.c', 730 'request.c', 731 'safe_memclear.c', 732 'sock_addr.c', 733 'stat_cache.c', 734 'stream.c', 735 'vector.c', 736] 737if target_machine.system() == 'windows' 738 common_src += [ 'xgetopt.c' ] 739endif 740main_src = [ 741 'configfile.c', 742 'connections.c', 743 'data_config.c', 744 'h2.c', 745 'inet_ntop_cache.c', 746 'ls-hpack/lshpack.c', 747 'algo_xxhash.c', 748 'network_write.c', 749 'network.c', 750 'reqpool.c', 751 'response.c', 752 'server.c', 753] 754 755lemon = executable('lemon', 756 sources: 'lemon.c', 757 native: true, 758) 759# generator doesn't handle additional "input dependencies" like lempar.c 760# => use custom_target 761configparser = custom_target('configparser', 762 input: ['configparser.y', 'lempar.c'], 763 output: ['configparser.c', 'configparser.h'], 764 command: [lemon, '-q', 'o=@OUTDIR@', '@INPUT0@', '@INPUT1@'], 765) 766ssi_exprparser = custom_target('mod_ssi_exprparser', 767 input: ['mod_ssi_exprparser.y', 'lempar.c'], 768 output: ['mod_ssi_exprparser.c', 'mod_ssi_exprparser.h'], 769 command: [lemon, '-q', 'o=@OUTDIR@', '@INPUT0@', '@INPUT1@'], 770) 771 772common_cflags = defs + [ 773 '-DHAVE_CONFIG_H', 774] 775 776if compiler.get_id() == 'gcc' or compiler.get_id() == 'clang' 777 common_cflags += [ 778 '-Wall', 779 '-g', 780 '-Wshadow', 781 '-W', 782 '-pedantic', 783 ] 784 if get_option('build_extra_warnings') 785 common_cflags += get_option('warn_cflags').split() 786 endif 787endif 788 789common_flags = [ declare_dependency( 790 compile_args: common_cflags, 791 # tests also use common_flags, and need this 792 include_directories: include_directories('.'), 793) ] 794 795lighttpd_flags = [] 796lighttpd_angel_flags = [] 797if target_machine.system() == 'windows' 798 lighttpd_flags += [ declare_dependency( 799 compile_args: [ 800 '-DLI_DECLARE_EXPORTS', 801 ], 802 ) ] 803 if compiler.get_id() == 'gcc' 804 libmsvcr70 = [ compiler.find_library('msvcr70') ] 805 lighttpd_flags += libmsvcr70 + [ declare_dependency( 806 link_args: [ 807 '-Wl,-subsystem,console', 808 ], 809 ) ] 810 lighttpd_angel_flags += libmsvcr70 + [ declare_dependency( 811 link_args: [ 812 '-Wl,-subsystem,console', 813 ], 814 ) ] 815 endif 816endif 817 818if compiler.get_id() == 'gcc' or target_machine.system() != 'darwin' 819 lighttpd_flags += [ declare_dependency( 820 link_args: [ 821 '-Wl,-export-dynamic', 822 ], 823 ) ] 824endif 825 826executable('lighttpd-angel', 827 sources: 'lighttpd-angel.c', 828 dependencies: common_flags + lighttpd_angel_flags, 829 c_args: ['-DSBIN_DIR="' + sbinddir + '"'], 830 install: true, 831 install_dir: sbinddir, 832) 833 834executable('lighttpd', configparser, 835 sources: common_src + main_src, 836 dependencies: [ common_flags, lighttpd_flags 837 , libattr 838 , libcrypto 839 , libdl 840 , libev 841 , libfam 842 , libpcre 843 , libunwind 844 , libxxhash 845 , libws2_32 846 ], 847 install: true, 848 install_dir: sbinddir, 849) 850 851test('test_array', executable('test_array', 852 sources: ['t/test_array.c', 'array.c', 'data_array.c', 'data_integer.c', 'data_string.c', 'buffer.c'], 853 dependencies: common_flags + libunwind, 854 build_by_default: false, 855)) 856 857test('test_buffer', executable('test_buffer', 858 sources: ['t/test_buffer.c', 'buffer.c'], 859 dependencies: common_flags + libunwind, 860 build_by_default: false, 861)) 862 863test('test_burl', executable('test_burl', 864 sources: ['t/test_burl.c', 'burl.c', 'buffer.c', 'base64.c'], 865 dependencies: common_flags + libunwind, 866 build_by_default: false, 867)) 868 869test('test_base64', executable('test_base64', 870 sources: ['t/test_base64.c', 'buffer.c', 'base64.c'], 871 dependencies: common_flags + libunwind, 872 build_by_default: false, 873)) 874 875test('test_configfile', executable('test_configfile', 876 sources: [ 877 't/test_configfile.c', 878 'buffer.c', 879 'array.c', 880 'data_config.c', 881 'data_integer.c', 882 'data_string.c', 883 'http_header.c', 884 'http_kv.c', 885 'vector.c', 886 'log.c', 887 'sock_addr.c', 888 ], 889 dependencies: common_flags + libpcre + libunwind, 890 build_by_default: false, 891)) 892 893test('test_keyvalue', executable('test_keyvalue', 894 sources: [ 895 't/test_keyvalue.c', 896 'burl.c', 897 'buffer.c', 898 'base64.c', 899 'array.c', 900 'data_integer.c', 901 'data_string.c', 902 'log.c', 903 ], 904 dependencies: common_flags + libpcre + libunwind, 905 build_by_default: false, 906)) 907 908test('test_mod_access', executable('test_mod_access', 909 sources: [ 910 't/test_mod_access.c', 911 'buffer.c', 912 'array.c', 913 'data_integer.c', 914 'data_string.c', 915 'log.c', 916 ], 917 dependencies: common_flags + libunwind, 918 build_by_default: false, 919)) 920 921test('test_mod_evhost', executable('test_mod_evhost', 922 sources: [ 923 't/test_mod_evhost.c', 924 'buffer.c', 925 'array.c', 926 'data_integer.c', 927 'data_string.c', 928 'log.c', 929 ], 930 dependencies: common_flags + libunwind, 931 build_by_default: false, 932)) 933 934test('test_mod_simple_vhost', executable('test_mod_simple_vhost', 935 sources: [ 936 't/test_mod_simple_vhost.c', 937 'buffer.c', 938 'array.c', 939 'data_integer.c', 940 'data_string.c', 941 'log.c', 942 ], 943 dependencies: common_flags + libunwind, 944 build_by_default: false, 945)) 946 947test('test_mod_userdir', executable('test_mod_userdir', 948 sources: [ 949 't/test_mod_userdir.c', 950 'buffer.c', 951 'array.c', 952 'data_integer.c', 953 'data_string.c', 954 'log.c', 955 ], 956 dependencies: common_flags + libunwind, 957 build_by_default: false, 958)) 959 960test('test_request', executable('test_request', 961 sources: [ 962 't/test_request.c', 963 'base64.c', 964 'buffer.c', 965 'burl.c', 966 'array.c', 967 'data_integer.c', 968 'data_string.c', 969 'http_header.c', 970 'http_kv.c', 971 'log.c', 972 'sock_addr.c', 973 ], 974 dependencies: common_flags + libunwind, 975 build_by_default: false, 976)) 977 978modules = [ 979 [ 'mod_access', [ 'mod_access.c' ] ], 980 [ 'mod_accesslog', [ 'mod_accesslog.c' ] ], 981 [ 'mod_alias', [ 'mod_alias.c' ] ], 982 [ 'mod_auth', [ 'mod_auth.c' ], [ libcrypto ] ], 983 [ 'mod_authn_file', [ 'mod_authn_file.c' ], [ libcrypt, libcrypto ] ], 984 [ 'mod_deflate', [ 'mod_deflate.c' ], libbz2 + libz + libbrotli ], 985 [ 'mod_dirlisting', [ 'mod_dirlisting.c' ], libpcre ], 986 [ 'mod_evasive', [ 'mod_evasive.c' ] ], 987 [ 'mod_evhost', [ 'mod_evhost.c' ] ], 988 [ 'mod_expire', [ 'mod_expire.c' ] ], 989 [ 'mod_extforward', [ 'mod_extforward.c' ] ], 990 [ 'mod_fastcgi', [ 'mod_fastcgi.c' ], libws2_32 ], 991 [ 'mod_flv_streaming', [ 'mod_flv_streaming.c' ] ], 992 [ 'mod_indexfile', [ 'mod_indexfile.c' ] ], 993 [ 'mod_proxy', [ 'mod_proxy.c' ], libws2_32 ], 994 [ 'mod_redirect', [ 'mod_redirect.c' ], libpcre ], 995 [ 'mod_rewrite', [ 'mod_rewrite.c' ], libpcre ], 996 [ 'mod_rrdtool', [ 'mod_rrdtool.c' ] ], 997 [ 'mod_scgi', [ 'mod_scgi.c' ], libws2_32 ], 998 [ 'mod_secdownload', [ 'mod_secdownload.c' ], libcrypto ], 999 [ 'mod_setenv', [ 'mod_setenv.c' ] ], 1000 [ 'mod_simple_vhost', [ 'mod_simple_vhost.c' ] ], 1001 [ 'mod_sockproxy', [ 'mod_sockproxy.c' ] ], 1002 [ 'mod_ssi', [ ssi_exprparser, 'mod_ssi_expr.c', 'mod_ssi.c' ], libws2_32 ], 1003 [ 'mod_staticfile', [ 'mod_staticfile.c' ] ], 1004 [ 'mod_status', [ 'mod_status.c' ] ], 1005 [ 'mod_uploadprogress', [ 'mod_uploadprogress.c' ] ], 1006 [ 'mod_userdir', [ 'mod_userdir.c' ] ], 1007 [ 'mod_usertrack', [ 'mod_usertrack.c' ], libcrypto ], 1008 [ 'mod_vhostdb', [ 'mod_vhostdb.c' ] ], 1009 [ 'mod_webdav', [ 'mod_webdav.c' ], libsqlite3 + libuuid + libxml2 + libelftc ], 1010 [ 'mod_wstunnel', [ 'mod_wstunnel.c' ], libcrypto ], 1011] 1012 1013if target_machine.system() != 'windows' 1014 modules += [ 1015 [ 'mod_cgi', [ 'mod_cgi.c' ] ], 1016 ] 1017endif 1018 1019if get_option('with_pcre') and (get_option('with_memcached') or get_option('with_gdbm')) 1020 modules += [ 1021 [ 'mod_trigger_b4_dl', [ 'mod_trigger_b4_dl.c' ], libpcre + libmemcached + libgdbm ], 1022 ] 1023endif 1024 1025if get_option('with_lua') 1026 modules += [ 1027 [ 'mod_cml', [ 'mod_cml.c', 'mod_cml_lua.c', 'mod_cml_funcs.c' ], liblua + libmemcached + libcrypto ], 1028 [ 'mod_magnet', [ 'mod_magnet.c', 'mod_magnet_cache.c' ], liblua ], 1029 ] 1030endif 1031 1032if get_option('with_maxminddb') 1033 modules += [ 1034 [ 'mod_maxminddb', [ 'mod_maxminddb.c' ], libmaxminddb ], 1035 ] 1036endif 1037 1038if get_option('with_geoip') 1039 modules += [ 1040 [ 'mod_geoip', [ 'mod_geoip.c' ], libgeoip ], 1041 ] 1042endif 1043 1044if get_option('with_mysql') 1045 modules += [ 1046 [ 'mod_authn_mysql', [ 'mod_authn_mysql.c' ], libcrypt + libmysqlclient + libcrypto ], 1047 [ 'mod_mysql_vhost', [ 'mod_mysql_vhost.c' ], libmysqlclient ], 1048 [ 'mod_vhostdb_mysql', [ 'mod_vhostdb_mysql.c' ], libmysqlclient ], 1049 ] 1050endif 1051 1052if get_option('with_pgsql') 1053 modules += [ 1054 [ 'mod_vhostdb_pgsql', [ 'mod_vhostdb_pgsql.c' ], libpq ], 1055 ] 1056endif 1057 1058if get_option('with_dbi') 1059 modules += [ 1060 [ 'mod_authn_dbi', [ 'mod_authn_dbi.c' ], libcrypt + libdbi + libcrypto ], 1061 [ 'mod_vhostdb_dbi', [ 'mod_vhostdb_dbi.c' ], libdbi ], 1062 ] 1063endif 1064 1065if get_option('with_krb5') 1066 modules += [ 1067 [ 'mod_authn_gssapi', [ 'mod_authn_gssapi.c' ], libkrb5 + libgssapi_krb5 ], 1068 ] 1069endif 1070 1071if get_option('with_ldap') 1072 modules += [ 1073 [ 'mod_authn_ldap', [ 'mod_authn_ldap.c' ], libldap + liblber ], 1074 [ 'mod_vhostdb_ldap', [ 'mod_vhostdb_ldap.c' ], libldap + liblber ], 1075 ] 1076endif 1077 1078if get_option('with_openssl') 1079 modules += [ 1080 [ 'mod_openssl', [ 'mod_openssl.c' ], libssl + libsslcrypto ], 1081 ] 1082endif 1083 1084if get_option('with_wolfssl') 1085 modules += [ 1086 [ 'mod_wolfssl', [ 'mod_wolfssl.c' ], libwolfssl ], 1087 ] 1088endif 1089 1090if get_option('with_mbedtls') 1091 modules += [ 1092 [ 'mod_mbedtls', [ 'mod_mbedtls.c' ], libmbedtls + libmbedx509 + libmbedcrypto ], 1093 ] 1094endif 1095 1096if get_option('with_nss') 1097 modules += [ 1098 [ 'mod_nss', [ 'mod_nss.c' ], libssl3 + libsmime3 + libnss3 + libnssutil3 ], 1099 ] 1100endif 1101 1102if get_option('with_gnutls') 1103 modules += [ 1104 [ 'mod_gnutls', [ 'mod_gnutls.c' ], libgnutls ], 1105 ] 1106endif 1107 1108if get_option('with_pam') 1109 modules += [ 1110 [ 'mod_authn_pam', [ 'mod_authn_pam.c' ], libpam ], 1111 ] 1112endif 1113 1114if get_option('with_sasl') 1115 modules += [ 1116 [ 'mod_authn_sasl', [ 'mod_authn_sasl.c' ], libsasl ], 1117 ] 1118endif 1119 1120foreach mod: modules 1121 mod_name = mod.get(0) 1122 mod_sources = mod.get(1) 1123 mod_deps = mod.length() > 2 ? mod.get(2) : [] 1124 shared_module(mod_name, 1125 sources: mod_sources, 1126 dependencies: [ common_flags, mod_deps ], 1127 name_prefix: '', 1128 install: true, 1129 install_dir: moduledir, 1130 ) 1131endforeach 1132