diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2017-10-28 22:41:55 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2017-10-28 22:41:55 -0400 |
commit | 735d9757f76cd3e0d01fa4e38cd1ba08c5aaddc7 (patch) | |
tree | 202753e5bd60c7cc1c9bd20840fe6ee422c35259 | |
parent | 3d257ec3a9be4e93ae8ffc117015bd94630a15dc (diff) | |
parent | 3ba68b25d4a5033d10efbb576db2326df970995d (diff) | |
download | lighttpd-git-735d9757f76cd3e0d01fa4e38cd1ba08c5aaddc7.tar.gz |
[scons] Merge branch 'personal/stbuehler/scons-cleanup'
-rw-r--r-- | SConstruct | 772 | ||||
-rw-r--r-- | config.py-sample | 15 | ||||
-rw-r--r-- | src/SConscript | 67 |
3 files changed, 543 insertions, 311 deletions
@@ -1,40 +1,154 @@ import os -import sys import re import string +import sys +from copy import copy from stat import * package = 'lighttpd' version = '1.4.48' -def checkCHeaders(autoconf, hdrs): - p = re.compile('[^A-Z0-9]') - for hdr in hdrs: - if not hdr: - continue - _hdr = Split(hdr) - if autoconf.CheckCHeader(_hdr): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', _hdr[-1].upper()) ]) - -def checkFunc(autoconf, func, header): - p = re.compile('[^A-Z0-9]') - if autoconf.CheckFunc(func, header): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', func.upper()) ]) - -def checkFuncs(autoconf, funcs): - p = re.compile('[^A-Z0-9]') - for func in funcs: - if autoconf.CheckFunc(func): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', func.upper()) ]) - -def checkTypes(autoconf, types): - p = re.compile('[^A-Z0-9]') - for type in types: - if autoconf.CheckType(type, '#include <sys/types.h>'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', type.upper()) ]) - -def checkGmtOffInStructTm(context): - source = """ +underscorify_reg = re.compile('[^A-Z0-9]') +def underscorify(id): + return underscorify_reg.sub('_', id.upper()) + +def fail(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + env.Exit(-1) + +class Autoconf: + class RestoreEnvLibs: + def __init__(self, env): + self.env = env + self.active = False + + def __enter__(self): + if self.active: + raise Exception('entered twice') + self.active = True + if 'LIBS' in self.env: + #print("Backup LIBS: " + repr(self.env['LIBS'])) + self.empty = False + self.backup_libs = copy(self.env['LIBS']) + else: + #print("No LIBS to backup") + self.empty = True + + def __exit__(self, type, value, traceback): + if not self.active: + raise Exception('exited twice') + self.active = False + if self.empty: + if 'LIBS' in self.env: + del self.env['LIBS'] + else: + #print("Restoring LIBS, now: " + repr(self.env['LIBS'])) + self.env['LIBS'] = self.backup_libs + #print("Restoring LIBS, to: " + repr(self.env['LIBS'])) + + def __init__(self, env): + self.conf = Configure(env, custom_tests = { + 'CheckGmtOffInStructTm': Autoconf.__checkGmtOffInStructTm, + 'CheckIPv6': Autoconf.__checkIPv6, + 'CheckWeakSymbols': Autoconf.__checkWeakSymbols, + }) + + def append(self, *args, **kw): + return self.conf.env.Append(*args, **kw) + + def Finish(self): + return self.conf.Finish() + + @property + def env(self): + return self.conf.env + + def restoreEnvLibs(self): + return Autoconf.RestoreEnvLibs(self.conf.env) + + def CheckType(self, *args, **kw): + return self.conf.CheckType(*args, **kw) + + def CheckLib(self, *args, **kw): + return self.conf.CheckLib(*args, autoadd = 0, **kw) + + def CheckLibWithHeader(self, *args, **kw): + return self.conf.CheckLibWithHeader(*args, autoadd = 0, **kw) + + def CheckGmtOffInStructTm(self): + return self.conf.CheckGmtOffInStructTm() + + def CheckIPv6(self): + return self.conf.CheckIPv6() + + def CheckWeakSymbols(self): + return self.conf.CheckWeakSymbols() + + def CheckCHeader(self, hdr): + return self.conf.CheckCHeader(hdr) + + def haveCHeader(self, hdr): + if self.CheckCHeader(hdr): + # if we have a list of headers define HAVE_ only for last one + target = hdr + if not isinstance(target, basestring): + target = target[-1] + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(target) ]) + return True + return False + + def haveCHeaders(self, hdrs): + for hdr in hdrs: + self.haveCHeader(hdr) + + def CheckFunc(self, func, header = None, libs = []): + with self.restoreEnvLibs(): + self.env.Append(LIBS = libs) + return self.conf.CheckFunc(func, header = header) + + def CheckFuncInLib(self, func, lib): + return self.CheckFunc(func, libs = [lib]) + + def haveFuncInLib(self, func, lib): + if self.CheckFuncInLib(func, lib): + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ]) + return True + return False + + def haveFunc(self, func, header = None, libs = []): + if self.CheckFunc(func, header = header, libs = libs): + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ]) + return True + return False + + def haveFuncs(self, funcs): + for func in funcs: + self.haveFunc(func) + + def haveTypes(self, types): + for type in types: + if self.conf.CheckType(type, '#include <sys/types.h>'): + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(type) ]) + + def CheckParseConfig(self, *args, **kw): + try: + self.conf.env.ParseConfig(*args, **kw) + return True + except Exception as e: + print(e.message, file=sys.stderr) + return False + + def CheckParseConfigForLib(self, lib, *args, **kw): + with self.restoreEnvLibs(): + self.env['LIBS'] = [] + if not self.CheckParseConfig(*args, **kw): + return False + self.env.Append(**{lib: self.env['LIBS']}) + return True + + @staticmethod + def __checkGmtOffInStructTm(context): + source = """ #include <time.h> int main() { struct tm a; @@ -42,14 +156,15 @@ int main() { return 0; } """ - context.Message('Checking for tm_gmtoff in struct tm...') - result = context.TryLink(source, '.c') - context.Result(result) + context.Message('Checking for tm_gmtoff in struct tm...') + result = context.TryLink(source, '.c') + context.Result(result) - return result + return result -def checkIPv6(context): - source = """ + @staticmethod + def __checkIPv6(context): + source = """ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -59,81 +174,87 @@ int main() { return 0; } """ - context.Message('Checking for IPv6 support...') - result = context.TryLink(source, '.c') - context.Result(result) + context.Message('Checking for IPv6 support...') + result = context.TryLink(source, '.c') + context.Result(result) - return result + return result -def checkWeakSymbols(context): - source = """ + @staticmethod + def __checkWeakSymbols(context): + source = """ __attribute__((weak)) void __dummy(void *x) { } int main() { void *x; __dummy(x); } """ - context.Message('Checking for weak symbol support...') - result = context.TryLink(source, '.c') - context.Result(result) + context.Message('Checking for weak symbol support...') + result = context.TryLink(source, '.c') + context.Result(result) - return result + return result -def checkProgram(env, withname, progname): - withname = 'with_' + withname - binpath = None + def checkProgram(self, withname, progname): + withname = 'with_' + withname + binpath = None - if env[withname] != 1: - binpath = env[withname] - else: - prog = env.Detect(progname) - if prog: - binpath = env.WhereIs(prog) + if self.env[withname] != 1: + binpath = self.env[withname] + else: + prog = self.env.Detect(progname) + if prog: + binpath = self.env.WhereIs(prog) - if binpath: - mode = os.stat(binpath)[ST_MODE] - if S_ISDIR(mode): - print >> sys.stderr, "* error: path `%s' is a directory" % (binpath) - env.Exit(-1) - if not S_ISREG(mode): - print >> sys.stderr, "* error: path `%s' is not a file or not exists" % (binpath) - env.Exit(-1) + if binpath: + mode = os.stat(binpath)[ST_MODE] + if S_ISDIR(mode): + fail("* error: path `%s' is a directory" % (binpath)) + if not S_ISREG(mode): + fail("* error: path `%s' is not a file or not exists" % (binpath)) - if not binpath: - print >> sys.stderr, "* error: can't find program `%s'" % (progname) - env.Exit(-1) + if not binpath: + fail("* error: can't find program `%s'" % (progname)) - return binpath + return binpath VariantDir('sconsbuild/build', 'src', duplicate = 0) VariantDir('sconsbuild/tests', 'tests', duplicate = 0) -vars = Variables() #('config.py') +vars = Variables() vars.AddVariables( ('prefix', 'prefix', '/usr/local'), ('bindir', 'binary directory', '${prefix}/bin'), ('sbindir', 'binary directory', '${prefix}/sbin'), ('libdir', 'library directory', '${prefix}/lib'), - PackageVariable('with_mysql', 'enable mysql support', 'no'), - PackageVariable('with_pgsql', 'enable pgsql support', 'no'), - PackageVariable('with_dbi', 'enable dbi support', 'no'), - PackageVariable('with_xml', 'enable xml support', 'no'), - PackageVariable('with_pcre', 'enable pcre support', 'yes'), PathVariable('CC', 'path to the c-compiler', None), BoolVariable('build_dynamic', 'enable dynamic build', 'yes'), BoolVariable('build_static', 'enable static build', 'no'), BoolVariable('build_fullstatic', 'enable fullstatic build', 'no'), - BoolVariable('with_sqlite3', 'enable sqlite3 support', 'no'), - BoolVariable('with_memcached', 'enable memcached support', 'no'), - BoolVariable('with_gdbm', 'enable gdbm support', 'no'), - BoolVariable('with_fam', 'enable FAM/gamin support', 'no'), - BoolVariable('with_openssl', 'enable openssl support', 'no'), - BoolVariable('with_gzip', 'enable gzip compression', 'no'), + BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'), - BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'), - BoolVariable('with_ldap', 'enable ldap auth support', 'no'), + PackageVariable('with_dbi', 'enable dbi support', 'no'), + BoolVariable('with_fam', 'enable FAM/gamin support', 'no'), + BoolVariable('with_gdbm', 'enable gdbm support', 'no'), + BoolVariable('with_geoip', 'enable GeoIP support', 'no'), BoolVariable('with_krb5', 'enable krb5 auth support', 'no'), - BoolVariable('with_geoip', 'enable GeoIP support', 'no') + BoolVariable('with_ldap', 'enable ldap auth support', 'no'), + # with_libev not supported + # with_libunwind not supported + BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'), + BoolVariable('with_memcached', 'enable memcached support', 'no'), + PackageVariable('with_mysql', 'enable mysql support', 'no'), + BoolVariable('with_openssl', 'enable openssl support', 'no'), + PackageVariable('with_pcre', 'enable pcre support', 'yes'), + PackageVariable('with_pgsql', 'enable pgsql support', 'no'), + BoolVariable('with_sqlite3', 'enable sqlite3 support (required for webdav props)', 'no'), + BoolVariable('with_uuid', 'enable uuid support (required for webdav locks)', 'no'), + # with_valgrind not supported + # with_xattr not supported + PackageVariable('with_xml', 'enable xml support (required for webdav props)', 'no'), + BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'), + + BoolVariable('with_all', 'enable all with_* features', 'no'), ) env = Environment( @@ -153,13 +274,25 @@ if env['CC'] == 'gcc': ## we need x-open 6 and bsd 4.3 features env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) +env.Append(CPPFLAGS = [ + '-D_FILE_OFFSET_BITS=64', + '-D_LARGEFILE_SOURCE', + '-D_LARGE_FILES', + '-D_GNU_SOURCE', +]) + +if env['with_all']: + for feature in vars.keys(): + # only enable 'with_*' flags + if not feature.startswith('with_'): continue + # don't overwrite manual arguments + if feature in vars.args: continue + # now activate + env[feature] = True + # cache configure checks if 1: - autoconf = Configure(env, custom_tests = { - 'CheckGmtOffInStructTm': checkGmtOffInStructTm, - 'CheckIPv6': checkIPv6, - 'CheckWeakSymbols': checkWeakSymbols, - }) + autoconf = Autoconf(env) if 'CFLAGS' in os.environ: autoconf.env.Append(CCFLAGS = os.environ['CFLAGS']) @@ -175,212 +308,314 @@ if 1: else: autoconf.env.Append(APPEND_LIBS = '') - autoconf.headerfile = "foo.h" - checkCHeaders(autoconf, string.split(""" - arpa/inet.h - crypt.h - fcntl.h - getopt.h - inttypes.h - linux/random.h - netinet/in.h - poll.h - pwd.h - stdint.h - stdlib.h - string.h - strings.h - sys/devpoll.h - sys/epoll.h - sys/event.h - sys/filio.h - sys/mman.h - sys/poll.h - sys/port.h - sys/prctl.h - sys/resource.h - sys/select.h - sys/sendfile.h - sys/socket.h - sys/time.h - sys/time.h sys/types.h sys/resource.h - sys/types.h netinet/in.h - sys/types.h sys/event.h - sys/types.h sys/mman.h - sys/types.h sys/select.h - sys/types.h sys/socket.h - sys/types.h sys/uio.h - sys/types.h sys/un.h - sys/uio.h - sys/un.h - sys/wait.h - syslog.h - unistd.h - winsock2.h""", "\n")) - - checkFuncs(autoconf, Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \ - strdup strerror strstr strtol sendfile getopt socket \ - gethostbyname poll epoll_ctl getrlimit chroot \ - getuid select signal pathconf madvise prctl\ - writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton \ - memset_s explicit_bzero clock_gettime pipe2 \ - arc4random_buf jrand48 srandom getloadavg')) - checkFunc(autoconf, 'getentropy', 'sys/random.h') - checkFunc(autoconf, 'getrandom', 'linux/random.h') - - checkTypes(autoconf, Split('pid_t size_t off_t')) - - autoconf.env.Append( LIBSQLITE3 = '', LIBXML2 = '', LIBMYSQL = '', LIBZ = '', - LIBPGSQL = '', LIBDBI = '', - LIBBZ2 = '', LIBCRYPT = '', LIBMEMCACHED = '', LIBFCGI = '', LIBPCRE = '', - LIBLDAP = '', LIBLBER = '', LIBLUA = '', LIBDL = '', LIBUUID = '', - LIBKRB5 = '', LIBGSSAPI_KRB5 = '', LIBGDBM = '', LIBSSL = '', LIBCRYPTO = '') - - if env['with_fam']: - if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = 'fam') - checkFuncs(autoconf, ['FAMNoExists']); - + autoconf.env.Append( + LIBBZ2 = '', + LIBCRYPT = '', + LIBCRYPTO = '', + LIBDBI = '', + LIBDL = '', + LIBFCGI = '', + LIBGDBM = '', + LIBGSSAPI_KRB5 = '', + LIBKRB5 = '', + LIBLBER = '', + LIBLDAP = '', + LIBLUA = '', + LIBMEMCACHED = '', + LIBMYSQL = '', + LIBPCRE = '', + LIBPGSQL = '', + LIBSQLITE3 = '', + LIBSSL = '', + LIBUUID = '', + LIBXML2 = '', + LIBZ = '', + ) + + autoconf.haveCHeaders([ + 'arpa/inet.h', + 'crypt.h', + 'fcntl.h', + 'getopt.h', + 'inttypes.h', + 'linux/random.h', + 'netinet/in.h', + 'poll.h', + 'pwd.h', + 'stdint.h', + 'stdlib.h', + 'string.h', + 'strings.h', + 'sys/devpoll.h', + 'sys/epoll.h', + 'sys/event.h', + 'sys/filio.h', + 'sys/mman.h', + 'sys/poll.h', + 'sys/port.h', + 'sys/prctl.h', + 'sys/resource.h', + 'sys/select.h', + 'sys/sendfile.h', + 'sys/socket.h', + 'sys/time.h', + 'sys/uio.h', + 'sys/un.h', + 'sys/wait.h', + 'syslog.h', + 'unistd.h', + 'winsock2.h', + + # "have" the last header if we include others before? + ['sys/time.h', 'sys/types.h', 'sys/resource.h'], + ['sys/types.h', 'netinet/in.h'], + ['sys/types.h', 'sys/event.h'], + ['sys/types.h', 'sys/mman.h'], + ['sys/types.h', 'sys/select.h'], + ['sys/types.h', 'sys/socket.h'], + ['sys/types.h', 'sys/uio.h'], + ['sys/types.h', 'sys/un.h'], + ]) + + autoconf.haveFuncs([ + 'arc4random_buf', + 'chroot', + 'clock_gettime', + 'dup2', + 'epoll_ctl', + 'explicit_bzero', + 'fork', + 'getcwd', + 'gethostbyname', + 'getloadavg', + 'getopt', + 'getrlimit', + 'getuid', + 'inet_ntoa', + 'inet_ntop', + 'inet_pton', + 'issetugid', + 'jrand48', + 'kqueue', + 'localtime_r', + 'lstat', + 'madvise', + 'memset_s', + 'memset', + 'mmap', + 'munmap', + 'pathconf', + 'pipe2', + 'poll', + 'port_create', + 'posix_fadvise', + 'prctl', + 'select', + 'send_file', + 'sendfile', + 'sendfile64', + 'sigaction', + 'signal', + 'socket', + 'srandom', + 'stat', + 'strchr', + 'strdup', + 'strerror', + 'strftime', + 'strstr', + 'strtol', + 'writev', + ]) + autoconf.haveFunc('getentropy', 'sys/random.h') + autoconf.haveFunc('getrandom', 'linux/random.h') + + autoconf.haveTypes(Split('pid_t size_t off_t')) + + # have crypt_r/crypt, and is -lcrypt needed? if autoconf.CheckLib('crypt'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') - oldlib = env['LIBS'] - env['LIBS'] += ['crypt'] - checkFuncs(autoconf, ['crypt', 'crypt_r']); - env['LIBS'] = oldlib + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], + LIBCRYPT = 'crypt', + ) + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = ['crypt'] + autoconf.haveFuncs(['crypt', 'crypt_r']) else: - checkFuncs(autoconf, ['crypt', 'crypt_r']); + autoconf.haveFuncs(['crypt', 'crypt_r']) + + if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) + + if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], LIBS = [ 'rt' ]) + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], + LIBS = [ 'rt' ], + ) - if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') + if autoconf.CheckIPv6(): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) - if env['with_openssl']: - if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto', LIBS = [ 'crypto' ]) + if autoconf.CheckWeakSymbols(): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) - if env['with_gzip']: - if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') + if autoconf.CheckGmtOffInStructTm(): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) - if env['with_krb5']: - if autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_KRB5' ], LIBKRB5 = 'krb5') - if autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): - autoconf.env.Append(LIBGSSAPI_KRB5 = 'gssapi_krb5') + if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): + autoconf.env.Append(LIBDL = 'dl') - if env['with_ldap']: - if autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') - if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') + # used in tests if present + if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'): + autoconf.env.Append(LIBFCGI = 'fcgi') if env['with_bzip2']: - if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') + if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): + fail("Couldn't find bz2") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], + LIBBZ2 = 'bz2', + ) + + if env['with_dbi']: + if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): + fail("Couldn't find dbi") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], + LIBDBI = 'dbi', + ) - if env['with_memcached']: - if autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') + if env['with_fam']: + if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): + fail("Couldn't find fam") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], + LIBS = [ 'fam' ], + ) + autoconf.haveFunc('FAMNoExists') if env['with_gdbm']: - if autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') - - if env['with_sqlite3']: - if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') + if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): + fail("Couldn't find gdbm") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], + LIBGDBM = 'gdbm', + ) if env['with_geoip']: - if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') + if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): + fail("Couldn't find geoip") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_GEOIP' ], + LIBGEOIP = 'GeoIP', + ) - ol = env['LIBS'] - if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'): - autoconf.env.Append(LIBFCGI = 'fcgi') - env['LIBS'] = ol - - ol = env['LIBS'] - if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): - autoconf.env.Append(LIBDL = 'dl') - env['LIBS'] = ol - - if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) + if env['with_krb5']: + if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): + fail("Couldn't find krb5") + if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): + fail("Couldn't find gssapi_krb5") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_KRB5' ], + LIBKRB5 = 'krb5', + LIBGSSAPI_KRB5 = 'gssapi_krb5', + ) - if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) + if env['with_ldap']: + if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): + fail("Couldn't find ldap") + if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): + fail("Couldn't find lber") + autoconf.env.Append( + CPPFLAGS = [ + '-DLDAP_DEPRECATED=1', + '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP', + '-DHAVE_LBER_H', '-DHAVE_LIBLBER', + ], + LIBLDAP = 'ldap', + LIBLBER = 'lber', + ) + + if env['with_lua']: + found_lua = False + for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: + print("Searching for lua: " + lua_name + " >= 5.0") + if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) + found_lua = True + break + if not found_lua: + fail("Couldn't find any lua implementation") - if autoconf.CheckGmtOffInStructTm(): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) + if env['with_memcached']: + if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): + fail("Couldn't find memcached") + autoconf.env.Append( + CPPFLAGS = [ '-DUSE_MEMCACHED' ], + LIBMEMCACHED = 'memcached', + ) + + if env['with_mysql']: + mysql_config = autoconf.checkProgram('mysql', 'mysql_config') + if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'): + fail("Couldn't find mysql") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ]) - if autoconf.CheckIPv6(): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) + if env['with_openssl']: + if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): + fail("Couldn't find openssl") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'], + LIBSSL = 'ssl', + LIBCRYPTO = 'crypto', + ) + + if env['with_pcre']: + pcre_config = autoconf.checkProgram('pcre', 'pcre-config') + if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'): + fail("Couldn't find pcre") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ]) + + if env['with_pgsql']: + if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'): + fail("Couldn't find libpq") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ]) - if autoconf.CheckWeakSymbols(): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) + if env['with_sqlite3']: + if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): + fail("Couldn't find sqlite3") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], + LIBSQLITE3 = 'sqlite3', + ) + + if env['with_uuid']: + if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): + fail("Couldn't find uuid") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], + LIBUUID = 'uuid', + ) + + if env['with_xml']: + xml2_config = autoconf.checkProgram('xml', 'xml2-config') + if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'): + fail("Couldn't find xml2") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ]) + + if env['with_zlib']: + if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): + fail("Couldn't find zlib") + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], + LIBZ = 'z', + ) env = autoconf.Finish() -def TryLua(env, name): - result = False - oldlibs = env['LIBS'] - try: - print("Searching for lua: " + name + " >= 5.0") - env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") - env.Append(LIBLUA = env['LIBS'][len(oldlibs):]) - env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) - result = True - except: - pass - env['LIBS'] = oldlibs - return result - -if env['with_lua']: - found_lua = False - for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: - if TryLua(env, lua_name): - found_lua = True - break - if not found_lua: - raise RuntimeError("Couldn't find any lua implementation") - -if env['with_pcre']: - pcre_config = checkProgram(env, 'pcre', 'pcre-config') - env.ParseConfig(pcre_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = 'pcre') - -if env['with_xml']: - xml2_config = checkProgram(env, 'xml', 'xml2-config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(xml2_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = env['LIBS']) - env['LIBS'] = oldlib - -if env['with_mysql']: - mysql_config = checkProgram(env, 'mysql', 'mysql_config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(mysql_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') - env['LIBS'] = oldlib - -if env['with_pgsql']: - pg_config = checkProgram(env, 'pgsql', 'pg_config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(pg_config + ' --includedir --libdir') - env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') - env['LIBS'] = oldlib - #if autoconf.CheckLibWithHeader('pq', 'libpq-fe.h', 'C'): - # env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') - -if env['with_dbi']: - if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): - env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') - if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']): env.Append(COMMON_LIB = 'bin') elif re.compile("darwin|aix").search(env['PLATFORM']): @@ -395,7 +630,6 @@ env.Append(CPPFLAGS = [ '-DPACKAGE_NAME=\\"' + package + '\\"', '-DPACKAGE_VERSION=\\"' + version + '\\"', '-DLIBRARY_DIR="\\"${libdir}\\""', - '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-D_LARGE_FILES' ] ) SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0) diff --git a/config.py-sample b/config.py-sample deleted file mode 100644 index d97ae534..00000000 --- a/config.py-sample +++ /dev/null @@ -1,15 +0,0 @@ -prefix='/home/jan/testbase/lighttpd-scons' -with_mysql='/usr/local/mysql/bin/mysql_config' -with_pcre='yes' -with_openssl='yes' -with_gzip='yes' -with_bzip2='yes' -with_memcache='yes' -with_sqlite3='yes' -with_xml='yes' -# default 'no' -build_static='no' -# default 'no' -build_fullstatic='no' -# default 'yes' -build_dynamic='yes' diff --git a/src/SConscript b/src/SConscript index 3665e45d..4c2ba11a 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,8 +1,9 @@ +import itertools import os import re import types -import itertools from collections import OrderedDict +from copy import copy # search any file, not just executables def WhereIsFile(file, paths): @@ -93,37 +94,37 @@ mod_ssi_exprparser = Lemon(env, 'mod_ssi_exprparser.y') ## the modules and how they are built modules = { 'mod_access' : { 'src' : [ 'mod_access.c' ] }, + 'mod_accesslog' : { 'src' : [ 'mod_accesslog.c' ] }, 'mod_alias' : { 'src' : [ 'mod_alias.c' ] }, + 'mod_auth' : { 'src' : [ 'mod_auth.c' ] }, + 'mod_authn_file' : { 'src' : [ 'mod_authn_file.c' ], 'lib' : [ env['LIBCRYPT'], env['LIBCRYPTO'] ] }, 'mod_cgi' : { 'src' : [ 'mod_cgi.c' ] }, - 'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] }, - 'mod_scgi' : { 'src' : [ 'mod_scgi.c' ] }, - 'mod_extforward' : { 'src' : [ 'mod_extforward.c' ] }, - 'mod_staticfile' : { 'src' : [ 'mod_staticfile.c' ] }, + 'mod_compress' : { 'src' : [ 'mod_compress.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, + 'mod_deflate' : { 'src' : [ 'mod_deflate.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, 'mod_dirlisting' : { 'src' : [ 'mod_dirlisting.c' ], 'lib' : [ env['LIBPCRE'] ] }, + 'mod_evasive' : { 'src' : [ 'mod_evasive.c' ] }, + 'mod_evhost' : { 'src' : [ 'mod_evhost.c' ] }, + 'mod_expire' : { 'src' : [ 'mod_expire.c' ] }, + 'mod_extforward' : { 'src' : [ 'mod_extforward.c' ] }, + 'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] }, + 'mod_flv_streaming' : { 'src' : [ 'mod_flv_streaming.c' ] }, 'mod_indexfile' : { 'src' : [ 'mod_indexfile.c' ] }, - 'mod_setenv' : { 'src' : [ 'mod_setenv.c' ] }, - 'mod_rrdtool' : { 'src' : [ 'mod_rrdtool.c' ] }, - 'mod_usertrack' : { 'src' : [ 'mod_usertrack.c' ] }, 'mod_proxy' : { 'src' : [ 'mod_proxy.c' ] }, - 'mod_userdir' : { 'src' : [ 'mod_userdir.c' ] }, + 'mod_redirect' : { 'src' : [ 'mod_redirect.c' ], 'lib' : [ env['LIBPCRE'] ] }, + 'mod_rewrite' : { 'src' : [ 'mod_rewrite.c' ], 'lib' : [ env['LIBPCRE'] ] }, + 'mod_rrdtool' : { 'src' : [ 'mod_rrdtool.c' ] }, + 'mod_scgi' : { 'src' : [ 'mod_scgi.c' ] }, 'mod_secdownload' : { 'src' : [ 'mod_secdownload.c' ], 'lib' : [ env['LIBCRYPTO'] ] }, - 'mod_accesslog' : { 'src' : [ 'mod_accesslog.c' ] }, + 'mod_setenv' : { 'src' : [ 'mod_setenv.c' ] }, 'mod_simple_vhost' : { 'src' : [ 'mod_simple_vhost.c' ] }, - 'mod_evhost' : { 'src' : [ 'mod_evhost.c' ] }, - 'mod_expire' : { 'src' : [ 'mod_expire.c' ] }, + 'mod_ssi' : { 'src' : [ 'mod_ssi_exprparser.c', 'mod_ssi_expr.c', 'mod_ssi.c' ] }, + 'mod_staticfile' : { 'src' : [ 'mod_staticfile.c' ] }, 'mod_status' : { 'src' : [ 'mod_status.c' ] }, - 'mod_compress' : { 'src' : [ 'mod_compress.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, - 'mod_deflate' : { 'src' : [ 'mod_deflate.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, - 'mod_redirect' : { 'src' : [ 'mod_redirect.c' ], 'lib' : [ env['LIBPCRE'] ] }, - 'mod_rewrite' : { 'src' : [ 'mod_rewrite.c' ], 'lib' : [ env['LIBPCRE'] ] }, - 'mod_auth' : { 'src' : [ 'mod_auth.c' ] }, - 'mod_authn_file' : { 'src' : [ 'mod_authn_file.c' ], 'lib' : [ env['LIBCRYPT'], env['LIBCRYPTO'] ] }, - 'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, 'mod_uploadprogress' : { 'src' : [ 'mod_uploadprogress.c' ] }, - 'mod_evasive' : { 'src' : [ 'mod_evasive.c' ] }, - 'mod_ssi' : { 'src' : [ 'mod_ssi_exprparser.c', 'mod_ssi_expr.c', 'mod_ssi.c' ] }, - 'mod_flv_streaming' : { 'src' : [ 'mod_flv_streaming.c' ] }, + 'mod_userdir' : { 'src' : [ 'mod_userdir.c' ] }, + 'mod_usertrack' : { 'src' : [ 'mod_usertrack.c' ] }, 'mod_vhostdb' : { 'src' : [ 'mod_vhostdb.c' ] }, + 'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, 'mod_wstunnel' : { 'src' : [ 'mod_wstunnel.c' ], 'lib' : [ env['LIBCRYPTO'] ] }, } @@ -141,11 +142,11 @@ if env['with_lua']: modules['mod_magnet'] = { 'src' : [ 'mod_magnet.c', 'mod_magnet_cache.c' ], 'lib' : [ env['LIBLUA'] ] } modules['mod_cml'] = { 'src' : [ 'mod_cml_lua.c', 'mod_cml.c', 'mod_cml_funcs.c' ], - 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'], env['LIBLUA'] ] + 'lib' : [ env['LIBMEMCACHED'], env['LIBLUA'] ] } if env['with_pcre'] and (env['with_memcached'] or env['with_gdbm']): - modules['mod_trigger_b4_dl'] = { 'src' : [ 'mod_trigger_b4_dl.c' ], 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'] ] } + modules['mod_trigger_b4_dl'] = { 'src' : [ 'mod_trigger_b4_dl.c' ], 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'], env['LIBGDBM'] ] } if env['with_mysql']: modules['mod_authn_mysql'] = { 'src' : [ 'mod_authn_mysql.c' ], 'lib' : [ env['LIBCRYPT'], env['LIBMYSQL'] ] } @@ -166,7 +167,7 @@ staticenv = env.Clone(CPPFLAGS=[ env['CPPFLAGS'], '-DLIGHTTPD_STATIC' ]) ## all the core-sources + the modules staticsrc = src + common_src -staticlib = env['LIBS'] +staticlib = copy(env['LIBS']) staticinit = '' for module in modules.keys(): staticsrc += modules[module]['src'] @@ -244,6 +245,10 @@ fullstatic_libs = GatherLibs(env, fullstaticlib) fullstatic_linkflags = [staticenv['LINKFLAGS'], '-static'] if (('pthread' in fullstatic_libs) or ('pcre' in fullstatic_libs)) and (platform.system() == 'Linux'): fullstatic_linkflags += ['-Wl,--whole-archive','-lpthread','-Wl,--no-whole-archive'] + fullstatic_libs.remove('pthread') +if 'gcc_s' in fullstatic_libs: + fullstatic_linkflags += ['-static-libgcc'] + fullstatic_libs.remove('gcc_s') ## includes all modules, linked statically fullstaticbin = staticenv.Program('../fullstatic/build/lighttpd', @@ -269,7 +274,15 @@ else: else: bin_linkflags += [ '-Wl,--export-dynamic' ] -instbin = env.Program(bin_targets, src, LINKFLAGS = bin_linkflags, LIBS = GatherLibs(env, env['LIBS'], common_lib, env['LIBDL'])) +instbin = env.Program(bin_targets, src, LINKFLAGS = bin_linkflags, + LIBS = GatherLibs( + env, + common_lib, + env['LIBCRYPTO'], + env['LIBDL'], + env['LIBPCRE'], + ) +) env.Depends(instbin, configparser) if env['COMMON_LIB'] == 'bin': @@ -281,7 +294,7 @@ for module in modules.keys(): libs = [ common_lib ] if modules[module].has_key('lib'): libs += modules[module]['lib'] - instlib += env.SharedLibrary(module, modules[module]['src'], LIBS= GatherLibs(env, libs)) + instlib += env.SharedLibrary(module, modules[module]['src'], LIBS = GatherLibs(env, libs)) env.Alias('modules', instlib) inst = [] |