version 1.1.1.1, 2013/10/14 10:32:48
|
version 1.1.1.2, 2016/11/02 10:35:00
|
Line 1
|
Line 1
|
import os |
import os |
import re |
import re |
import types |
import types |
|
import itertools |
|
from collections import OrderedDict |
|
|
|
# search any file, not just executables |
|
def WhereIsFile(file, paths): |
|
for d in paths: |
|
f = os.path.join(d, file) |
|
if os.path.isfile(f): |
|
try: |
|
st = os.stat(f) |
|
except OSError: |
|
# os.stat() raises OSError, not IOError if the file |
|
# doesn't exist, so in this case we let IOError get |
|
# raised so as to not mask possibly serious disk or |
|
# network issues. |
|
continue |
|
return os.path.normpath(f) |
|
return None |
|
|
|
def FlattenLibs(libs): |
|
if isinstance(libs, basestring): |
|
return [libs] |
|
else: |
|
return [item for sublibs in libs for item in FlattenLibs(sublibs)] |
|
|
|
# removes all but the *LAST* occurance of a lib in the list |
|
def RemoveDuplicateLibs(libs): |
|
libs = FlattenLibs(libs) |
|
# remove empty strings from list |
|
libs = list(filter(lambda x: x != '', libs)) |
|
return list(reversed(OrderedDict.fromkeys(reversed(libs)))) |
|
|
Import('env') |
Import('env') |
|
|
common_src = Split("buffer.c log.c \ | def GatherLibs(env, *libs): |
keyvalue.c chunk.c \ | return RemoveDuplicateLibs(env['LIBS'] + list(libs) + [env['APPEND_LIBS']]) |
http_chunk.c stream.c fdevent.c \ | |
stat_cache.c plugin.c joblist.c etag.c array.c \ | common_src = Split("base64.c buffer.c log.c \ |
data_string.c data_count.c data_array.c \ | keyvalue.c chunk.c \ |
data_integer.c md5.c data_fastcgi.c \ | http_chunk.c stream.c fdevent.c \ |
fdevent_select.c fdevent_libev.c \ | stat_cache.c plugin.c joblist.c etag.c array.c \ |
fdevent_poll.c fdevent_linux_sysepoll.c \ | data_string.c data_count.c data_array.c \ |
fdevent_solaris_devpoll.c fdevent_solaris_port.c \ | data_integer.c md5.c data_fastcgi.c \ |
fdevent_freebsd_kqueue.c \ | vector.c \ |
data_config.c bitset.c \ | fdevent_select.c fdevent_libev.c \ |
inet_ntop_cache.c crc32.c \ | fdevent_poll.c fdevent_linux_sysepoll.c \ |
connections-glue.c \ | fdevent_solaris_devpoll.c fdevent_solaris_port.c \ |
configfile-glue.c \ | fdevent_freebsd_kqueue.c \ |
http-header-glue.c \ | data_config.c \ |
splaytree.c network_writev.c \ | inet_ntop_cache.c crc32.c \ |
network_write.c network_linux_sendfile.c \ | connections-glue.c \ |
network_freebsd_sendfile.c \ | configfile-glue.c \ |
network_solaris_sendfilev.c network_openssl.c \ | http-header-glue.c \ |
status_counter.c \ | splaytree.c network_writev.c \ |
| network_write_mmap.c network_write_no_mmap.c \ |
| network_write.c network_linux_sendfile.c \ |
| network_freebsd_sendfile.c \ |
| network_solaris_sendfilev.c network_openssl.c \ |
| status_counter.c safe_memclear.c network_darwin_sendfile.c \ |
") |
") |
|
|
src = Split("server.c response.c connections.c network.c \ |
src = Split("server.c response.c connections.c network.c \ |
configfile.c configparser.c request.c proc_open.c") | configfile.c configparser.c request.c proc_open.c") |
|
|
lemon = env.Program('lemon', 'lemon.c') | lemon = env.Program('lemon', 'lemon.c', LIBS = GatherLibs(env)) |
|
|
configparser = env.Command(['configparser.c', 'configparser.h'], 'configparser.y', '(cd build; ../' + lemon[0].path + ' -q ../$SOURCE ../src/lempar.c; cd ..)') | def Lemon(env, input): |
env.Depends(configparser, lemon) | parser = env.Command([input.replace('.y', '.c'),input.replace('.y', '.h')], input, '(cd sconsbuild/build; ../../' + lemon[0].path + ' -q ../../$SOURCE ../../src/lempar.c)') |
| env.Depends(parser, lemon) |
|
|
mod_ssi_exprparser = env.Command(['mod_ssi_exprparser.c', 'mod_ssi_exprparser.h'], 'mod_ssi_exprparser.y', '(cd build; ../' + lemon[0].path + ' -q ../$SOURCE ../src/lempar.c; cd ..)') | configparser = Lemon(env, 'configparser.y') |
env.Depends(mod_ssi_exprparser, lemon) | mod_ssi_exprparser = Lemon(env, 'mod_ssi_exprparser.y') |
|
|
## the modules and how they are built |
## the modules and how they are built |
modules = { |
modules = { |
Line 53 modules = {
|
Line 90 modules = {
|
'mod_usertrack' : { 'src' : [ 'mod_usertrack.c' ] }, |
'mod_usertrack' : { 'src' : [ 'mod_usertrack.c' ] }, |
'mod_proxy' : { 'src' : [ 'mod_proxy.c' ] }, |
'mod_proxy' : { 'src' : [ 'mod_proxy.c' ] }, |
'mod_userdir' : { 'src' : [ 'mod_userdir.c' ] }, |
'mod_userdir' : { 'src' : [ 'mod_userdir.c' ] }, |
'mod_secdownload' : { 'src' : [ 'mod_secure_download.c' ] }, | 'mod_secdownload' : { 'src' : [ 'mod_secdownload.c' ] }, |
'mod_accesslog' : { 'src' : [ 'mod_accesslog.c' ] }, |
'mod_accesslog' : { 'src' : [ 'mod_accesslog.c' ] }, |
'mod_simple_vhost' : { 'src' : [ 'mod_simple_vhost.c' ] }, |
'mod_simple_vhost' : { 'src' : [ 'mod_simple_vhost.c' ] }, |
'mod_evhost' : { 'src' : [ 'mod_evhost.c' ] }, |
'mod_evhost' : { 'src' : [ 'mod_evhost.c' ] }, |
Line 67 modules = {
|
Line 104 modules = {
|
'lib' : [ env['LIBCRYPT'], env['LIBLDAP'], env['LIBLBER'] ] }, |
'lib' : [ env['LIBCRYPT'], env['LIBLDAP'], env['LIBLBER'] ] }, |
'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, |
'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, |
'mod_mysql_vhost' : { 'src' : [ 'mod_mysql_vhost.c' ], 'lib' : [ env['LIBMYSQL'] ] }, |
'mod_mysql_vhost' : { 'src' : [ 'mod_mysql_vhost.c' ], 'lib' : [ env['LIBMYSQL'] ] }, |
'mod_trigger_b4_dl' : { 'src' : [ 'mod_trigger_b4_dl.c' ], 'lib' : [ env['LIBPCRE'] ] }, |
|
'mod_cml' : { |
|
'src' : [ 'mod_cml_lua.c', 'mod_cml.c', 'mod_cml_funcs.c' ], |
|
'lib' : [ env['LIBPCRE'], env['LIBMEMCACHE'], env['LIBLUA'], env['LIBLUALIB'] ] }, |
|
# 'mod_uploadprogress' : { 'src' : [ 'mod_uploadprogress.c' ] }, |
# 'mod_uploadprogress' : { 'src' : [ 'mod_uploadprogress.c' ] }, |
'mod_evasive' : { 'src' : [ 'mod_evasive.c' ] }, |
'mod_evasive' : { 'src' : [ 'mod_evasive.c' ] }, |
'mod_ssi' : { 'src' : [ 'mod_ssi_exprparser.c', 'mod_ssi_expr.c', 'mod_ssi.c' ], 'lib' : [ env['LIBPCRE'] ] }, | 'mod_ssi' : { 'src' : [ 'mod_ssi_exprparser.c', 'mod_ssi_expr.c', 'mod_ssi.c' ] }, |
'mod_flv_streaming' : { 'src' : [ 'mod_flv_streaming.c' ] }, |
'mod_flv_streaming' : { 'src' : [ 'mod_flv_streaming.c' ] }, |
'mod_magnet' : { 'src' : [ 'mod_magnet.c', 'mod_magnet_cache.c' ], 'lib' : [ env['LIBLUA'] ] }, | 'mod_cml': { |
| 'src' : [ 'mod_cml_lua.c', 'mod_cml.c', 'mod_cml_funcs.c' ], |
| 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'], env['LIBLUA'] ] |
| }, |
} |
} |
|
|
staticenv = env.Copy(CPPFLAGS=[ env['CPPFLAGS'], '-DLIGHTTPD_STATIC', '-DOPENSSL_NO_KRB5']) | if env['with_memcached']: |
| modules['mod_trigger_b4_dl'] = { 'src' : [ 'mod_trigger_b4_dl.c' ], 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'] ] } |
|
|
|
if env['with_lua']: |
|
modules['mod_magnet'] = { 'src' : [ 'mod_magnet.c', 'mod_magnet_cache.c' ], 'lib' : [ env['LIBLUA'] ] } |
|
|
|
staticenv = env.Clone(CPPFLAGS=[ env['CPPFLAGS'], '-DLIGHTTPD_STATIC' ]) |
|
|
## all the core-sources + the modules |
## all the core-sources + the modules |
staticsrc = src + common_src |
staticsrc = src + common_src |
|
|
Line 91 for module in modules.keys():
|
Line 133 for module in modules.keys():
|
if modules[module].has_key('lib'): |
if modules[module].has_key('lib'): |
staticlib += modules[module]['lib'] |
staticlib += modules[module]['lib'] |
|
|
open('plugin-static.h', 'w+').write(staticinit) | def WriteStaticPluginHeader(target, source, env): |
| do_write = True |
| data = env['STATICINIT'] |
| # only touch the file if content actually changes |
| try: |
| with open(target[0].abspath, 'r') as f: |
| do_write = (data != f.read()) |
| except IOError: |
| pass |
| if do_write: |
| with open(target[0].abspath, 'w+') as f: |
| f.write(env['STATICINIT']) |
|
|
|
env['STATICINIT'] = staticinit |
|
staticheader = env.AlwaysBuild(env.Command('plugin-static.h', [], WriteStaticPluginHeader)) |
|
|
## turn all src-files into objects |
## turn all src-files into objects |
staticobj = [] |
staticobj = [] |
|
static_plugin_obj = None |
for cfile in staticsrc: |
for cfile in staticsrc: |
staticobj += [ staticenv.Object('static-' + cfile.replace('.c', ''), cfile) ] | if cfile == 'plugin.c': |
| static_plugin_obj = [ staticenv.Object('static-' + cfile.replace('.c', ''), cfile) ] |
| staticobj += static_plugin_obj |
| else: |
| staticobj += [ staticenv.Object('static-' + cfile.replace('.c', ''), cfile) ] |
| env.Depends(static_plugin_obj, 'plugin-static.h') |
|
|
staticbin = staticenv.Program('lighttpd-semi-static', | ## includes all modules, but links dynamically against other libs |
| staticbin = staticenv.Program('../static/build/lighttpd', |
staticobj, |
staticobj, |
LIBS = staticlib | LIBS = GatherLibs(env, staticlib) |
) |
) |
|
|
## you might have to adjust the list of libs and the order for your setup |
## you might have to adjust the list of libs and the order for your setup |
Line 111 fullstaticlib = []
|
Line 174 fullstaticlib = []
|
## 1. find the lib |
## 1. find the lib |
## 2. check the deps |
## 2. check the deps |
## 3. add them to the libs |
## 3. add them to the libs |
searchlibs = os.pathsep.join([ '/lib/', '/usr/lib/', '/usr/local/lib/' ]) | #searchlibs = os.pathsep.join([ '/lib/', '/usr/lib/', '/usr/local/lib/' ]) |
| searchlibs = [] |
| searchpathre = re.compile(r'\bSEARCH_DIR\("=([^"]+)"\)') |
| f = os.popen('ld --verbose | grep SEARCH_DIR', 'r') |
| for aword in searchpathre.findall(f.read()): |
| searchlibs += [ aword] |
| f.close |
| |
lddre = re.compile(r'^\s+lib([^=-]+)(?:-[\.0-9]+)?\.so\.[0-9]+ =>', re.MULTILINE) |
lddre = re.compile(r'^\s+lib([^=-]+)(?:-[\.0-9]+)?\.so\.[0-9]+ =>', re.MULTILINE) |
for libs in staticlib: |
for libs in staticlib: |
if type(libs) is types.StringType: libs = [ libs ] |
if type(libs) is types.StringType: libs = [ libs ] |
for lib in libs: |
for lib in libs: |
fullstaticlib += [ lib ] |
fullstaticlib += [ lib ] |
solibpath = env.WhereIs('lib' + lib + '.so', searchlibs) | solibpath = WhereIsFile('lib' + lib + '.so', paths = searchlibs) |
fullstaticlib += [ lib ] | |
if solibpath is None: |
if solibpath is None: |
continue |
continue |
|
|
Line 127 for libs in staticlib:
|
Line 196 for libs in staticlib:
|
fullstaticlib += [ aword ] |
fullstaticlib += [ aword ] |
f.close |
f.close |
|
|
| ## includes all modules, linked statically |
fullstaticbin = staticenv.Program('lighttpd-static', | fullstaticbin = staticenv.Program('../fullstatic/build/lighttpd', |
staticobj, |
staticobj, |
LIBS = fullstaticlib, | LIBS = GatherLibs(env, fullstaticlib), |
LINKFLAGS= ['-static'] | LINKFLAGS= [staticenv['LINKFLAGS'], '-static'] |
) |
) |
|
|
Alias('static', staticbin) |
Alias('static', staticbin) |
Line 151 else:
|
Line 220 else:
|
else: |
else: |
bin_linkflags += [ '-Wl,--export-dynamic' ] |
bin_linkflags += [ '-Wl,--export-dynamic' ] |
|
|
instbin = env.Program(bin_targets, src, LINKFLAGS = bin_linkflags, LIBS= [ env['LIBS'], common_lib, env['LIBDL'] ]) | instbin = env.Program(bin_targets, src, LINKFLAGS = bin_linkflags, LIBS = GatherLibs(env, env['LIBS'], common_lib, env['LIBDL'])) |
env.Depends(instbin, configparser) |
env.Depends(instbin, configparser) |
|
|
if env['COMMON_LIB'] == 'bin': |
if env['COMMON_LIB'] == 'bin': |
Line 163 for module in modules.keys():
|
Line 232 for module in modules.keys():
|
libs = [ common_lib ] |
libs = [ common_lib ] |
if modules[module].has_key('lib'): |
if modules[module].has_key('lib'): |
libs += modules[module]['lib'] |
libs += modules[module]['lib'] |
instlib += env.SharedLibrary(module, modules[module]['src'], LIBS= [ libs ]) | instlib += env.SharedLibrary(module, modules[module]['src'], LIBS= GatherLibs(env, libs)) |
| env.Alias('modules', instlib) |
|
|
inst = [] |
inst = [] |
|
|
Line 189 env.Alias('install', inst)
|
Line 259 env.Alias('install', inst)
|
|
|
pkgdir = '.' |
pkgdir = '.' |
tarname = env['package'] + '-' + env['version'] |
tarname = env['package'] + '-' + env['version'] |
|
|