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