SConstruct 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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.64'
  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 OSError:
  116. return False
  117. except Exception as e:
  118. print(e.message, file=sys.stderr)
  119. return False
  120. def CheckParseConfigForLib(self, lib, *args, **kw):
  121. with self.restoreEnvLibs():
  122. self.env['LIBS'] = []
  123. if not self.CheckParseConfig(*args, **kw):
  124. return False
  125. self.env.Append(**{lib: self.env['LIBS']})
  126. return True
  127. @staticmethod
  128. def __checkGmtOffInStructTm(context):
  129. source = """
  130. #include <time.h>
  131. int main() {
  132. struct tm a;
  133. a.tm_gmtoff = 0;
  134. return 0;
  135. }
  136. """
  137. context.Message('Checking for tm_gmtoff in struct tm...')
  138. result = context.TryLink(source, '.c')
  139. context.Result(result)
  140. return result
  141. @staticmethod
  142. def __checkIPv6(context):
  143. source = """
  144. #include <sys/types.h>
  145. #include <sys/socket.h>
  146. #include <netinet/in.h>
  147. int main() {
  148. struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
  149. return 0;
  150. }
  151. """
  152. context.Message('Checking for IPv6 support...')
  153. result = context.TryLink(source, '.c')
  154. context.Result(result)
  155. return result
  156. @staticmethod
  157. def __checkWeakSymbols(context):
  158. source = """
  159. __attribute__((weak)) void __dummy(void *x) { }
  160. int main() {
  161. void *x;
  162. __dummy(x);
  163. }
  164. """
  165. context.Message('Checking for weak symbol support...')
  166. result = context.TryLink(source, '.c')
  167. context.Result(result)
  168. return result
  169. def checkProgram(self, withname, progname):
  170. withname = 'with_' + withname
  171. binpath = None
  172. if self.env[withname] != 1:
  173. binpath = self.env[withname]
  174. else:
  175. prog = self.env.Detect(progname)
  176. if prog:
  177. binpath = self.env.WhereIs(prog)
  178. if binpath:
  179. mode = os.stat(binpath)[ST_MODE]
  180. if S_ISDIR(mode):
  181. fail("* error: path `%s' is a directory" % (binpath))
  182. if not S_ISREG(mode):
  183. fail("* error: path `%s' is not a file or not exists" % (binpath))
  184. if not binpath:
  185. fail("* error: can't find program `%s'" % (progname))
  186. return binpath
  187. VariantDir('sconsbuild/build', 'src', duplicate = 0)
  188. VariantDir('sconsbuild/tests', 'tests', duplicate = 0)
  189. vars = Variables()
  190. vars.AddVariables(
  191. ('prefix', 'prefix', '/usr/local'),
  192. ('bindir', 'binary directory', '${prefix}/bin'),
  193. ('sbindir', 'binary directory', '${prefix}/sbin'),
  194. ('libdir', 'library directory', '${prefix}/lib'),
  195. PathVariable('CC', 'path to the c-compiler', None),
  196. BoolVariable('build_dynamic', 'enable dynamic build', 'yes'),
  197. BoolVariable('build_static', 'enable static build', 'no'),
  198. BoolVariable('build_fullstatic', 'enable fullstatic build', 'no'),
  199. BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'),
  200. BoolVariable('with_brotli', 'enable brotli compression', 'no'),
  201. PackageVariable('with_dbi', 'enable dbi support', 'no'),
  202. BoolVariable('with_fam', 'enable FAM/gamin 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', '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_pcre2', 'enable pcre2 support', 'yes'),
  218. PackageVariable('with_pcre', 'enable pcre support', 'no'),
  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_xxhash', 'build with system-provided xxhash', 'no'),
  227. BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'),
  228. BoolVariable('with_zstd', 'enable zstd compression', 'no'),
  229. BoolVariable('with_all', 'enable all with_* features', 'no'),
  230. )
  231. env = Environment(
  232. ENV = dict(os.environ), # make sure we have a dict here so .Clone() works properly
  233. variables = vars,
  234. CPPPATH = Split('#sconsbuild/build')
  235. )
  236. env.Help(vars.GenerateHelpText(env))
  237. if env.subst('${CC}') != '':
  238. env['CC'] = env.subst('${CC}')
  239. env['package'] = package
  240. env['version'] = version
  241. if env['CC'] == 'gcc':
  242. ## we need x-open 6 and bsd 4.3 features
  243. env.Append(CCFLAGS = Split('-pipe -Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99'))
  244. env.Append(CPPFLAGS = [
  245. '-D_TIME_BITS=64',
  246. '-D_FILE_OFFSET_BITS=64',
  247. '-D_LARGEFILE_SOURCE',
  248. '-D_LARGE_FILES',
  249. '-D_GNU_SOURCE',
  250. ])
  251. if env['with_all']:
  252. for feature in vars.keys():
  253. # only enable 'with_*' flags
  254. if not feature.startswith('with_'): continue
  255. # don't overwrite manual arguments
  256. if feature in vars.args: continue
  257. # now activate
  258. env[feature] = True
  259. # cache configure checks
  260. if 1:
  261. autoconf = Autoconf(env)
  262. if 'CFLAGS' in os.environ:
  263. autoconf.env.Append(CCFLAGS = os.environ['CFLAGS'])
  264. print(">> Appending custom build flags : " + os.environ['CFLAGS'])
  265. if 'LDFLAGS' in os.environ:
  266. autoconf.env.Append(LINKFLAGS = os.environ['LDFLAGS'])
  267. print(">> Appending custom link flags : " + os.environ['LDFLAGS'])
  268. if 'LIBS' in os.environ:
  269. autoconf.env.Append(APPEND_LIBS = os.environ['LIBS'])
  270. print(">> Appending custom libraries : " + os.environ['LIBS'])
  271. else:
  272. autoconf.env.Append(APPEND_LIBS = '')
  273. autoconf.env.Append(
  274. LIBBROTLI = '',
  275. LIBBZ2 = '',
  276. LIBCRYPT = '',
  277. LIBCRYPTO = '',
  278. LIBDBI = '',
  279. LIBDL = '',
  280. LIBGNUTLS = '',
  281. LIBGSSAPI_KRB5 = '',
  282. LIBKRB5 = '',
  283. LIBLBER = '',
  284. LIBLDAP = '',
  285. LIBLUA = '',
  286. LIBMBEDTLS = '',
  287. LIBMBEDX509 = '',
  288. LIBMBEDCRYPTO = '',
  289. LIBMYSQL = '',
  290. LIBNSS = '',
  291. LIBPAM = '',
  292. LIBPCRE = '',
  293. LIBPGSQL = '',
  294. LIBSASL = '',
  295. LIBSQLITE3 = '',
  296. LIBSSL = '',
  297. LIBSSLCRYPTO = '',
  298. LIBUUID = '',
  299. LIBWOLFSSL = '',
  300. LIBX509 = '',
  301. LIBXML2 = '',
  302. LIBXXHASH = '',
  303. LIBZ = '',
  304. LIBZSTD = '',
  305. )
  306. autoconf.haveCHeaders([
  307. 'arpa/inet.h',
  308. 'crypt.h',
  309. 'dlfcn.h',
  310. 'fcntl.h',
  311. 'getopt.h',
  312. 'inttypes.h',
  313. 'linux/random.h',
  314. 'malloc.h',
  315. 'poll.h',
  316. 'pwd.h',
  317. 'stdint.h',
  318. 'stdlib.h',
  319. 'string.h',
  320. 'strings.h',
  321. 'sys/epoll.h',
  322. 'sys/inotify.h',
  323. 'sys/loadavg.h',
  324. 'sys/poll.h',
  325. 'sys/prctl.h',
  326. 'sys/procctl.h',
  327. 'sys/sendfile.h',
  328. 'sys/time.h',
  329. 'sys/wait.h',
  330. 'syslog.h',
  331. 'unistd.h',
  332. 'winsock2.h',
  333. # "have" the last header if we include others before?
  334. ['sys/types.h', 'sys/time.h', 'sys/resource.h'],
  335. ['sys/types.h', 'netinet/in.h'],
  336. ['sys/types.h', 'sys/event.h'],
  337. ['sys/types.h', 'sys/mman.h'],
  338. ['sys/types.h', 'sys/select.h'],
  339. ['sys/types.h', 'sys/socket.h'],
  340. ['sys/types.h', 'sys/uio.h'],
  341. ['sys/types.h', 'sys/un.h'],
  342. ])
  343. autoconf.haveFuncs([
  344. 'arc4random_buf',
  345. 'chroot',
  346. 'clock_gettime',
  347. 'copy_file_range',
  348. 'epoll_ctl',
  349. 'explicit_bzero',
  350. 'explicit_memset',
  351. 'fork',
  352. 'getloadavg',
  353. 'getrlimit',
  354. 'getuid',
  355. 'gmtime_r',
  356. 'inet_aton',
  357. 'inet_pton',
  358. 'issetugid',
  359. 'jrand48',
  360. 'kqueue',
  361. 'localtime_r',
  362. 'lstat',
  363. 'madvise',
  364. 'malloc_trim',
  365. 'mallopt',
  366. 'mempcpy',
  367. 'memset_s',
  368. 'mkostemp',
  369. 'mmap',
  370. 'pipe2',
  371. 'poll',
  372. 'pread',
  373. 'preadv',
  374. 'pwrite',
  375. 'pwritev',
  376. 'select',
  377. 'sendfile',
  378. 'sendfile64',
  379. 'sigaction',
  380. 'signal',
  381. 'splice',
  382. 'srandom',
  383. 'strerror_r',
  384. 'timegm',
  385. 'writev',
  386. ])
  387. autoconf.haveFunc('getentropy', 'sys/random.h')
  388. autoconf.haveFunc('getrandom', 'linux/random.h')
  389. if re.compile("sunos|solaris").search(env['PLATFORM']):
  390. autoconf.haveCHeaders([
  391. 'port.h',
  392. 'priv.h',
  393. 'sys/devpoll.h',
  394. 'sys/filio.h',
  395. ])
  396. autoconf.haveFunc('port_create', 'port.h')
  397. autoconf.haveFunc('sendfilev')
  398. autoconf.haveFunc('setpflags', 'priv.h')
  399. autoconf.haveTypes(Split('pid_t size_t off_t'))
  400. # have crypt_r/crypt, and is -lcrypt needed?
  401. if autoconf.CheckLib('crypt'):
  402. autoconf.env.Append(
  403. LIBCRYPT = 'crypt',
  404. )
  405. with autoconf.restoreEnvLibs():
  406. autoconf.env['LIBS'] = ['crypt']
  407. autoconf.haveFuncs(['crypt', 'crypt_r'])
  408. else:
  409. autoconf.haveFuncs(['crypt', 'crypt_r'])
  410. if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'):
  411. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ])
  412. if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'):
  413. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ])
  414. if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'):
  415. autoconf.env.Append(
  416. CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ],
  417. LIBS = [ 'elftc' ],
  418. )
  419. if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'):
  420. autoconf.env.Append(
  421. CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ],
  422. LIBS = [ 'rt' ],
  423. )
  424. if autoconf.CheckIPv6():
  425. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ])
  426. if autoconf.CheckWeakSymbols():
  427. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ])
  428. if autoconf.CheckGmtOffInStructTm():
  429. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ])
  430. if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'):
  431. autoconf.env.Append(LIBDL = 'dl')
  432. if env['with_bzip2']:
  433. if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'):
  434. fail("Couldn't find bz2")
  435. autoconf.env.Append(
  436. CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ],
  437. LIBBZ2 = 'bz2',
  438. )
  439. if env['with_brotli']:
  440. if not autoconf.CheckParseConfigForLib('LIBBROTLI', 'pkg-config --static --cflags --libs libbrotlienc'):
  441. fail("Couldn't find libbrotlienc")
  442. autoconf.env.Append(
  443. CPPFLAGS = [ '-DHAVE_BROTLI_ENCODE_H', '-DHAVE_BROTLI' ],
  444. )
  445. if env['with_dbi']:
  446. if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'):
  447. fail("Couldn't find dbi")
  448. autoconf.env.Append(
  449. CPPFLAGS = [ '-DHAVE_DBI' ],
  450. LIBDBI = 'dbi',
  451. )
  452. if env['with_fam'] and not autoconf.CheckCHeader('sys/inotify.h'):
  453. if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'):
  454. fail("Couldn't find fam")
  455. autoconf.env.Append(
  456. CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ],
  457. LIBS = [ 'fam' ],
  458. )
  459. autoconf.haveFunc('FAMNoExists')
  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.4', 'lua-5.4', '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_mysql']:
  501. mysql_config = autoconf.checkProgram('mysql', 'mysql_config')
  502. if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'):
  503. fail("Couldn't find mysql")
  504. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL' ])
  505. if env['with_nss']:
  506. nss_config = autoconf.checkProgram('nss', 'nss-config')
  507. if not autoconf.CheckParseConfigForLib('LIBNSS', nss_config + ' --cflags --libs'):
  508. fail("Couldn't find NSS")
  509. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_NSS3_NSS_H' ])
  510. if env['with_openssl']:
  511. if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'):
  512. fail("Couldn't find openssl")
  513. autoconf.env.Append(
  514. CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'],
  515. LIBSSL = 'ssl',
  516. LIBSSLCRYPTO = 'crypto',
  517. LIBCRYPTO = 'crypto',
  518. )
  519. if env['with_wolfssl']:
  520. if type(env['with_wolfssl']) is str:
  521. autoconf.env.AppendUnique(
  522. CPPPATH = [ env['with_wolfssl'] + '/include',
  523. env['with_wolfssl'] + '/include/wolfssl' ],
  524. LIBPATH = [ env['with_wolfssl'] + '/lib' ],
  525. )
  526. if not autoconf.CheckLibWithHeader('wolfssl', 'wolfssl/ssl.h', 'C'):
  527. fail("Couldn't find wolfssl")
  528. autoconf.env.Append(
  529. CPPFLAGS = [ '-DHAVE_WOLFSSL_SSL_H' ],
  530. LIBWOLFSSL= 'wolfssl',
  531. LIBCRYPTO = 'wolfssl',
  532. )
  533. if env['with_mbedtls']:
  534. if not autoconf.CheckLibWithHeader('mbedtls', 'mbedtls/ssl.h', 'C'):
  535. fail("Couldn't find mbedtls")
  536. autoconf.env.Append(
  537. CPPFLAGS = [ '-DHAVE_LIBMBEDCRYPTO' ],
  538. LIBMBEDTLS = 'mbedtls',
  539. LIBMBEDX509 = 'mbedx509',
  540. LIBMBEDCRYPTO = 'mbedcrypto',
  541. LIBCRYPTO = 'mbedcrypto',
  542. )
  543. if env['with_nettle']:
  544. if not autoconf.CheckLibWithHeader('nettle', 'nettle/nettle-types.h', 'C'):
  545. fail("Couldn't find Nettle")
  546. autoconf.env.Append(
  547. CPPFLAGS = [ '-DHAVE_NETTLE_NETTLE_TYPES_H' ],
  548. LIBCRYPTO = 'nettle',
  549. )
  550. if env['with_gnutls']:
  551. if not autoconf.CheckLibWithHeader('gnutls', 'gnutls/crypto.h', 'C'):
  552. fail("Couldn't find gnutls")
  553. autoconf.env.Append(
  554. CPPFLAGS = [ '-DHAVE_GNUTLS_CRYPTO_H' ],
  555. LIBGNUTLS = 'gnutls',
  556. )
  557. if not autoconf.env.exists('LIBCRYPTO'):
  558. autoconf.env.Append(
  559. LIBCRYPTO = 'gnutls',
  560. )
  561. if env['with_pam']:
  562. if not autoconf.CheckLibWithHeader('pam', 'security/pam_appl.h', 'C'):
  563. fail("Couldn't find pam")
  564. autoconf.env.Append(
  565. CPPFLAGS = [ '-DHAVE_PAM' ],
  566. LIBPAM = 'pam',
  567. )
  568. if env['with_pcre2'] and not env['with_pcre']:
  569. pcre2_config = autoconf.checkProgram('pcre2', 'pcre2-config')
  570. if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre2_config + ' --cflags --libs8'):
  571. fail("Couldn't find pcre2")
  572. autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE2_H', '-DHAVE_PCRE' ])
  573. elif 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_PCRE' ])
  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' ])
  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_xxhash']:
  609. if not autoconf.CheckLibWithHeader('xxhash', 'xxhash.h', 'C'):
  610. fail("Couldn't find xxhash")
  611. autoconf.env.Append(
  612. CPPFLAGS = [ '-DHAVE_XXHASH_H' ],
  613. LIBXXHASH = 'xxhash',
  614. )
  615. if env['with_zlib']:
  616. if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'):
  617. fail("Couldn't find zlib")
  618. autoconf.env.Append(
  619. CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ],
  620. LIBZ = 'z',
  621. )
  622. if env['with_zstd']:
  623. if not autoconf.CheckLibWithHeader('zstd', 'zstd.h', 'C'):
  624. fail("Couldn't find zstd")
  625. autoconf.env.Append(
  626. CPPFLAGS = [ '-DHAVE_ZSTD_H', '-DHAVE_ZSTD' ],
  627. LIBZSTD = 'zstd',
  628. )
  629. env = autoconf.Finish()
  630. if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']):
  631. env.Append(COMMON_LIB = 'bin')
  632. elif re.compile("darwin|aix").search(env['PLATFORM']):
  633. env.Append(COMMON_LIB = 'lib')
  634. else:
  635. env.Append(COMMON_LIB = False)
  636. versions = version.split('.')
  637. version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2])
  638. env.Append(CPPFLAGS = [
  639. '-DLIGHTTPD_VERSION_ID=' + hex(version_id),
  640. '-DPACKAGE_NAME=\\"' + package + '\\"',
  641. '-DPACKAGE_VERSION=\\"' + version + '\\"',
  642. '-DLIBRARY_DIR="\\"${libdir}\\""',
  643. ] )
  644. SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0)
  645. SConscript('tests/SConscript', exports = 'env', variant_dir = 'sconsbuild/tests')