Blame src/SConstruct

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