aboutsummaryrefslogtreecommitdiffstats
path: root/games/battletanks/files/patch-SConstruct
blob: d65bd1f6f72aba10d4a194afa534e17fe3209cfd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
--- SConstruct.orig	2009-12-10 14:58:55 UTC
+++ SConstruct
@@ -16,7 +16,7 @@ env['BUILDERS']['Library'] = picLibBuilder
 env['BUILDERS']['StaticLibrary'] = picLibBuilder
 env['BUILDERS']['Library'] = picLibBuilder
 
-opts = Options(['options.cache'])
+opts = Variables(['options.cache'])
 #opts.Add('CC', 'C compiler')
 #opts.Add('CXX', 'C++ compiler')
 opts.Add('CCFLAGS', 'General options that are passed to the C compiler')
@@ -30,12 +30,13 @@ if sys.platform != "win32":
 
 if sys.platform != "win32":
 	opts.Add('prefix', 'prefix for **nix packaging', '')
+	opts.Add('DESTDIR', 'staging dir (also for packaging)', '')
 	opts.Add('lib_dir', 'resources directory (default: prefix/lib)', '')
 	opts.Add('plugins_dir', 'plugins directory (default: prefix/lib/btanks)', '')
 	opts.Add('resources_dir', 'resources directory (default: prefix/share/btanks)', '')
-	opts.Add(BoolOption('gcc_visibility', 'gcc visibility', 'true'))
+	opts.Add(BoolVariable('gcc_visibility', 'gcc visibility', 'true'))
 
-opts.Add(EnumOption('mode', 'build mode', 'release', allowed_values=('debug','release')))
+opts.Add(EnumVariable('mode', 'build mode', 'release', allowed_values=('debug','release')))
 
 opts.Update(env)
 opts.Save('options.cache', env.Clone())
@@ -47,16 +48,18 @@ import SCons.Util
 Export('debug')
 
 import SCons.Util
-if os.environ.has_key('CC'):
+if 'CC' in os.environ:
 	env['CC'] = os.environ['CC']
-if os.environ.has_key('CFLAGS'):
+if 'CFLAGS' in os.environ:
 	env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
-if os.environ.has_key('CXX'):
+if 'CXX' in os.environ:
 	env['CXX'] = os.environ['CXX']
-if os.environ.has_key('CXXFLAGS'):
+if 'CXXFLAGS' in os.environ:
 	env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
-if os.environ.has_key('LDFLAGS'):
+if 'LDFLAGS' in os.environ:
 	env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
