Renamed namespaces to all lowercase
[supertux.git] / SConscript
1 #  SuperTux
2 #  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
3 #
4 #  This program is free software: you can redistribute it and/or modify
5 #  it under the terms of the GNU General Public License as published by
6 #  the Free Software Foundation, either version 3 of the License, or
7 #  (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program.  If not, see <http:#www.gnu.org/licenses/>.
16
17 class Project:
18     def __init__(self):
19         self.build_squirrel()
20         self.build_tinygettext()
21         self.build_binreloc()
22         self.build_findlocale()
23         self.build_miniswig()
24         self.build_supertux()
25         self.build_tests()
26         
27     def build_tinygettext(self):
28         env = Environment(CPPPATH=[".", "src"])
29         env.ParseConfig("sdl-config --libs --cflags")
30         self.libtinygettext = env.StaticLibrary("tinygettext", Glob("external/tinygettext/tinygettext/*.cpp"))
31
32     def build_binreloc(self):
33         env = Environment(CPPPATH=["external/binreloc/", "."])
34         self.libbinreloc = env.StaticLibrary("binreloc", "external/binreloc/binreloc.c")
35
36     def build_findlocale(self):
37         env = Environment(CPPPATH=["external/findlocale/", "."])
38         self.libfindlocale = env.StaticLibrary("findlocale", "external/findlocale/findlocale.c")
39
40     def build_squirrel(self):
41         env = Environment(CPPPATH=["external/squirrel/include/"])
42         self.libsquirrel = env.StaticLibrary("squirrel",
43                                              Glob("external/squirrel/squirrel/*.cpp") +
44                                              Glob("external/squirrel/sqstdlib/*.cpp") +
45                                              Glob("external/squirrel/sqstdlib/*.c"))
46
47     def build_miniswig(self):
48         env = Environment(CPPPATH=[".", "tools/miniswig/"])
49         miniswig_bin = env.Program('miniswig',
50                                    ['tools/miniswig/parser.yy',
51                                     'tools/miniswig/lexer.ll',
52                                     'tools/miniswig/create_docu.cpp',
53                                     'tools/miniswig/xmlwriter.cpp',
54                                     'tools/miniswig/create_wrapper.cpp',
55                                     'tools/miniswig/main.cpp',
56                                     'tools/miniswig/tree.cpp'])
57
58         # env = self.env.Clone()
59         # env.Append(MINISWIG=miniswig_bin)
60
61         # env.Depends(env.Command('src/scripting/miniswig.tmp', 'src/scripting/wrapper.interface.hpp',
62         #                         ["$CXX -E -Isrc/ -x c -CC $SOURCE -o $TARGET -DSCRIPTING_API"]),
63         #             ['src/scripting/interface.hpp',
64         #              'src/scripting/game_objects.hpp'])
65
66         # env.Depends(env.Command(['src/scripting/wrapper.cpp', 'src/scripting/wrapper.hpp'], 'src/scripting/miniswig.tmp',
67         #                         ["$MINISWIG --input $SOURCE --output-cpp ${TARGETS[0]} --output-hpp ${TARGETS[1]} "+
68         #                          "--module windstille --select-namespace Scripting"]),
69         #             miniswig_bin)
70         
71         # g++ -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o miniswig.tmp -Isrc
72         # tools/miniswig/miniswig --input miniswig.tmp \
73         #                         --output-cpp src/scripting/wrapper.cpp \
74         #                         --output-hpp src/scripting/wrapper.hpp \
75         #                         --module supertux \
76         #                         --select-namespace scripting
77         
78     def build_supertux(self):
79         self.env = Environment(CPPPATH=["external/squirrel/include/",
80                                         "external/findlocale/",
81                                         "external/binreloc/",
82                                         "external/obstack/",
83                                         "external/tinygettext/",
84                                         "src/",
85                                         "/usr/include/AL/", # yuck
86                                         "."],
87                                CXXFLAGS=["-O2", "-g3",
88                                          "-ansi",
89                                          "-pedantic",
90                                          "-Wall",
91                                          "-Wextra",
92                                          "-Wnon-virtual-dtor",
93                                          "-Weffc++",
94                                          # "-Wconversion",
95                                          "-Werror",
96                                          # "-Wshadow",
97                                          "-Wcast-qual",
98                                          "-Winit-self", # only works with >= -O1
99                                          "-Wno-unused-parameter"])
100
101         # Add libraries
102         self.env.ParseConfig("sdl-config --libs --cflags")
103         self.env.ParseConfig("pkg-config --libs --cflags openal")
104         self.env.ParseConfig("pkg-config --libs --cflags vorbis vorbisfile ogg")
105         self.env.Append(LIBS=[self.libsquirrel, self.libbinreloc, self.libtinygettext, self.libfindlocale])
106         self.env.Append(LIBS=["SDL_image", "curl", "GL", "GLEW", "physfs"])
107
108         # Create config.h
109         self.iconv_const = 0
110         config_h = open('config.h', 'w')
111         config_h.write('#define PACKAGE_NAME "Supertux"\n')
112         config_h.write('#define PACKAGE_VERSION "Milestone 2"\n')
113         config_h.write('#define ENABLE_BINRELOC 1\n')
114         config_h.write('#define APPDATADIR "data"\n')
115         config_h.write('#define HAVE_LIBCURL 1\n')
116         config_h.write('#define HAVE_OPENGL 1\n')
117         config_h.write('#define ICONV_CONST %s\n' % self.iconv_const)
118         config_h.close()
119
120         version_h = open('version.h', 'w')
121         version_h.close()
122
123         # base source
124         supertux_sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/supertux/menu/*.cpp")
125
126         # optional video drivers
127         supertux_sources += Glob("src/video/gl/*.cpp")
128         supertux_sources += Glob("src/video/sdl/*.cpp")
129
130         self.libsupertux = self.env.StaticLibrary("supertux", supertux_sources)
131         self.env.Program("supertux", ["src/main.cpp", self.libsupertux])
132
133     def build_tests(self):
134         for filename in Glob("test/*_test.cpp", strings=True):
135             self.env.Program(filename[:-4], [filename, self.libsupertux])
136
137 project = Project()
138
139 # EOF #