2005-09-24 12:07:57 +00:00
|
|
|
import os
|
2005-10-01 12:35:55 +00:00
|
|
|
import sys
|
2005-09-24 12:07:57 +00:00
|
|
|
import re
|
2005-10-01 12:35:55 +00:00
|
|
|
import string
|
|
|
|
from stat import *
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
package = 'lighttpd'
|
2014-04-02 10:04:09 +00:00
|
|
|
version = '1.4.36'
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
def checkCHeaders(autoconf, hdrs):
|
|
|
|
p = re.compile('[^A-Z0-9]')
|
|
|
|
for hdr in hdrs:
|
2006-10-04 13:26:23 +00:00
|
|
|
if not hdr:
|
2005-10-18 16:21:34 +00:00
|
|
|
continue
|
|
|
|
_hdr = Split(hdr)
|
|
|
|
if autoconf.CheckCHeader(_hdr):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', _hdr[-1].upper()) ])
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
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()) ])
|
|
|
|
|
2005-10-01 12:35:55 +00:00
|
|
|
def checkProgram(env, 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 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 not binpath:
|
|
|
|
print >> sys.stderr, "* error: can't find program `%s'" % (progname)
|
|
|
|
env.Exit(-1)
|
|
|
|
|
|
|
|
return binpath
|
2005-09-24 12:07:57 +00:00
|
|
|
|
2005-10-26 11:23:07 +00:00
|
|
|
def checkStructMember(context):
|
|
|
|
struct_member = """
|
|
|
|
#include <time.h>
|
|
|
|
int main() {
|
|
|
|
struct tm a;
|
|
|
|
a.tm_gmtoff = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
context.Message('Checking for tm_gmtoff in struct tm...')
|
|
|
|
result = context.TryLink(struct_member, '.c')
|
|
|
|
context.Result(result)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
BuildDir('build', 'src', duplicate = 0)
|
|
|
|
|
|
|
|
opts = Options('config.py')
|
|
|
|
opts.AddOptions(
|
|
|
|
('prefix', 'prefix', '/usr/local'),
|
|
|
|
('bindir', 'binary directory', '${prefix}/bin'),
|
2006-01-07 10:10:17 +00:00
|
|
|
('sbindir', 'binary directory', '${prefix}/sbin'),
|
2005-09-24 12:07:57 +00:00
|
|
|
('libdir', 'library directory', '${prefix}/lib'),
|
|
|
|
PackageOption('with_mysql', 'enable mysql support', 'no'),
|
|
|
|
PackageOption('with_xml', 'enable xml support', 'no'),
|
|
|
|
PackageOption('with_pcre', 'enable pcre support', 'yes'),
|
2006-01-20 19:42:33 +00:00
|
|
|
PathOption('CC', 'path to the c-compiler', None),
|
2006-01-07 10:10:17 +00:00
|
|
|
BoolOption('build_dynamic', 'enable dynamic build', 'yes'),
|
|
|
|
BoolOption('build_static', 'enable static build', 'no'),
|
|
|
|
BoolOption('build_fullstatic', 'enable fullstatic build', 'no'),
|
2005-09-24 12:07:57 +00:00
|
|
|
BoolOption('with_sqlite3', 'enable sqlite3 support', 'no'),
|
|
|
|
BoolOption('with_memcache', 'enable memcache support', 'no'),
|
|
|
|
BoolOption('with_fam', 'enable FAM/gamin support', 'no'),
|
|
|
|
BoolOption('with_openssl', 'enable memcache support', 'no'),
|
|
|
|
BoolOption('with_gzip', 'enable gzip compression', 'no'),
|
2005-11-15 10:32:15 +00:00
|
|
|
BoolOption('with_bzip2', 'enable bzip2 compression', 'no'),
|
2005-11-18 11:59:48 +00:00
|
|
|
BoolOption('with_lua', 'enable lua support for mod_cml', 'no'),
|
|
|
|
BoolOption('with_ldap', 'enable ldap auth support', 'no'))
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
env = Environment(
|
|
|
|
env = os.environ,
|
|
|
|
options = opts,
|
2006-01-31 13:20:10 +00:00
|
|
|
CPPPATH = Split('#build')
|
2005-09-24 12:07:57 +00:00
|
|
|
)
|
|
|
|
|
2006-01-20 19:42:33 +00:00
|
|
|
env.Help(opts.GenerateHelpText(env))
|
|
|
|
|
|
|
|
if env.subst('${CC}') is not '':
|
|
|
|
env['CC'] = env.subst('${CC}')
|
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
env['package'] = package
|
|
|
|
env['version'] = version
|
2005-11-18 13:27:17 +00:00
|
|
|
if env['CC'] == 'gcc':
|
2006-01-31 13:20:10 +00:00
|
|
|
## we need x-open 6 and bsd 4.3 features
|
2006-02-14 16:10:14 +00:00
|
|
|
env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99'))
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
# cache configure checks
|
|
|
|
if 1:
|
2005-10-26 11:23:07 +00:00
|
|
|
autoconf = Configure(env, custom_tests = {'CheckStructMember': checkStructMember })
|
|
|
|
autoconf.headerfile = "foo.h"
|
2005-10-18 16:21:34 +00:00
|
|
|
checkCHeaders(autoconf, string.split("""
|
2006-10-04 13:26:23 +00:00
|
|
|
arpa/inet.h
|
|
|
|
fcntl.h
|
|
|
|
netinet/in.h
|
|
|
|
sys/types.h netinet/in.h
|
|
|
|
stdlib.h
|
2005-10-18 16:21:34 +00:00
|
|
|
string.h
|
|
|
|
sys/socket.h
|
|
|
|
sys/types.h sys/socket.h
|
2006-10-04 13:26:23 +00:00
|
|
|
sys/time.h
|
|
|
|
unistd.h
|
|
|
|
sys/sendfile.h
|
|
|
|
sys/uio.h
|
|
|
|
sys/types.h sys/uio.h
|
|
|
|
getopt.h
|
|
|
|
sys/epoll.h
|
|
|
|
sys/select.h
|
|
|
|
sys/types.h sys/select.h
|
|
|
|
poll.h
|
2005-10-18 16:21:34 +00:00
|
|
|
sys/poll.h
|
2006-10-04 13:26:23 +00:00
|
|
|
sys/devpoll.h
|
2005-10-18 16:21:34 +00:00
|
|
|
sys/filio.h
|
|
|
|
sys/mman.h
|
|
|
|
sys/types.h sys/mman.h
|
|
|
|
sys/event.h
|
|
|
|
sys/types.h sys/event.h
|
|
|
|
sys/port.h
|
|
|
|
winsock2.h
|
|
|
|
pwd.h
|
|
|
|
sys/syslimits.h
|
|
|
|
sys/resource.h
|
|
|
|
sys/time.h sys/types.h sys/resource.h
|
2006-10-04 13:26:23 +00:00
|
|
|
sys/un.h
|
|
|
|
sys/types.h sys/un.h
|
|
|
|
syslog.h
|
|
|
|
stdint.h
|
|
|
|
inttypes.h
|
2005-12-15 14:30:46 +00:00
|
|
|
sys/prctl.h
|
2005-10-18 16:21:34 +00:00
|
|
|
sys/wait.h""", "\n"))
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
checkFuncs(autoconf, Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \
|
|
|
|
strdup strerror strstr strtol sendfile getopt socket \
|
2010-08-06 21:57:15 +00:00
|
|
|
gethostbyname poll epoll_ctl getrlimit chroot \
|
2005-12-15 14:30:46 +00:00
|
|
|
getuid select signal pathconf madvise prctl\
|
2009-04-26 21:02:16 +00:00
|
|
|
writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton'))
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
checkTypes(autoconf, Split('pid_t size_t off_t'))
|
|
|
|
|
2006-10-04 13:26:23 +00:00
|
|
|
autoconf.env.Append( LIBSQLITE3 = '', LIBXML2 = '', LIBMYSQL = '', LIBZ = '',
|
2006-01-08 18:42:12 +00:00
|
|
|
LIBBZ2 = '', LIBCRYPT = '', LIBMEMCACHE = '', LIBFCGI = '', LIBPCRE = '',
|
2006-01-03 12:53:41 +00:00
|
|
|
LIBLDAP = '', LIBLBER = '', LIBLUA = '', LIBLUALIB = '', LIBDL = '')
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
if env['with_fam']:
|
|
|
|
if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = 'fam')
|
2005-12-15 14:30:46 +00:00
|
|
|
checkFuncs(autoconf, ['FAMNoExists']);
|
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
if autoconf.CheckLibWithHeader('crypt', 'crypt.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CRYPT_H', '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt')
|
|
|
|
|
2006-09-28 07:25:15 +00:00
|
|
|
if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid')
|
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
if env['with_openssl']:
|
|
|
|
if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBS = [ 'ssl', 'crypto' ])
|
|
|
|
|
|
|
|
if env['with_gzip']:
|
|
|
|
if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z')
|
|
|
|
|
2005-11-15 10:32:15 +00:00
|
|
|
if env['with_ldap']:
|
|
|
|
if autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'):
|
2006-01-08 18:42:12 +00:00
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap')
|
2005-11-15 10:32:15 +00:00
|
|
|
if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber')
|
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
if env['with_bzip2']:
|
|
|
|
if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2')
|
|
|
|
|
|
|
|
if env['with_memcache']:
|
|
|
|
if autoconf.CheckLibWithHeader('memcache', 'memcache.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MEMCACHE_H', '-DHAVE_LIBMEMCACHE' ], LIBMEMCACHE = 'memcache')
|
|
|
|
|
|
|
|
if env['with_sqlite3']:
|
|
|
|
if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'):
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3')
|
|
|
|
|
2006-01-08 18:42:12 +00:00
|
|
|
ol = env['LIBS']
|
2005-10-01 12:35:55 +00:00
|
|
|
if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'):
|
|
|
|
autoconf.env.Append(LIBFCGI = 'fcgi')
|
2006-01-08 18:42:12 +00:00
|
|
|
env['LIBS'] = ol
|
2005-10-01 12:35:55 +00:00
|
|
|
|
2006-01-08 18:42:12 +00:00
|
|
|
ol = env['LIBS']
|
2005-11-18 13:27:17 +00:00
|
|
|
if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'):
|
|
|
|
autoconf.env.Append(LIBDL = 'dl')
|
2006-01-08 18:42:12 +00:00
|
|
|
env['LIBS'] = ol
|
2005-11-18 13:27:17 +00:00
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
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' ])
|
|
|
|
|
2005-10-26 11:23:07 +00:00
|
|
|
if autoconf.CheckStructMember():
|
|
|
|
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ])
|
2005-09-24 12:07:57 +00:00
|
|
|
|
|
|
|
env = autoconf.Finish()
|
|
|
|
|
2006-09-16 11:27:38 +00:00
|
|
|
if env['with_lua']:
|
|
|
|
oldlibs = env['LIBS']
|
|
|
|
env.ParseConfig("pkg-config 'lua >= 5.0' --cflags --libs")
|
|
|
|
lualibs = env['LIBS'][len(oldlibs):]
|
|
|
|
env.Append(LIBLUA = lualibs)
|
|
|
|
env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ])
|
|
|
|
env['LIBS'] = oldlibs
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2006-09-16 11:27:38 +00:00
|
|
|
|
2005-09-24 12:07:57 +00:00
|
|
|
if env['with_pcre']:
|
2005-10-01 12:35:55 +00:00
|
|
|
pcre_config = checkProgram(env, 'pcre', 'pcre-config')
|
2005-09-24 12:07:57 +00:00
|
|
|
env.ParseConfig(pcre_config + ' --cflags --libs')
|
|
|
|
env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = 'pcre')
|
|
|
|
|
|
|
|
if env['with_xml']:
|
2005-10-01 12:35:55 +00:00
|
|
|
xml2_config = checkProgram(env, 'xml', 'xml2-config')
|
2006-01-04 23:31:32 +00:00
|
|
|
oldlib = env['LIBS']
|
2006-10-04 13:26:23 +00:00
|
|
|
env['LIBS'] = []
|
2005-09-24 12:07:57 +00:00
|
|
|
env.ParseConfig(xml2_config + ' --cflags --libs')
|
2006-01-04 23:31:32 +00:00
|
|
|
env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = env['LIBS'])
|
|
|
|
env['LIBS'] = oldlib
|
2005-09-24 12:07:57 +00:00
|
|
|
|
2005-11-18 11:59:48 +00:00
|
|
|
if env['with_mysql']:
|
|
|
|
mysql_config = checkProgram(env, 'mysql', 'mysql_config')
|
2006-01-04 23:31:32 +00:00
|
|
|
oldlib = env['LIBS']
|
2006-10-04 13:26:23 +00:00
|
|
|
env['LIBS'] = []
|
2005-11-18 11:59:48 +00:00
|
|
|
env.ParseConfig(mysql_config + ' --cflags --libs')
|
|
|
|
env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient')
|
2006-01-04 23:31:32 +00:00
|
|
|
env['LIBS'] = oldlib
|
2005-11-18 11:59:48 +00:00
|
|
|
|
2005-10-01 12:35:55 +00:00
|
|
|
if re.compile("cygwin|mingw").search(env['PLATFORM']):
|
|
|
|
env.Append(COMMON_LIB = 'bin')
|
|
|
|
elif re.compile("darwin|aix").search(env['PLATFORM']):
|
|
|
|
env.Append(COMMON_LIB = 'lib')
|
|
|
|
else:
|
|
|
|
env.Append(COMMON_LIB = False)
|
|
|
|
|
|
|
|
versions = string.split(version, '.')
|
|
|
|
version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2])
|
2006-10-04 13:26:23 +00:00
|
|
|
env.Append(CPPFLAGS = [
|
2005-10-01 12:35:55 +00:00
|
|
|
'-DLIGHTTPD_VERSION_ID=' + str(version_id),
|
2005-09-24 12:07:57 +00:00
|
|
|
'-DPACKAGE_NAME=\\"' + package + '\\"',
|
|
|
|
'-DPACKAGE_VERSION=\\"' + version + '\\"',
|
|
|
|
'-DLIBRARY_DIR="\\"${libdir}\\""',
|
2005-09-26 09:44:36 +00:00
|
|
|
'-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-D_LARGE_FILES'
|
2005-09-24 12:07:57 +00:00
|
|
|
] )
|
|
|
|
|
|
|
|
SConscript( 'src/SConscript', 'env', build_dir = 'build', duplicate = 0)
|
|
|
|
SConscript( 'tests/SConscript', 'env' )
|