2 # Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
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.
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.
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/>.
18 development_cxx_flags =["-O2", "-g3",
29 "-Winit-self", # only works with >= -O1
30 "-Wno-unused-parameter"]
35 self.build_tinygettext()
37 self.build_findlocale()
42 def build_tinygettext(self):
43 env = Environment(CPPPATH=[".", "src"])
44 env.ParseConfig("sdl-config --libs --cflags")
45 self.libtinygettext = env.StaticLibrary("tinygettext", Glob("external/tinygettext/tinygettext/*.cpp"))
47 def build_binreloc(self):
48 env = Environment(CPPPATH=["external/binreloc/", "."])
49 self.libbinreloc = env.StaticLibrary("binreloc", "external/binreloc/binreloc.c")
51 def build_findlocale(self):
52 env = Environment(CPPPATH=["external/findlocale/", "."])
53 self.libfindlocale = env.StaticLibrary("findlocale", "external/findlocale/findlocale.c")
55 def build_squirrel(self):
56 env = Environment(CPPPATH=["external/squirrel/include/"])
57 self.libsquirrel = env.StaticLibrary("squirrel",
58 Glob("external/squirrel/squirrel/*.cpp") +
59 Glob("external/squirrel/sqstdlib/*.cpp") +
60 Glob("external/squirrel/sqstdlib/*.c"))
62 def build_miniswig(self):
63 cxx_flags = development_cxx_flags[:]
64 cxx_flags.remove("-Werror")
65 env = Environment(CXXFLAGS=cxx_flags, CPPPATH=[".", "tools/miniswig/"])
66 miniswig_bin = env.Program('miniswig',
67 ['tools/miniswig/parser.yy',
68 'tools/miniswig/lexer.ll',
69 'tools/miniswig/create_docu.cpp',
70 'tools/miniswig/xmlwriter.cpp',
71 'tools/miniswig/create_wrapper.cpp',
72 'tools/miniswig/main.cpp',
73 'tools/miniswig/tree.cpp'])
75 env.Append(MINISWIG=miniswig_bin)
76 env.Depends(env.Command('src/scripting/miniswig.tmp',
77 'src/scripting/wrapper.interface.hpp',
78 ["$CXX -E -Isrc/ -x c -CC $SOURCE -o $TARGET -DSCRIPTING_API"]),
81 env.Depends(env.Command(['src/scripting/wrapper.cpp', 'src/scripting/wrapper.hpp'],
82 'src/scripting/miniswig.tmp',
85 "--output-cpp ${TARGETS[0]} " +
86 "--output-hpp ${TARGETS[1]} " +
87 "--module supertux " +
88 "--select-namespace scripting"]),
91 # g++ -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o miniswig.tmp -Isrc
92 # tools/miniswig/miniswig --input miniswig.tmp \
93 # --output-cpp src/scripting/wrapper.cpp \
94 # --output-hpp src/scripting/wrapper.hpp \
96 # --select-namespace scripting
98 def build_supertux(self):
99 self.env = Environment(CPPPATH=["external/squirrel/include/",
100 "external/findlocale/",
101 "external/binreloc/",
103 "external/tinygettext/",
105 "/usr/include/AL/", # yuck
107 CXXFLAGS=development_cxx_flags)
110 self.env.ParseConfig("sdl-config --libs --cflags")
111 self.env.ParseConfig("pkg-config --libs --cflags openal")
112 self.env.ParseConfig("pkg-config --libs --cflags vorbis vorbisfile ogg")
113 self.env.Append(LIBS=[self.libsquirrel, self.libbinreloc, self.libtinygettext, self.libfindlocale])
114 self.env.Append(LIBS=["SDL_image", "curl", "GL", "GLEW", "physfs"])
118 config_h = open('config.h', 'w')
119 config_h.write('#define PACKAGE_NAME "supertux2"\n')
120 config_h.write('#define PACKAGE_VERSION "Milestone 2"\n')
121 config_h.write('#define ENABLE_BINRELOC 1\n')
122 config_h.write('#define INSTALL_SUBDIR_BIN "games/"\n')
123 config_h.write('#define INSTALL_SUBDIR_SHARE "share/games/supertux2/"\n')
124 config_h.write('#define HAVE_LIBCURL 1\n')
125 config_h.write('#define HAVE_OPENGL 1\n')
126 config_h.write('#define ICONV_CONST %s\n' % self.iconv_const)
129 version_h = open('version.h', 'w')
133 supertux_sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/supertux/menu/*.cpp")
135 # optional video drivers
136 supertux_sources += Glob("src/video/gl/*.cpp")
137 supertux_sources += Glob("src/video/sdl/*.cpp")
139 self.libsupertux = self.env.StaticLibrary("supertux", supertux_sources)
140 self.env.Program("supertux", ["src/main.cpp", self.libsupertux])
142 def build_tests(self):
143 for filename in Glob("test/*_test.cpp", strings=True):
144 self.env.Program(filename[:-4], [filename, self.libsupertux])