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