| 1 |
import os |
|---|
| 2 |
import sys |
|---|
| 3 |
import re |
|---|
| 4 |
import string |
|---|
| 5 |
from stat import * |
|---|
| 6 |
|
|---|
| 7 |
package = 'lighttpd' |
|---|
| 8 |
version = '1.5.0' |
|---|
| 9 |
|
|---|
| 10 |
def checkCHeaders(autoconf, hdrs): |
|---|
| 11 |
p = re.compile('[^A-Z0-9]') |
|---|
| 12 |
for hdr in hdrs: |
|---|
| 13 |
if not hdr: |
|---|
| 14 |
continue |
|---|
| 15 |
_hdr = Split(hdr) |
|---|
| 16 |
if autoconf.CheckCHeader(_hdr): |
|---|
| 17 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', _hdr[-1].upper()) ]) |
|---|
| 18 |
|
|---|
| 19 |
def checkFuncs(autoconf, funcs): |
|---|
| 20 |
p = re.compile('[^A-Z0-9]') |
|---|
| 21 |
for func in funcs: |
|---|
| 22 |
if autoconf.CheckFunc(func): |
|---|
| 23 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', func.upper()) ]) |
|---|
| 24 |
|
|---|
| 25 |
def checkTypes(autoconf, types): |
|---|
| 26 |
p = re.compile('[^A-Z0-9]') |
|---|
| 27 |
for type in types: |
|---|
| 28 |
if autoconf.CheckType(type, '#include <sys/types.h>'): |
|---|
| 29 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', type.upper()) ]) |
|---|
| 30 |
|
|---|
| 31 |
def checkProgram(env, withname, progname): |
|---|
| 32 |
withname = 'with_' + withname |
|---|
| 33 |
binpath = None |
|---|
| 34 |
|
|---|
| 35 |
if env[withname] != 1: |
|---|
| 36 |
binpath = env[withname] |
|---|
| 37 |
else: |
|---|
| 38 |
prog = env.Detect(progname) |
|---|
| 39 |
if prog: |
|---|
| 40 |
binpath = env.WhereIs(prog) |
|---|
| 41 |
|
|---|
| 42 |
if binpath: |
|---|
| 43 |
mode = os.stat(binpath)[ST_MODE] |
|---|
| 44 |
if S_ISDIR(mode): |
|---|
| 45 |
print >> sys.stderr, "* error: path `%s' is a directory" % (binpath) |
|---|
| 46 |
env.Exit(-1) |
|---|
| 47 |
if not S_ISREG(mode): |
|---|
| 48 |
print >> sys.stderr, "* error: path `%s' is not a file or not exists" % (binpath) |
|---|
| 49 |
env.Exit(-1) |
|---|
| 50 |
|
|---|
| 51 |
if not binpath: |
|---|
| 52 |
print >> sys.stderr, "* error: can't find program `%s'" % (progname) |
|---|
| 53 |
env.Exit(-1) |
|---|
| 54 |
|
|---|
| 55 |
return binpath |
|---|
| 56 |
|
|---|
| 57 |
def checkStructMember(context): |
|---|
| 58 |
struct_member = """ |
|---|
| 59 |
#include <time.h> |
|---|
| 60 |
int main() { |
|---|
| 61 |
struct tm a; |
|---|
| 62 |
a.tm_gmtoff = 0; |
|---|
| 63 |
return 0; |
|---|
| 64 |
} |
|---|
| 65 |
""" |
|---|
| 66 |
context.Message('Checking for tm_gmtoff in struct tm...') |
|---|
| 67 |
result = context.TryLink(struct_member, '.c') |
|---|
| 68 |
context.Result(result) |
|---|
| 69 |
|
|---|
| 70 |
return result |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
BuildDir('build', 'src', duplicate = 0) |
|---|
| 74 |
|
|---|
| 75 |
opts = Options('config.py') |
|---|
| 76 |
opts.AddOptions( |
|---|
| 77 |
('prefix', 'prefix', '/usr/local'), |
|---|
| 78 |
('bindir', 'binary directory', '${prefix}/bin'), |
|---|
| 79 |
('sbindir', 'binary directory', '${prefix}/sbin'), |
|---|
| 80 |
('libdir', 'library directory', '${prefix}/lib'), |
|---|
| 81 |
PackageOption('with_mysql', 'enable mysql support', 'no'), |
|---|
| 82 |
PackageOption('with_xml', 'enable xml support', 'no'), |
|---|
| 83 |
PackageOption('with_pcre', 'enable pcre support', 'yes'), |
|---|
| 84 |
PathOption('CC', 'path to the c-compiler', None), |
|---|
| 85 |
PathOption('PSDK_HOME', 'path to the platform SDK', None), |
|---|
| 86 |
PathOption('VC_TOOLKIT_HOME', 'path to the Visual C++ Toolkit', None), |
|---|
| 87 |
BoolOption('build_dynamic', 'enable dynamic build', 'yes'), |
|---|
| 88 |
BoolOption('build_static', 'enable static build', 'no'), |
|---|
| 89 |
BoolOption('build_fullstatic', 'enable fullstatic build', 'no'), |
|---|
| 90 |
BoolOption('with_sqlite3', 'enable sqlite3 support', 'no'), |
|---|
| 91 |
BoolOption('with_memcache', 'enable memcache support', 'no'), |
|---|
| 92 |
BoolOption('with_fam', 'enable FAM/gamin support', 'no'), |
|---|
| 93 |
BoolOption('with_openssl', 'enable memcache support', 'no'), |
|---|
| 94 |
BoolOption('with_gzip', 'enable gzip compression', 'no'), |
|---|
| 95 |
BoolOption('with_bzip2', 'enable bzip2 compression', 'no'), |
|---|
| 96 |
BoolOption('with_lua', 'enable lua support for mod_cml', 'no'), |
|---|
| 97 |
BoolOption('with_xattr', 'enable xattr support', 'no'), |
|---|
| 98 |
BoolOption('with_uuid', 'enable LOCK support (requires uuid) for mod_webdav', 'no'), |
|---|
| 99 |
BoolOption('with_ldap', 'enable ldap auth support', 'no')) |
|---|
| 100 |
|
|---|
| 101 |
env = Environment( |
|---|
| 102 |
options = opts |
|---|
| 103 |
) |
|---|
| 104 |
|
|---|
| 105 |
env.Help(opts.GenerateHelpText(env)) |
|---|
| 106 |
cpppath = [ '#build/' ] |
|---|
| 107 |
libpath = [ '/lib/', '/usr/lib/', '/usr/local/lib/' ] |
|---|
| 108 |
path = [ '/bin/', '/usr/bin/' ] |
|---|
| 109 |
|
|---|
| 110 |
if env.subst('${CC}') is not '': |
|---|
| 111 |
env['CC'] = env.subst('${CC}') |
|---|
| 112 |
|
|---|
| 113 |
if env.subst('${VC_TOOLKIT_HOME}') is not '': |
|---|
| 114 |
cpppath += [ '${VC_TOOLKIT_HOME}/include' ] |
|---|
| 115 |
libpath += [ '${VC_TOOLKIT_HOME}/lib' ] |
|---|
| 116 |
path += [ env.subst('${VC_TOOLKIT_HOME}/bin') ] |
|---|
| 117 |
|
|---|
| 118 |
if env.subst('${PSDK_HOME}') is not '': |
|---|
| 119 |
cpppath += [ '${PSDK_HOME}/include' ] |
|---|
| 120 |
libpath += [ '${PSDK_HOME}/lib' ] |
|---|
| 121 |
path += [ env.subst('${PSDK_HOME}/bin') ] |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
## build new environment with a clean PATH |
|---|
| 125 |
|
|---|
| 126 |
env = Environment(options = opts, ENV = { "PATH" : path}) |
|---|
| 127 |
|
|---|
| 128 |
env.Append(CPPPATH = cpppath) |
|---|
| 129 |
env.Append(LIBPATH = libpath) |
|---|
| 130 |
|
|---|
| 131 |
env['package'] = package |
|---|
| 132 |
env['version'] = version |
|---|
| 133 |
if env['CC'] == 'gcc': |
|---|
| 134 |
## we need x-open 6 and bsd 4.3 features |
|---|
| 135 |
env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) |
|---|
| 136 |
else: |
|---|
| 137 |
env.Append(CCFLAGS = Split('/Zi /W3')) |
|---|
| 138 |
# cache configure checks |
|---|
| 139 |
if 1: |
|---|
| 140 |
autoconf = Configure(env, custom_tests = {'CheckStructMember': checkStructMember }) |
|---|
| 141 |
autoconf.headerfile = "foo.h" |
|---|
| 142 |
checkCHeaders(autoconf, string.split(""" |
|---|
| 143 |
arpa/inet.h |
|---|
| 144 |
fcntl.h |
|---|
| 145 |
netinet/in.h |
|---|
| 146 |
sys/types.h netinet/in.h |
|---|
| 147 |
stdlib.h |
|---|
| 148 |
string.h |
|---|
| 149 |
sys/socket.h |
|---|
| 150 |
sys/types.h sys/socket.h |
|---|
| 151 |
sys/time.h |
|---|
| 152 |
unistd.h |
|---|
| 153 |
sys/sendfile.h |
|---|
| 154 |
sys/uio.h |
|---|
| 155 |
sys/types.h sys/uio.h |
|---|
| 156 |
getopt.h |
|---|
| 157 |
sys/epoll.h |
|---|
| 158 |
sys/select.h |
|---|
| 159 |
sys/types.h sys/select.h |
|---|
| 160 |
poll.h |
|---|
| 161 |
sys/poll.h |
|---|
| 162 |
sys/devpoll.h |
|---|
| 163 |
sys/filio.h |
|---|
| 164 |
sys/mman.h |
|---|
| 165 |
sys/types.h sys/mman.h |
|---|
| 166 |
sys/event.h |
|---|
| 167 |
sys/types.h sys/event.h |
|---|
| 168 |
sys/port.h |
|---|
| 169 |
winsock2.h |
|---|
| 170 |
pwd.h |
|---|
| 171 |
sys/syslimits.h |
|---|
| 172 |
sys/resource.h |
|---|
| 173 |
sys/time.h sys/types.h sys/resource.h |
|---|
| 174 |
sys/un.h |
|---|
| 175 |
sys/types.h sys/un.h |
|---|
| 176 |
syslog.h |
|---|
| 177 |
stdint.h |
|---|
| 178 |
inttypes.h |
|---|
| 179 |
sys/prctl.h |
|---|
| 180 |
libaio.h |
|---|
| 181 |
aio.h |
|---|
| 182 |
sys/wait.h""", "\n")) |
|---|
| 183 |
|
|---|
| 184 |
checkFuncs(autoconf, Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \ |
|---|
| 185 |
strdup strerror strstr strtol sendfile getopt socket \ |
|---|
| 186 |
gethostbyname poll sigtimedwait epoll_ctl getrlimit chroot \ |
|---|
| 187 |
getuid select signal pathconf madvise prctl inet_aton strptime \ |
|---|
| 188 |
writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise')) |
|---|
| 189 |
|
|---|
| 190 |
checkTypes(autoconf, Split('pid_t size_t off_t')) |
|---|
| 191 |
|
|---|
| 192 |
autoconf.env.Append( LIBSQLITE3 = '', LIBXML2 = '', LIBMYSQL = '', LIBZ = '', |
|---|
| 193 |
LIBBZ2 = '', LIBCRYPT = '', LIBMEMCACHE = '', LIBFCGI = '', LIBPCRE = '', |
|---|
| 194 |
LIBLDAP = '', LIBLBER = '', LIBLUA = '', LIBLUALIB = '', LIBDL = '', LIBUUID = '') |
|---|
| 195 |
|
|---|
| 196 |
if env['with_fam']: |
|---|
| 197 |
if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): |
|---|
| 198 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = 'fam') |
|---|
| 199 |
checkFuncs(autoconf, ['FAMNoExists']); |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
if autoconf.CheckLibWithHeader('crypt', 'crypt.h', 'C'): |
|---|
| 203 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CRYPT_H', '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') |
|---|
| 204 |
|
|---|
| 205 |
if env['with_openssl']: |
|---|
| 206 |
if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): |
|---|
| 207 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBS = [ 'ssl', 'crypto' ]) |
|---|
| 208 |
|
|---|
| 209 |
if env['with_gzip']: |
|---|
| 210 |
if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): |
|---|
| 211 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') |
|---|
| 212 |
|
|---|
| 213 |
if env['with_ldap']: |
|---|
| 214 |
if autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): |
|---|
| 215 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') |
|---|
| 216 |
if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): |
|---|
| 217 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') |
|---|
| 218 |
|
|---|
| 219 |
if env['with_bzip2']: |
|---|
| 220 |
if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): |
|---|
| 221 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') |
|---|
| 222 |
|
|---|
| 223 |
if env['with_xattr']: |
|---|
| 224 |
if autoconf.CheckLibWithHeader('attr', 'attr/xattr.h', 'C'): |
|---|
| 225 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_XATTR' ], LIBATTR = 'attr') |
|---|
| 226 |
|
|---|
| 227 |
if env['with_memcache']: |
|---|
| 228 |
if autoconf.CheckLibWithHeader('memcache', 'memcache.h', 'C'): |
|---|
| 229 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MEMCACHE_H', '-DHAVE_LIBMEMCACHE' ], LIBMEMCACHE = 'memcache') |
|---|
| 230 |
|
|---|
| 231 |
if env['with_sqlite3']: |
|---|
| 232 |
if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): |
|---|
| 233 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') |
|---|
| 234 |
|
|---|
| 235 |
if env['with_lua']: |
|---|
| 236 |
autoconf.CheckLibWithHeader('m', 'math.h', 'C') |
|---|
| 237 |
if autoconf.CheckLibWithHeader('lua', 'lua.h', 'C'): |
|---|
| 238 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H', '-DHAVE_LIBLUA' ], LIBLUA = 'lua') |
|---|
| 239 |
else: |
|---|
| 240 |
print >> sys.stderr, "* error: --with_lua set but lua not found" |
|---|
| 241 |
|
|---|
| 242 |
if env['with_uuid']: |
|---|
| 243 |
if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): |
|---|
| 244 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_H' ], LIBUUID = 'uuid') |
|---|
| 245 |
|
|---|
| 246 |
## ol = env['LIBS'] |
|---|
| 247 |
## if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'): |
|---|
| 248 |
## autoconf.env.Append(LIBFCGI = 'fcgi') |
|---|
| 249 |
## env['LIBS'] = ol |
|---|
| 250 |
|
|---|
| 251 |
ol = env['LIBS'] |
|---|
| 252 |
if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): |
|---|
| 253 |
autoconf.env.Append(LIBDL = 'dl') |
|---|
| 254 |
env['LIBS'] = ol |
|---|
| 255 |
|
|---|
| 256 |
if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'): |
|---|
| 257 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) |
|---|
| 258 |
|
|---|
| 259 |
if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'): |
|---|
| 260 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) |
|---|
| 261 |
|
|---|
| 262 |
if autoconf.CheckStructMember(): |
|---|
| 263 |
autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) |
|---|
| 264 |
|
|---|
| 265 |
env = autoconf.Finish() |
|---|
| 266 |
|
|---|
| 267 |
if env['with_pcre']: |
|---|
| 268 |
pcre_config = checkProgram(env, 'pcre', 'pcre-config') |
|---|
| 269 |
env.ParseConfig(pcre_config + ' --cflags --libs') |
|---|
| 270 |
env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = 'pcre') |
|---|
| 271 |
|
|---|
| 272 |
if env['with_xml']: |
|---|
| 273 |
xml2_config = checkProgram(env, 'xml', 'xml2-config') |
|---|
| 274 |
oldlib = env['LIBS'] |
|---|
| 275 |
env['LIBS'] = [] |
|---|
| 276 |
env.ParseConfig(xml2_config + ' --cflags --libs') |
|---|
| 277 |
env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = env['LIBS']) |
|---|
| 278 |
env['LIBS'] = oldlib |
|---|
| 279 |
|
|---|
| 280 |
if env['with_mysql']: |
|---|
| 281 |
mysql_config = checkProgram(env, 'mysql', 'mysql_config') |
|---|
| 282 |
oldlib = env['LIBS'] |
|---|
| 283 |
env['LIBS'] = [] |
|---|
| 284 |
env.ParseConfig(mysql_config + ' --cflags --libs') |
|---|
| 285 |
env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') |
|---|
| 286 |
env['LIBS'] = oldlib |
|---|
| 287 |
|
|---|
| 288 |
if re.compile("cygwin|mingw").search(env['PLATFORM']): |
|---|
| 289 |
env.Append(COMMON_LIB = 'bin') |
|---|
| 290 |
elif re.compile("darwin|aix").search(env['PLATFORM']): |
|---|
| 291 |
env.Append(COMMON_LIB = 'lib') |
|---|
| 292 |
elif re.compile("win32").search(env['PLATFORM']): |
|---|
| 293 |
env['LIBS'] += [ 'wsock32' ] |
|---|
| 294 |
env.Append(COMMON_LIB = False) |
|---|
| 295 |
else: |
|---|
| 296 |
env.Append(COMMON_LIB = False) |
|---|
| 297 |
|
|---|
| 298 |
versions = string.split(version, '.') |
|---|
| 299 |
version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2]) |
|---|
| 300 |
env.Append(CPPFLAGS = [ |
|---|
| 301 |
'-DLIGHTTPD_VERSION_ID=' + str(version_id), |
|---|
| 302 |
'-DPACKAGE_NAME=\\"' + package + '\\"', |
|---|
| 303 |
'-DPACKAGE_VERSION=\\"' + version + '\\"', |
|---|
| 304 |
'-DLIBRARY_DIR="\\"${libdir}\\""', |
|---|
| 305 |
'-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-D_LARGE_FILES' |
|---|
| 306 |
] ) |
|---|
| 307 |
|
|---|
| 308 |
SConscript( 'src/SConscript', 'env', build_dir = 'build', duplicate = 0) |
|---|
| 309 |
SConscript( 'tests/SConscript', 'env' ) |
|---|