Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[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_supertux()
23         self.build_tests()
24
25     def build_tinygettext(self):
26         env = Environment(CPPPATH=["external/tinygettext/",
27                                    "external/squirrel/include/",
28                                    ".",
29                                    "src"])
30         env.ParseConfig("sdl-config --libs --cflags")
31         self.libtinygettext = env.StaticLibrary("tinygettext", Glob("external/tinygettext/*.cpp"))
32
33     def build_binreloc(self):
34         env = Environment(CPPPATH=["external/binreloc/", "."])
35         self.libbinreloc = env.StaticLibrary("binreloc", "external/binreloc/binreloc.c")
36
37     def build_squirrel(self):
38         env = Environment(CPPPATH=["external/squirrel/include/"])
39         self.libsquirrel = env.StaticLibrary("squirrel",
40                                              Glob("external/squirrel/squirrel/*.cpp") +
41                                              Glob("external/squirrel/sqstdlib/*.cpp") +
42                                              Glob("external/squirrel/sqstdlib/*.c"))
43
44     def build_supertux(self):
45         self.env = Environment(CPPPATH=["external/squirrel/include/",
46                                         "external/",
47                                         "external/obstack",
48                                         "src/",
49                                         "/usr/include/AL/", # yuck
50                                         "."],
51                                CXXFLAGS=["-O2", "-g3",
52                                          "-ansi",
53                                          "-pedantic",
54                                          "-Wall",
55                                          "-Wextra",
56                                          "-Wnon-virtual-dtor",
57                                          # "-Weffc++",
58                                          # "-Wconversion",
59                                          "-Werror",
60                                          # "-Wshadow",
61                                          "-Wcast-qual",
62                                          "-Winit-self", # only works with >= -O1
63                                          "-Wno-unused-parameter"])
64
65         # Add libraries
66         self.env.ParseConfig("sdl-config --libs --cflags")
67         self.env.ParseConfig("pkg-config --libs --cflags openal")
68         self.env.ParseConfig("pkg-config --libs --cflags vorbis vorbisfile ogg")
69         self.env.Append(LIBS=[self.libsquirrel, self.libbinreloc, self.libtinygettext])
70         self.env.Append(LIBS=["SDL_image", "curl", "GL", "physfs"])
71
72         # Create config.h
73         self.iconv_const = 0
74         config_h = open('config.h', 'w')
75         config_h.write('#define PACKAGE_NAME "Supertux"\n')
76         config_h.write('#define PACKAGE_VERSION "Milestone 2"\n')
77         config_h.write('#define ENABLE_BINRELOC 1\n')
78         config_h.write('#define APPDATADIR "data"\n')
79         config_h.write('#define HAVE_LIBCURL 1\n')
80         config_h.write('#define HAVE_OPENGL 1\n')
81         config_h.write('#define DEBUG 1\n')
82         config_h.write('#define ICONV_CONST %s\n' % self.iconv_const)
83         config_h.close()
84
85         version_h = open('version.h', 'w')
86         version_h.close()
87
88         # base source
89         supertux_sources = Glob("src/*.cpp") + Glob("src/*/*.cpp")
90
91         # optional video drivers
92         supertux_sources += Glob("src/video/gl/*.cpp")
93         supertux_sources += Glob("src/video/sdl/*.cpp")
94
95         self.libsupertux = self.env.StaticLibrary("supertux", supertux_sources)
96         self.env.Program("supertux", ["src/main.cpp", self.libsupertux])
97
98     def build_tests(self):
99         for filename in Glob("test/*_test.cpp", strings=True):
100             self.env.Program(filename[:-4], [filename, self.libsupertux])
101
102 project = Project()
103
104 # EOF #