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.
 
 
 
 
 
 

740 lines
20 KiB

  1. from __future__ import print_function
  2. import os
  3. import re
  4. import string
  5. import sys
  6. from copy import copy
  7. from stat import *
  8. try:
  9. string_types = basestring
  10. except NameError:
  11. string_types = str
  12. package = 'lighttpd'
  13. version = '1.4.56'
  14. underscorify_reg = re.compile('[^A-Z0-9]')
  15. def underscorify(id):
  16. return underscorify_reg.sub('_', id.upper())
  17. def fail(*args, **kwargs):
  18. print(*args, file=sys.stderr, **kwargs)
  19. sys.exit(-1)
  20. class Autoconf:
  21. class RestoreEnvLibs:
  22. def __init__(self, env):
  23. self.env = env
  24. self.active = False
  25. def __enter__(self):
  26. if self.active:
  27. raise Exception('entered twice')
  28. self.active = True
  29. if 'LIBS' in self.env:
  30. #print("Backup LIBS: " + repr(self.env['LIBS']))
  31. self.empty = False
  32. self.backup_libs = copy(self.env['LIBS'])
  33. else:
  34. #print("No LIBS to backup")
  35. self.empty = True
  36. def __exit__(self, type, value, traceback):
  37. if not self.active:
  38. raise Exception('exited twice')
  39. self.active = False
  40. if self.empty:
  41. if 'LIBS' in self.env:
  42. del self.env['LIBS']
  43. else:
  44. #print("Restoring LIBS, now: " + repr(self.env['LIBS']))
  45. self.env['LIBS'] = self.backup_libs
  46. #print("Restoring LIBS, to: " + repr(self.env['LIBS']))
  47. def __init__(self, env):
  48. self.conf = Configure(env, custom_tests = {
  49. 'CheckGmtOffInStructTm': Autoconf.__checkGmtOffInStructTm,
  50. 'CheckIPv6': Autoconf.__checkIPv6,
  51. 'CheckWeakSymbols': Autoconf.__checkWeakSymbols,
  52. })
  53. def append(self, *args, **kw):
  54. return self.conf.env.Append(*args, **kw)
  55. def Finish(self):
  56. return self.conf.Finish()
  57. @property
  58. def env(self):
  59. return self.conf.env
  60. def restoreEnvLibs(self):
  61. return Autoconf.RestoreEnvLibs(self.conf.env)
  62. def CheckType(self, *args, **kw):
  63. return self.conf.CheckType(*args, **kw)
  64. def CheckLib(self, *args, **kw):
  65. return self.conf.CheckLib(*args, autoadd = 0, **kw)
  66. def CheckLibWithHeader(self, *args, **kw):
  67. return self.conf.CheckLibWithHeader(*args, autoadd = 0, **kw)
  68. def CheckGmtOffInStructTm(self):
  69. return self.conf.CheckGmtOffInStructTm()
  70. def CheckIPv6(self):
  71. return self.conf.CheckIPv6()
  72. def CheckWeakSymbols(self):
  73. return self.conf.CheckWeakSymbols()
  74. def CheckCHeader(self, hdr):
  75. return self.conf.CheckCHeader(hdr)
  76. def haveCHeader(self, hdr):
  77. if self.CheckCHeader(hdr):
  78. # if we have a list of headers define HAVE_ only for last one
  79. target = hdr
  80. if not isinstance(target, string_types):
  81. target = target[-1]
  82. self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(target) ])
  83. return True
  84. return False
  85. def haveCHeaders(self, hdrs):
  86. for hdr in hdrs:
  87. self.haveCHeader(hdr)
  88. def CheckFunc(self, func, header = None, libs = []):
  89. with self.restoreEnvLibs():
  90. self.env.Append(LIBS = libs)
  91. return self.conf.CheckFunc(func, header = header)
  92. def CheckFuncInLib(self, func, lib):
  93. return self.CheckFunc(func, libs = [lib])
  94. def haveFuncInLib(self, func, lib):
  95. if self.CheckFuncInLib(func, lib):
  96. self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ])
  97. return True
  98. return False
  99. def haveFunc(self, func, header = None, libs = []):
  100. if self.CheckFunc(func, header = header, libs = libs):
  101. self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ])
  102. return True
  103. return False
  104. def haveFuncs(self, funcs):
  105. for func in funcs:
  106. self.haveFunc(func)
  107. def haveTypes(self, types):
  108. for type in types:
  109. if self.conf.CheckType(type, '#include <sys/types.h>'):
  110. self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(type) ])
  111. def CheckParseConfig(self, *args, **kw):
  112. try:
  113. self.conf.env.ParseConfig(*args, **kw)
  114. return True
  115. except Exception as e:
  116. print(e.message, file=sys.stderr)
  117. return False
  118. def CheckParseConfigForLib(self, lib, *args, **kw):
  119. with self.restoreEnvLibs():
  120. self.env['LIBS'] = []
  121. if not self.CheckParseConfig(*args, **kw):
  122. return False
  123. self.env.Append(**{lib: self.env['LIBS']})
  124. return True
  125. @staticmethod
  126. def __checkGmtOffInStructTm(context):
  127. source = """
  128. #include <time.h>
  129. int main() {
  130. struct tm a;
  131. a.tm_gmtoff = 0;
  132. return 0;
  133. }
  134. """
  135. context.Message('Checking for tm_gmtoff in struct tm...')
  136. result = context.TryLink(source, '.c')
  137. context.Result(result)
  138. return result
  139. @staticmethod
  140. def __checkIPv6(context):
  141. source = """
  142. #include <sys/types.h>
  143. #include <sys/socket.h>
  144. #include <netinet/in.h>
  145. int main() {
  146. struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
  147. return 0;
  148. }
  149. """
  150. context.Message('Checking for IPv6 support...')
  151. result = context.TryLink(source, '.c')
  152. context.Result(result)
  153. return result
  154. @staticmethod
  155. def __checkWeakSymbols(context):
  156. source = """
  157. __attribute__((weak)) void __dummy(void *x) { }
  158. int main() {
  159. void *x;
  160. __dummy(x);
  161. }
  162. """
  163. context.Message('Checking for weak symbol support...')
  164. result = context.TryLink(source, '.c')
  165. context.Result(result)
  166. return result
  167. def checkProgram(self, withname, progname):
  168. withname = 'with_' + withname
  169. binpath = None
  170. if self.env[withname] != 1:
  171. binpath = self.env[withname]
  172. else:
  173. prog = self.env.Detect(progname)
  174. if prog:
  175. binpath = self.env.WhereIs(prog)
  176. if binpath:
  177. mode = os.stat(binpath)[ST_MODE]
  178. if S_ISDIR(mode):
  179. fail("* error: path `%s' is a directory" % (binpath))
  180. if not S_ISREG(mode):
  181. fail("* error: path `%s' is not a file or not exists" % (binpath))
  182. if not binpath:
  183. fail("* error: can't find program `%s'" % (progname))
  184. return binpath
  185. VariantDir('sconsbuild/build', 'src', duplicate = 0)
  186. VariantDir('sconsbuild/tests', 'tests', duplicate = 0)
  187. vars = Variables()
  188. vars.AddVariables(
  189. ('prefix', 'prefix', '/usr/local'),
  190. ('bindir', 'binary directory', '${prefix}/bin'),
  191. ('sbindir', 'binary directory', '${prefix}/sbin'),
  192. ('libdir', 'library directory', '${prefix}/lib'),
  193. PathVariable('CC', 'path to the c-compiler', None),
  194. BoolVariable('build_dynamic', 'enable dynamic build', 'yes'),
  195. BoolVariable('build_static', 'enable static build', 'no'),
  196. BoolVariable('build_fullstatic', 'enable fullstatic build', 'no'),
  197. BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'),
  198. BoolVariable('with_brotli', 'enable brotli compression', 'no'),
  199. PackageVariable('with_dbi', 'enable dbi support', 'no'),
  200. BoolVariable('with_fam', 'enable FAM/gamin support', 'no'),
  201. BoolVariable('with_gdbm', 'enable gdbm support', 'no'),
  202. BoolVariable('with_geoip', 'enable GeoIP support', 'no'),
  203. BoolVariable('with_maxminddb', 'enable MaxMind GeoIP2 support', 'no'),
  204. BoolVariable('with_krb5', 'enable krb5 auth support', 'no'),
  205. BoolVariable('with_ldap', 'enable ldap auth support', 'no'),
  206. # with_libev not supported
  207. # with_libunwind not supported
  208. BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'),
  209. BoolVariable('with_memcached', 'enable memcached support', 'no'),
  210. PackageVariable('with_mysql', 'enable mysql support', 'no'),
  211. BoolVariable('with_openssl', 'enable openssl support', 'no'),
  212. PackageVariable('with_gnutls', 'enable GnuTLS support', 'no'),
  213. PackageVariable('with_mbedtls', 'enable mbedTLS support', 'no'),
  214. PackageVariable('with_nss', 'enable NSS crypto support', 'no'),
  215. PackageVariable('with_wolfssl', 'enable wolfSSL support', 'no'),
  216. BoolVariable('with_nettle', 'enable Nettle support', 'no'),
  217. BoolVariable('with_pam', 'enable PAM auth support', 'no'),
  218. PackageVariable('with_pcre', 'enable pcre support', 'yes'),
  219. PackageVariable('with_pgsql', 'enable pgsql support', 'no'),
  220. PackageVariable('with_sasl', 'enable SASL support', 'no'),
  221. BoolVariable('with_sqlite3', 'enable sqlite3 support (required for webdav props)', 'no'),
  222. BoolVariable('with_uuid', 'enable uuid support (required for webdav locks)', 'no'),
  223. # with_valgrind not supported
  224. # with_xattr not supported
  225. PackageVariable('with_xml', 'enable xml support (required for webdav props)', 'no'),
  226. BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'),
  227. BoolVariable('with_all', 'enable all with_* features', 'no'),
  228. )
  229. env = Environment(
  230. ENV = dict(os.environ), # make sure we have a dict here so .Clone() works properly
  231. variables = vars,
  232. CPPPATH = Split('#sconsbuild/build')
  233. )
  234. env.Help(vars.GenerateHelpText(env))
  235. if env.subst('${CC}') != '':
  236. env['CC'] = env.subst('${CC}')
  237. env['package'] = package
  238. env['version'] = version
  239. if env['CC'] == 'gcc':
  240. ## we need x-open 6 and bsd 4.3 features
  241. env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99'))
  242. env.Append(CPPFLAGS = [
  243. '-D_FILE_OFFSET_BITS=64',
  244. '-D_LARGEFILE_SOURCE',
  245. '-D_LARGE_FILES',
  246. '-D_GNU_SOURCE',
  247. ])
  248. if env['with_all']:
  249. for feature in vars.keys():
  250. # only enable 'with_*' flags
  251. if not feature.startswith('with_'): continue
  252. # don't overwrite manual arguments
  253. if feature in vars.args: continue
  254. # now activate
  255. env[feature] = True
  256. # cache configure checks
  257. if 1:
  258. autoconf = Autoconf(env)
  259. if 'CFLAGS' in os.environ:
  260. autoconf.env.Append(CCFLAGS = os.environ['CFLAGS'])
  261. print(">> Appending custom build flags : " + os.environ['CFLAGS'])
  262. if 'LDFLAGS' in os.environ:
  263. autoconf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
  264. print(">> Appending custom link flags : " + os.environ['LDFLAGS'])
  265. if 'LIBS' in os.environ:
  266. autoconf.env.Append(APPEND_LIBS = os.environ['LIBS'])
  267. print(">> Appending custom libraries : " + os.environ['LIBS'])
  268. else:
  269. autoconf.env.Append(APPEND_LIBS = '')
  270. autoconf.env.Append(
  271. LIBBROTLI = '',
  272. LIBBZ2 = '',
  273. LIBCRYPT = '',
  274. LIBCRYPTO = '',
  275. LIBDBI = '',
  276. LIBDL = '',
  277. LIBFCGI = '',
  278. LIBGDBM = '',
  279. LIBGNUTLS = '',
  280. LIBGSSAPI_KRB5 = '',
  281. LIBKRB5 = '',
  282. LIBLBER = '',
  283. LIBLDAP = '',
  284. LIBLUA = '',
  285. LIBMEMCACHED = '',
  286. LIBMYSQL = '',
  287. LIBNSS = '',
  288. LIBPAM = '',
  289. LIBPCRE = '',
  290. LIBPGSQL = '',
  291. LIBSASL = '',
  292. LIBSQLITE3 = '',
  293. LIBSSL = '',
  294. LIBUUID = '',
  295. LIBX509 = '',
  296. LIBXML2 = '',
  297. LIBZ = '',
  298. )
  299. autoconf.haveCHeaders([
  300. 'arpa/inet.h',
  301. 'crypt.h',
  302. 'fcntl.h',
  303. 'getopt.h',
  304. 'inttypes.h',
  305. 'linux/random.h',
  306. 'poll.h',
  307. 'pwd.h',
  308. 'stdint.h',
  309. 'stdlib.h',
  310. 'string.h',
  311. 'strings.h',
  312. 'sys/devpoll.h',
  313. 'sys/epoll.h',
  314. 'sys/filio.h',
  315. 'sys/loadavg.h',
  316. 'sys/poll.h',
  317. 'sys/port.h',
  318. 'sys/prctl.h',
  319. 'sys/sendfile.h',
  320. 'sys/time.h',
  321. 'sys/wait.h',
  322. 'syslog.h',
  323. 'unistd.h',
  324. 'winsock2.h',
  325. # "have" the last header if we include others before?
  326. ['sys/types.h', 'sys/time.h', 'sys/resource.h'],
  327. ['sys/types.h', 'netinet/in.h'],
  328. ['sys/types.h', 'sys/event.h'],
  329. ['sys/types.h', 'sys/mman.h'],
  330. ['sys/types.h', 'sys/select.h'],
  331. ['sys/types.h', 'sys/socket.h'],
  332. ['sys/types.h', 'sys/uio.h'],
  333. ['sys/types.h', 'sys/un.h'],
  334. ])
  335. autoconf.haveFuncs([
  336. 'arc4random_buf',
  337. 'chroot',
  338. 'clock_gettime',
  339. 'copy_file_range',
  340. 'dup2',
  341. 'epoll_ctl',
  342. 'explicit_bzero',
  343. 'explicit_memset',
  344. 'fork',
  345. 'getcwd',
  346. 'gethostbyname',
  347. 'getloadavg',
  348. 'getopt',
  349. 'getrlimit',
  350. 'getuid',
  351. 'inet_ntoa',
  352. 'inet_ntop',
  353. 'inet_pton',
  354. 'issetugid',
  355. 'jrand48',
  356. 'kqueue',
  357. 'localtime_r',
  358. 'lstat',
  359. 'madvise',
  360. 'memset_s',
  361. 'memset',
  362. 'mmap',
  363. 'munmap',
  364. 'pathconf',
  365. 'pipe2',
  366. 'poll',
  367. 'port_create',
  368. 'posix_fadvise',
  369. 'prctl',
  370. 'select',
  371. 'send_file',
  372. 'sendfile',
  373. 'sendfile64',
  374. 'sigaction',
  375. 'signal',
  376. 'socket',
  377. 'srandom',
  378. 'stat',
  379. 'strchr',
  380. 'strdup',
  381. 'strerror',
  382. 'strftime',
  383. 'strstr',
  384. 'strtol',
  385. 'writev',
  386. ])
  387. autoconf.haveFunc('getentropy', 'sys/random.h')
  388. autoconf.haveFunc('getrandom', 'linux/random.h')
  389. autoconf.haveTypes(Split('pid_t size_t off_t'))
  390. # have crypt_r/crypt, and is -lcrypt needed?
  391. if autoconf.CheckLib('crypt'):
  392. autoconf.env.Append(
  393. CPPFLAGS = [ '-DHAVE_LIBCRYPT' ],
  394. LIBCRYPT = 'crypt',
  395. )
  396. with autoconf.restoreEnvLibs():
  397. autoconf.env['LIBS'] = ['crypt']
  398. autoconf.haveFuncs(['crypt', 'crypt_r'])
  399. else:
  400. autoconf.haveFuncs(['crypt', 'crypt_r'])
  401. if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'):
  402. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ])
  403. if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'):
  404. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ])
  405. if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'):
  406. autoconf.env.Append(
  407. CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ],
  408. LIBS = [ 'elftc' ],
  409. )
  410. if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'):
  411. autoconf.env.Append(
  412. CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ],
  413. LIBS = [ 'rt' ],
  414. )
  415. if autoconf.CheckIPv6():
  416. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ])
  417. if autoconf.CheckWeakSymbols():
  418. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ])
  419. if autoconf.CheckGmtOffInStructTm():
  420. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ])
  421. if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'):
  422. autoconf.env.Append(LIBDL = 'dl')
  423. # used in tests if present
  424. if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'):
  425. autoconf.env.Append(LIBFCGI = 'fcgi')
  426. if env['with_bzip2']:
  427. if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'):
  428. fail("Couldn't find bz2")
  429. autoconf.env.Append(
  430. CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ],
  431. LIBBZ2 = 'bz2',
  432. )
  433. if env['with_brotli']:
  434. if not autoconf.CheckParseConfigForLib('LIBBROTLI', 'pkg-config --static --cflags --libs libbrotlienc'):
  435. fail("Couldn't find libbrotlienc")
  436. autoconf.env.Append(
  437. CPPFLAGS = [ '-DHAVE_BROTLI_ENCODE_H', '-DHAVE_BROTLI' ],
  438. )
  439. if env['with_dbi']:
  440. if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'):
  441. fail("Couldn't find dbi")
  442. autoconf.env.Append(
  443. CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ],
  444. LIBDBI = 'dbi',
  445. )
  446. if env['with_fam']:
  447. if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'):
  448. fail("Couldn't find fam")
  449. autoconf.env.Append(
  450. CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ],
  451. LIBS = [ 'fam' ],
  452. )
  453. autoconf.haveFunc('FAMNoExists')
  454. if env['with_gdbm']:
  455. if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'):
  456. fail("Couldn't find gdbm")
  457. autoconf.env.Append(
  458. CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ],
  459. LIBGDBM = 'gdbm',
  460. )
  461. if env['with_geoip']:
  462. if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'):
  463. fail("Couldn't find geoip")
  464. autoconf.env.Append(
  465. CPPFLAGS = [ '-DHAVE_GEOIP' ],
  466. LIBGEOIP = 'GeoIP',
  467. )
  468. if env['with_maxminddb']:
  469. if not autoconf.CheckLibWithHeader('maxminddb', 'maxminddb.h', 'C'):
  470. fail("Couldn't find maxminddb")
  471. autoconf.env.Append(
  472. CPPFLAGS = [ '-DHAVE_MAXMINDDB' ],
  473. LIBMAXMINDDB = 'maxminddb',
  474. )
  475. if env['with_krb5']:
  476. if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'):
  477. fail("Couldn't find krb5")
  478. if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'):
  479. fail("Couldn't find gssapi_krb5")
  480. autoconf.env.Append(
  481. CPPFLAGS = [ '-DHAVE_KRB5' ],
  482. LIBKRB5 = 'krb5',
  483. LIBGSSAPI_KRB5 = 'gssapi_krb5',
  484. )
  485. if env['with_ldap']:
  486. if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'):
  487. fail("Couldn't find ldap")
  488. if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'):
  489. fail("Couldn't find lber")
  490. autoconf.env.Append(
  491. CPPFLAGS = [
  492. '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP',
  493. '-DHAVE_LBER_H', '-DHAVE_LIBLBER',
  494. ],
  495. LIBLDAP = 'ldap',
  496. LIBLBER = 'lber',
  497. )
  498. if env['with_lua']:
  499. found_lua = False
  500. for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']:
  501. print("Searching for lua: " + lua_name + " >= 5.0")
  502. if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"):
  503. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ])
  504. found_lua = True
  505. break
  506. if not found_lua:
  507. fail("Couldn't find any lua implementation")
  508. if env['with_memcached']:
  509. if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'):
  510. fail("Couldn't find memcached")
  511. autoconf.env.Append(
  512. CPPFLAGS = [ '-DUSE_MEMCACHED' ],
  513. LIBMEMCACHED = 'memcached',
  514. )
  515. if env['with_mysql']:
  516. mysql_config = autoconf.checkProgram('mysql', 'mysql_config')
  517. if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'):
  518. fail("Couldn't find mysql")
  519. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ])
  520. if env['with_nss']:
  521. nss_config = autoconf.checkProgram('nss', 'nss-config')
  522. if not autoconf.CheckParseConfigForLib('LIBNSS', nss_config + ' --cflags --libs'):
  523. fail("Couldn't find NSS")
  524. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_NSS3_NSS_H' ])
  525. if env['with_openssl']:
  526. if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'):
  527. fail("Couldn't find openssl")
  528. autoconf.env.Append(
  529. CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'],
  530. LIBSSL = 'ssl',
  531. LIBCRYPTO = 'crypto',
  532. )
  533. if env['with_wolfssl']:
  534. if type(env['with_wolfssl']) is str:
  535. autoconf.env.AppendUnique(
  536. CPPPATH = [ env['with_wolfssl'] + '/include',
  537. env['with_wolfssl'] + '/include/wolfssl' ],
  538. LIBPATH = [ env['with_wolfssl'] + '/lib' ],
  539. )
  540. if not autoconf.CheckLibWithHeader('wolfssl', 'wolfssl/ssl.h', 'C'):
  541. fail("Couldn't find wolfssl")
  542. autoconf.env.Append(
  543. CPPFLAGS = [ '-DHAVE_WOLFSSL_SSL_H' ],
  544. LIBSSL = '',
  545. LIBCRYPTO = 'wolfssl',
  546. )
  547. if env['with_mbedtls']:
  548. if not autoconf.CheckLibWithHeader('mbedtls', 'mbedtls/ssl.h', 'C'):
  549. fail("Couldn't find mbedtls")
  550. autoconf.env.Append(
  551. CPPFLAGS = [ '-DHAVE_LIBMBEDCRYPTO' ],
  552. LIBSSL = 'mbedtls',
  553. LIBX509 = 'mbedx509',
  554. LIBCRYPTO = 'mbedcrypto',
  555. )
  556. if env['with_nettle']:
  557. if not autoconf.CheckLibWithHeader('nettle', 'nettle/nettle-types.h', 'C'):
  558. fail("Couldn't find Nettle")
  559. autoconf.env.Append(
  560. CPPFLAGS = [ '-DHAVE_NETTLE_NETTLE_TYPES_H' ],
  561. LIBCRYPTO = 'nettle',
  562. )
  563. if env['with_gnutls']:
  564. if not autoconf.CheckLibWithHeader('gnutls', 'gnutls/crypto.h', 'C'):
  565. fail("Couldn't find gnutls")
  566. autoconf.env.Append(
  567. CPPFLAGS = [ '-DHAVE_GNUTLS_CRYPTO_H' ],
  568. LIBGNUTLS = 'gnutls',
  569. )
  570. if not autoconf.env.exists('LIBCRYPTO'):
  571. autoconf.env.Append(
  572. LIBCRYPTO = 'gnutls',
  573. )
  574. if env['with_pam']:
  575. if not autoconf.CheckLibWithHeader('pam', 'security/pam_appl.h', 'C'):
  576. fail("Couldn't find pam")
  577. autoconf.env.Append(
  578. CPPFLAGS = [ '-DHAVE_PAM' ],
  579. LIBPAM = 'pam',
  580. )
  581. if env['with_pcre']:
  582. pcre_config = autoconf.checkProgram('pcre', 'pcre-config')
  583. if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'):
  584. fail("Couldn't find pcre")
  585. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ])
  586. if env['with_pgsql']:
  587. if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'):
  588. fail("Couldn't find libpq")
  589. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ])
  590. if env['with_sasl']:
  591. if not autoconf.CheckLibWithHeader('sasl2', 'sasl/sasl.h', 'C'):
  592. fail("Couldn't find libsasl2")
  593. autoconf.env.Append(
  594. CPPFLAGS = [ '-DHAVE_SASL' ],
  595. LIBSASL = 'sasl2',
  596. )
  597. if env['with_sqlite3']:
  598. if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'):
  599. fail("Couldn't find sqlite3")
  600. autoconf.env.Append(
  601. CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ],
  602. LIBSQLITE3 = 'sqlite3',
  603. )
  604. if env['with_uuid']:
  605. if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'):
  606. fail("Couldn't find uuid")
  607. autoconf.env.Append(
  608. CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ],
  609. LIBUUID = 'uuid',
  610. )
  611. if env['with_xml']:
  612. xml2_config = autoconf.checkProgram('xml', 'xml2-config')
  613. if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'):
  614. fail("Couldn't find xml2")
  615. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ])
  616. if env['with_zlib']:
  617. if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'):
  618. fail("Couldn't find zlib")
  619. autoconf.env.Append(
  620. CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ],
  621. LIBZ = 'z',
  622. )
  623. env = autoconf.Finish()
  624. if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']):
  625. env.Append(COMMON_LIB = 'bin')
  626. elif re.compile("darwin|aix").search(env['PLATFORM']):
  627. env.Append(COMMON_LIB = 'lib')
  628. else:
  629. env.Append(COMMON_LIB = False)
  630. versions = version.split('.')
  631. version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2])
  632. env.Append(CPPFLAGS = [
  633. '-DLIGHTTPD_VERSION_ID=' + hex(version_id),
  634. '-DPACKAGE_NAME=\\"' + package + '\\"',
  635. '-DPACKAGE_VERSION=\\"' + version + '\\"',
  636. '-DLIBRARY_DIR="\\"${libdir}\\""',
  637. ] )
  638. SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0)
  639. SConscript('tests/SConscript', exports = 'env', variant_dir = 'sconsbuild/tests')