lighttpd 1.4.x https://www.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

991 lines
28 KiB

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