Bug 607719: revamp the testconfig setup (r=brbaker)
[tamarin-stm.git] / configure.py
blob930bb1c02a41ce436ae409ca981b5bd717d8385e
1 #!/usr/bin/env python
2 # -*- Mode: Python; indent-tabs-mode: nil -*-
3 # vi: set ts=4 sw=4 expandtab:
4 # ***** BEGIN LICENSE BLOCK *****
5 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 # The contents of this file are subject to the Mozilla Public License Version
8 # 1.1 (the "License"); you may not use this file except in compliance with
9 # the License. You may obtain a copy of the License at
10 # http://www.mozilla.org/MPL/
12 # Software distributed under the License is distributed on an "AS IS" basis,
13 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 # for the specific language governing rights and limitations under the
15 # License.
17 # The Original Code is [Open Source Virtual Machine].
19 # The Initial Developer of the Original Code is
20 # Adobe System Incorporated.
21 # Portions created by the Initial Developer are Copyright (C) 2005-2006
22 # the Initial Developer. All Rights Reserved.
24 # Contributor(s):
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
41 # This script runs just like a traditional configure script, to do configuration
42 # testing and makefile generation.
44 #****************************************************************************
45 # If you're building android the following Android SDK commands must be run
46 # before invoking configure.py and the makefile it produces:
47 # The android sdk volume should be mounted to /Volumes/android
48 # cd /Volumes/android/device
49 # run . build/envsetup.sh
50 # run choosecombo and press enter at each prompt
52 #****************************************************************************
54 import os
55 import os.path
56 import sys
57 import build.process
58 import re
59 import subprocess
61 thisdir = os.path.dirname(os.path.abspath(__file__))
63 # Look for additional modules in our build/ directory.
64 sys.path.append(thisdir)
66 from build.configuration import *
67 import build.getopt
68 import build.avmfeatures
71 # Used to set the mac SDK parameters
72 def _setSDKParams(sdk_version,os_ver):
74 # On 10.5/6 systems, and only if "--mac-sdk=104u" is passed in, compile for the 10.4u SDK and override CC/CXX (set in configuration.py) to use gcc/gxx 4.0.x
75 if sdk_version == '104u':
76 os_ver,sdk_number = '10.4','10.4u'
77 config._acvars['CXX'] = 'g++-4.0'
78 config._acvars['CC'] = 'gcc-4.0'
79 elif sdk_version == '105':
80 os_ver,sdk_number = '10.5','10.5'
81 elif sdk_version == '106':
82 os_ver,sdk_number = '10.6','10.6'
83 # For future expansion
84 #elif sdk_version == '107':
85 #os_ver,sdk_number = '10.7','10.7'
86 else:
87 print'Unknown SDK version -> %s. Expected values are 104u, 105 or 106.' % sdk_version
88 sys.exit(2)
90 if not os.path.exists("/Developer/SDKs/MacOSX%s.sdk" % sdk_number):
91 print'Could not find /Developer/SDKs/MacOSX%s.sdk' % sdk_number
92 sys.exit(2)
93 else:
94 return os_ver,sdk_number
96 # Used to set GCC flags for the android build
97 def _setGCCVersionedFlags(FLAGS, MAJOR_VERSION, MINOR_VERSION, current_cpu):
98 # can't enable -Werror for gcc prior to 4.3 due to unavoidable "clobbered" warnings in Interpreter.cpp
99 # warnings have been updated to try to include all those enabled by current Flash/AIR builds -- disable with caution, or risk integration pain
100 if MAJOR_VERSION >= 4:
101 FLAGS += "-Wstrict-null-sentinel "
102 if (MAJOR_VERSION == 4 and MINOR_VERSION <= 2) or current_cpu == 'mips': # 4.0 - 4.2
103 FLAGS += "-Wstrict-aliasing=0 "
104 else: # gcc 4.3 or later
105 FLAGS += "-Werror -Wempty-body -Wno-logical-op -Wmissing-field-initializers -Wstrict-aliasing=3 -Wno-array-bounds -Wno-clobbered -Wstrict-overflow=0 -funit-at-a-time "
107 return FLAGS
109 o = build.getopt.Options()
111 config = Configuration(thisdir, options = o,
112 sourcefile = 'core/avmplus.h')
114 arm_fpu = o.getBoolArg("arm-fpu",False)
115 arm_neon = o.getBoolArg("arm-neon",False)
116 arm_arch = o.arm_arch
118 buildTamarin = o.getBoolArg('tamarin', True)
119 if buildTamarin:
120 config.subst("ENABLE_TAMARIN", 1)
122 buildShell = o.getBoolArg("shell", False)
123 if (buildShell):
124 config.subst("ENABLE_SHELL", 1)
126 the_os, cpu = config.getTarget()
128 APP_CPPFLAGS = "-DAVMSHELL_BUILD "
129 APP_CXXFLAGS = ""
130 APP_CFLAGS = ""
131 OPT_CXXFLAGS = "-O3 "
132 OPT_CPPFLAGS = ""
133 DEBUG_CPPFLAGS = "-DDEBUG -D_DEBUG "
134 DEBUG_CXXFLAGS = ""
135 DEBUG_CFLAGS = ""
136 DEBUG_LDFLAGS = ""
137 OS_LIBS = []
138 OS_LDFLAGS = ""
139 MMGC_CPPFLAGS = "-DAVMSHELL_BUILD "
140 AVMSHELL_CPPFLAGS = ""
141 AVMSHELL_LDFLAGS = ""
142 MMGC_DEFINES = {'SOFT_ASSERTS': None}
143 NSPR_INCLUDES = ""
144 NSPR_LDOPTS = ""
145 DISABLE_RTMPE = None
147 if 'APP_CPPFLAGS' in os.environ:
148 APP_CPPFLAGS += os.environ['APP_CPPFLAGS'] + " "
149 if 'APP_CXXFLAGS' in os.environ:
150 APP_CXXFLAGS += os.environ['APP_CXXFLAGS'] + " "
151 if 'APP_CFLAGS' in os.environ:
152 APP_CFLAGS += os.environ['APP_CFLAGS'] + " "
153 if 'OPT_CXXFLAGS' in os.environ:
154 OPT_CXXFLAGS += os.environ['OPT_CXXFLAGS'] + " "
155 if 'OPT_CPPFLAGS' in os.environ:
156 OPT_CPPFLAGS += os.environ['OPT_CPPFLAGS'] + " "
157 if 'DEBUG_CPPFLAGS' in os.environ:
158 DEBUG_CPPFLAGS += os.environ['DEBUG_CPPFLAGS'] + " "
159 if 'DEBUG_CXXFLAGS' in os.environ:
160 DEBUG_CXXFLAGS += os.environ['DEBUG_CXXFLAGS'] + " "
161 if 'DEBUG_CFLAGS' in os.environ:
162 DEBUG_CFLAGS += os.environ['DEBUG_CFLAGS'] + " "
163 if 'DEBUG_LDFLAGS' in os.environ:
164 DEBUG_LDFLAGS += os.environ['DEBUG_LDFLAGS'] + " "
165 if 'OS_LDFLAGS' in os.environ:
166 OS_LDFLAGS += os.environ['OS_LDFLAGS'] + " "
167 if 'MMGC_CPPFLAGS' in os.environ:
168 MMGC_CPPFLAGS += os.environ['MMGC_CPPFLAGS'] + " "
169 if 'AVMSHELL_CPPFLAGS' in os.environ:
170 AVMSHELL_CPPFLAGS += os.environ['AVMSHELL_CPPFLAGS'] + " "
171 if 'AVMSHELL_LDFLAGS' in os.environ:
172 AVMSHELL_LDFLAGS += os.environ['AVMSHELL_LDFLAGS'] + " "
173 if 'NSPR_INCLUDES' in os.environ:
174 NSPR_INCLUDES += os.environ['NSPR_INCLUDES'] + " "
175 if 'NSPR_LDOPTS' in os.environ:
176 NSPR_LDOPTS += os.environ['NSPR_LDOPTS'] + " "
177 if 'DISABLE_RTMPE' in os.environ:
178 DISABLE_RTMPE += os.environ['DISABLE_RTMPE'] + " "
179 if o.getBoolArg('valgrind', False, False):
180 OPT_CXXFLAGS = "-O1 -g "
182 valinc = '$(topsrcdir)/other-licenses'
183 if 'VALGRIND_HOME' in os.environ:
184 valinc = os.environ['VALGRIND_HOME'] + '/include'
185 APP_CPPFLAGS += '-I' + valinc + ' '
187 # See build/avmfeatures.py for the code that processes switches for
188 # standard feature names.
189 APP_CPPFLAGS += build.avmfeatures.featureSettings(o)
191 if not o.getBoolArg("methodenv-impl32", True):
192 APP_CPPFLAGS += "-DVMCFG_METHODENV_IMPL32=0 "
194 memoryProfiler = o.getBoolArg("memory-profiler", False)
195 if memoryProfiler:
196 APP_CPPFLAGS += "-DMMGC_MEMORY_PROFILER "
198 MMGC_INTERIOR_PTRS = o.getBoolArg('mmgc-interior-pointers', False)
199 if MMGC_INTERIOR_PTRS:
200 MMGC_DEFINES['MMGC_INTERIOR_PTRS'] = None
202 MMGC_DYNAMIC = o.getBoolArg('mmgc-shared', False)
203 if MMGC_DYNAMIC:
204 MMGC_DEFINES['MMGC_DLL'] = None
205 MMGC_CPPFLAGS += "-DMMGC_IMPL "
207 # For -Wreorder, see https://bugzilla.mozilla.org/show_bug.cgi?id=475750
208 if config.getCompiler() == 'GCC':
209 if 'CXX' in os.environ:
210 rawver = build.process.run_for_output(['$CXX', '--version'])
211 else:
212 rawver = build.process.run_for_output(['gcc', '--version'])
213 vre = re.compile(".* ([3-9]\.[0-9]+\.[0-9]+)[ \n]")
214 ver = vre.match(rawver).group(1)
215 ver_arr = ver.split('.')
216 GCC_MAJOR_VERSION = int(ver_arr[0])
217 GCC_MINOR_VERSION = int(ver_arr[1])
220 if the_os == 'android':
221 try:
222 ANDROID_BUILD_TOP = os.environ['ANDROID_BUILD_TOP']
223 except:
224 print('\nANDROID_BUILD_TOP not found in environment\nPlease mount android.dmg and cd to /Volumes/android/device\n' \
225 'Run . build/envsetup.sh\nRun choosecombo and press enter at each prompt\n')
226 exit(0)
228 ANDROID_INCLUDES = "-I$(ANDROID_BUILD_TOP)/bionic/libc/arch-arm/include "\
229 "-I$(ANDROID_BUILD_TOP)/bionic/libc/kernel/arch-arm "\
230 "-I$(ANDROID_BUILD_TOP)/bionic/libc/kernel/common "\
231 "-I$(ANDROID_BUILD_TOP)/bionic/libm/include "\
232 "-I$(ANDROID_BUILD_TOP)/bionic/libstdc++/include "\
233 "-I$(ANDROID_BUILD_TOP)/bionic/libc/include "\
234 "-I$(ANDROID_BUILD_TOP)/external/webkit/WebKit/android/stl "\
235 "-I$(ANDROID_BUILD_TOP)/external/openssl/include "\
236 "-I$(ANDROID_BUILD_TOP)/frameworks/base/opengl/include "
238 # These flags are shared with some of the other builds such as ARM, but better to keep them separate here for flexibility
239 COMMON_CXX_FLAGS = "-Wall -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof " \
240 "-Wno-switch -Wpointer-arith -Wwrite-strings -Woverloaded-virtual -Wsign-promo " \
241 "-fmessage-length=0 -fno-exceptions -fno-rtti -fsigned-char "
243 # Additional flags used by android
244 APP_CXX_FLAGS = "%s -Wctor-dtor-privacy -Wlogical-op -Wstrict-overflow=1 " \
245 "-Wmissing-include-dirs -Wno-missing-field-initializers -Wno-type-limits -Wno-unused-parameter " \
246 "-Wnon-virtual-dtor -Wstrict-null-sentinel -Wno-missing-braces -Wno-multichar -Wno-psabi -Wno-reorder " \
247 "-fno-strict-aliasing -fpic -funwind-tables -fstack-protector -finline-limit=200 -MD -fwrapv " % COMMON_CXX_FLAGS
248 APP_CXXFLAGS += _setGCCVersionedFlags(APP_CXX_FLAGS, GCC_MAJOR_VERSION, GCC_MINOR_VERSION, cpu)
250 # LFLAGS_HEADLESS gets picked up in configuration.py by MKPROGRAM
251 LFLAGS_HEADLESS = "-nostdlib -Bdynamic -Wl,-T,"\
252 "$(ANDROID_BUILD_TOP)/build/core/armelf.x -Wl,"\
253 "-dynamic-linker,/system/bin/linker -Wl,"\
254 "-z,nocopyreloc "\
255 "-L$(ANDROID_BUILD_TOP)/out/target/product/generic/system/lib -Wl,"\
256 "-rpath-link=$(ANDROID_BUILD_TOP)/out/target/product/generic/system/lib "\
257 "$(ANDROID_BUILD_TOP)/out/target/product/generic/obj/lib/crtbegin_dynamic.o "\
258 "$(ANDROID_BUILD_TOP)/out/target/product/generic/obj/lib/crtend_android.o "
260 # SEARCH_DIRS gets picked up in configuration.py by MKPROGRAM
261 SEARCH_DIRS = "-L/Volumes/Builds$(topsrcdir)/objdir-release/"
263 BASE_M_FLAGS = "-mlong-calls -mthumb-interwork -mthumb"
265 if arm_arch == "armv7-a" or arm_arch == None:
266 BASE_CXX_FLAGS = "%s -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH__=7 " \
267 "-DARMV6_ASSEMBLY -DTARGET_NEON -DSDK_ON2_OPT -DSDK_ON2_OPT_ARM11 -DFP_ON2_USE_C_FILTERING_FUNCTIONS " % BASE_M_FLAGS
268 APP_CXXFLAGS += BASE_CXX_FLAGS
270 elif arm_arch == "armv6":
271 BASE_CXX_FLAGS = "%s -march=armv6 -mfloat-abi=soft -D__ARM_ARCH__=6 -DARMV5_ASSEMBLY -DARMV6_ASSEMBLY " % BASE_M_FLAGS
272 APP_CXXFLAGS += BASE_CXX_FLAGS
273 LFLAGS_HEADLESS += "-Wl,--no-enum-size-warning"
275 elif arm_arch == "armv5":
276 BASE_CXX_FLAGS = "%s -march=armv5te -mfloat-abi=soft -mtune=xscale -D__ARM_ARCH__=5 -DARMV5_ASSEMBLY " % BASE_M_FLAGS
277 APP_CXXFLAGS += BASE_CXX_FLAGS
278 LFLAGS_HEADLESS += "-Wl,--no-enum-size-warning"
280 else:
281 raise Exception('Unrecognized architecture: %s' % arm_arch)
283 APP_CPPFLAGS += "-DAVMPLUS_UNIX -DUNIX -Dlinux -DUSE_PTHREAD_MUTEX -DNO_SYS_SIGNAL -DHAVE_STDARG -DNO_CONSOLE_FWRITE -DAVMPLUS_ARM %s" % ANDROID_INCLUDES
285 else:
286 APP_CXXFLAGS = "-Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof -Wno-switch "\
287 "-Wparentheses -Wpointer-arith -Wreorder -Wsign-compare -Wunused-parameter -Wwrite-strings -Wno-ctor-dtor-privacy -Woverloaded-virtual "\
288 "-Wsign-promo -Wno-char-subscripts -fmessage-length=0 -fno-exceptions -fno-rtti -fno-check-new -fstrict-aliasing -fsigned-char "
289 APP_CXXFLAGS += _setGCCVersionedFlags(APP_CXXFLAGS, GCC_MAJOR_VERSION, GCC_MINOR_VERSION, cpu)
291 if cpu == 'sh4':
292 APP_CXXFLAGS += "-mieee -Wno-cast-align "
294 if arm_fpu:
295 ARM_FPU_FLAGS = "-mfloat-abi=softfp -mfpu=vfp -march=%s -Wno-cast-align " % arm_arch # compile to use hardware fpu
296 OPT_CXXFLAGS += ARM_FPU_FLAGS
297 DEBUG_CXXFLAGS += ARM_FPU_FLAGS
298 if arm_neon:
299 ARM_NEON_FLAGS = "-mfloat-abi=softfp -mfpu=neon -march=%s -Wno-cast-align " % arm_arch # compile to use neon vfp
300 OPT_CXXFLAGS += ARM_NEON_FLAGS
301 DEBUG_CXXFLAGS += ARM_NEON_FLAGS
302 #if arm_arch:
303 #OPT_CXXFLAGS += "-march=%s " % arm_arch
304 #DEBUG_CXXFLAGS += "-march=%s " % arm_arch
306 if config.getDebug():
307 APP_CXXFLAGS += ""
308 else:
309 APP_CXXFLAGS += "-Wuninitialized "
310 DEBUG_CXXFLAGS += "-g "
311 elif config.getCompiler() == 'VS':
312 if cpu == "arm":
313 APP_CXXFLAGS = "-W4 -WX -wd4291 -wd4201 -wd4189 -wd4740 -wd4127 -fp:fast -GF -GS- -Zc:wchar_t- "
314 OS_LDFLAGS += "-MAP "
315 if config.getDebug():
316 DEBUG_CXXFLAGS = "-Od "
317 DEBUG_CFLAGS = "-Od "
318 APP_CXXFLAGS += "-GR- -fp:fast -GS- -Zc:wchar_t- -Zc:forScope "
319 else:
320 OPT_CXXFLAGS = "-O2 -GR- "
321 if arm_arch:
322 OPT_CXXFLAGS += "-QR%s " % arm_arch
323 if arm_fpu:
324 OPT_CXXFLAGS += "-QRfpe- " # compile to use hardware fpu
325 else:
326 APP_CXXFLAGS = "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
327 APP_CFLAGS = "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
328 if cpu == 'x86_64':
329 pass # 64 bit VC does NaN comparisons incorrectly with fp:fast
330 else:
331 APP_CXXFLAGS += "-fp:fast "
332 APP_CFLAGS += "-fp:fast "
333 OS_LDFLAGS += "-MAP "
334 if config.getDebug():
335 DEBUG_CXXFLAGS = "-Od "
336 DEBUG_CFLAGS = "-Od "
337 else:
338 OPT_CXXFLAGS = "-O2 -Ob1 -GR- "
339 OPT_CFLAGS = "-O2 -Ob1 -GR- "
340 if memoryProfiler:
341 OPT_CXXFLAGS += "-Oy- -Zi "
342 DEBUG_CXXFLAGS += "-Zi "
343 DEBUG_CFLAGS += "-Zi "
344 DEBUG_LDFLAGS += "-DEBUG "
345 elif config.getCompiler() == 'SunStudio':
346 APP_CXXFLAGS = "-template=no%extdef -erroff"
347 OPT_CXXFLAGS = "-xO2 "
348 DEBUG_CXXFLAGS += "-g "
349 else:
350 raise Exception('Unrecognized compiler: ' + config.getCompiler())
352 zlib_include_dir = o.getStringArg('zlib-include-dir')
353 if zlib_include_dir is not None:
354 AVMSHELL_CPPFLAGS += "-I%s " % zlib_include_dir
356 zlib_lib = o.getStringArg('zlib-lib')
357 if zlib_lib is not None:
358 AVMSHELL_LDFLAGS = zlib_lib
359 else:
360 AVMSHELL_LDFLAGS = '$(call EXPAND_LIBNAME,zlib)'
362 sys_root_dir = o.getStringArg('sys-root-dir')
363 if sys_root_dir is not None:
364 OS_LDFLAGS += " --sysroot=%s " % sys_root_dir
365 OPT_CXXFLAGS += " --sysroot=%s " % sys_root_dir
367 if the_os == "darwin":
368 # Get machine's OS version number and trim off anything after '10.x'
369 p = subprocess.Popen('sw_vers -productVersion', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
370 os_ver = p.stdout.read()
371 parts = os_ver.split('.')
372 os_ver = parts[0] + '.' + parts[1]
374 AVMSHELL_LDFLAGS += " -exported_symbols_list " + thisdir + "/platform/mac/avmshell/exports.exp"
375 MMGC_DEFINES.update({'TARGET_API_MAC_CARBON': 1,
376 'DARWIN': 1,
377 '_MAC': None,
378 'AVMPLUS_MAC': None,
379 'TARGET_RT_MAC_MACHO': 1})
380 APP_CXXFLAGS += "-fpascal-strings -faltivec -fasm-blocks "
382 # If an sdk is selected align OS and gcc/g++ versions to it
383 if o.mac_sdk_version is not None:
384 os_ver,sdk_number = _setSDKParams(o.mac_sdk_version, os_ver)
385 APP_CXXFLAGS += "-mmacosx-version-min=%s -isysroot /Developer/SDKs/MACOSX%s.sdk " % (os_ver,sdk_number)
386 else:
387 APP_CXXFLAGS += "-mmacosx-version-min=%s " % os_ver
389 config.subst("MACOSX_DEPLOYMENT_TARGET",os_ver)
391 if cpu == 'ppc64':
392 APP_CXXFLAGS += "-arch ppc64 "
393 APP_CFLAGS += "-arch ppc64 "
394 OS_LDFLAGS += "-arch ppc64 "
395 elif cpu == 'x86_64':
396 APP_CXXFLAGS += "-arch x86_64 "
397 APP_CFLAGS += "-arch x86_64 "
398 OS_LDFLAGS += "-arch x86_64 "
400 elif the_os == "windows" or the_os == "cygwin":
401 MMGC_DEFINES.update({'WIN32': None,
402 '_CRT_SECURE_NO_DEPRECATE': None})
403 OS_LDFLAGS += "-MAP "
404 if cpu == "arm":
405 APP_CPPFLAGS += "-DARM -D_ARM_ -DUNICODE -DUNDER_CE=1 -DMMGC_ARM "
406 if arm_fpu:
407 APP_CPPFLAGS += "-DARMV6 -QRarch6 "
408 else:
409 APP_CPPFLAGS += "-DARMV5 -QRarch5t "
410 OS_LIBS.append('mmtimer corelibc coredll')
411 else:
412 APP_CPPFLAGS += "-DWIN32_LEAN_AND_MEAN -D_CONSOLE "
413 OS_LIBS.append('winmm')
414 OS_LIBS.append('shlwapi')
415 OS_LIBS.append('AdvAPI32')
416 elif the_os == "linux":
417 MMGC_DEFINES.update({'UNIX': None,
418 'AVMPLUS_UNIX': None})
419 OS_LIBS.append('pthread')
420 # if cpu == "x86_64":
421 # # workaround https://bugzilla.mozilla.org/show_bug.cgi?id=467776
422 # OPT_CXXFLAGS += '-fno-schedule-insns2 '
423 if config.getDebug():
424 OS_LIBS.append("dl")
425 elif the_os == "android":
426 MMGC_DEFINES.update({'AVMFEATURE_OVERRIDE_GLOBAL_NEW': 0,
427 'RTMFPUTIL_OVERRIDE_OPERATOR_NEW': None})
429 BASE_D_FLAGS = "-DANDROID -DNETSCAPE -DDISABLE_DRM -DGENERIC_PLATFORM -DHAVE_SYS_UIO_H -Dlinux -DNEEDS_IN6_H -DUNIX -Dcompress=zlib_compress "
430 if DISABLE_RTMPE:
431 BASE_D_FLAGS += "-DDISABLE_RTMPE "
433 APP_CXXFLAGS += BASE_D_FLAGS
435 if config.getDebug():
436 DEBUG_CXXFLAGS += "-DDEBUG -D_DEBUG -DASYNC_DEBUG -O0 -ggdb3 "
437 DEBUG_CPPFLAGS = ""
438 else:
439 APP_CXXFLAGS += "-DNDEBUG -O3 -fomit-frame-pointer -fvisibility=hidden -finline-functions -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fvisibility-inlines-hidden "
440 DEBUG_CPPFLAGS = ""
441 elif the_os == "sunos":
442 if config.getCompiler() != 'GCC':
443 APP_CXXFLAGS = "-template=no%extdef -erroff"
444 OPT_CXXFLAGS = "-xO2 "
445 DEBUG_CXXFLAGS = "-g "
446 MMGC_DEFINES.update({'UNIX': None,
447 'AVMPLUS_UNIX': None,
448 'SOLARIS': None})
449 OS_LIBS.append('pthread')
450 APP_CPPFLAGS += '-DAVMPLUS_CDECL '
451 if config.getDebug():
452 OS_LIBS.append("dl")
453 else:
454 raise Exception("Unsupported OS")
456 if cpu == "i686":
457 if config.getCompiler() == 'GCC' and the_os == 'darwin':
458 #only mactel always has sse2
459 APP_CPPFLAGS += "-msse2 "
460 elif cpu == "powerpc":
461 # we detect this in core/avmbuild.h and MMgc/*build.h
462 None
463 elif cpu == "ppc64":
464 # we detect this in core/avmbuild.h and MMgc/*build.h
465 None
466 elif cpu == "sparc":
467 APP_CPPFLAGS += "-DAVMPLUS_SPARC "
468 elif cpu == "x86_64":
469 # we detect this in core/avmbuild.h and MMgc/*build.h
470 None
471 elif cpu == "arm":
472 # we detect this in core/avmbuild.h and MMgc/*build.h
473 None
474 elif cpu == "mips":
475 # we detect this in core/avmbuild.h and MMgc/*build.h
476 None
477 elif cpu == "sh4":
478 # work around for a problem with tas.b instruction on some sh4 boards
479 APP_CPPFLAGS += "-DUSE_PTHREAD_MUTEX "
480 else:
481 raise Exception("Unsupported CPU")
483 if o.getBoolArg('perfm'):
484 APP_CPPFLAGS += "-DPERFM "
486 if o.help:
487 sys.stdout.write(o.getHelp())
488 sys.exit(1)
491 # Append MMGC_DEFINES to APP_CPPFLAGS
492 APP_CPPFLAGS += ''.join(val is None and ('-D%s ' % var) or ('-D%s=%s ' % (var, val))
493 for (var, val) in MMGC_DEFINES.iteritems())
496 config.subst("APP_CPPFLAGS", APP_CPPFLAGS)
497 config.subst("APP_CXXFLAGS", APP_CXXFLAGS)
498 config.subst("OPT_CPPFLAGS", OPT_CPPFLAGS)
499 config.subst("OPT_CXXFLAGS", OPT_CXXFLAGS)
500 config.subst("DEBUG_CPPFLAGS", DEBUG_CPPFLAGS)
501 config.subst("DEBUG_CXXFLAGS", DEBUG_CXXFLAGS)
502 config.subst("DEBUG_LDFLAGS", DEBUG_LDFLAGS)
503 config.subst("OS_LIBS", " ".join(OS_LIBS))
504 config.subst("OS_LDFLAGS", OS_LDFLAGS)
505 config.subst("MMGC_CPPFLAGS", MMGC_CPPFLAGS)
506 config.subst("AVMSHELL_CPPFLAGS", AVMSHELL_CPPFLAGS)
507 config.subst("AVMSHELL_LDFLAGS", AVMSHELL_LDFLAGS)
508 config.subst("MMGC_DYNAMIC", MMGC_DYNAMIC and 1 or '')
509 if the_os == "android":
510 config.subst("LFLAGS_HEADLESS", LFLAGS_HEADLESS)
511 config.subst("SEARCH_DIRS", SEARCH_DIRS)
513 config.generate("Makefile")
515 o.finish()