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