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