Decrease numbers of debug messages: some of them are removed, some now require a...
[dbw.git] / wscript
blobbb6229091df8d01f102f7d1a3762a47e8803c12a
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os
6 INGAMEVER='git-'+os.popen('git-rev-parse --default HEAD').readline().strip('\n')
7 #RELEASE =1
8 # the following two variables are used by the target "waf dist"
9 VERSION=str(INGAMEVER) #+'.'+str(RELEASE)
10 APPNAME='blobwars'
12 # these variables are mandatory ('/' are converted automatically)
13 srcdir = 'src'
14 blddir = 'build'
16 def init():
17 pass
19 def set_options(opt):
20 # options provided in a script in a subdirectory named "src"
21 opt.sub_options('src')
23 # options provided by the modules
24 opt.tool_options('g++')
26 # custom options
27 opt.add_option('--with-mapeditor', action='store_true', help='Build a simple map editor', dest='mapedit')
28 opt.add_option('--bindir', type='string', default='games/bin/', help='Put binaries into this dir (relative to prefix)', dest='bindir')
29 opt.add_option('--docsdir', type='string', default='share/doc/dirtystudios/blobwars/', help='Put docs into this dir (relative to prefix)', dest='docsdir')
30 opt.add_option('--datadir', type='string', default='share/games/dirtystudios/blobwars/', help='Put data files into this dir (relative to prefix)', dest='datadir')
33 iconv_test = """
34 #include <iconv.h>
36 int main()
39 ICONV_CONST char* in_orig = "boo";
40 size_t in_len = 6;
41 char* out;
42 size_t out_len;
43 iconv_t cd;
45 iconv(cd, &in_orig, &in_len, &out, &out_len);
47 return 0;
49 """
52 def check_iconv(conf):
53 conf.check_header2('iconv.h')
54 conf.check_library2('iconv', mandatory=0)
56 test = conf.create_test_configurator()
57 test.code = "#define ICONV_CONST const\n" + iconv_test
58 test.uselib = 'ICONV'
59 status = test.run()
61 if status:
62 conf.check_message_custom('we can compile iconv program', '', 'yes, with const')
63 conf.add_define('ICONV_CONST', 'const', 0)
64 else:
65 test.code = "#define ICONV_CONST \n" + iconv_test
66 status = test.run()
67 if status:
68 conf.check_message_custom('we can compile iconv program', '', 'yes, without const')
69 conf.add_define('ICONV_CONST', ' ', 0)
70 else:
71 conf.check_message('we can compile iconv program', '', 0)
72 raise "Compilation failed"
74 pass
76 def configure(conf):
77 import Params
78 pre = conf.env['PREFIX']
79 conf.env['BINDIR'] = pre + Params.g_options.bindir
80 conf.env['DOCSDIR'] = pre + Params.g_options.docsdir
81 conf.env['DATADIR'] = pre + Params.g_options.datadir
82 conf.env['MAPEDIT'] = Params.g_options.mapedit
84 conf.check_tool('g++')
86 conf.sub_config('src')
88 conf.env['CXXFLAGS']='-g -Wall -O0' # -I/home/dirty_ice/crossdev/winroot/include'
89 conf.env['CCFLAGS']='-g -Wall -O0'
90 #conf.env['LINKFLAGS']='-L/home/dirty_ice/crossdev/winroot/lib'
91 #conf.env['SOME_INSTALL_DIR']='/tmp/ahoy/lib/'
93 #conf.find_program('sdl-config')
94 conf.check_pkg('sdl', vnum='1.2')
95 conf.check_tool('checks')
96 conf.check_library2('SDL_image')
97 conf.check_library2('SDL_mixer')
98 conf.check_library2('SDL_ttf')
99 conf.check_library2('physfs')
100 check_iconv(conf)
101 conf.check_header2('boost/format.hpp')
103 platform=conf.detect_platform()
104 conf.check_message_custom("platform", '', platform)
105 if (platform != 'cygwin'):
106 conf.add_define('UNIX', 1)
107 else:
108 conf.add_define('WIN32', 1)
110 #conf.env['LIBPATH']='/home/dirty_ice/SDL_ttf-2.0.9/fkinst/usr/local/lib'
111 #conf.env['LIB']='SDL_ttfdebug'
113 conf.add_define('VERSION', INGAMEVER)
114 #conf.add_define('RELEASE', RELEASE)
115 conf.add_define('DATADIR', conf.env['DATADIR'])
117 conf.write_config_header('config.h')
119 def build(bld):
120 bld.add_subdirs('.')
122 ## installing resources and files - call them under build(bld) or shutdown()
123 ## to trigger the glob, ad a star in the name
124 ## the functions are not called if not in install mode
125 #install_files('PREFIX', '', 'src/a2.h src/a1.h')
126 #install_files('PREFIX', 'subfolder/subsubfolder', 'src/*.h')
127 #install_as('PREFIX', 'dir/bar.png', 'foo.png')
129 def shutdown():
130 import os, Params
131 if not Params.g_commands['build']: return
132 os.popen('ln -f -s build/default/dirtyblobwars ../dirtyblobwars')
133 os.popen('ln -f -s build/default/dirtyblobwars-mapeditor ../mapedit')
134 #EOF