[mod_auth] require digest uri= match original URI
[lighttpd.git] / src / meson.build
blob4bc92ad5b62e302e624bb79c63eca4429ea02a53
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))
154 conf_data.set('HAVE_EXPLICIT_MEMSET', compiler.has_function('explicit_memset', args: defs))
156 conf_data.set('HAVE_CLOCK_GETTIME', compiler.has_header_symbol('time.h', 'clock_gettime'))
157 clock_lib = []
158 if not(conf_data.get('HAVE_CLOCK_GETTIME'))
159         if compiler.has_function('clock_gettime', args: defs + ['-lrt'], prefix: '#include <time.h>')
160                 conf_data.set('HAVE_CLOCK_GETTIME', true)
161                 clock_lib = [ compiler.find_library('rt') ]
162         endif
163 endif
165 libelftc = []
166 if compiler.has_function('elftc_copyfile', args: defs + ['-lelftc'], prefix: '#include <libelftc.h>')
167         conf_data.set('HAVE_ELFTC_COPYFILE', true)
168         libelftc = [ compiler.find_library('elftc') ]
169 endif
171 conf_data.set('HAVE_IPV6', compiler.compiles('''
172         #include <sys/types.h>
173         #include <sys/socket.h>
174         #include <netinet/in.h>
176         int main() {
177                 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
178                 return 0;
179         }
180 ''',
181         name: 'IPv6 support',
182         args: defs
185 conf_data.set('HAVE_WEAK_SYMBOLS', compiler.compiles('''
186         __attribute__((weak)) void __dummy(void *x) { }
187         int main() {
188                 void *x;
189                 __dummy(x);
190         }
191 ''',
192         name: 'weak symbols',
193         args: defs
196 conf_data.set('HAVE_STRUCT_TM_GMTOFF', compiler.compiles('''
197         #include <time.h>
198         int main(void) {
199                 struct tm t;
200                 t.tm_gmtoff = 0;
201                 return 0;
202         }
203 ''',
204         name: 'struct tm gmt offset',
205         args: defs
208 conf_data.set('LIGHTTPD_VERSION_ID', 10400)
209 conf_data.set_quoted('PACKAGE_NAME', meson.project_name())
210 conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
211 conf_data.set_quoted('LIBRARY_DIR', moduledir)
213 conf_data.set('LIGHTTPD_STATIC', get_option('build_static'))
214 libdl = []
215 if not(get_option('build_static'))
216         if target_machine.system() != 'windows'
217                 libdl = [ compiler.find_library('dl') ]
218                 if not(compiler.has_function('dlopen', args: defs, dependencies: libdl, prefix: '#include <dlfcn.h>'))
219                         error('Couldn\'t find dlfcn.h or dlopen in lib dl')
220                 endif
221         endif
222 endif
224 libbz2 = []
225 if get_option('with_bzip')
226         libbz2 = [ compiler.find_library('bz2') ]
227         if compiler.has_function('BZ2_bzCompress', args: defs, dependencies: libbz2, prefix: '#include <bzlib.h>')
228                 conf_data.set('HAVE_BZLIB_H', true)
229                 conf_data.set('HAVE_LIBBZ2', true)
230         else
231                 error('Couldn\'t find bz2 header / library')
232         endif
233 endif
235 if get_option('with_dbi')
236         libdbi = dependency('dbi', required: false)
237         if libdbi.found()
238                 libdbi = [ libdbi ]
239         else
240                 libdbi = [ compiler.find_library('dbi') ]
241                 if not(compiler.has_function('dbi_conn_connect', args: defs, dependencies: libdbi, prefix: '#include <dbi/dbi.h>'))
242                         error('Couldn\'t find dbi/dbi.h or dbi_conn_connect in lib dbi')
243                 endif
244         endif
245         conf_data.set('HAVE_DBI', true)
246 endif
248 libfam = []
249 if get_option('with_fam')
250         libfam = [ compiler.find_library('fam') ]
251         if not(compiler.has_function('FAMOpen2', args: defs, dependencies: libfam, prefix: '#include <fam.h>'))
252                 error('Couldn\'t find fam.h or FAMOpen2 in lib fam')
253         endif
254         conf_data.set('HAVE_FAM_H', true)
255 endif
257 libgeoip = []
258 if get_option('with_geoip')
259         libgeoip = dependency('geoip', required: false)
260         if libgeoip.found()
261                 libgeoip = [ libgeoip ]
262         else
263                 libgeoip = [ compiler.find_library('GeoIP') ]
264                 if not(compiler.has_function('GeoIP_country_name_by_addr', args: defs, dependencies: libgeoip))
265                         error('Couldn\'t find GeoIP_country_name_by_addr in lib GeoIP')
266                 endif
267         endif
268 endif
270 libgdbm = []
271 if get_option('with_gdbm')
272         libgdbm = [ compiler.find_library('gdbm') ]
273         if not(compiler.has_function('gdbm_open', args: defs, dependencies: libgdbm, prefix: '#include <gdbm.h>'))
274                 error('Couldn\'t find gdbm.h or gdbm_open in lib gdbm')
275         endif
276         conf_data.set('HAVE_GDBM_H', true)
277         conf_data.set('HAVE_GDBM', true)
278 endif
280 libkrb5 = []
281 libgssapi_krb5 = []
282 if get_option('with_krb5')
283         libkrb5 = dependency('krb5', required: false)
284         if libkrb5.found()
285                 libkrb5 = [ libkrb5 ]
286         else
287                 libkrb5 = [ compiler.find_library('krb5') ]
288                 if not(compiler.has_function('krb5_init_context', args: defs, dependencies: libkrb5))
289                         error('Couldn\'t find krb5_init_context in lib krb5')
290                 endif
291         endif
293         libgssapi_krb5 = dependency('krb5-gssapi', required: false)
294         if libgssapi_krb5.found()
295                 libgssapi_krb5 = [ libgssapi_krb5 ]
296         else
297                 libgssapi_krb5 = [ compiler.find_library('gssapi_krb5') ]
298         endif
300         conf_data.set('HAVE_KRB5', true)
301 endif
303 libldap = []
304 liblber = []
305 if get_option('with_ldap')
306         libldap = [ compiler.find_library('ldap') ]
307         if not(compiler.has_function('ldap_sasl_bind_s',
308                 args: defs,
309                 dependencies: libldap,
310                 prefix: '''
311                         #include <ldap.h>
312                 '''
313         ))
314                 error('Couldn\'t find ldap.h or ldap_bind in lib libldap')
315         endif
316         conf_data.set('HAVE_LDAP_H', true)
317         conf_data.set('HAVE_LIBLDAP', true)
318         liblber = [ compiler.find_library('lber') ]
319         if not(compiler.has_function('ber_printf', args: defs, dependencies: liblber, prefix: '#include <lber.h>'))
320                 error('Couldn\'t find lber.h or ber_printf in lib liblber')
321         endif
322         conf_data.set('HAVE_LBER_H', true)
323         conf_data.set('HAVE_LIBLBER', true)
324 endif
326 libpam = []
327 if get_option('with_pam')
328         libpam = [ compiler.find_library('pam') ]
329         if not(compiler.has_function('pam_start',
330                 args: defs,
331                 dependencies: libpam,
332                 prefix: '''
333                         #include <security/pam_appl.h>
334                 '''
335         ))
336                 error('Couldn\'t find security/pam_appl.h or pam_start in lib libpam')
337         endif
338         conf_data.set('HAVE_PAM', true)
339 endif
341 libev = []
342 if get_option('with_libev')
343         libev = dependency('ev', required: false)
344         if libev.found()
345                 libev = [ libev ]
346         elif compiler.has_header('ev.h') and compiler.has_function('ev_time', args: defs + ['-lev'])
347                 libev = [ compiler.find_library('ev') ]
348         else
349                 error('Couldn\'t find libev header / library')
350         endif
351         conf_data.set('HAVE_LIBEV', true)
352 endif
354 libunwind = []
355 if get_option('with_libunwind')
356         libunwind = [ dependency('libunwind') ]
357 endif
359 liblua = []
360 if get_option('with_lua')
361         found_lua = false
362         foreach l: ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']
363                 if not(found_lua)
364                         liblua = dependency(l, required: false)
365                         found_lua = liblua.found()
366                 endif
367         endforeach
368         if not(found_lua)
369                 error('Couldn\'t find any lua library')
370         endif
371         liblua = [ liblua ]
372         conf_data.set('HAVE_LUA_H', true)
373 endif
375 libmemcached = []
376 if get_option('with_memcached')
377         # manual search:
378         # header: libmemcached/memcached.h
379         # function: memcached (-lmemcached)
380         libmemcached = [ dependency('libmemcached') ]
381         conf_data.set('USE_MEMCACHED', true)
382 endif
384 libmysqlclient = []
385 if get_option('with_mysql')
386         # manual search: extend include path with 'mysql/'
387         # header: mysql.h
388         # function: mysql_real_connect (-lmariadb)
389         libmysqlclient = [ dependency('mariadb') ]
390         #-# function: mysql_real_connect (-lmysqlclient)
391         #-libmysqlclient = [ dependency('mysqlclient') ]
392         conf_data.set('HAVE_MYSQL', true)
393 endif
395 libssl = []
396 libcrypto = []
397 if get_option('with_openssl')
398         # manual search:
399         # header: openssl/ssl.h
400         # function: SSL_new (-lssl)
401         # function: BIO_f_base64 (-lcrypto)
402         libssl = [ dependency('libssl') ]
403         libcrypto = [ dependency('libcrypto') ]
404         conf_data.set('HAVE_OPENSSL_SSL_H', true)
405         conf_data.set('HAVE_LIBSSL', true)
406 endif
407 if get_option('with_wolfssl') != 'false'
408         # manual search:
409         # header: wolfssl/ssl.h
410         # function: wolfSSL_Init (-lwolfssl)
411         p = get_option('with_wolfssl')
412         if p == 'true'
413                 p = '/usr/local'
414         endif
415         i = include_directories(p+'/include', p+'/include/wolfssl')
416         libwolfssl_includes_dep = [ declare_dependency(include_directories: i) ]
417         libcrypto = [ compiler.find_library('libwolfssl', dirs: [ p+'/lib', p+'/lib64' ]) ]
418         libcrypto += libwolfssl_includes_dep
419         conf_data.set('HAVE_WOLFSSL_SSL_H', true)
420 endif
422 libpcre = []
423 if get_option('with_pcre')
424         # manual search:
425         # header: pcre.h
426         # function: pcre_exec (-lpcre)
427         libpcre = [ dependency('libpcre') ]
428         conf_data.set('HAVE_PCRE_H', true)
429         conf_data.set('HAVE_LIBPCRE', true)
430 endif
432 libpq = []
433 if get_option('with_pgsql')
434         # manual search:
435         # header: libpq-fe.h
436         # function: PQsetdbLogin (-lpq)
437         libpq = [ dependency('libpq') ]
438         conf_data.set('HAVE_PGSQL', true)
439 endif
441 if get_option('with_sasl')
442         libsasl = dependency('sasl2', required: false)
443         if libsasl.found()
444                 libsasl = [ libsasl2 ]
445         else
446                 libsasl = [ compiler.find_library('sasl2') ]
447                 if not(compiler.has_function('sasl_server_init', args: defs, dependencies: libsasl, prefix: '#include <sasl/sasl.h>'))
448                         error('Couldn\'t find sasl/sasl.h or sasl_server_init in libsasl2')
449                 endif
450         endif
451         conf_data.set('HAVE_SASL', true)
452 endif
454 #if get_option('with_valgrind')
455 #endif
457 libuuid = []
458 if get_option('with_webdav_locks')
459         libuuid = dependency('uuid', required: false)
460         if libuuid.found()
461                 libuuid = [ libuuid ]
462         elif compiler.has_function('uuid_generate', args: defs, prefix: '#include <uuid/uuid.h>')
463                 # uuid_generate in libc, everything is fine, no lib needed
464                 libuuid = []
465         else
466                 libuuid = compiler.find_library('uuid')
467                 if not(compiler.has_function('uuid_generate',
468                         args: defs,
469                         dependencies: libuuid,
470                         prefix: '#include <uuid/uuid.h>'
471                 ))
472                         error('Couldn\'t find uuid/uuid.h or uuid_generate in lib c and uuid')
473                 endif
474         endif
475         conf_data.set('HAVE_LIBUUID', true)
476         conf_data.set('HAVE_UUID_UUID_H', true)
477 endif
479 libxml2 = []
480 libsqlite3 = []
481 if get_option('with_webdav_props')
482         libxml2 = dependency('libxml-2.0', required: false)
483         if libxml2.found()
484                 libxml2 = [ libxml2 ]
485         else
486                 libxml2_includes = []
487                 libxml2_includes_dep = []
488                 libxml2_found_header = compiler.has_header('libxml/tree.h')
489                 foreach i: include_base_paths
490                         if not(libxml2_found_header)
491                                 message('Searching in ' + join_paths(i, 'libxml2'))
492                                 i = include_directories(join_paths(i, 'libxml2'))
493                                 if compiler.has_header('libxml/tree.h', include_directories: i)
494                                         libxml2_found_header = true
495                                         libxml2_includes = [ i ]
496                                         libxml2_includes_dep = [ declare_dependency(include_directories: i) ]
497                                 endif
498                         endif
499                 endforeach
500                 if not(libxml2_found_header)
501                         error('Couldn\'t find libxml/tree.h')
502                 endif
503                 libxml2 = [ compiler.find_library('xml2') ]
504                 if not(compiler.has_function('xmlParseChunk',
505                         args: defs,
506                         dependencies: libxml2,
507                         include_directories: libxml2_includes,
508                         prefix: '''
509                                 #include <libxml/tree.h>
510                         '''
511                 ))
512                         error('Couldn\'t find xmlParseChunk in lib xml2')
513                 endif
514                 # has_function doesn't like "internal dependencies"
515                 libxml2 += libxml2_includes_dep
516         endif
517         conf_data.set('HAVE_LIBXML_H', true)
519         libsqlite3 = dependency('sqlite31', required: false)
520         if libsqlite3.found()
521                 libsqlite3 = [ libsqlite3 ]
522         else
523                 libsqlite3 = [ compiler.find_library('sqlite3') ]
524                 if not(compiler.has_function('sqlite3_reset',
525                         args: defs,
526                         dependencies: libsqlite3,
527                         prefix: '''
528                                 #include <sqlite3.h>
529                         '''
530                 ))
531                         error('Couldn\'t find sqlite3.h or sqlite3_reset in lib sqlite3')
532                 endif
533         endif
534         conf_data.set('HAVE_SQLITE3_H', true)
535 endif
537 libattr = []
538 if get_option('with_xattr')
539         libattr = [ compiler.find_library('attr') ]
540         if not(compiler.has_function('attr_get',
541                 args: defs,
542                 dependencies: libattr,
543                 prefix: '''
544                         #include <sys/types.h>
545                         #include <attr/attributes.h>
546                 '''
547         ))
548                 error('Couldn\'t find attr/attributes.h or attr_get in lib attr')
549         endif
550         conf_data.set('HAVE_ATTR_ATTRIBUTES_H', true)
551         conf_data.set('HAVE_XATTR', true)
552 endif
554 libz = []
555 if get_option('with_zlib')
556         libz = dependency('zlib', required: false)
557         if libz.found()
558                 libz = [ libz ]
559         else
560                 # windows alternative names? 'zlib', 'zdll'
561                 libz = [ compiler.find_library('z') ]
562                 if not(compiler.has_function('deflate', args: defs, dependencies: libz, prefix: '#include <zlib.h>'))
563                         error('Couldn\'t find z header / library')
564                 endif
565         endif
566         conf_data.set('HAVE_ZLIB_H', true)
567         conf_data.set('HAVE_LIBZ', true)
568 endif
570 configure_file(
571         output : 'config.h',
572         configuration : conf_data,
575 common_src = [
576         'algo_sha1.c',
577         'array.c',
578         'base64.c',
579         'buffer.c',
580         'burl.c',
581         'chunk.c',
582         'configfile-glue.c',
583         'connections-glue.c',
584         'crc32.c',
585         'data_array.c',
586         'data_config.c',
587         'data_integer.c',
588         'data_string.c',
589         'etag.c',
590         'fdevent_freebsd_kqueue.c',
591         'fdevent_libev.c',
592         'fdevent_linux_sysepoll.c',
593         'fdevent_poll.c',
594         'fdevent_select.c',
595         'fdevent_solaris_devpoll.c',
596         'fdevent_solaris_port.c',
597         'fdevent.c',
598         'gw_backend.c',
599         'http_auth.c',
600         'http_chunk.c',
601         'http_header.c',
602         'http_kv.c',
603         'http_vhostdb.c',
604         'http-header-glue.c',
605         'joblist.c',
606         'keyvalue.c',
607         'log.c',
608         'md5.c',
609         'plugin.c',
610         'rand.c',
611         'request.c',
612         'safe_memclear.c',
613         'sock_addr.c',
614         'splaytree.c',
615         'stat_cache.c',
616         'stream.c',
617         'vector.c',
619 if target_machine.system() == 'windows'
620         common_src += [ 'xgetopt.c' ]
621 endif
622 main_src = [
623         'configfile.c',
624         'connections.c',
625         'inet_ntop_cache.c',
626         'network_write.c',
627         'network.c',
628         'response.c',
629         'server.c',
632 lemon = executable('lemon',
633         sources: 'lemon.c',
634         native: true,
636 # generator doesn't handle additional "input dependencies" like lempar.c
637 # => use custom_target
638 configparser = custom_target('configparser',
639         input:  ['configparser.y', 'lempar.c'],
640         output: ['configparser.c', 'configparser.h'],
641         command: [lemon, '-q', 'o=@OUTDIR@', '@INPUT0@', '@INPUT1@'],
643 ssi_exprparser = custom_target('mod_ssi_exprparser',
644         input:  ['mod_ssi_exprparser.y', 'lempar.c'],
645         output: ['mod_ssi_exprparser.c', 'mod_ssi_exprparser.h'],
646         command: [lemon, '-q', 'o=@OUTDIR@', '@INPUT0@', '@INPUT1@'],
649 common_cflags = defs + [
650         '-DHAVE_CONFIG_H',
653 if compiler.get_id() == 'gcc' or compiler.get_id() == 'clang'
654         common_cflags += [
655                 '-Wall',
656                 '-g',
657                 '-Wshadow',
658                 '-W',
659                 '-pedantic',
660         ]
661         if get_option('build_extra_warnings')
662                 common_cflags += get_option('warn_cflags').split()
663         endif
664 endif
666 common_flags = [ declare_dependency(
667         compile_args: common_cflags,
668         # tests also use common_flags, and need this
669         include_directories: include_directories('.'),
670 ) ]
672 lighttpd_flags = []
673 lighttpd_angel_flags = []
674 if target_machine.system() == 'windows'
675         lighttpd_flags += [ declare_dependency(
676                 compile_args: [
677                         '-DLI_DECLARE_EXPORTS',
678                 ],
679         ) ]
680         if compiler.get_id() == 'gcc'
681                 libmsvcr70 = [ compiler.find_library('msvcr70') ]
682                 lighttpd_flags += libmsvcr70 + [ declare_dependency(
683                         link_args: [
684                                 '-Wl,-subsystem,console',
685                         ],
686                 ) ]
687                 lighttpd_angel_flags += libmsvcr70 + [ declare_dependency(
688                         link_args: [
689                                 '-Wl,-subsystem,console',
690                         ],
691                 ) ]
692         endif
693 endif
695 if compiler.get_id() == 'gcc' or target_machine.system() != 'darwin'
696         lighttpd_flags += [ declare_dependency(
697                 link_args: [
698                         '-Wl,-export-dynamic',
699                 ],
700         ) ]
701 endif
703 executable('lighttpd-angel',
704         sources: 'lighttpd-angel.c',
705         dependencies: common_flags + lighttpd_angel_flags,
706         c_args: ['-DSBIN_DIR="' + sbinddir + '"'],
707         install: true,
708         install_dir: sbinddir,
711 executable('lighttpd', configparser,
712         sources: common_src + main_src,
713         # libssl needed?
714         dependencies: [ common_flags, lighttpd_flags
715                 , libattr
716                 , libcrypto
717                 , libdl
718                 , libev
719                 , libfam
720                 , libpcre
721                 , libunwind
722                 , libws2_32
723         ],
724         install: true,
725         install_dir: sbinddir,
728 test('test_array', executable('test_array',
729         sources: ['t/test_array.c', 'array.c', 'data_array.c', 'data_integer.c', 'data_string.c', 'buffer.c'],
730         dependencies: common_flags + libunwind,
731         build_by_default: false,
734 test('test_buffer', executable('test_buffer',
735         sources: ['t/test_buffer.c', 'buffer.c'],
736         dependencies: common_flags + libunwind,
737         build_by_default: false,
740 test('test_burl', executable('test_burl',
741         sources: ['t/test_burl.c', 'burl.c', 'buffer.c', 'base64.c'],
742         dependencies: common_flags + libunwind,
743         build_by_default: false,
746 test('test_base64', executable('test_base64',
747         sources: ['t/test_base64.c', 'buffer.c', 'base64.c'],
748         dependencies: common_flags + libunwind,
749         build_by_default: false,
752 test('test_configfile', executable('test_configfile',
753         sources: [
754                 't/test_configfile.c',
755                 'buffer.c',
756                 'array.c',
757                 'data_config.c',
758                 'data_integer.c',
759                 'data_string.c',
760                 'http_header.c',
761                 'http_kv.c',
762                 'vector.c',
763                 'log.c',
764                 'sock_addr.c',
765         ],
766         dependencies: common_flags + libpcre + libunwind,
767         build_by_default: false,
770 test('test_keyvalue', executable('test_keyvalue',
771         sources: [
772                 't/test_keyvalue.c',
773                 'burl.c',
774                 'buffer.c',
775                 'base64.c',
776                 'array.c',
777                 'data_integer.c',
778                 'data_string.c',
779                 'log.c',
780         ],
781         dependencies: common_flags + libpcre + libunwind,
782         build_by_default: false,
785 test('test_mod_access', executable('test_mod_access',
786         sources: [
787                 't/test_mod_access.c',
788                 'configfile-glue.c',
789                 'buffer.c',
790                 'array.c',
791                 'data_config.c',
792                 'data_integer.c',
793                 'data_string.c',
794                 'http_header.c',
795                 'http_kv.c',
796                 'vector.c',
797                 'log.c',
798                 'sock_addr.c',
799         ],
800         dependencies: common_flags + libpcre + libunwind,
801         build_by_default: false,
804 test('test_mod_evhost', executable('test_mod_evhost',
805         sources: [
806                 't/test_mod_evhost.c',
807                 'configfile-glue.c',
808                 'buffer.c',
809                 'array.c',
810                 'data_config.c',
811                 'data_integer.c',
812                 'data_string.c',
813                 'http_header.c',
814                 'http_kv.c',
815                 'vector.c',
816                 'log.c',
817                 'sock_addr.c',
818         ],
819         dependencies: common_flags + libpcre + libunwind,
820         build_by_default: false,
823 test('test_mod_simple_vhost', executable('test_mod_simple_vhost',
824         sources: [
825                 't/test_mod_simple_vhost.c',
826                 'configfile-glue.c',
827                 'buffer.c',
828                 'array.c',
829                 'data_config.c',
830                 'data_integer.c',
831                 'data_string.c',
832                 'http_header.c',
833                 'http_kv.c',
834                 'vector.c',
835                 'log.c',
836                 'sock_addr.c',
837         ],
838         dependencies: common_flags + libpcre + libunwind,
839         build_by_default: false,
842 test('test_request', executable('test_request',
843         sources: [
844                 't/test_request.c',
845                 'request.c',
846                 'buffer.c',
847                 'array.c',
848                 'data_integer.c',
849                 'data_string.c',
850                 'http_header.c',
851                 'http_kv.c',
852                 'log.c',
853                 'sock_addr.c',
854         ],
855         dependencies: common_flags + libunwind,
856         build_by_default: false,
859 modules = [
860         [ 'mod_access', [ 'mod_access.c' ] ],
861         [ 'mod_accesslog', [ 'mod_accesslog.c' ] ],
862         [ 'mod_alias', [ 'mod_alias.c' ] ],
863         [ 'mod_auth', [ 'mod_auth.c' ], [ libcrypto ] ],
864         [ 'mod_authn_file', [ 'mod_authn_file.c' ], [ libcrypt, libcrypto ] ],
865         [ 'mod_compress', [ 'mod_compress.c' ], libbz2 + libz ],
866         [ 'mod_deflate', [ 'mod_deflate.c' ], libbz2 + libz ],
867         [ 'mod_dirlisting', [ 'mod_dirlisting.c' ], libpcre ],
868         [ 'mod_evasive', [ 'mod_evasive.c' ] ],
869         [ 'mod_evhost', [ 'mod_evhost.c' ] ],
870         [ 'mod_expire', [ 'mod_expire.c' ] ],
871         [ 'mod_extforward', [ 'mod_extforward.c' ] ],
872         [ 'mod_fastcgi', [ 'mod_fastcgi.c' ], libws2_32 ],
873         [ 'mod_flv_streaming', [ 'mod_flv_streaming.c' ] ],
874         [ 'mod_indexfile', [ 'mod_indexfile.c' ] ],
875         [ 'mod_proxy', [ 'mod_proxy.c' ], libws2_32 ],
876         [ 'mod_redirect', [ 'mod_redirect.c' ], libpcre ],
877         [ 'mod_rewrite', [ 'mod_rewrite.c' ], libpcre ],
878         [ 'mod_rrdtool', [ 'mod_rrdtool.c' ] ],
879         [ 'mod_scgi', [ 'mod_scgi.c' ], libws2_32 ],
880         [ 'mod_secdownload', [ 'mod_secdownload.c' ], libcrypto ],
881         [ 'mod_setenv', [ 'mod_setenv.c' ] ],
882         [ 'mod_simple_vhost', [ 'mod_simple_vhost.c' ] ],
883         [ 'mod_sockproxy', [ 'mod_sockproxy.c' ] ],
884         [ 'mod_ssi', [ ssi_exprparser, 'mod_ssi_expr.c', 'mod_ssi.c' ], libws2_32 ],
885         [ 'mod_staticfile', [ 'mod_staticfile.c' ] ],
886         [ 'mod_status', [ 'mod_status.c' ] ],
887         [ 'mod_uploadprogress', [ 'mod_uploadprogress.c' ] ],
888         [ 'mod_userdir', [ 'mod_userdir.c' ] ],
889         [ 'mod_usertrack', [ 'mod_usertrack.c' ] ],
890         [ 'mod_vhostdb', [ 'mod_vhostdb.c' ] ],
891         [ 'mod_webdav', [ 'mod_webdav.c' ], libsqlite3 + libuuid + libxml2 + libelftc ],
892         [ 'mod_wstunnel', [ 'mod_wstunnel.c' ], libcrypto ],
895 if target_machine.system() != 'windows'
896         modules += [
897                 [ 'mod_cgi', [ 'mod_cgi.c' ] ],
898         ]
899 endif
901 if get_option('with_pcre') and (get_option('with_memcached') or get_option('with_gdbm'))
902         modules += [
903                 [ 'mod_trigger_b4_dl', [ 'mod_trigger_b4_dl.c' ], libpcre + libmemcached + libgdbm ],
904         ]
905 endif
907 if get_option('with_lua')
908         modules += [
909                 [ 'mod_cml', [ 'mod_cml.c', 'mod_cml_lua.c', 'mod_cml_funcs.c' ], liblua + libmemcached ],
910                 [ 'mod_magnet', [ 'mod_magnet.c', 'mod_magnet_cache.c' ], liblua ],
911         ]
912 endif
914 if get_option('with_maxminddb')
915         modules += [
916                 [ 'mod_maxminddb', [ 'mod_maxminddb.c' ], libmaxminddb ],
917         ]
918 endif
920 if get_option('with_geoip')
921         modules += [
922                 [ 'mod_geoip', [ 'mod_geoip.c' ], libgeoip ],
923         ]
924 endif
926 if get_option('with_mysql')
927         modules += [
928                 [ 'mod_authn_mysql', [ 'mod_authn_mysql.c' ], libcrypt + libmysqlclient ],
929                 [ 'mod_mysql_vhost', [ 'mod_mysql_vhost.c' ], libmysqlclient ],
930                 [ 'mod_vhostdb_mysql', [ 'mod_vhostdb_mysql.c' ], libmysqlclient ],
931         ]
932 endif
934 if get_option('with_pgsql')
935         modules += [
936                 [ 'mod_vhostdb_pgsql', [ 'mod_vhostdb_pgsql.c' ], libpq ],
937         ]
938 endif
940 if get_option('with_dbi')
941         modules += [
942                 [ 'mod_vhostdb_dbi', [ 'mod_vhostdb_dbi.c' ], libdbi ],
943         ]
944 endif
946 if get_option('with_krb5')
947         modules += [
948                 [ 'mod_authn_gssapi', [ 'mod_authn_gssapi.c' ], libkrb5 + libgssapi_krb5 ],
949         ]
950 endif
952 if get_option('with_ldap')
953         modules += [
954                 [ 'mod_authn_ldap', [ 'mod_authn_ldap.c' ], libldap + liblber ],
955                 [ 'mod_vhostdb_ldap', [ 'mod_vhostdb_ldap.c' ], libldap + liblber ],
956         ]
957 endif
959 if get_option('with_openssl')
960         modules += [
961                 [ 'mod_openssl', [ 'mod_openssl.c' ], libssl + libcrypto ],
962         ]
963 endif
965 if get_option('with_wolfssl') != 'false'
966         modules += [
967                 [ 'mod_openssl', [ 'mod_openssl.c' ], libcrypto ],
968         ]
969 endif
971 if get_option('with_pam')
972         modules += [
973                 [ 'mod_authn_pam', [ 'mod_authn_pam.c' ], libpam ],
974         ]
975 endif
977 if get_option('with_sasl')
978         modules += [
979                 [ 'mod_authn_sasl', [ 'mod_authn_sasl.c' ], libsasl ],
980         ]
981 endif
983 foreach mod: modules
984         mod_name = mod.get(0)
985         mod_sources = mod.get(1)
986         mod_deps = mod.length() > 2 ? mod.get(2) : []
987         shared_module(mod_name,
988                 sources: mod_sources,
989                 dependencies: [ common_flags, mod_deps ],
990                 name_prefix: '',
991                 install: true,
992                 install_dir: moduledir,
993         )
994 endforeach