Removed that logo from this bramch aswell..
[dbw.git] / wscript
blobfd3349824f779054f7dc5792bfeafb8db2587851
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os
6 HAVE_GIT=os.system("git rev-parse --git-dir >/dev/null 2>/dev/null") == 0
7 if (HAVE_GIT):
8 TAG=os.popen('git describe --tag --candidates=0 2>/dev/null').readline().strip('\n')
9 if (TAG != ''):
10 INGAMEVER="git-"+TAG
11 else:
12 INGAMEVER='git-'+os.popen('git-rev-parse --default HEAD').readline().strip('\n')
13 BRANCH=os.popen("git branch | grep -e '^\*' | sed 's/^\* //'").readline().strip('\n')
14 else:
15 INGAMEVER="0.0-r1"
16 BRANCH="release"
19 # the following two variables are used by the target "waf dist"
20 VERSION=str(INGAMEVER)
21 APPNAME='dirtyblobwars'
23 # these variables are mandatory ('/' are converted automatically)
24 srcdir = 'src'
25 blddir = 'build'
27 import Params
28 Params.g_autoconfig = 1
30 def init():
31 pass
33 def set_options(opt):
34 # options provided in a script in a subdirectory named "src"
35 opt.sub_options('src')
37 # options provided by the modules
38 opt.tool_options('g++')
39 opt.tool_options('boost')
41 # custom options
42 opt.add_option('--with-mapeditor', action='store_true', help='Build a simple map editor', dest='mapedit')
43 opt.add_option('--bindir', type='string', default='games/bin/', help='Put binaries into this dir (relative to prefix)', dest='bindir')
44 opt.add_option('--docsdir', type='string', default='share/doc/dirtystudios/blobwars/', help='Put docs into this dir (relative to prefix)', dest='docsdir')
45 opt.add_option('--datadir', type='string', default='share/games/dirtystudios/blobwars/', help='Put data files into this dir (relative to prefix)', dest='datadir')
48 iconv_test = """
49 #include <iconv.h>
51 int main()
54 ICONV_CONST char* in_orig = "boo";
55 size_t in_len = 6;
56 char* out;
57 size_t out_len;
58 iconv_t cd;
60 iconv(cd, &in_orig, &in_len, &out, &out_len);
62 return 0;
64 """
67 def check_iconv(conf):
68 conf.check_header2('iconv.h')
69 conf.check_library2('iconv', mandatory=0)
71 test = conf.create_test_configurator()
72 test.code = "#define ICONV_CONST const\n" + iconv_test
73 test.uselib = 'ICONV'
74 status = test.run()
76 if status:
77 conf.check_message('we can compile iconv program', '', 1, 'with const')
78 conf.env['defines']['ICONV_CONST'] = 'const'
79 else:
80 test.code = "#define ICONV_CONST \n" + iconv_test
81 status = test.run()
82 if status:
83 conf.check_message('we can compile iconv program', '', 1, 'without const')
84 conf.env['defines']['ICONV_CONST'] = ' '
85 else:
86 conf.check_message('we can compile iconv program', '', 0)
87 raise "Compilation failed"
89 pass
91 def check_jpeg(conf):
92 from Params import fatal
94 if not conf.check_library2('jpeg.dll', uselib='JPEG', mandatory = 0):
95 conf.check_library2('jpeg', uselib='JPEG')
96 # whaa! Why there aren't any people who can program? Making a header without including required headers?!?!
97 # Looks, not only Parallel Realities can't code..
98 test = conf.create_header_configurator()
99 test.name = 'jpeglib.h'
100 test.header_code = "#include <cstdio>\n"
101 test.mandatory = 1
102 test.run()
104 pass
106 def boost_header(conf, name):
107 test = conf.create_header_configurator()
108 test.name = name
109 test.mandatory = 1
110 test.uselib = "BOOST"
111 test.run()
113 pass
115 def configure(conf):
116 import Params
117 from Params import fatal
118 pre = conf.env['PREFIX']
119 conf.env['BINDIR'] = pre + Params.g_options.bindir
120 conf.env['DOCSDIR'] = pre + Params.g_options.docsdir
121 conf.env['DATADIR'] = pre + Params.g_options.datadir
122 conf.env['MAPEDIT'] = Params.g_options.mapedit
124 conf.check_tool('g++')
126 #conf.sub_config('src')
128 #conf.env['CXXFLAGS']='-g -Wall -O0' # -I/home/dirty_ice/crossdev/winroot/include'
129 #conf.env['CCFLAGS']='-g -Wall -O0'
130 #conf.env['LINKFLAGS']='-L/home/dirty_ice/crossdev/winroot/lib'
131 if (Params.g_options.debug_level == "ultradebug"):
132 conf.env['CXXFLAGS'] += ["-Wabi", "-Wctor-dtor-privacy", "-Wnon-virtual-dtor", "-Wreorder", "-Weffc++", "-Wstrict-null-sentinel", "-Wold-style-cast", "-Woverloaded-virtual", "-Wsign-promo", "-Wformat=2", "-Winit-self", "-Wswitch-default", "-Wswitch-enum", "-Wunused", "-Wextra", "-Wfloat-equal", "-Wundef", "-Wpointer-arith", "-Wcast-qual", "-Wcast-align", "-Wwrite-strings", "-Wconversion", "-Waddress", "-Wmissing-field-initializers", "-Wmissing-noreturn", "-Wmissing-format-attribute", "-Wpacked", "-Wno-invalid-offsetof", "-Wvolatile-register-var", "-Wcomment", "-Wtrigraphs", "-Wimport"]
135 # check SDL stuff
136 conf.check_pkg2('sdl', '1.2')
137 conf.check_tool('checks')
138 conf.check_header2('SDL/SDL_image.h')
139 conf.check_library2('SDL_image')
140 conf.check_header2('SDL/SDL_mixer.h')
141 conf.check_library2('SDL_mixer')
142 conf.check_header2('SDL/SDL_ttf.h')
143 conf.check_library2('SDL_ttf')
144 conf.check_header2('physfs.h')
146 # check physfs
147 conf.check_library2('physfs')
148 conf.check_header2('physfs.h')
150 # check iconv
151 check_iconv(conf)
153 # check libpng
154 conf.check_pkg2('libpng12', '1.2', uselib='PNG')
156 # check libjpeg
157 check_jpeg(conf)
159 # check boost stuff
160 #conf.env["WANT_BOOST"] = ""
161 conf.check_tool('boost')
162 boost_header(conf, 'boost/format.hpp')
163 boost_header(conf, 'boost/scoped_ptr.hpp')
164 boost_header(conf, 'boost/shared_ptr.hpp')
165 boost_header(conf, 'boost/tokenizer.hpp')
167 platform=conf.detect_platform()
168 conf.check_message_custom("platform", '', platform)
169 if (platform != 'cygwin'):
170 conf.define('UNIX', 1)
171 else:
172 conf.define('WIN32', 1)
174 conf.env['VERSION'] = INGAMEVER
175 conf.env['BRANCH'] = BRANCH
176 conf.define('VERSION', INGAMEVER)
177 conf.define('BRANCH', BRANCH)
178 conf.define('DATADIR', conf.env['DATADIR'])
180 conf.write_config_header('config.h')
182 def build(bld):
183 import preproc
184 preproc.strict_quotes = 1
186 bld.add_subdirs('.')
188 def shutdown():
189 import os, Params
190 if not Params.g_commands['build']: return
191 os.popen('ln -f -s build/default/dirtyblobwars ../dirtyblobwars')
192 os.popen('ln -f -s build/default/dirtyblobwars-mapeditor ../mapedit')
193 #EOF