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.

651 lines
17 KiB

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