From 79fd8ebfef5a6ad8c00e70cb6862b24b254aab3f Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 16 Nov 2004 16:09:11 +0000 Subject: [PATCH] improve the sconsbuild, still lots of work needed to completely replace automake with it SVN-Revision: 2095 --- SConstruct | 176 ++++++++++++++++++--------------------------------------- lib/SConscript | 5 ++ src/SConscript | 5 ++ 3 files changed, 64 insertions(+), 122 deletions(-) create mode 100644 lib/SConscript create mode 100644 src/SConscript diff --git a/SConstruct b/SConstruct index f5a250ee3..c871b8d21 100644 --- a/SConstruct +++ b/SConstruct @@ -1,123 +1,55 @@ # -# A simple SConstruct file. -# See http://www.scons.org/ for more information about what SCons is and how it -# may help you... :-) -# I've never done anything with SCons before. Quite obviously this script is in -# a non-working state!! Maybe someone with more knowledge of the materia can -# take over.... -# - Benjamin P. 'litespeed' Jung - -# - -# TODO: such static entries are obviously not what we want. -# Using e.g. 'sdl-config' to obtain parameters would be muuuuuch -# better. - - -DATA_PREFIX = '\\\"/usr/local/share/supertux\\\"' -LOCALEDIR = '\\\"/usr/local/share/locale\\\"' - -CCFLAGS = [ - '-O2', - '-DDATA_PREFIX=' + DATA_PREFIX, - '-DLOCALEDIR=' + LOCALEDIR -] - -CPPPATH = ['/usr/include/SDL', '/usr/include/X11', 'src', 'lib', 'intl', '.'] - -LIBPATH = [ - 'lib', - '/lib', - '/usr/lib', - '/usr/lib/X11', - '/usr/local/lib' -] - -LIBS = [ - 'supertux', - 'SDL', - 'SDL_gfx', - 'SDL_image', - 'SDL_mixer', - 'SDL_sound', - 'pthread', - 'm', - 'dl', - 'asound', - 'GL', - 'GLU' -] - - -libsupertux_src = [ - 'lib/app/globals.cpp', - 'lib/app/setup.cpp', - 'lib/audio/musicref.cpp', - 'lib/audio/sound_manager.cpp', - 'lib/gui/button.cpp', - 'lib/gui/menu.cpp', - 'lib/gui/mousecursor.cpp', - 'lib/math/physic.cpp', - 'lib/math/vector.cpp', - 'lib/special/game_object.cpp', - 'lib/special/moving_object.cpp', - 'lib/special/sprite.cpp', - 'lib/special/sprite_manager.cpp', - 'lib/special/timer.cpp', - 'lib/special/frame_rate.cpp', - 'lib/utils/configfile.cpp', - 'lib/utils/lispreader.cpp', - 'lib/utils/lispwriter.cpp', - 'lib/video/drawing_context.cpp', - 'lib/video/font.cpp', - 'lib/video/screen.cpp', - 'lib/video/surface.cpp' -] - -supertux_src = [ - 'src/background.cpp', - 'src/badguy.cpp', - 'src/badguy_specs.cpp', - 'src/bitmask.cpp', - 'src/camera.cpp', - 'src/collision.cpp', - 'src/door.cpp', - 'src/gameloop.cpp', - 'src/gameobjs.cpp', - 'src/high_scores.cpp', - 'src/interactive_object.cpp', - 'src/intro.cpp', - 'src/level.cpp', - 'src/level_subset.cpp', - 'src/leveleditor.cpp', - 'src/misc.cpp', - 'src/particlesystem.cpp', - 'src/player.cpp', - 'src/resources.cpp', - 'src/scene.cpp', - 'src/sector.cpp', - 'src/special.cpp', - 'src/statistics.cpp', - 'src/supertux.cpp', - 'src/tile.cpp', - 'src/tile_manager.cpp', - 'src/tilemap.cpp', - 'src/title.cpp', - 'src/worldmap.cpp' -] - - -StaticLibrary( - target = 'lib/supertux', - source = libsupertux_src, - CPPPATH = CPPPATH, - CCFLAGS = CCFLAGS -) - -Program( - target = 'src/supertux', - source = supertux_src, - CPPPATH = CPPPATH, - CCFLAGS = CCFLAGS, - LIBPATH = LIBPATH, - LIBS = LIBS -) +# SConstruct build file. See http://www.scons.org for details. + +# based on a script from chenlee@ustc.edu +def Glob(dirs, pattern = '*' ): + import os, fnmatch + files = [] + for dir in dirs: + for file in os.listdir( Dir(dir).srcnode().abspath ): + if fnmatch.fnmatch(file, pattern) : + files.append( os.path.join( dir, file ) ) + return files + +opts = Options('custom.py') +opts.Add('CXX', 'The C++ compiler', 'g++') +opts.Add('CXXFLAGS', 'Additional C++ compiler flags', '') +opts.Add('CPPPATH', 'Additional preprocessor paths', '') +opts.Add('CPPFLAGS', 'Additional preprocessor flags', '') +opts.Add('LIBPATH', 'Additional library paths', '') +opts.Add('LIBS', 'Additional libraries', '') +opts.Add('DESTDIR', \ + 'destination directory for installation. It is prepended to PREFIX', '') +opts.Add('PREFIX', 'Installation prefix', '/usr/local') + +env = Environment(options = opts) +conf = Configure(env) + +# TODO check -config apps in the Configure context + +if not conf.CheckLib('SDL_mixer'): + print "Couldn't find SDL_mixer library!" + Exit(1) +if not conf.CheckLib('SDL_image'): + print "Couldn't find SDL_image library!" + Exit(1) +if not conf.CheckLib('GL'): + print "Couldn't find OpenGL library!" + Exit(1) + +env = conf.Finish() + +env.ParseConfig('sdl-config --cflags --libs') +env.Append(CPPPATH = ["#", "#/src", "#/lib"]) +env.Append(CPPDEFINES = \ + {'DATA_PREFIX':"'\"" + env['PREFIX'] + "/share/supertux\"'" , + 'LOCALEDIR' :"'\"" + env['PREFIX'] + "/locales\"'"}) + +env.Append(LIBS = ["supertux"]) +env.Append(LIBPATH=["#"]) + +build_dir="build/linux" + +env.Export(["env", "Glob"]) +env.SConscript("lib/SConscript", build_dir=build_dir + "/lib", duplicate=0) +env.SConscript("src/SConscript", build_dir=build_dir + "/src", duplicate=0) diff --git a/lib/SConscript b/lib/SConscript new file mode 100644 index 000000000..6a98af1fd --- /dev/null +++ b/lib/SConscript @@ -0,0 +1,5 @@ +Import('*') + +libsupertux_src = Glob(dirs=["app", "audio", "gui", "math", + "special", "utils", "video"], pattern="*.cpp") +env.Library(target="supertux", source=libsupertux_src) diff --git a/src/SConscript b/src/SConscript new file mode 100644 index 000000000..7d937e686 --- /dev/null +++ b/src/SConscript @@ -0,0 +1,5 @@ +Import('*') + +supertux_src = Glob(dirs=[".", "object"], pattern="*.cpp") +env.Program(target="#/supertux", source = supertux_src) + -- 2.11.0