2008-11-20 23:31:44 +00:00
|
|
|
#!/usr/bin/env python
|
2008-06-24 19:19:20 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2008-11-20 23:31:44 +00:00
|
|
|
"""
|
|
|
|
waf build script for Lighttpd 2.x
|
|
|
|
License and Copyright: see COPYING file
|
|
|
|
"""
|
|
|
|
|
2008-11-25 14:56:12 +00:00
|
|
|
import Options, types, os, sys, Runner, Utils
|
2008-07-17 22:30:02 +00:00
|
|
|
from time import gmtime, strftime, timezone
|
2008-06-24 19:19:20 +00:00
|
|
|
|
|
|
|
# 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'
|
|
|
|
|
2008-07-17 22:30:02 +00:00
|
|
|
|
2008-11-20 23:31:44 +00:00
|
|
|
def set_options(opt):
|
2008-06-24 19:19:20 +00:00
|
|
|
opt.tool_options('compiler_cc')
|
2008-07-15 20:12:33 +00:00
|
|
|
opt.tool_options('ragel', tdir = '.')
|
2008-11-20 23:31:44 +00:00
|
|
|
|
|
|
|
# ./waf configure options
|
2008-06-24 19:19:20 +00:00
|
|
|
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)
|
2008-11-20 23:31:44 +00:00
|
|
|
opt.add_option('--static', action='store_true', help='build a static lighttpd with all modules added', dest = 'static', default = False)
|
2008-06-24 19:19:20 +00:00
|
|
|
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 = '')
|
2008-09-02 18:29:21 +00:00
|
|
|
opt.add_option('--debug', action='store_true', help='Do not compile with -O2', dest = 'debug', default = False)
|
2009-01-01 16:47:23 +00:00
|
|
|
opt.add_option('--extra-warnings', action='store_true', help='show more warnings while compiling', dest='extra_warnings', default=False)
|
2008-06-24 19:19:20 +00:00
|
|
|
|
|
|
|
def configure(conf):
|
2008-07-15 20:12:33 +00:00
|
|
|
opts = Options.options
|
2008-11-21 01:00:13 +00:00
|
|
|
|
2008-11-20 23:31:44 +00:00
|
|
|
conf.define('APPNAME', APPNAME)
|
|
|
|
conf.define('VERSION', VERSION)
|
2008-11-21 01:00:13 +00:00
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
conf.check_tool('compiler_cc')
|
2008-06-30 14:24:29 +00:00
|
|
|
conf.check_tool('ragel', tooldir = '.')
|
2008-11-21 01:00:13 +00:00
|
|
|
|
|
|
|
conf.env['CCFLAGS'] = tolist(conf.env['CCFLAGS'])
|
2008-11-20 23:31:44 +00:00
|
|
|
|
|
|
|
# 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)
|
2009-01-01 16:47:23 +00:00
|
|
|
|
2009-01-12 00:20:06 +00:00
|
|
|
if opts.all:
|
|
|
|
opts.lua = True
|
|
|
|
|
2009-01-01 16:47:23 +00:00
|
|
|
if opts.extra_warnings:
|
|
|
|
conf.env['CCFLAGS'] += [
|
2009-01-04 21:38:24 +00:00
|
|
|
'-g', '-g2', '-Wall', '-Wmissing-declarations',
|
2009-01-01 16:47:23 +00:00
|
|
|
'-Wdeclaration-after-statement', '-Wno-pointer-sign', '-Wcast-align', '-Winline', '-Wsign-compare',
|
2009-01-04 21:38:24 +00:00
|
|
|
'-Wnested-externs', '-Wpointer-arith'#, '-Werror', '-Wbad-function-cast', '-Wmissing-prototypes'
|
2009-01-01 16:47:23 +00:00
|
|
|
]
|
|
|
|
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'
|
|
|
|
]
|
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
if opts.lua:
|
2008-11-20 23:31:44 +00:00
|
|
|
if not conf.check_cfg(package='lua5.1', uselib_store='lua', args='--cflags --libs'):
|
2008-06-24 19:19:20 +00:00
|
|
|
conf.env['LIB_lua'] = [ 'm' ]
|
2008-11-20 23:31:44 +00:00
|
|
|
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:
|
2008-11-21 01:25:10 +00:00
|
|
|
conf.check(lib='dl', uselib_store='dl')
|
2008-11-20 23:31:44 +00:00
|
|
|
|
|
|
|
# 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
|
2008-11-20 23:44:13 +00:00
|
|
|
if sys.platform == 'linux2':
|
2008-11-20 23:31:44 +00:00
|
|
|
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')
|
2008-11-23 21:36:00 +00:00
|
|
|
conf.check(function_name='writev', header_name='sys/uio.h', define_name='HAVE_WRITEV')
|
2008-11-20 23:31:44 +00:00
|
|
|
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')
|
2009-03-04 01:47:08 +00:00
|
|
|
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')
|
2008-11-20 23:31:44 +00:00
|
|
|
|
|
|
|
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)
|
2008-11-25 14:56:12 +00:00
|
|
|
|
|
|
|
revno = get_revno(conf)
|
|
|
|
if revno:
|
|
|
|
conf.define('LIGHTTPD_REVISION', revno)
|
|
|
|
|
2008-11-16 21:16:52 +00:00
|
|
|
conf.write_config_header('include/lighttpd/config.h')
|
2008-11-20 23:31:44 +00:00
|
|
|
|
|
|
|
Utils.pprint('WHITE', '----------------------------------------')
|
|
|
|
Utils.pprint('BLUE', 'Summary:')
|
|
|
|
print_summary(conf, 'Install Lighttpd/' + VERSION + ' in', conf.env['PREFIX'])
|
2008-11-25 14:56:12 +00:00
|
|
|
if revno:
|
|
|
|
print_summary(conf, 'Revision', revno)
|
2008-11-20 23:31:44 +00:00
|
|
|
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')
|
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
bld.add_subdirs('src')
|
2008-11-20 23:31:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def print_summary(conf, msg, result, color = 'GREEN'):
|
|
|
|
conf.check_message_1(msg)
|
|
|
|
conf.check_message_2(result, color)
|
2008-06-24 19:19:20 +00:00
|
|
|
|
2008-11-21 01:00:13 +00:00
|
|
|
def tolist(x):
|
|
|
|
if type(x) is types.ListType:
|
|
|
|
return x
|
|
|
|
return [x]
|
2008-07-15 20:12:33 +00:00
|
|
|
|
2008-11-25 14:56:12 +00:00
|
|
|
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
|