env = Environment(tools = ['default', 'textfile'])
name = 'helianthus'
description = 'Helianthus is a library to create small games'
version = '0.1.0'
# user options
DEBUG = ARGUMENTS.get('DEBUG', 0)
opts = Variables(name + '.conf')
opts.Add(PathVariable('PREFIX', 'Directory to install under', '/usr/local', PathVariable.PathAccept))
opts.Update(env)
opts.Save(name + '.conf', env)
# config
libs = ['sdl2', 'SDL2_mixer', 'SDL2_image', 'freetype2']
ldflags = ' -lGL '
# compute build options
flags = ' -lm -Wall -fmessage-length=0 ' + ldflags
if int(DEBUG):
flags += ' -O0 -g -fdebug-prefix-map=src=../src'
else:
flags += ' -O3 '
# files lists
target = name
headers = [
'common.h',
'drawing.h',
'font.h',
'group.h',
'sprite.h',
'world.h' ]
root_headers = [
name + '.h' ]
sources = [
'animation.c',
'array.c',
'collider.c',
'common.c',
'drawing.c',
'font.c',
'geometry.c',
'group.c',
'test.c',
'sound.c',
'sprite.c',
'world.c',
'worldui.c',
'blob.S' ]
# build
env.ParseConfig('pkg-config --cflags --libs ' + ' '.join(libs))
static_library = env.StaticLibrary(
target = target,
source = sources,
parse_flags = flags )
shared_library = env.SharedLibrary(
target = target,
source = sources,
parse_flags = flags,
SHLIBVERSION = version )
# install
idir_prefix = '$PREFIX'
idir_lib = '$PREFIX/lib'
idir_inc = '$PREFIX/include'
env.Export('env idir_prefix idir_lib idir_inc')
pcdict = {
'@prefix@' : idir_prefix,
'@exec_prefix@' : '$${prefix}',
'@libdir@' : ('$${exec_prefix}/lib' if idir_lib == '$PREFIX/lib' else idir_lib),
'@includedir@' : ('$${prefix}/include' if idir_inc == '$PREFIX/include' else idir_inc) + '/' + name,
'@NAME@' : name,
'@DESC@' : description,
'@VERSION@' : version,
'@DEPS@' : ' '.join(libs),
'@CONFIG_LIBS@' : '-l' + name + ldflags,
'@CONFIG_CFLAGS@' : '',
}
pcfile = env.Substfile(name + '.pc.in', SUBST_DICT = pcdict)
env.Install(idir_lib, static_library)
env.InstallVersionedLib(idir_lib, shared_library)
env.Install(idir_lib + '/pkgconfig', pcfile)
env.Install(idir_inc + '/' + name + '/' + name, headers)
env.Install(idir_inc + '/' + name, root_headers)
env.Alias('install', idir_prefix)