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.
 
 
 
 
 
 

731 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. PackageVariable('with_dbi', 'enable dbi support', 'no'),
  199. BoolVariable('with_fam', 'enable FAM/gamin support', 'no'),
  200. BoolVariable('with_gdbm', 'enable gdbm support', 'no'),
  201. BoolVariable('with_geoip', 'enable GeoIP support', 'no'),
  202. BoolVariable('with_maxminddb', 'enable MaxMind GeoIP2 support', 'no'),
  203. BoolVariable('with_krb5', 'enable krb5 auth support', 'no'),
  204. BoolVariable('with_ldap', 'enable ldap auth support', 'no'),
  205. # with_libev not supported
  206. # with_libunwind not supported
  207. BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'),
  208. BoolVariable('with_memcached', 'enable memcached support', 'no'),
  209. PackageVariable('with_mysql', 'enable mysql support', 'no'),
  210. BoolVariable('with_openssl', 'enable openssl support', 'no'),
  211. PackageVariable('with_gnutls', 'enable GnuTLS support', 'no'),
  212. PackageVariable('with_mbedtls', 'enable mbedTLS support', 'no'),
  213. PackageVariable('with_nss', 'enable NSS crypto support', 'no'),
  214. PackageVariable('with_wolfssl', 'enable wolfSSL support', 'no'),
  215. BoolVariable('with_nettle', 'enable Nettle support', 'no'),
  216. BoolVariable('with_pam', 'enable PAM auth support', 'no'),
  217. PackageVariable('with_pcre', 'enable pcre support', 'yes'),
  218. PackageVariable('with_pgsql', 'enable pgsql support', 'no'),
  219. PackageVariable('with_sasl', 'enable SASL support', 'no'),
  220. BoolVariable('with_sqlite3', 'enable sqlite3 support (required for webdav props)', 'no'),
  221. BoolVariable('with_uuid', 'enable uuid support (required for webdav locks)', 'no'),
  222. # with_valgrind not supported
  223. # with_xattr not supported
  224. PackageVariable('with_xml', 'enable xml support (required for webdav props)', 'no'),
  225. BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'),
  226. BoolVariable('with_all', 'enable all with_* features', 'no'),
  227. )
  228. env = Environment(
  229. ENV = os.environ,
  230. variables = vars,
  231. CPPPATH = Split('#sconsbuild/build')
  232. )
  233. env.Help(vars.GenerateHelpText(env))
  234. if env.subst('${CC}') is not '':
  235. env['CC'] = env.subst('${CC}')
  236. env['package'] = package
  237. env['version'] = version
  238. if env['CC'] == 'gcc':
  239. ## we need x-open 6 and bsd 4.3 features
  240. env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99'))
  241. env.Append(CPPFLAGS = [
  242. '-D_FILE_OFFSET_BITS=64',
  243. '-D_LARGEFILE_SOURCE',
  244. '-D_LARGE_FILES',
  245. '-D_GNU_SOURCE',
  246. ])
  247. if env['with_all']:
  248. for feature in vars.keys():
  249. # only enable 'with_*' flags
  250. if not feature.startswith('with_'): continue
  251. # don't overwrite manual arguments
  252. if feature in vars.args: continue
  253. # now activate
  254. env[feature] = True
  255. # cache configure checks
  256. if 1:
  257. autoconf = Autoconf(env)
  258. if 'CFLAGS' in os.environ:
  259. autoconf.env.Append(CCFLAGS = os.environ['CFLAGS'])
  260. print(">> Appending custom build flags : " + os.environ['CFLAGS'])
  261. if 'LDFLAGS' in os.environ:
  262. autoconf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
  263. print(">> Appending custom link flags : " + os.environ['LDFLAGS'])
  264. if 'LIBS' in os.environ:
  265. autoconf.env.Append(APPEND_LIBS = os.environ['LIBS'])
  266. print(">> Appending custom libraries : " + os.environ['LIBS'])
  267. else:
  268. autoconf.env.Append(APPEND_LIBS = '')
  269. autoconf.env.Append(
  270. LIBBZ2 = '',
  271. LIBCRYPT = '',
  272. LIBCRYPTO = '',
  273. LIBDBI = '',
  274. LIBDL = '',
  275. LIBFCGI = '',
  276. LIBGDBM = '',
  277. LIBGNUTLS = '',
  278. LIBGSSAPI_KRB5 = '',
  279. LIBKRB5 = '',
  280. LIBLBER = '',
  281. LIBLDAP = '',
  282. LIBLUA = '',
  283. LIBMEMCACHED = '',
  284. LIBMYSQL = '',
  285. LIBNSS = '',
  286. LIBPAM = '',
  287. LIBPCRE = '',
  288. LIBPGSQL = '',
  289. LIBSASL = '',
  290. LIBSQLITE3 = '',
  291. LIBSSL = '',
  292. LIBUUID = '',
  293. LIBX509 = '',
  294. LIBXML2 = '',
  295. LIBZ = '',
  296. )
  297. autoconf.haveCHeaders([
  298. 'arpa/inet.h',
  299. 'crypt.h',
  300. 'fcntl.h',
  301. 'getopt.h',
  302. 'inttypes.h',
  303. 'linux/random.h',
  304. 'poll.h',
  305. 'pwd.h',
  306. 'stdint.h',
  307. 'stdlib.h',
  308. 'string.h',
  309. 'strings.h',
  310. 'sys/devpoll.h',
  311. 'sys/epoll.h',
  312. 'sys/filio.h',
  313. 'sys/loadavg.h',
  314. 'sys/poll.h',
  315. 'sys/port.h',
  316. 'sys/prctl.h',
  317. 'sys/sendfile.h',
  318. 'sys/time.h',
  319. 'sys/wait.h',
  320. 'syslog.h',
  321. 'unistd.h',
  322. 'winsock2.h',
  323. # "have" the last header if we include others before?
  324. ['sys/types.h', 'sys/time.h', 'sys/resource.h'],
  325. ['sys/types.h', 'netinet/in.h'],
  326. ['sys/types.h', 'sys/event.h'],
  327. ['sys/types.h', 'sys/mman.h'],
  328. ['sys/types.h', 'sys/select.h'],
  329. ['sys/types.h', 'sys/socket.h'],
  330. ['sys/types.h', 'sys/uio.h'],
  331. ['sys/types.h', 'sys/un.h'],
  332. ])
  333. autoconf.haveFuncs([
  334. 'arc4random_buf',
  335. 'chroot',
  336. 'clock_gettime',
  337. 'copy_file_range',
  338. 'dup2',
  339. 'epoll_ctl',
  340. 'explicit_bzero',
  341. 'explicit_memset',
  342. 'fork',
  343. 'getcwd',
  344. 'gethostbyname',
  345. 'getloadavg',
  346. 'getopt',
  347. 'getrlimit',
  348. 'getuid',
  349. 'inet_ntoa',
  350. 'inet_ntop',
  351. 'inet_pton',
  352. 'issetugid',
  353. 'jrand48',
  354. 'kqueue',
  355. 'localtime_r',
  356. 'lstat',
  357. 'madvise',
  358. 'memset_s',
  359. 'memset',
  360. 'mmap',
  361. 'munmap',
  362. 'pathconf',
  363. 'pipe2',
  364. 'poll',
  365. 'port_create',
  366. 'posix_fadvise',
  367. 'prctl',
  368. 'select',
  369. 'send_file',
  370. 'sendfile',
  371. 'sendfile64',
  372. 'sigaction',
  373. 'signal',
  374. 'socket',
  375. 'srandom',
  376. 'stat',
  377. 'strchr',
  378. 'strdup',
  379. 'strerror',
  380. 'strftime',
  381. 'strstr',
  382. 'strtol',
  383. 'writev',
  384. ])
  385. autoconf.haveFunc('getentropy', 'sys/random.h')
  386. autoconf.haveFunc('getrandom', 'linux/random.h')
  387. autoconf.haveTypes(Split('pid_t size_t off_t'))
  388. # have crypt_r/crypt, and is -lcrypt needed?
  389. if autoconf.CheckLib('crypt'):
  390. autoconf.env.Append(
  391. CPPFLAGS = [ '-DHAVE_LIBCRYPT' ],
  392. LIBCRYPT = 'crypt',
  393. )
  394. with autoconf.restoreEnvLibs():
  395. autoconf.env['LIBS'] = ['crypt']
  396. autoconf.haveFuncs(['crypt', 'crypt_r'])
  397. else:
  398. autoconf.haveFuncs(['crypt', 'crypt_r'])
  399. if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'):
  400. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ])
  401. if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'):
  402. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ])
  403. if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'):
  404. autoconf.env.Append(
  405. CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ],
  406. LIBS = [ 'elftc' ],
  407. )
  408. if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'):
  409. autoconf.env.Append(
  410. CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ],
  411. LIBS = [ 'rt' ],
  412. )
  413. if autoconf.CheckIPv6():
  414. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ])
  415. if autoconf.CheckWeakSymbols():
  416. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ])
  417. if autoconf.CheckGmtOffInStructTm():
  418. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ])
  419. if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'):
  420. autoconf.env.Append(LIBDL = 'dl')
  421. # used in tests if present
  422. if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'):
  423. autoconf.env.Append(LIBFCGI = 'fcgi')
  424. if env['with_bzip2']:
  425. if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'):
  426. fail("Couldn't find bz2")
  427. autoconf.env.Append(
  428. CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ],
  429. LIBBZ2 = 'bz2',
  430. )
  431. if env['with_dbi']:
  432. if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'):
  433. fail("Couldn't find dbi")
  434. autoconf.env.Append(
  435. CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ],
  436. LIBDBI = 'dbi',
  437. )
  438. if env['with_fam']:
  439. if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'):
  440. fail("Couldn't find fam")
  441. autoconf.env.Append(
  442. CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ],
  443. LIBS = [ 'fam' ],
  444. )
  445. autoconf.haveFunc('FAMNoExists')
  446. if env['with_gdbm']:
  447. if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'):
  448. fail("Couldn't find gdbm")
  449. autoconf.env.Append(
  450. CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ],
  451. LIBGDBM = 'gdbm',
  452. )
  453. if env['with_geoip']:
  454. if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'):
  455. fail("Couldn't find geoip")
  456. autoconf.env.Append(
  457. CPPFLAGS = [ '-DHAVE_GEOIP' ],
  458. LIBGEOIP = 'GeoIP',
  459. )
  460. if env['with_maxminddb']:
  461. if not autoconf.CheckLibWithHeader('maxminddb', 'maxminddb.h', 'C'):
  462. fail("Couldn't find maxminddb")
  463. autoconf.env.Append(
  464. CPPFLAGS = [ '-DHAVE_MAXMINDDB' ],
  465. LIBMAXMINDDB = 'maxminddb',
  466. )
  467. if env['with_krb5']:
  468. if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'):
  469. fail("Couldn't find krb5")
  470. if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'):
  471. fail("Couldn't find gssapi_krb5")
  472. autoconf.env.Append(
  473. CPPFLAGS = [ '-DHAVE_KRB5' ],
  474. LIBKRB5 = 'krb5',
  475. LIBGSSAPI_KRB5 = 'gssapi_krb5',
  476. )
  477. if env['with_ldap']:
  478. if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'):
  479. fail("Couldn't find ldap")
  480. if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'):
  481. fail("Couldn't find lber")
  482. autoconf.env.Append(
  483. CPPFLAGS = [
  484. '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP',
  485. '-DHAVE_LBER_H', '-DHAVE_LIBLBER',
  486. ],
  487. LIBLDAP = 'ldap',
  488. LIBLBER = 'lber',
  489. )
  490. if env['with_lua']:
  491. found_lua = False
  492. for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']:
  493. print("Searching for lua: " + lua_name + " >= 5.0")
  494. if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"):
  495. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ])
  496. found_lua = True
  497. break
  498. if not found_lua:
  499. fail("Couldn't find any lua implementation")
  500. if env['with_memcached']:
  501. if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'):
  502. fail("Couldn't find memcached")
  503. autoconf.env.Append(
  504. CPPFLAGS = [ '-DUSE_MEMCACHED' ],
  505. LIBMEMCACHED = 'memcached',
  506. )
  507. if env['with_mysql']:
  508. mysql_config = autoconf.checkProgram('mysql', 'mysql_config')
  509. if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'):
  510. fail("Couldn't find mysql")
  511. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ])
  512. if env['with_nss']:
  513. nss_config = autoconf.checkProgram('nss', 'nss-config')
  514. if not autoconf.CheckParseConfigForLib('LIBNSS', nss_config + ' --cflags --libs'):
  515. fail("Couldn't find NSS")
  516. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_NSS3_NSS_H' ])
  517. if env['with_openssl']:
  518. if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'):
  519. fail("Couldn't find openssl")
  520. autoconf.env.Append(
  521. CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'],
  522. LIBSSL = 'ssl',
  523. LIBCRYPTO = 'crypto',
  524. )
  525. if env['with_wolfssl']:
  526. if type(env['with_wolfssl']) is str:
  527. autoconf.env.AppendUnique(
  528. CPPPATH = [ env['with_wolfssl'] + '/include',
  529. env['with_wolfssl'] + '/include/wolfssl' ],
  530. LIBPATH = [ env['with_wolfssl'] + '/lib' ],
  531. )
  532. if not autoconf.CheckLibWithHeader('wolfssl', 'wolfssl/ssl.h', 'C'):
  533. fail("Couldn't find wolfssl")
  534. autoconf.env.Append(
  535. CPPFLAGS = [ '-DHAVE_WOLFSSL_SSL_H' ],
  536. LIBSSL = '',
  537. LIBCRYPTO = 'wolfssl',
  538. )
  539. if env['with_mbedtls']:
  540. if not autoconf.CheckLibWithHeader('mbedtls', 'mbedtls/ssl.h', 'C'):
  541. fail("Couldn't find mbedtls")
  542. autoconf.env.Append(
  543. CPPFLAGS = [ '-DHAVE_LIBMBEDCRYPTO' ],
  544. LIBSSL = 'mbedtls',
  545. LIBX509 = 'mbedx509',
  546. LIBCRYPTO = 'mbedcrypto',
  547. )
  548. if env['with_nettle']:
  549. if not autoconf.CheckLibWithHeader('nettle', 'nettle/nettle-types.h', 'C'):
  550. fail("Couldn't find Nettle")
  551. autoconf.env.Append(
  552. CPPFLAGS = [ '-DHAVE_NETTLE_NETTLE_TYPES_H' ],
  553. LIBCRYPTO = 'nettle',
  554. )
  555. if env['with_gnutls']:
  556. if not autoconf.CheckLibWithHeader('gnutls', 'gnutls/crypto.h', 'C'):
  557. fail("Couldn't find gnutls")
  558. autoconf.env.Append(
  559. CPPFLAGS = [ '-DHAVE_GNUTLS_CRYPTO_H' ],
  560. LIBGNUTLS = 'gnutls',
  561. )
  562. if not autoconf.env.exists('LIBCRYPTO'):
  563. autoconf.env.Append(
  564. LIBCRYPTO = 'gnutls',
  565. )
  566. if env['with_pam']:
  567. if not autoconf.CheckLibWithHeader('pam', 'security/pam_appl.h', 'C'):
  568. fail("Couldn't find pam")
  569. autoconf.env.Append(
  570. CPPFLAGS = [ '-DHAVE_PAM' ],
  571. LIBPAM = 'pam',
  572. )
  573. if env['with_pcre']:
  574. pcre_config = autoconf.checkProgram('pcre', 'pcre-config')
  575. if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'):
  576. fail("Couldn't find pcre")
  577. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ])
  578. if env['with_pgsql']:
  579. if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'):
  580. fail("Couldn't find libpq")
  581. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ])
  582. if env['with_sasl']:
  583. if not autoconf.CheckLibWithHeader('sasl2', 'sasl/sasl.h', 'C'):
  584. fail("Couldn't find libsasl2")
  585. autoconf.env.Append(
  586. CPPFLAGS = [ '-DHAVE_SASL' ],
  587. LIBSASL = 'sasl2',
  588. )
  589. if env['with_sqlite3']:
  590. if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'):
  591. fail("Couldn't find sqlite3")
  592. autoconf.env.Append(
  593. CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ],
  594. LIBSQLITE3 = 'sqlite3',
  595. )
  596. if env['with_uuid']:
  597. if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'):
  598. fail("Couldn't find uuid")
  599. autoconf.env.Append(
  600. CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ],
  601. LIBUUID = 'uuid',
  602. )
  603. if env['with_xml']:
  604. xml2_config = autoconf.checkProgram('xml', 'xml2-config')
  605. if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'):
  606. fail("Couldn't find xml2")
  607. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ])
  608. if env['with_zlib']:
  609. if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'):
  610. fail("Couldn't find zlib")
  611. autoconf.env.Append(
  612. CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ],
  613. LIBZ = 'z',
  614. )
  615. env = autoconf.Finish()
  616. if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']):
  617. env.Append(COMMON_LIB = 'bin')
  618. elif re.compile("darwin|aix").search(env['PLATFORM']):
  619. env.Append(COMMON_LIB = 'lib')
  620. else:
  621. env.Append(COMMON_LIB = False)
  622. versions = version.split('.')
  623. version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2])
  624. env.Append(CPPFLAGS = [
  625. '-DLIGHTTPD_VERSION_ID=' + hex(version_id),
  626. '-DPACKAGE_NAME=\\"' + package + '\\"',
  627. '-DPACKAGE_VERSION=\\"' + version + '\\"',
  628. '-DLIBRARY_DIR="\\"${libdir}\\""',
  629. ] )
  630. SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0)
  631. SConscript('tests/SConscript', exports = 'env', variant_dir = 'sconsbuild/tests')