icfp11/wscript

87 lines
2.0 KiB
Plaintext
Raw Normal View History

2008-07-11 20:38:17 +00:00
#! /usr/bin/env python
# encoding: utf-8
# wscript
VERSION='0.0.1'
APPNAME='icfp08'
srcdir = '.'
blddir = 'build'
2008-07-11 21:30:34 +00:00
###########################
import types
def tolist(x):
if type(x) is types.ListType:
return x
return [x]
def env_mod(conf, use):
types = [ 'LIB', 'STATICLIB', 'LIBPATH', 'CPPPATH', 'CXXDEFINES', 'CCFLAGS', 'CXXFLAGS', 'LINKFLAGS' ]
bak = {}
for t in types:
bak[t] = conf.env[t]
for u in use:
conf.env[t] = tolist(conf.env[t]) + tolist(conf.env['%s_%s' % (t, u)])
return bak
def env_mod_revert(conf, bak):
for (k,v) in bak.items():
conf.env[k] = v
def CHECK_INCLUDE_FILES(conf, header, define, uselib = '', path = None, mandatory = 0, use = []):
envbak = env_mod(conf, use)
hconf = conf.create_header_configurator()
hconf.mandatory = mandatory
hconf.name = header
hconf.uselib_store = uselib
hconf.define = define
if path: hconf.path += path
res = hconf.run()
env_mod_revert(conf, envbak)
return res
def PKGCONFIG(conf, name, uselib = None, define = '', version = '', mandatory = 0):
if not uselib: uselib = name
hconf = conf.create_pkgconfig_configurator()
hconf.name = name
hconf.version = version
hconf.uselib_store = uselib
hconf.define = define
hconf.mandatory = mandatory
res = hconf.run()
return res
###########################
2008-07-11 20:38:17 +00:00
def set_options(opt):
opt.tool_options('compiler_cc')
2008-07-11 22:20:05 +00:00
opt.tool_options('ragel', tooldir = '.')
2008-07-11 20:38:17 +00:00
def configure(conf):
conf.check_tool('compiler_cc')
conf.check_tool('ragel', tooldir = '.')
common_ccflags = [
'-std=gnu99', '-Wall', '-g', '-Wshadow', '-W', '-pedantic',
# '-fPIC', '-D_GNU_SOURCE',
]
conf.env['CCFLAGS'] += common_ccflags
2008-07-11 21:30:34 +00:00
PKGCONFIG(conf, "glib-2.0", uselib = 'glib', mandatory = 1)
incdir = conf.env['CPPPATH_glib'][0]
conf.env['CPPPATH_glib'] += [ incdir+'/glib-2.0/', incdir + '/glib-2.0/include/' ]
CHECK_INCLUDE_FILES(conf, "glib.h", "HAVE_GLIB_H", uselib = 'glib', use = ['glib'], mandatory = 1)
2008-07-12 00:17:29 +00:00
conf.write_config_header('src/config.h')
2008-07-11 21:30:34 +00:00
2008-07-11 20:38:17 +00:00
def build(bld):
bld.add_subdirs('src')