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 226libbz2 = [] 227if get_option('with_bzip') 228 libbz2 = [ compiler.find_library('bz2') ] 229 if compiler.has_function('BZ2_bzCompress', args: defs, dependencies: libbz2, prefix: '#include <bzlib.h>') 230 conf_data.set('HAVE_BZLIB_H', true) 231 conf_data.set('HAVE_LIBBZ2', true) 232 else 233 error('Couldn\'t find bz2 header / library') 234 endif 235endif 236 237if get_option('with_dbi') 238 libdbi = dependency('dbi', required: false) 239 if libdbi.found() 240 libdbi = [ libdbi ] 241 else 242 libdbi = [ compiler.find_library('dbi') ] 243 if not(compiler.has_function('dbi_conn_connect', args: defs, dependencies: libdbi, prefix: '#include <dbi/dbi.h>')) 244 error('Couldn\'t find dbi/dbi.h or dbi_conn_connect in lib dbi') 245 endif 246 endif 247 conf_data.set('HAVE_DBI', true) 248endif 249 250libfam = [] 251if get_option('with_fam') 252 libfam = [ compiler.find_library('fam') ] 253 if not(compiler.has_function('FAMOpen2', args: defs, dependencies: libfam, prefix: '#include <fam.h>')) 254 error('Couldn\'t find fam.h or FAMOpen2 in lib fam') 255 endif 256 conf_data.set('HAVE_FAM_H', true) 257endif 258 259libmaxminddb = [] 260if get_option('with_maxminddb') 261 libmaxminddb = [ compiler.find_library('maxminddb') ] 262 if not(compiler.has_function('MMDB_open', args: defs, dependencies: libmaxminddb, prefix: '#include <maxminddb.h>')) 263 error('Couldn\'t find maxminddb.h or MMDB_open in lib maxminddb') 264 endif 265endif 266 267libgeoip = [] 268if get_option('with_geoip') 269 libgeoip = dependency('geoip', required: false) 270 if libgeoip.found() 271 libgeoip = [ libgeoip ] 272 else 273 libgeoip = [ compiler.find_library('GeoIP') ] 274 if not(compiler.has_function('GeoIP_country_name_by_addr', args: defs, dependencies: libgeoip)) 275 error('Couldn\'t find GeoIP_country_name_by_addr in lib GeoIP') 276 endif 277 endif 278endif 279 280libgdbm = [] 281if get_option('with_gdbm') 282 libgdbm = [ compiler.find_library('gdbm') ] 283 if not(compiler.has_function('gdbm_open', args: defs, dependencies: libgdbm, prefix: '#include <gdbm.h>')) 284 error('Couldn\'t find gdbm.h or gdbm_open in lib gdbm') 285 endif 286 conf_data.set('HAVE_GDBM_H', true) 287 conf_data.set('HAVE_GDBM', true) 288endif 289 290libkrb5 = [] 291libgssapi_krb5 = [] 292if get_option('with_krb5') 293 libkrb5 = dependency('krb5', required: false) 294 if libkrb5.found() 295 libkrb5 = [ libkrb5 ] 296 else 297 libkrb5 = [ compiler.find_library('krb5') ] 298 if not(compiler.has_function('krb5_init_context', args: defs, dependencies: libkrb5)) 299 error('Couldn\'t find krb5_init_context in lib krb5') 300 endif 301 endif 302 303 libgssapi_krb5 = dependency('krb5-gssapi', required: false) 304 if libgssapi_krb5.found() 305 libgssapi_krb5 = [ libgssapi_krb5 ] 306 else 307 libgssapi_krb5 = [ compiler.find_library('gssapi_krb5') ] 308 endif 309 310 conf_data.set('HAVE_KRB5', true) 311endif 312 313libldap = [] 314liblber = [] 315if get_option('with_ldap') 316 libldap = [ compiler.find_library('ldap') ] 317 if not(compiler.has_function('ldap_sasl_bind_s', 318 args: defs, 319 dependencies: libldap, 320 prefix: ''' 321 #include <ldap.h> 322 ''' 323 )) 324 error('Couldn\'t find ldap.h or ldap_bind in lib libldap') 325 endif 326 conf_data.set('HAVE_LDAP_H', true) 327 conf_data.set('HAVE_LIBLDAP', true) 328 liblber = [ compiler.find_library('lber') ] 329 if not(compiler.has_function('ber_printf', args: defs, dependencies: liblber, prefix: '#include <lber.h>')) 330 error('Couldn\'t find lber.h or ber_printf in lib liblber') 331 endif 332 conf_data.set('HAVE_LBER_H', true) 333 conf_data.set('HAVE_LIBLBER', true) 334endif 335 336libpam = [] 337if get_option('with_pam') 338 libpam = [ compiler.find_library('pam') ] 339 if not(compiler.has_function('pam_start', 340 args: defs, 341 dependencies: libpam, 342 prefix: ''' 343 #include <security/pam_appl.h> 344 ''' 345 )) 346 error('Couldn\'t find security/pam_appl.h or pam_start in lib libpam') 347 endif 348 conf_data.set('HAVE_PAM', true) 349endif 350 351libev = [] 352if get_option('with_libev') 353 libev = dependency('ev', required: false) 354 if libev.found() 355 libev = [ libev ] 356 elif compiler.has_header('ev.h') and compiler.has_function('ev_time', args: defs + ['-lev']) 357 libev = [ compiler.find_library('ev') ] 358 else 359 error('Couldn\'t find libev header / library') 360 endif 361 conf_data.set('HAVE_LIBEV', true) 362endif 363 364libunwind = [] 365if get_option('with_libunwind') 366 libunwind = [ dependency('libunwind') ] 367endif 368 369liblua = [] 370if get_option('with_lua') 371 found_lua = false 372 foreach l: ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua'] 373 if not(found_lua) 374 liblua = dependency(l, required: false) 375 found_lua = liblua.found() 376 endif 377 endforeach 378 if not(found_lua) 379 error('Couldn\'t find any lua library') 380 endif 381 liblua = [ liblua ] 382 conf_data.set('HAVE_LUA_H', true) 383endif 384 385libmemcached = [] 386if get_option('with_memcached') 387 # manual search: 388 # header: libmemcached/memcached.h 389 # function: memcached (-lmemcached) 390 libmemcached = [ dependency('libmemcached') ] 391 conf_data.set('USE_MEMCACHED', true) 392endif 393 394libmysqlclient = [] 395if get_option('with_mysql') 396 # manual search: extend include path with 'mysql/' 397 # header: mysql.h 398 # function: mysql_real_connect (-lmariadb) 399 libmysqlclient = [ dependency('libmariadb') ] 400 #-# function: mysql_real_connect (-lmysqlclient) 401 #-libmysqlclient = [ dependency('mysqlclient') ] 402 conf_data.set('HAVE_MYSQL', true) 403endif 404 405libssl = [] 406libx509 = [] 407libcrypto = [] 408libgnutls = [] 409if get_option('with_openssl') 410 # manual search: 411 # header: openssl/ssl.h 412 # function: SSL_new (-lssl) 413 # function: BIO_f_base64 (-lcrypto) 414 libssl = [ dependency('libssl') ] 415 libcrypto = [ dependency('libcrypto') ] 416 conf_data.set('HAVE_OPENSSL_SSL_H', true) 417 conf_data.set('HAVE_LIBSSL', true) 418endif 419if get_option('with_wolfssl') != 'false' 420 # manual search: 421 # header: wolfssl/ssl.h 422 # function: wolfSSL_Init (-lwolfssl) 423 p = get_option('with_wolfssl') 424 if p == 'true' 425 p = '/usr/local' 426 endif 427 i = include_directories(p+'/include', p+'/include/wolfssl') 428 libwolfssl_includes_dep = [ declare_dependency(include_directories: i) ] 429 libcrypto = [ compiler.find_library('libwolfssl', dirs: [ p+'/lib', p+'/lib64' ]) ] 430 libcrypto += libwolfssl_includes_dep 431 conf_data.set('HAVE_WOLFSSL_SSL_H', true) 432endif 433if get_option('with_mbedtls') 434 # manual search: 435 # header: mbedtls/ssl.h 436 # function: mbedtls_cipher_info_from_type (-lmbedtls) 437 # function: mbedtls_x509_get_name (-lmbedx509) 438 # function: mbedtls_base64_encode (-lmbedcrypto) 439 libssl = [ dependency('libmbedtls') ] 440 libx509 = [ dependency('libmbedx509') ] 441 libcrypto = [ dependency('libmbedcrypto') ] 442 conf_data.set('HAVE_LIBMBEDCRYPTO', true) 443endif 444if get_option('with_nettle') != 'false' 445 # manual search: 446 # header: nettle/nettle-types.h 447 # function: nettle_md5_init (-lnettle) 448 libcrypto = [ dependency('libnettle') ] 449 conf_data.set('HAVE_NETTLE_NETTLE_TYPES_H', true) 450endif 451if get_option('with_gnutls') 452 # manual search: 453 # header: gnutls/gnutls.h 454 # function: gnutls_check_version (-lgnutls) 455 libgnutls = [ dependency('libgnutls') ] 456 conf_data.set('HAVE_GNUTLS_CRYPTO_H', true) 457 if not(get_option('with_openssl')) and not(get_option('with_wolfssl')) and not(get_option('with_mbedtls')) and not(getoption('with_nettle')) 458 libcrypto = [ dependency('libgnutls') ] 459 endif 460endif 461if get_option('with_nss') 462 # manual search: 463 # header: nss3/nss.h 464 # function: NSSSSL_GetVersion (-lssl3) 465 # function: NSSSMIME_GetVersion (-lsmime3) 466 # function: NSS_GetVersion (-lnss3) 467 # function: NSSUTIL_GetVersion (-lnssutil3) 468 libssl3 = [ dependency('libssl3') ] 469 libsmime3 = [ dependency('libsmime3') ] 470 libnss3 = [ dependency('libnss3') ] 471 libnssutil3 = [ dependency('libnssutil3') ] 472 conf_data.set('HAVE_NSS3_NSS_H', true) 473endif 474 475libpcre = [] 476if get_option('with_pcre') 477 # manual search: 478 # header: pcre.h 479 # function: pcre_exec (-lpcre) 480 libpcre = [ dependency('libpcre') ] 481 conf_data.set('HAVE_PCRE_H', true) 482 conf_data.set('HAVE_LIBPCRE', true) 483endif 484 485libpq = [] 486if get_option('with_pgsql') 487 # manual search: 488 # header: libpq-fe.h 489 # function: PQsetdbLogin (-lpq) 490 libpq = [ dependency('libpq') ] 491 conf_data.set('HAVE_PGSQL', true) 492endif 493 494if get_option('with_sasl') 495 libsasl = dependency('sasl2', required: false) 496 if libsasl.found() 497 libsasl = [ libsasl2 ] 498 else 499 libsasl = [ compiler.find_library('sasl2') ] 500 if not(compiler.has_function('sasl_server_init', args: defs, dependencies: libsasl, prefix: '#include <sasl/sasl.h>')) 501 error('Couldn\'t find sasl/sasl.h or sasl_server_init in libsasl2') 502 endif 503 endif 504 conf_data.set('HAVE_SASL', true) 505endif 506 507#if get_option('with_valgrind') 508#endif 509 510libuuid = [] 511if get_option('with_webdav_locks') 512 libuuid = dependency('uuid', required: false) 513 if libuuid.found() 514 libuuid = [ libuuid ] 515 elif compiler.has_function('uuid_generate', args: defs, prefix: '#include <uuid/uuid.h>') 516 # uuid_generate in libc, everything is fine, no lib needed 517 libuuid = [] 518 else 519 libuuid = compiler.find_library('uuid') 520 if not(compiler.has_function('uuid_generate', 521 args: defs, 522 dependencies: libuuid, 523 prefix: '#include <uuid/uuid.h>' 524 )) 525 error('Couldn\'t find uuid/uuid.h or uuid_generate in lib c and uuid') 526 endif 527 endif 528 conf_data.set('HAVE_LIBUUID', true) 529 conf_data.set('HAVE_UUID_UUID_H', true) 530endif 531 532libxml2 = [] 533libsqlite3 = [] 534if get_option('with_webdav_props') 535 libxml2 = dependency('libxml-2.0', required: false) 536 if libxml2.found() 537 libxml2 = [ libxml2 ] 538 else 539 libxml2_includes = [] 540 libxml2_includes_dep = [] 541 libxml2_found_header = compiler.has_header('libxml/tree.h') 542 foreach i: include_base_paths 543 if not(libxml2_found_header) 544 message('Searching in ' + join_paths(i, 'libxml2')) 545 i = include_directories(join_paths(i, 'libxml2')) 546 if compiler.has_header('libxml/tree.h', include_directories: i) 547 libxml2_found_header = true 548 libxml2_includes = [ i ] 549 libxml2_includes_dep = [ declare_dependency(include_directories: i) ] 550 endif 551 endif 552 endforeach 553 if not(libxml2_found_header) 554 error('Couldn\'t find libxml/tree.h') 555 endif 556 libxml2 = [ compiler.find_library('xml2') ] 557 if not(compiler.has_function('xmlParseChunk', 558 args: defs, 559 dependencies: libxml2, 560 include_directories: libxml2_includes, 561 prefix: ''' 562 #include <libxml/tree.h> 563 ''' 564 )) 565 error('Couldn\'t find xmlParseChunk in lib xml2') 566 endif 567 # has_function doesn't like "internal dependencies" 568 libxml2 += libxml2_includes_dep 569 endif 570 conf_data.set('HAVE_LIBXML_H', true) 571 572 libsqlite3 = dependency('sqlite31', required: false) 573 if libsqlite3.found() 574 libsqlite3 = [ libsqlite3 ] 575 else 576 libsqlite3 = [ compiler.find_library('sqlite3') ] 577 if not(compiler.has_function('sqlite3_reset', 578 args: defs, 579 dependencies: libsqlite3, 580 prefix: ''' 581 #include <sqlite3.h> 582 ''' 583 )) 584 error('Couldn\'t find sqlite3.h or sqlite3_reset in lib sqlite3') 585 endif 586 endif 587 conf_data.set('HAVE_SQLITE3_H', true) 588endif 589 590libattr = [] 591if get_option('with_xattr') 592 if compiler.has_function('getxattr', 593 args: defs, 594 prefix: ''' 595 #include <sys/types.h> 596 #include <sys/xattr.h> 597 ''' 598 ) 599 conf_data.set('HAVE_SYS_XATTR_H', true) 600 conf_data.set('HAVE_XATTR', true) 601 else 602 libattr = [ compiler.find_library('attr') ] 603 if not(compiler.has_function('attr_get', 604 args: defs, 605 dependencies: libattr, 606 prefix: ''' 607 #include <sys/types.h> 608 #include <attr/attributes.h> 609 ''' 610 )) 611 error('Couldn\'t find attr/attributes.h or attr_get in lib attr') 612 endif 613 conf_data.set('HAVE_ATTR_ATTRIBUTES_H', true) 614 conf_data.set('HAVE_XATTR', true) 615 endif 616endif 617 618libz = [] 619if get_option('with_zlib') 620 libz = dependency('zlib', required: false) 621 if libz.found() 622 libz = [ libz ] 623 else 624 # windows alternative names? 'zlib', 'zdll' 625 libz = [ compiler.find_library('z') ] 626 if not(compiler.has_function('deflate', args: defs, dependencies: libz, prefix: '#include <zlib.h>')) 627 error('Couldn\'t find z header / library') 628 endif 629 endif 630 conf_data.set('HAVE_ZLIB_H', true) 631 conf_data.set('HAVE_LIBZ', true) 632endif 633 634configure_file( 635 output : 'config.h', 636 configuration : conf_data, 637) 638 639common_src = [ 640 'algo_sha1.c', 641 'array.c', 642 'base64.c', 643 'buffer.c', 644 'burl.c', 645 'chunk.c', 646 'configfile-glue.c', 647 'connections-glue.c', 648 'crc32.c', 649 'data_array.c', 650 'data_integer.c', 651 'data_string.c', 652 'etag.c', 653 'fdevent_freebsd_kqueue.c', 654 'fdevent_libev.c', 655 'fdevent_linux_sysepoll.c', 656 'fdevent_poll.c', 657 'fdevent_select.c', 658 'fdevent_solaris_devpoll.c', 659 'fdevent_solaris_port.c', 660 'fdevent.c', 661 'gw_backend.c', 662 'http_auth.c', 663 'http_chunk.c', 664 'http_header.c', 665 'http_kv.c', 666 'http_vhostdb.c', 667 'http-header-glue.c', 668 'keyvalue.c', 669 'log.c', 670 'md5.c', 671 'plugin.c', 672 'rand.c', 673 'request.c', 674 'safe_memclear.c', 675 'sock_addr.c', 676 'splaytree.c', 677 'stat_cache.c', 678 'stream.c', 679 'vector.c', 680] 681if target_machine.system() == 'windows' 682 common_src += [ 'xgetopt.c' ] 683endif 684main_src = [ 685 'configfile.c', 686 'connections.c', 687 'data_config.c', 688 'h2.c', 689 'inet_ntop_cache.c', 690 'ls-hpack/lshpack.c', 691 'ls-hpack/deps/xxhash/xxhash.c', 692 'network_write.c', 693 'network.c', 694 'reqpool.c', 695 'response.c', 696 'server.c', 697] 698 699lemon = executable('lemon', 700 sources: 'lemon.c', 701 native: true, 702) 703# generator doesn't handle additional "input dependencies" like lempar.c 704# => use custom_target 705configparser = custom_target('configparser', 706 input: ['configparser.y', 'lempar.c'], 707 output: ['configparser.c', 'configparser.h'], 708 command: [lemon, '-q', 'o=@OUTDIR@', '@INPUT0@', '@INPUT1@'], 709) 710ssi_exprparser = custom_target('mod_ssi_exprparser', 711 input: ['mod_ssi_exprparser.y', 'lempar.c'], 712 output: ['mod_ssi_exprparser.c', 'mod_ssi_exprparser.h'], 713 command: [lemon, '-q', 'o=@OUTDIR@', '@INPUT0@', '@INPUT1@'], 714) 715 716common_cflags = defs + [ 717 '-DHAVE_CONFIG_H', 718] 719 720if compiler.get_id() == 'gcc' or compiler.get_id() == 'clang' 721 common_cflags += [ 722 '-Wall', 723 '-g', 724 '-Wshadow', 725 '-W', 726 '-pedantic', 727 ] 728 if get_option('build_extra_warnings') 729 common_cflags += get_option('warn_cflags').split() 730 endif 731endif 732 733common_flags = [ declare_dependency( 734 compile_args: common_cflags, 735 # tests also use common_flags, and need this 736 include_directories: include_directories('.'), 737) ] 738 739lighttpd_flags = [] 740lighttpd_angel_flags = [] 741if target_machine.system() == 'windows' 742 lighttpd_flags += [ declare_dependency( 743 compile_args: [ 744 '-DLI_DECLARE_EXPORTS', 745 ], 746 ) ] 747 if compiler.get_id() == 'gcc' 748 libmsvcr70 = [ compiler.find_library('msvcr70') ] 749 lighttpd_flags += libmsvcr70 + [ declare_dependency( 750 link_args: [ 751 '-Wl,-subsystem,console', 752 ], 753 ) ] 754 lighttpd_angel_flags += libmsvcr70 + [ declare_dependency( 755 link_args: [ 756 '-Wl,-subsystem,console', 757 ], 758 ) ] 759 endif 760endif 761 762if compiler.get_id() == 'gcc' or target_machine.system() != 'darwin' 763 lighttpd_flags += [ declare_dependency( 764 link_args: [ 765 '-Wl,-export-dynamic', 766 ], 767 ) ] 768endif 769 770executable('lighttpd-angel', 771 sources: 'lighttpd-angel.c', 772 dependencies: common_flags + lighttpd_angel_flags, 773 c_args: ['-DSBIN_DIR="' + sbinddir + '"'], 774 install: true, 775 install_dir: sbinddir, 776) 777 778executable('lighttpd', configparser, 779 sources: common_src + main_src, 780 # libssl needed? 781 dependencies: [ common_flags, lighttpd_flags 782 , libattr 783 , libcrypto 784 , libdl 785 , libev 786 , libfam 787 , libpcre 788 , libunwind 789 , libws2_32 790 ], 791 c_args: [ 792 '-DLS_HPACK_USE_LARGE_TABLES=0', 793 '-DXXH_HEADER_NAME="ls-hpack/deps/xxhash/xxhash.h"' 794 ], 795 install: true, 796 install_dir: sbinddir, 797) 798 799test('test_array', executable('test_array', 800 sources: ['t/test_array.c', 'array.c', 'data_array.c', 'data_integer.c', 'data_string.c', 'buffer.c'], 801 dependencies: common_flags + libunwind, 802 build_by_default: false, 803)) 804 805test('test_buffer', executable('test_buffer', 806 sources: ['t/test_buffer.c', 'buffer.c'], 807 dependencies: common_flags + libunwind, 808 build_by_default: false, 809)) 810 811test('test_burl', executable('test_burl', 812 sources: ['t/test_burl.c', 'burl.c', 'buffer.c', 'base64.c'], 813 dependencies: common_flags + libunwind, 814 build_by_default: false, 815)) 816 817test('test_base64', executable('test_base64', 818 sources: ['t/test_base64.c', 'buffer.c', 'base64.c'], 819 dependencies: common_flags + libunwind, 820 build_by_default: false, 821)) 822 823test('test_configfile', executable('test_configfile', 824 sources: [ 825 't/test_configfile.c', 826 'buffer.c', 827 'array.c', 828 'data_config.c', 829 'data_integer.c', 830 'data_string.c', 831 'http_header.c', 832 'http_kv.c', 833 'vector.c', 834 'log.c', 835 'sock_addr.c', 836 ], 837 dependencies: common_flags + libpcre + libunwind, 838 build_by_default: false, 839)) 840 841test('test_keyvalue', executable('test_keyvalue', 842 sources: [ 843 't/test_keyvalue.c', 844 'burl.c', 845 'buffer.c', 846 'base64.c', 847 'array.c', 848 'data_integer.c', 849 'data_string.c', 850 'log.c', 851 ], 852 dependencies: common_flags + libpcre + libunwind, 853 build_by_default: false, 854)) 855 856test('test_mod_access', executable('test_mod_access', 857 sources: [ 858 't/test_mod_access.c', 859 'buffer.c', 860 'array.c', 861 'data_integer.c', 862 'data_string.c', 863 'log.c', 864 ], 865 dependencies: common_flags + libunwind, 866 build_by_default: false, 867)) 868 869test('test_mod_evhost', executable('test_mod_evhost', 870 sources: [ 871 't/test_mod_evhost.c', 872 'buffer.c', 873 'array.c', 874 'data_integer.c', 875 'data_string.c', 876 'log.c', 877 ], 878 dependencies: common_flags + libunwind, 879 build_by_default: false, 880)) 881 882test('test_mod_simple_vhost', executable('test_mod_simple_vhost', 883 sources: [ 884 't/test_mod_simple_vhost.c', 885 'buffer.c', 886 'array.c', 887 'data_integer.c', 888 'data_string.c', 889 'log.c', 890 ], 891 dependencies: common_flags + libunwind, 892 build_by_default: false, 893)) 894 895test('test_mod_userdir', executable('test_mod_userdir', 896 sources: [ 897 't/test_mod_userdir.c', 898 'buffer.c', 899 'array.c', 900 'data_integer.c', 901 'data_string.c', 902 'log.c', 903 ], 904 dependencies: common_flags + libunwind, 905 build_by_default: false, 906)) 907 908test('test_request', executable('test_request', 909 sources: [ 910 't/test_request.c', 911 'base64.c', 912 'buffer.c', 913 'burl.c', 914 'array.c', 915 'data_integer.c', 916 'data_string.c', 917 'http_header.c', 918 'http_kv.c', 919 'log.c', 920 'sock_addr.c', 921 ], 922 dependencies: common_flags + libunwind, 923 build_by_default: false, 924)) 925 926modules = [ 927 [ 'mod_access', [ 'mod_access.c' ] ], 928 [ 'mod_accesslog', [ 'mod_accesslog.c' ] ], 929 [ 'mod_alias', [ 'mod_alias.c' ] ], 930 [ 'mod_auth', [ 'mod_auth.c' ], [ libcrypto ] ], 931 [ 'mod_authn_file', [ 'mod_authn_file.c' ], [ libcrypt, libcrypto ] ], 932 [ 'mod_deflate', [ 'mod_deflate.c' ], libbz2 + libz ], 933 [ 'mod_dirlisting', [ 'mod_dirlisting.c' ], libpcre ], 934 [ 'mod_evasive', [ 'mod_evasive.c' ] ], 935 [ 'mod_evhost', [ 'mod_evhost.c' ] ], 936 [ 'mod_expire', [ 'mod_expire.c' ] ], 937 [ 'mod_extforward', [ 'mod_extforward.c' ] ], 938 [ 'mod_fastcgi', [ 'mod_fastcgi.c' ], libws2_32 ], 939 [ 'mod_flv_streaming', [ 'mod_flv_streaming.c' ] ], 940 [ 'mod_indexfile', [ 'mod_indexfile.c' ] ], 941 [ 'mod_proxy', [ 'mod_proxy.c' ], libws2_32 ], 942 [ 'mod_redirect', [ 'mod_redirect.c' ], libpcre ], 943 [ 'mod_rewrite', [ 'mod_rewrite.c' ], libpcre ], 944 [ 'mod_rrdtool', [ 'mod_rrdtool.c' ] ], 945 [ 'mod_scgi', [ 'mod_scgi.c' ], libws2_32 ], 946 [ 'mod_secdownload', [ 'mod_secdownload.c' ], libcrypto ], 947 [ 'mod_setenv', [ 'mod_setenv.c' ] ], 948 [ 'mod_simple_vhost', [ 'mod_simple_vhost.c' ] ], 949 [ 'mod_sockproxy', [ 'mod_sockproxy.c' ] ], 950 [ 'mod_ssi', [ ssi_exprparser, 'mod_ssi_expr.c', 'mod_ssi.c' ], libws2_32 ], 951 [ 'mod_staticfile', [ 'mod_staticfile.c' ] ], 952 [ 'mod_status', [ 'mod_status.c' ] ], 953 [ 'mod_uploadprogress', [ 'mod_uploadprogress.c' ] ], 954 [ 'mod_userdir', [ 'mod_userdir.c' ] ], 955 [ 'mod_usertrack', [ 'mod_usertrack.c' ] ], 956 [ 'mod_vhostdb', [ 'mod_vhostdb.c' ] ], 957 [ 'mod_webdav', [ 'mod_webdav.c' ], libsqlite3 + libuuid + libxml2 + libelftc ], 958 [ 'mod_wstunnel', [ 'mod_wstunnel.c' ], libcrypto ], 959] 960 961if target_machine.system() != 'windows' 962 modules += [ 963 [ 'mod_cgi', [ 'mod_cgi.c' ] ], 964 ] 965endif 966 967if get_option('with_pcre') and (get_option('with_memcached') or get_option('with_gdbm')) 968 modules += [ 969 [ 'mod_trigger_b4_dl', [ 'mod_trigger_b4_dl.c' ], libpcre + libmemcached + libgdbm ], 970 ] 971endif 972 973if get_option('with_lua') 974 modules += [ 975 [ 'mod_cml', [ 'mod_cml.c', 'mod_cml_lua.c', 'mod_cml_funcs.c' ], liblua + libmemcached ], 976 [ 'mod_magnet', [ 'mod_magnet.c', 'mod_magnet_cache.c' ], liblua ], 977 ] 978endif 979 980if get_option('with_maxminddb') 981 modules += [ 982 [ 'mod_maxminddb', [ 'mod_maxminddb.c' ], libmaxminddb ], 983 ] 984endif 985 986if get_option('with_geoip') 987 modules += [ 988 [ 'mod_geoip', [ 'mod_geoip.c' ], libgeoip ], 989 ] 990endif 991 992if get_option('with_mysql') 993 modules += [ 994 [ 'mod_authn_mysql', [ 'mod_authn_mysql.c' ], libcrypt + libmysqlclient ], 995 [ 'mod_mysql_vhost', [ 'mod_mysql_vhost.c' ], libmysqlclient ], 996 [ 'mod_vhostdb_mysql', [ 'mod_vhostdb_mysql.c' ], libmysqlclient ], 997 ] 998endif 999 1000if get_option('with_pgsql') 1001 modules += [ 1002 [ 'mod_vhostdb_pgsql', [ 'mod_vhostdb_pgsql.c' ], libpq ], 1003 ] 1004endif 1005 1006if get_option('with_dbi') 1007 modules += [ 1008 [ 'mod_authn_dbi', [ 'mod_authn_dbi.c' ], libcrypt + libdbi ], 1009 [ 'mod_vhostdb_dbi', [ 'mod_vhostdb_dbi.c' ], libdbi ], 1010 ] 1011endif 1012 1013if get_option('with_krb5') 1014 modules += [ 1015 [ 'mod_authn_gssapi', [ 'mod_authn_gssapi.c' ], libkrb5 + libgssapi_krb5 ], 1016 ] 1017endif 1018 1019if get_option('with_ldap') 1020 modules += [ 1021 [ 'mod_authn_ldap', [ 'mod_authn_ldap.c' ], libldap + liblber ], 1022 [ 'mod_vhostdb_ldap', [ 'mod_vhostdb_ldap.c' ], libldap + liblber ], 1023 ] 1024endif 1025 1026if get_option('with_openssl') 1027 modules += [ 1028 [ 'mod_openssl', [ 'mod_openssl.c' ], libssl + libcrypto ], 1029 ] 1030endif 1031 1032if get_option('with_wolfssl') != 'false' 1033 modules += [ 1034 [ 'mod_openssl', [ 'mod_openssl.c' ], libcrypto ], 1035 ] 1036endif 1037 1038if get_option('with_mbedtls') != 'false' 1039 modules += [ 1040 [ 'mod_mbedtls', [ 'mod_mbedtls.c' ], libssl + libx509 + libcrypto ], 1041 ] 1042endif 1043 1044if get_option('with_nss') != 'false' 1045 modules += [ 1046 [ 'mod_nss', [ 'mod_nss.c' ], libssl3 + libsmime3 + libnss3 + libnssutil3 ], 1047 ] 1048endif 1049 1050if get_option('with_gnutls') != 'false' 1051 modules += [ 1052 [ 'mod_gnutls', [ 'mod_gnutls.c' ], libgnutls ], 1053 ] 1054endif 1055 1056if get_option('with_pam') 1057 modules += [ 1058 [ 'mod_authn_pam', [ 'mod_authn_pam.c' ], libpam ], 1059 ] 1060endif 1061 1062if get_option('with_sasl') 1063 modules += [ 1064 [ 'mod_authn_sasl', [ 'mod_authn_sasl.c' ], libsasl ], 1065 ] 1066endif 1067 1068foreach mod: modules 1069 mod_name = mod.get(0) 1070 mod_sources = mod.get(1) 1071 mod_deps = mod.length() > 2 ? mod.get(2) : [] 1072 shared_module(mod_name, 1073 sources: mod_sources, 1074 dependencies: [ common_flags, mod_deps ], 1075 name_prefix: '', 1076 install: true, 1077 install_dir: moduledir, 1078 ) 1079endforeach 1080