the upcoming 2.0 version
https://redmine.lighttpd.net/projects/lighttpd2
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
6.5 KiB
160 lines
6.5 KiB
#!/usr/bin/env python |
|
# encoding: utf-8 |
|
|
|
""" |
|
waf build script for Lighttpd 2.x |
|
License and Copyright: see COPYING file |
|
""" |
|
|
|
import Options, types, os, sys, Runner, Utils |
|
from time import gmtime, strftime, timezone |
|
|
|
# the following two variables are used by the target "waf dist" |
|
VERSION='2.0-pre' |
|
APPNAME='lighttpd' |
|
|
|
# these variables are mandatory ('/' are converted automatically) |
|
srcdir = '.' |
|
blddir = 'build' |
|
|
|
|
|
def set_options(opt): |
|
opt.tool_options('compiler_cc') |
|
opt.tool_options('ragel', tdir = '.') |
|
|
|
# ./waf configure options |
|
opt.add_option('--with-lua', action='store_true', help='with lua 5.1 for mod_magnet [default: off]', dest = 'lua', default = False) |
|
opt.add_option('--with-all', action='store_true', help='Enable all features', dest = 'all', default = False) |
|
opt.add_option('--static', action='store_true', help='build a static lighttpd with all modules added', dest = 'static', default = False) |
|
opt.add_option('--append', action='store', help='Append string to binary names / library dir', dest = 'append', default = '') |
|
opt.add_option('--lib-dir', action='store', help='Module directory [default: prefix + /lib/lighttpd + append]', dest = 'libdir', default = '') |
|
opt.add_option('--debug', action='store_true', help='Do not compile with -O2', dest = 'debug', default = False) |
|
opt.add_option('--extra-warnings', action='store_true', help='show more warnings while compiling', dest='extra_warnings', default=False) |
|
|
|
def configure(conf): |
|
opts = Options.options |
|
|
|
conf.check_message_2('The waf build system has been disabled, please use cmake for the time being.', 'RED') |
|
sys.exit(1) |
|
|
|
conf.define('APPNAME', APPNAME) |
|
conf.define('VERSION', VERSION) |
|
|
|
conf.check_tool('compiler_cc') |
|
conf.check_tool('ragel', tooldir = '.') |
|
|
|
conf.env['CCFLAGS'] = tolist(conf.env['CCFLAGS']) |
|
|
|
# check for available libraries |
|
conf.check_cfg(package='glib-2.0', uselib_store='glib', atleast_version='2.16', args='--cflags --libs', mandatory=True) |
|
conf.check_cfg(package='gmodule-2.0', uselib_store='gmodule', atleast_version='2.16', args='--cflags --libs', mandatory=True) |
|
conf.check_cfg(package='gthread-2.0', uselib_store='gthread', atleast_version='2.16', args='--cflags --libs', mandatory=True) |
|
conf.check(header_name="glib.h", uselib='glib', mandatory=True) |
|
glib_version = conf.check_cfg(modversion='glib-2.0') |
|
|
|
conf.check(lib='ev', uselib_store='ev', mandatory=True) |
|
conf.check(header_name='ev.h', uselib='ev', mandatory=True) |
|
|
|
if opts.all: |
|
opts.lua = True |
|
|
|
if opts.extra_warnings: |
|
conf.env['CCFLAGS'] += [ |
|
'-g', '-g2', '-Wall', '-Wmissing-declarations', |
|
'-Wdeclaration-after-statement', '-Wno-pointer-sign', '-Wcast-align', '-Winline', '-Wsign-compare', |
|
'-Wnested-externs', '-Wpointer-arith'#, '-Werror', '-Wbad-function-cast', '-Wmissing-prototypes' |
|
] |
|
conf.env['LDFLAGS'] += [ |
|
'-g', '-g2', '-Wall', '-Wmissing-prototypes', '-Wmissing-declarations', |
|
'-Wdeclaration-after-statement', '-Wno-pointer-sign', '-Wcast-align', '-Winline', '-Wsign-compare', |
|
'-Wnested-externs', '-Wpointer-arith', '-Wl,--as-needed'#, '-Werror', '-Wbad-function-cast' |
|
] |
|
|
|
if opts.lua: |
|
if not conf.check_cfg(package='lua5.1', uselib_store='lua', args='--cflags --libs'): |
|
conf.env['LIB_lua'] = [ 'm' ] |
|
conf.check(lib='lua', uselib_store='lua', mandatory=True) |
|
conf.check(header_name='lua.h', uselib='lua', mandatory=True) |
|
conf.check(function_name='lua_setfield', header_name='lua.h', uselib='lua', mandatory=True) |
|
conf.define('HAVE_LUA_H', 1) |
|
conf.define('HAVE_LIBLUA', 1) |
|
|
|
if not opts.static: |
|
conf.check(lib='dl', uselib_store='dl') |
|
|
|
# check for available headers |
|
conf.check(header_name='sys/socket.h') |
|
conf.check(header_name='netinet/in.h') |
|
conf.check(header_name='arpa/inet.h') |
|
conf.check(header_name='sys/uio.h') |
|
conf.check(header_name='sys/mman.h') |
|
conf.check(header_name='sys/sendfile.h') |
|
conf.check(header_name='sys/un.h') |
|
|
|
# check for available functions |
|
if sys.platform == 'linux2': |
|
conf.check(function_name='sendfile', header_name='sys/sendfile.h', define_name='HAVE_SENDFILE') |
|
conf.check(function_name='sendfile64', header_name='sys/sendfile.h', define_name='HAVE_SENDFILE64') |
|
else: |
|
conf.check(function_name='sendfile', header_name=['sys/types.h','sys/socket.h','sys/uio.h'], define_name='HAVE_SENDFILE') |
|
conf.check(function_name='writev', header_name='sys/uio.h', define_name='HAVE_WRITEV') |
|
conf.check(function_name='inet_aton', header_name='arpa/inet.h', define_name='HAVE_INET_ATON') |
|
conf.check(function_name='inet_atop', define_name='HAVE_IPV6') |
|
conf.check(function_name='posix_fadvise', header_name='fcntl.h', define_name='HAVE_POSIX_FADVISE') |
|
conf.check(function_name='mmap', header_name='sys/mman.h', define_name='HAVE_MMAP') |
|
conf.check(function_name='fpathconf', header_name='unistd.h', define_name='HAVE_FPATHCONF') |
|
conf.check(function_name='pathconf', header_name='unistd.h', define_name='HAVE_PATHCONF') |
|
conf.check(function_name='dirfd', header_name=['sys/types.h', 'dirent.h'], define_name='HAVE_DIRFD') |
|
|
|
conf.env['CPPPATH_lighty'] += [ '../include' ] |
|
|
|
conf.env['CPPPATH_lightymod'] += [ '../include' ] |
|
|
|
conf.sub_config('src') |
|
|
|
conf.define('LIGHTTPD_VERSION_ID', 20000) |
|
conf.define('PACKAGE_NAME', APPNAME) |
|
conf.define('PACKAGE_VERSION', VERSION) |
|
conf.define('PACKAGE_BUILD_DATE', strftime("%b %d %Y %H:%M:%S UTC", gmtime())); |
|
conf.define('LIBRARY_DIR', opts.libdir) |
|
conf.define('HAVE_CONFIG_H', 1) |
|
|
|
revno = get_revno(conf) |
|
if revno: |
|
conf.define('LIGHTTPD_REVISION', revno) |
|
|
|
conf.write_config_header('include/lighttpd/config.h') |
|
|
|
Utils.pprint('WHITE', '----------------------------------------') |
|
Utils.pprint('BLUE', 'Summary:') |
|
print_summary(conf, 'Install Lighttpd/' + VERSION + ' in', conf.env['PREFIX']) |
|
if revno: |
|
print_summary(conf, 'Revision', revno) |
|
print_summary(conf, 'Using glib version', glib_version) |
|
print_summary(conf, 'With library directory', opts.libdir) |
|
print_summary(conf, 'Build static binary', 'yes' if opts.static else 'no', 'YELLOW' if opts.static else 'GREEN') |
|
print_summary(conf, 'Build debug binary', 'yes' if opts.debug else 'no', 'YELLOW' if opts.debug else 'GREEN') |
|
print_summary(conf, 'With lua support', 'yes' if opts.lua else 'no', 'GREEN' if opts.lua else 'YELLOW') |
|
|
|
|
|
def build(bld): |
|
bld.add_subdirs('src') |
|
|
|
|
|
def print_summary(conf, msg, result, color = 'GREEN'): |
|
conf.check_message_1(msg) |
|
conf.check_message_2(result, color) |
|
|
|
def tolist(x): |
|
if type(x) is types.ListType: |
|
return x |
|
return [x] |
|
|
|
def get_revno(conf): |
|
if os.path.exists('.bzr'): |
|
try: |
|
revno = Utils.cmd_output('bzr version-info --custom --template="{revno}"') |
|
if revno: |
|
return revno.strip() |
|
except: |
|
pass
|
|
|