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) WITH_FULL_UNICODE_FONT = ARGUMENTS.get('WITH_FULL_UNICODE_FONT', 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 -DNDEBUG ' if int(WITH_FULL_UNICODE_FONT): flags += ' -DWITH_FULL_UNICODE_FONT' # files lists target = name headers = [ 'animation.h', 'common.h', 'colors.h', 'drawing.h', 'font.h', 'framebuffer.h', 'group.h', 'nuklear.h', 'nuklear-heli.h', 'sound.h', 'sprite.h', 'window.h' ] root_headers = [ name + '.h', name + '-nk.h' ] sources = [ 'animation.c', 'array.c', 'collider.c', 'common.c', 'drawing.c', 'font.c', 'framebuffer.c', 'geometry.c', 'gl.c', 'group.c', 'nuklear-heli.c', 'test.c', 'sound.c', 'sprite.c', 'window.c', 'windowui.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)