aboutsummaryrefslogtreecommitdiff
path: root/games/gtkradiant/files/patch-SConstruct
blob: 7484c3a34b55463e1ebcffe411a4d5ff83f336ea (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
--- SConstruct.orig	2006-02-10 22:01:20 UTC
+++ SConstruct
@@ -1,9 +1,8 @@
 # scons build script
 # http://scons.sourceforge.net
 
-import commands, re, sys, os, pickle, string, popen2
+import subprocess as commands, re, sys, os, pickle, string
 from makeversion import radiant_makeversion, get_version
-from osx_setup import do_osx_setup
 
 # to access some internal stuff
 import SCons
@@ -11,7 +10,7 @@ import SCons
 conf_filename='site.conf'
 # there is a default hardcoded value, you can override on command line, those are saved between runs
 # we only handle strings
-serialized=['CC', 'CXX', 'JOBS', 'BUILD', 'SETUP']
+serialized=['CC', 'CXX', 'CCFLAGS', 'CXXFLAGS', 'LINKFLAGS', 'LOCALBASE', 'JOBS', 'BUILD', 'SETUP']
 
 # help -------------------------------------------
 
@@ -55,7 +54,7 @@ SETUP
 #EnsurePythonVersion(2,1)
 # above 0.90
 EnsureSConsVersion( 0, 96 )
-print 'SCons ' + SCons.__version__
+print('SCons ' + SCons.__version__)
 
 # end sanity -------------------------------------
 
@@ -64,18 +63,11 @@ print 'SCons ' + SCons.__version__
 # TODO: detect Darwin / OSX
 
 # CPU type
-g_cpu = commands.getoutput('uname -m')
-exp = re.compile('.*i?86.*')
-if (g_cpu == 'Power Macintosh' or g_cpu == 'ppc'):
-  g_cpu = 'ppc'
-elif exp.match(g_cpu):
-  g_cpu = 'x86'
-else:
-  g_cpu = 'cpu'
+g_cpu = 'cpu'
 
 # OS
 OS = commands.getoutput('uname')
-print "OS=\"" + OS + "\""
+print("OS=\"" + OS + "\"")
 
 if (OS == 'Linux'):
   # libc .. do the little magic!
@@ -99,13 +91,15 @@ g_build_root = 'build'
 
 site_dict = {}
 if (os.path.exists(conf_filename)):
-	site_file = open(conf_filename, 'r')
+	print( conf_filename )
+	site_file = open(conf_filename, 'rb')
 	p = pickle.Unpickler(site_file)
-	site_dict = p.load()
-	print 'Loading build configuration from ' + conf_filename
+	try: site_dict = p.load()
+	except EOFError: site_dict = {}
+	print('Loading build configuration from ' + conf_filename)
 	for k, v in site_dict.items():
 		exec_cmd = k + '=\"' + v + '\"'
-		print exec_cmd
+		print(exec_cmd)
 		exec(exec_cmd)
 
 # end site settings ------------------------------
@@ -113,9 +107,9 @@ if (os.path.exists(conf_filename)):
 # command line settings --------------------------
 
 for k in serialized:
-	if (ARGUMENTS.has_key(k)):
+	if (k in ARGUMENTS):
 		exec_cmd = k + '=\"' + ARGUMENTS[k] + '\"'
-		print 'Command line: ' + exec_cmd
+		print('Command line: ' + exec_cmd)
 		exec(exec_cmd)
 
 # end command line settings ----------------------
@@ -123,14 +117,14 @@ for k in serialized:
 # sanity check -----------------------------------
 
 if (SETUP == '1' and BUILD != 'release' and BUILD != 'info'):
-  print 'Forcing release build for setup'
+  print('Forcing release build for setup')
   BUILD = 'release'
 
 def GetGCCVersion(name):
   ret = commands.getstatusoutput('%s -dumpversion' % name)
   if ( ret[0] != 0 ):
     return None
-  vers = string.split(ret[1], '.')
+  vers = ret[1].split('.')
   if ( len(vers) == 2 ):
     return [ vers[0], vers[1], 0 ]
   elif ( len(vers) == 3 ):
@@ -140,9 +134,9 @@ def GetGCCVersion(name):
 ver_cc = GetGCCVersion(CC)
 ver_cxx = GetGCCVersion(CXX)
 
-if ( ver_cc is None or ver_cxx is None or ver_cc[0] < '3' or ver_cxx[0] < '3' or ver_cc != ver_cxx ):
-  print 'Compiler version check failed - need gcc 3.x or later:'
-  print 'CC: %s %s\nCXX: %s %s' % ( CC, repr(ver_cc), CXX, repr(ver_cxx) )
+if ( ver_cc is None or ver_cxx is None or int(ver_cc[0]) < 3 or int(ver_cxx[0]) < 3 or ver_cc != ver_cxx ):
+  print('Compiler version check failed - need gcc 3.x or later:')
+  print('CC: %s %s\nCXX: %s %s' % ( CC, repr(ver_cc), CXX, repr(ver_cxx) ))
   Exit(1)
 
 # end sanity check -------------------------------
@@ -153,7 +147,7 @@ for k in serialized:
 	exec_cmd = 'site_dict[\'' + k + '\'] = ' + k
 	exec(exec_cmd)
 
-site_file = open(conf_filename, 'w')
+site_file = open(conf_filename, 'wb')
 p = pickle.Pickler(site_file)
 p.dump(site_dict)
 site_file.close()
@@ -172,8 +166,8 @@ LINK = CXX
 # common flags
 warningFlags = '-W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter '
 warningFlagsCXX = '-Wno-non-virtual-dtor -Wreorder ' # -Wold-style-cast
-CCFLAGS = '' + warningFlags
-CXXFLAGS = '-pipe -DQ_NO_STLPORT ' + warningFlags + warningFlagsCXX
+CCFLAGS += ' '
+CXXFLAGS += ' -pipe -DQ_NO_STLPORT '
 CPPPATH = []
 if (BUILD == 'debug'):
 	CXXFLAGS += '-g -D_DEBUG '
@@ -182,15 +176,14 @@ elif (BUILD == 'release'):
 	CXXFLAGS += '-O2 '
 	CCFLAGS += '-O2 '
 elif ( BUILD == 'info' ):
-	print 'Preparing OSX release'
+	print('Preparing OSX release')
 	( line, major, minor ) = get_version()
 	do_osx_setup( major, minor, 'osx-radiant-%s.run' % line )
 	sys.exit( 0 )
 else:
-	print 'Unknown build configuration ' + BUILD
+	print('Unknown build configuration ' + BUILD)
 	sys.exit( 0 )
 
-LINKFLAGS = ''
 if ( OS == 'Linux' ):
 
   # static
@@ -218,6 +211,11 @@ if ( OS == 'Darwin' ):
   CPPPATH.append('/sw/include')
   CPPPATH.append('/usr/X11R6/include')
   LINKFLAGS += '-L/sw/lib -L/usr/lib -L/usr/X11R6/lib '
+elif ( OS == 'FreeBSD' ):
+  CCFLAGS += '-fPIC '
+  CXXFLAGS += '-fPIC '
+  CPPPATH.append(LOCALBASE + '/include')
+  LINKFLAGS += '-L' + LOCALBASE + '/lib '
 
 CPPPATH.append('libs')
 
@@ -248,7 +246,7 @@ class idEnvironment(Environment):
   def useGtk2(self):
     self['CXXFLAGS'] += '`pkg-config gtk+-2.0 --cflags` '
     self['CCFLAGS'] += '`pkg-config gtk+-2.0 --cflags` '
-    self['LINKFLAGS'] += '-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpango-1.0 -lgdk_pixbuf-2.0 '
+    self['LINKFLAGS'] += '-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpango-1.0 -lgdk_pixbuf-2.0 -lgobject-2.0 '
    
   def useGtkGLExt(self):
     self['CXXFLAGS'] += '`pkg-config gtkglext-1.0 --cflags` '
@@ -278,18 +276,18 @@ class idEnvironment(Environment):
         print('ERROR: CheckLDD: target %s not found\n' % target[0])
         Exit(1)
     # not using os.popen3 as I want to check the return code
-    ldd = popen2.Popen3('`which ldd` -r %s' % target[0], 1)
-    stdout_lines = ldd.fromchild.readlines()
-    stderr_lines = ldd.childerr.readlines()
+    ldd = commands.Popen(['ldd', str(file)], 1, stdout=commands.PIPE, stderr=commands.PIPE)
+    stdout_lines = ldd.stdout.readlines()
+    stderr_lines = ldd.stderr.readlines()
     ldd_ret = ldd.wait()
     del ldd
     have_undef = 0
     if ( ldd_ret != 0 ):
-        print "ERROR: ldd command returned with exit code %d" % ldd_ret
+        print("ERROR: ldd command returned with exit code %d" % ldd_ret)
         os.system('rm %s' % target[0])
         Exit()
     for i_line in stderr_lines:
-        print repr(i_line)
+        print(repr(i_line))
         regex = re.compile('undefined symbol: (.*)\t\\((.*)\\)\n')
         if ( regex.match(i_line) ):
             symbol = regex.sub('\\1', i_line)
@@ -298,11 +296,11 @@ class idEnvironment(Environment):
             except:
                 have_undef = 1
         else:
-            print "ERROR: failed to parse ldd stderr line: %s" % i_line
+            print("ERROR: failed to parse ldd stderr line: %s" % i_line)
             os.system('rm %s' % target[0])
             Exit(1)
     if ( have_undef ):
-        print "ERROR: undefined symbols"
+        print("ERROR: undefined symbols")
         os.system('rm %s' % target[0])
         Exit(1)
   
@@ -317,8 +315,14 @@ g_env = idEnvironment()
 # export the globals
 GLOBALS = 'g_env INSTALL SETUP g_cpu'
 
-radiant_makeversion('\\ngcc version: %s.%s.%s' % ( ver_cc[0], ver_cc[1], ver_cc[2] ) )
+def get_compiler_info(cxx):
+  ret = commands.getstatusoutput('%s -v' % cxx)
+  if (ret[0] != 0): return None
+  info = re.search('(gcc|clang) version [0-9.]+', ret[1])
+  return info.group(0) if info else None
 
+radiant_makeversion('\\n%s' % get_compiler_info(CXX))
+
 # end general configuration ----------------------
 
 # targets ----------------------------------------
@@ -326,7 +330,7 @@ radiant_makeversion('\\ngcc version: %s.%s.%s' % ( ver
 Default('.')
 
 Export('GLOBALS ' + GLOBALS)
-BuildDir(g_build, '.', duplicate = 0)
+VariantDir(g_build, '.', duplicate = 0)
 SConscript(g_build + '/SConscript')
 
 # end targets ------------------------------------