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)
9c0711
WITH_FULL_UNICODE_FONT = ARGUMENTS.get('WITH_FULL_UNICODE_FONT', 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
a20939
libs = ['sdl2', 'SDL2_mixer', 'SDL2_image', 'freetype2']
f63775
ldflags = ' -lGL '
833ed7
833ed7
833ed7
# compute build options
833ed7
f63775
flags = ' -lm -Wall -fmessage-length=0 ' + ldflags
f34b93
if int(DEBUG):
f8c1ea
	flags += ' -O0 -g -fdebug-prefix-map=src=../src'
f34b93
else:
2406d3
	flags += ' -O3 -DNDEBUG '
833ed7
9c0711
if int(WITH_FULL_UNICODE_FONT):
9c0711
	flags += ' -DWITH_FULL_UNICODE_FONT'
9c0711
833ed7
833ed7
# files lists
833ed7
833ed7
target = name
833ed7
833ed7
headers = [
dba3fc
	'animation.h',
833ed7
	'common.h',
7ac038
	'colors.h',
833ed7
	'drawing.h',
a20939
	'font.h',
1d641c
	'framebuffer.h',
833ed7
	'group.h',
b53a5c
	'nuklear.h',
b53a5c
	'nuklear-heli.h',
ca6bde
	'sound.h',
833ed7
	'sprite.h',
d7d433
	'window.h' ]
833ed7
833ed7
root_headers = [
b53a5c
	name + '.h',
b53a5c
	name + '-nk.h' ]
833ed7
833ed7
sources = [
833ed7
	'animation.c',
833ed7
	'array.c',
833ed7
	'collider.c',
833ed7
	'common.c',
833ed7
	'drawing.c',
a20939
	'font.c',
1d641c
	'framebuffer.c',
8bc1f1
	'geometry.c',
deef1d
	'gl.c',
833ed7
	'group.c',
b53a5c
	'nuklear-heli.c',
833ed7
	'test.c',
833ed7
	'sound.c',
833ed7
	'sprite.c',
d7d433
	'window.c',
d7d433
	'windowui.c',
a20939
	'blob.S' ]
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),
f63775
	'@CONFIG_LIBS@'   : '-l' + name + ldflags,
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)