improve the sconsbuild, still lots of work needed to completely replace automake...
[supertux.git] / SConstruct
1 #
2 # SConstruct build file. See http://www.scons.org for details.
3
4 # based on a script from chenlee@ustc.edu
5 def Glob(dirs, pattern = '*' ):
6     import os, fnmatch 
7     files = []
8     for dir in dirs:
9         for file in os.listdir( Dir(dir).srcnode().abspath ): 
10             if fnmatch.fnmatch(file, pattern) : 
11                 files.append( os.path.join( dir, file ) ) 
12     return files 
13
14 opts = Options('custom.py')
15 opts.Add('CXX', 'The C++ compiler', 'g++')
16 opts.Add('CXXFLAGS', 'Additional C++ compiler flags', '')
17 opts.Add('CPPPATH', 'Additional preprocessor paths', '')
18 opts.Add('CPPFLAGS', 'Additional preprocessor flags', '')
19 opts.Add('LIBPATH', 'Additional library paths', '')
20 opts.Add('LIBS', 'Additional libraries', '')
21 opts.Add('DESTDIR', \
22         'destination directory for installation. It is prepended to PREFIX', '')
23 opts.Add('PREFIX', 'Installation prefix', '/usr/local')
24
25 env = Environment(options = opts)
26 conf = Configure(env)
27
28 # TODO check -config apps in the Configure context
29     
30 if not conf.CheckLib('SDL_mixer'):
31     print "Couldn't find SDL_mixer library!"
32     Exit(1)
33 if not conf.CheckLib('SDL_image'):
34     print "Couldn't find SDL_image library!"
35     Exit(1)
36 if not conf.CheckLib('GL'):
37     print "Couldn't find OpenGL library!"
38     Exit(1)
39
40 env = conf.Finish()
41
42 env.ParseConfig('sdl-config --cflags --libs')
43 env.Append(CPPPATH = ["#", "#/src", "#/lib"])
44 env.Append(CPPDEFINES = \
45         {'DATA_PREFIX':"'\"" + env['PREFIX'] + "/share/supertux\"'" ,
46          'LOCALEDIR'  :"'\"" + env['PREFIX'] + "/locales\"'"})
47
48 env.Append(LIBS = ["supertux"])
49 env.Append(LIBPATH=["#"])
50
51 build_dir="build/linux"
52
53 env.Export(["env", "Glob"])
54 env.SConscript("lib/SConscript", build_dir=build_dir + "/lib", duplicate=0)
55 env.SConscript("src/SConscript", build_dir=build_dir + "/src", duplicate=0)