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