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