+if 'CPPPATH' in os.environ:
+	env['CPPPATH'] = os.environ['CPPPATH'].split()
 
 if (sys.platform != "win32" and env['gcc_visibility']): 
 	env.Append(CCFLAGS=['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
@@ -98,9 +101,6 @@ else:
 	if debug:
 		env.Append(CCFLAGS=['-ggdb', '-D_FORTIFY_SOURCE=2'])
 		env.Append(CPPFLAGS=['-ggdb', '-D_FORTIFY_SOURCE=2'])
-	else: 
-		env.Append(CCFLAGS=['-O3'])
-		env.Append(CPPFLAGS=['-O3'])
 		
 	env.Append(CPPFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe', '-pthread'])
 	env.Append(CCFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe', '-pthread'])
@@ -119,17 +119,17 @@ else: 
 
 #print conf.env['CCFLAGS']
 
-if not conf.CheckLibWithHeader('expat', 'expat.h', 'c', "XML_ParserCreate(NULL);", False):
+if not conf.CheckLibWithHeader('expat', 'expat.h', 'c', None, "XML_ParserCreate(NULL);", False):
 	Exit(1)
 
-if not conf.CheckLibWithHeader('z', 'zlib.h', 'c', "zlibVersion();", False):
+if not conf.CheckLibWithHeader('z', 'zlib.h', 'c', None, "zlibVersion();", False):
 	Exit(1)
 
 if sys.platform == "win32":
 	conf.env.Append(LINKFLAGS = ['/SUBSYSTEM:WINDOWS', '/FORCE'])
 	conf.env.Append(LIBS=['SDLmain'])
 
-if not conf.CheckLibWithHeader('SDL', 'SDL.h', 'c++', "SDL_Init(0);", False):
+if not conf.CheckLibWithHeader('SDL', 'SDL.h', 'c++', None, "SDL_Init(0);", False):
 	Exit(1)
 	
 
@@ -140,23 +140,23 @@ Export('smpeg_lib')
 	smpeg_lib = 'smpeg_d'
 Export('smpeg_lib')
 
-if not conf.CheckLibWithHeader(smpeg_lib, 'smpeg/smpeg.h', 'c++', "SMPEG_new_data(malloc(42), 42, NULL, 0);", False):
+if not conf.CheckLibWithHeader(smpeg_lib, 'smpeg/smpeg.h', 'c++', None, "SMPEG_new_data(malloc(42), 42, NULL, 0);", False):
 	Exit(1)
 
-if not conf.CheckLibWithHeader('SDL_image', 'SDL_image.h', 'c++', "IMG_Load(0);", False):
+if not conf.CheckLibWithHeader('SDL_image', 'SDL_image.h', 'c++', None, "IMG_Load(0);", False):
 	Exit(1)
 
-if not conf.CheckLibWithHeader('vorbisfile', 'vorbis/vorbisfile.h', 'c++', "ov_open(0, 0, 0, 0);", False):
+if not conf.CheckLibWithHeader('vorbisfile', 'vorbis/vorbisfile.h', 'c++', None, "ov_open(0, 0, 0, 0);", False):
 	Exit(1)
 
 if sys.platform == 'win32':
-	if not conf.CheckLibWithHeader('lua', 'lua.hpp', 'c++', "lua_newstate(NULL, NULL);", False):
+	if not conf.CheckLibWithHeader('lua', 'lua.hpp', 'c++', None, "lua_newstate(NULL, NULL);", False):
 		Exit(1)
 
 if sys.platform != 'win32':
-	have_sse = conf.CheckLibWithHeader('m', "xmmintrin.h", 'c', '_mm_set_ss(1.0f);', False)
+	have_sse = conf.CheckLibWithHeader('m', "xmmintrin.h", 'c', None, '_mm_set_ss(1.0f);', False)
 else: 
-	have_sse = conf.CheckLibWithHeader('kernel32', "xmmintrin.h", 'c', '_mm_set_ss(1.0f);', False) # hackish lib :(
+	have_sse = conf.CheckLibWithHeader('kernel32', "xmmintrin.h", 'c', None, '_mm_set_ss(1.0f);', False) # hackish lib :(
 
 conf.Finish()
 
@@ -205,7 +205,7 @@ try : 
 
 	except: 
 		info = sys.exc_info()
-		print "%s %s %s" %(info[0], info[1], info[2])
+		print("%s %s %s" %(info[0], info[1], info[2]))
 except : 
 	svnversion = os.popen('svnversion -n .', 'r')
 	version = svnversion.readline().strip()
@@ -238,7 +238,10 @@ version = version[version.rfind(':') + 1:]
 			env.Append(CPPDEFINES='PLUGINS_DIR="\\"' + plugins_dir + '\\""')
 
 version = version[version.rfind(':') + 1:]
-revision = int(version.replace('M', ''))
+try:
+    revision = int(version.replace('M', ''))
+except ValueError:
+    revision = 0
 
 Export('version')
 Export('revision')
@@ -246,31 +249,35 @@ version = '0.9.%s' %version
 Export('plugins_dir')
 
 version = '0.9.%s' %version
-print "version: %s" %version
+print("version: %s" %version)
 
 bt_sublibs = ['mrt', 'sdlx', 'objects', 'clunk']
 env.Append(CPPPATH=['#'])
 
 if (os.path.exists('private')):
 	dir = 'private'
-	BuildDir('#/build/' + buildmode + '/' + dir, dir, 0)
+	VariantDir('#/build/' + buildmode + '/' + dir, dir, 0)
 	SConscript('#/build/' + buildmode + '/' + dir + '/SConscript')	
 
 for dir in bt_sublibs:
-	BuildDir('#/build/' + buildmode + '/' + dir, dir, 0)
+	VariantDir('#/build/' + buildmode + '/' + dir, dir, 0)
 	SConscript('#/build/' + buildmode + '/' + dir + '/SConscript')
 
 for dir in bt_sublibs:
 	env.Append(LIBPATH=['#/build/' + buildmode + '/' + dir])
 
-env.BuildDir('#/build/' + buildmode + '/editor', 'editor', 0)
+env.VariantDir('#/build/' + buildmode + '/editor', 'editor', 0)
 SConscript('#/build/' + buildmode + '/editor/SConscript')
 
 env.Append(LIBPATH=['#/build/' + buildmode + '/engine'])
 
-env.BuildDir('#/build/' + buildmode + '/engine', 'engine', 0)
+env.VariantDir('#/build/' + buildmode + '/engine', 'engine', 0)
 SConscript('#/build/' + buildmode + '/engine/' + 'SConscript')
 
 if len(install_targets) > 0:
-	install_targets.append(env.Command(resources_dir + '/resources.dat', '#/data', 'zip -q -0 -r  $TARGET * -x \*.svn\* -x \*.wav', chdir='data'))
+	install_targets.append(
+	    env.Command(env['DESTDIR'] + resources_dir + '/resources.dat',
+		'#/data',
+		'zip -q -0 -r $TARGET * -x \*.svn\* -x \*.wav',
+		chdir='data'))
 	env.Alias('install', install_targets)