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
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.
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 android public sdk/ndk must be set up on your
46 # build machine. # See the wiki page here for instructions on how to create
47 # the android public sdk/ndk:
48 # https://zerowing.corp.adobe.com/display/FlashPlayer/android+tamarin+shell+support
50 # Before building edit the /android-public/android-vars.sh script
51 # and check that the ANDROIDTOP variable is set correctly. Then run the script
52 # before invoking configure.py:
53 # . /android-public/android-vars.sh
55 #****************************************************************************
64 thisdir
= os
.path
.dirname(os
.path
.abspath(__file__
))
66 # Look for additional modules in our build/ directory.
67 sys
.path
.append(thisdir
)
69 from build
.configuration
import *
71 import build
.avmfeatures
74 # Used to set the mac SDK parameters
75 def _setSDKParams(sdk_version
,os_ver
):
77 # 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
78 if sdk_version
== '104u':
79 os_ver
,sdk_number
= '10.4','10.4u'
80 config
._acvars
['CXX'] = 'g++-4.0'
81 config
._acvars
['CC'] = 'gcc-4.0'
82 elif sdk_version
== '105':
83 os_ver
,sdk_number
= '10.5','10.5'
84 elif sdk_version
== '106':
85 os_ver
,sdk_number
= '10.6','10.6'
86 # For future expansion
87 #elif sdk_version == '107':
88 #os_ver,sdk_number = '10.7','10.7'
90 print'Unknown SDK version -> %s. Expected values are 104u, 105 or 106.' % sdk_version
93 if not os
.path
.exists("/Developer/SDKs/MacOSX%s.sdk" % sdk_number
):
94 print'Could not find /Developer/SDKs/MacOSX%s.sdk' % sdk_number
97 return os_ver
,sdk_number
99 # Used to set GCC flags for the android build
100 def _setGCCVersionedFlags(FLAGS
, MAJOR_VERSION
, MINOR_VERSION
, current_cpu
):
101 # can't enable -Werror for gcc prior to 4.3 due to unavoidable "clobbered" warnings in Interpreter.cpp
102 # warnings have been updated to try to include all those enabled by current Flash/AIR builds -- disable with caution, or risk integration pain
103 if MAJOR_VERSION
>= 4:
104 FLAGS
+= "-Wstrict-null-sentinel "
105 if (MAJOR_VERSION
== 4 and MINOR_VERSION
<= 2) or current_cpu
== 'mips': # 4.0 - 4.2
106 FLAGS
+= "-Wstrict-aliasing=0 "
107 else: # gcc 4.3 or later
108 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 "
112 o
= build
.getopt
.Options()
114 config
= Configuration(thisdir
, options
= o
,
115 sourcefile
= 'core/avmplus.h')
117 arm_fpu
= o
.getBoolArg("arm-fpu",False)
118 arm_neon
= o
.getBoolArg("arm-neon",False)
119 arm_arch
= o
.arm_arch
121 buildTamarin
= o
.getBoolArg('tamarin', True)
123 config
.subst("ENABLE_TAMARIN", 1)
125 buildShell
= o
.getBoolArg("shell", True)
127 config
.subst("ENABLE_SHELL", 1)
129 buildAot
= o
.peekBoolArg("aot", False)
131 config
.subst("ENABLE_AOT", 1)
133 the_os
, cpu
= config
.getTarget()
135 APP_CPPFLAGS
= "-DAVMSHELL_BUILD "
138 OPT_CXXFLAGS
= "-O3 "
140 DEBUG_CPPFLAGS
= "-DDEBUG -D_DEBUG "
146 LDFLAGS
= config
._acvars
['LDFLAGS']
147 MMGC_CPPFLAGS
= "-DAVMSHELL_BUILD "
148 AVMSHELL_CPPFLAGS
= ""
149 AVMSHELL_LDFLAGS
= ""
150 MMGC_DEFINES
= {'SOFT_ASSERTS': None}
154 ANDROIDPLATFORMVER
= "android-8"
156 if 'APP_CPPFLAGS' in os
.environ
:
157 APP_CPPFLAGS
+= os
.environ
['APP_CPPFLAGS'] + " "
158 if 'APP_CXXFLAGS' in os
.environ
:
159 APP_CXXFLAGS
+= os
.environ
['APP_CXXFLAGS'] + " "
160 if 'APP_CFLAGS' in os
.environ
:
161 APP_CFLAGS
+= os
.environ
['APP_CFLAGS'] + " "
162 if 'OPT_CXXFLAGS' in os
.environ
:
163 OPT_CXXFLAGS
+= os
.environ
['OPT_CXXFLAGS'] + " "
164 if 'OPT_CPPFLAGS' in os
.environ
:
165 OPT_CPPFLAGS
+= os
.environ
['OPT_CPPFLAGS'] + " "
166 if 'DEBUG_CPPFLAGS' in os
.environ
:
167 DEBUG_CPPFLAGS
+= os
.environ
['DEBUG_CPPFLAGS'] + " "
168 if 'DEBUG_CXXFLAGS' in os
.environ
:
169 DEBUG_CXXFLAGS
+= os
.environ
['DEBUG_CXXFLAGS'] + " "
170 if 'DEBUG_CFLAGS' in os
.environ
:
171 DEBUG_CFLAGS
+= os
.environ
['DEBUG_CFLAGS'] + " "
172 if 'DEBUG_LDFLAGS' in os
.environ
:
173 DEBUG_LDFLAGS
+= os
.environ
['DEBUG_LDFLAGS'] + " "
174 if 'OS_LDFLAGS' in os
.environ
:
175 OS_LDFLAGS
+= os
.environ
['OS_LDFLAGS'] + " "
176 if 'MMGC_CPPFLAGS' in os
.environ
:
177 MMGC_CPPFLAGS
+= os
.environ
['MMGC_CPPFLAGS'] + " "
178 if 'AVMSHELL_CPPFLAGS' in os
.environ
:
179 AVMSHELL_CPPFLAGS
+= os
.environ
['AVMSHELL_CPPFLAGS'] + " "
180 if 'AVMSHELL_LDFLAGS' in os
.environ
:
181 AVMSHELL_LDFLAGS
+= os
.environ
['AVMSHELL_LDFLAGS'] + " "
182 if 'NSPR_INCLUDES' in os
.environ
:
183 NSPR_INCLUDES
+= os
.environ
['NSPR_INCLUDES'] + " "
184 if 'NSPR_LDOPTS' in os
.environ
:
185 NSPR_LDOPTS
+= os
.environ
['NSPR_LDOPTS'] + " "
186 if 'DISABLE_RTMPE' in os
.environ
:
187 DISABLE_RTMPE
+= os
.environ
['DISABLE_RTMPE'] + " "
188 if o
.getBoolArg('valgrind', False, False):
189 OPT_CXXFLAGS
= "-O1 -g "
191 # check that there is a valid hg repo here
192 hg_returncode
= subprocess
.call(['hg', 'id', '-n'],
193 stdout
=subprocess
.PIPE
,
194 stderr
=subprocess
.PIPE
)
195 if hg_returncode
== 0: # success
196 # HGVERSION is to be set at "make" time
197 HGVERSION
= "$(shell hg parents --template '{rev}:{node|short}')"
198 APP_CPPFLAGS
+= '-DHGVERSION="${HGVERSION}" '
199 config
.subst("HGVERSION", HGVERSION
, recursive
=False)
201 valinc
= '$(topsrcdir)/other-licenses'
202 if 'VALGRIND_HOME' in os
.environ
:
203 valinc
= os
.environ
['VALGRIND_HOME'] + '/include'
204 APP_CPPFLAGS
+= '-I' + valinc
+ ' '
206 # See build/avmfeatures.py for the code that processes switches for
207 # standard feature names.
208 APP_CPPFLAGS
+= build
.avmfeatures
.featureSettings(o
)
210 if not o
.getBoolArg("methodenv-impl32", True):
211 APP_CPPFLAGS
+= "-DVMCFG_METHODENV_IMPL32=0 "
213 memoryProfiler
= o
.getBoolArg("memory-profiler", False)
215 APP_CPPFLAGS
+= "-DMMGC_MEMORY_PROFILER "
217 MMGC_INTERIOR_PTRS
= o
.getBoolArg('mmgc-interior-pointers', False)
218 if MMGC_INTERIOR_PTRS
:
219 MMGC_DEFINES
['MMGC_INTERIOR_PTRS'] = None
221 MMGC_DYNAMIC
= o
.getBoolArg('mmgc-shared', False)
223 MMGC_DEFINES
['MMGC_DLL'] = None
224 MMGC_CPPFLAGS
+= "-DMMGC_IMPL "
226 # For -Wreorder, see https://bugzilla.mozilla.org/show_bug.cgi?id=475750
227 if config
.getCompiler() == 'GCC':
228 if 'CXX' in os
.environ
:
229 rawver
= build
.process
.run_for_output(['$CXX', '--version'])
231 rawver
= build
.process
.run_for_output(['gcc', '--version'])
232 vre
= re
.compile(".* ([3-9]\.[0-9]+\.[0-9]+)[ \n]")
233 ver
= vre
.match(rawver
).group(1)
234 ver_arr
= ver
.split('.')
235 GCC_MAJOR_VERSION
= int(ver_arr
[0])
236 GCC_MINOR_VERSION
= int(ver_arr
[1])
239 if the_os
== 'android':
241 ANDROID_BUILD_TOP
= os
.environ
['ANDROID_BUILD_TOP']
243 print('\nANDROID_BUILD_TOP not found in environment\nPlease run /android-public/android-vars.sh')
246 ANDROID_INCLUDES
= "-I$(topsrcdir)/other-licenses/zlib "\
247 "-I$(ANDROID_BUILD_TOP)/android-ndk/platforms/%s/arch-arm/usr/include "\
248 "-I$(ANDROID_BUILD_TOP)/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/darwin-x86/bin "\
249 "-I$(ANDROID_BUILD_TOP)/android-sdk-mac_86 "\
250 "-I$(ANDROID_BUILD_TOP)/android-ndk/sources/cxx-stl/stlport/stlport "\
251 "-I$(ANDROID_BUILD_TOP)/openssl/include "\
252 "-I$(ANDROID_BUILD_TOP)/frameworks/base/opengl/include " % ANDROIDPLATFORMVER
254 # These flags are shared with some of the other builds such as ARM, but better to keep them separate here for flexibility
255 COMMON_CXX_FLAGS
= "-Wall -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof " \
256 "-Wno-switch -Wpointer-arith -Wwrite-strings -Woverloaded-virtual -Wsign-promo " \
257 "-fmessage-length=0 -fno-exceptions -fno-rtti -fsigned-char "
259 # Additional flags used by android
260 APP_CXX_FLAGS
= "%s -Wctor-dtor-privacy -Wlogical-op -Wstrict-overflow=1 " \
261 "-Wmissing-include-dirs -Wno-missing-field-initializers -Wno-type-limits -Wno-unused-parameter " \
262 "-Wnon-virtual-dtor -Wstrict-null-sentinel -Wno-missing-braces -Wno-multichar -Wno-psabi -Wno-reorder " \
263 "-fno-strict-aliasing -fpic -funwind-tables -fstack-protector -finline-limit=200 -MD -fwrapv " % COMMON_CXX_FLAGS
264 APP_CXXFLAGS
+= _setGCCVersionedFlags(APP_CXX_FLAGS
, GCC_MAJOR_VERSION
, GCC_MINOR_VERSION
, cpu
)
266 # LFLAGS_HEADLESS gets picked up in configuration.py by MKPROGRAM
267 LFLAGS_HEADLESS
= "-nostdlib -Bdynamic -Wl,-T,"\
268 "$(ANDROID_BUILD_TOP)/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/darwin-x86/arm-eabi/lib/ldscripts/armelf.x -Wl,"\
269 "-dynamic-linker,/system/bin/linker -Wl,"\
271 "-L$(ANDROID_BUILD_TOP)/android-ndk/platforms/%s/arch-arm/usr/lib -Wl,"\
272 "-rpath-link=$(ANDROID_BUILD_TOP)/android-ndk/platforms/%s/arch-arm/usr/lib "\
273 "$(ANDROID_BUILD_TOP)/android-ndk/platforms/%s/arch-arm/usr/lib/crtbegin_dynamic.o "\
274 "$(ANDROID_BUILD_TOP)/android-ndk/platforms/%s/arch-arm/usr/lib/crtend_android.o " % (ANDROIDPLATFORMVER
,ANDROIDPLATFORMVER
,ANDROIDPLATFORMVER
,ANDROIDPLATFORMVER
)
276 LDFLAGS
+= "$(ANDROID_BUILD_TOP)/openssl/libcrypto.a $(ANDROID_BUILD_TOP)/openssl/libssl.a"
278 # SEARCH_DIRS gets picked up in configuration.py by MKPROGRAM
279 SEARCH_DIRS
= "-L$(topsrcdir)/objdir-release/"
281 BASE_M_FLAGS
= "-mlong-calls -mthumb-interwork -mthumb"
283 if arm_arch
== "armv7-a" or arm_arch
== None:
284 BASE_CXX_FLAGS
= "%s -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH__=7 " \
285 "-DARMV6_ASSEMBLY -DTARGET_NEON -DSDK_ON2_OPT -DSDK_ON2_OPT_ARM11 -DFP_ON2_USE_C_FILTERING_FUNCTIONS " % BASE_M_FLAGS
286 APP_CXXFLAGS
+= BASE_CXX_FLAGS
288 elif arm_arch
== "armv6":
289 BASE_CXX_FLAGS
= "%s -march=armv6 -mfloat-abi=soft -D__ARM_ARCH__=6 -DARMV5_ASSEMBLY -DARMV6_ASSEMBLY " % BASE_M_FLAGS
290 APP_CXXFLAGS
+= BASE_CXX_FLAGS
291 LFLAGS_HEADLESS
+= "-Wl,--no-enum-size-warning"
293 elif arm_arch
== "armv5":
294 BASE_CXX_FLAGS
= "%s -march=armv5te -mfloat-abi=soft -mtune=xscale -D__ARM_ARCH__=5 -DARMV5_ASSEMBLY " % BASE_M_FLAGS
295 APP_CXXFLAGS
+= BASE_CXX_FLAGS
296 LFLAGS_HEADLESS
+= "-Wl,--no-enum-size-warning"
299 raise Exception('Unrecognized architecture: %s' % arm_arch
)
301 APP_CPPFLAGS
+= "-DAVMPLUS_UNIX -DUNIX -Dlinux -DUSE_PTHREAD_MUTEX -DNO_SYS_SIGNAL -DHAVE_STDARG -DNO_CONSOLE_FWRITE -DAVMPLUS_ARM %s" % ANDROID_INCLUDES
304 APP_CXXFLAGS
= "-Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof -Wno-switch "\
305 "-Wparentheses -Wpointer-arith -Wreorder -Wsign-compare -Wunused-parameter -Wwrite-strings -Wno-ctor-dtor-privacy -Woverloaded-virtual "\
306 "-Wsign-promo -Wno-char-subscripts -fmessage-length=0 -fno-exceptions -fno-rtti -fno-check-new -fstrict-aliasing -fsigned-char "
307 APP_CXXFLAGS
+= _setGCCVersionedFlags(APP_CXXFLAGS
, GCC_MAJOR_VERSION
, GCC_MINOR_VERSION
, cpu
)
310 APP_CXXFLAGS
+= "-mieee -Wno-cast-align "
313 ARM_FPU_FLAGS
= "-mfloat-abi=softfp -mfpu=vfp -march=%s -Wno-cast-align " % arm_arch
# compile to use hardware fpu
314 OPT_CXXFLAGS
+= ARM_FPU_FLAGS
315 DEBUG_CXXFLAGS
+= ARM_FPU_FLAGS
317 ARM_NEON_FLAGS
= "-mfloat-abi=softfp -mfpu=neon -march=%s -Wno-cast-align " % arm_arch
# compile to use neon vfp
318 OPT_CXXFLAGS
+= ARM_NEON_FLAGS
319 DEBUG_CXXFLAGS
+= ARM_NEON_FLAGS
321 #OPT_CXXFLAGS += "-march=%s " % arm_arch
322 #DEBUG_CXXFLAGS += "-march=%s " % arm_arch
324 if config
.getDebug():
327 APP_CXXFLAGS
+= "-Wuninitialized "
328 DEBUG_CXXFLAGS
+= "-g "
329 elif config
.getCompiler() == 'VS':
331 APP_CXXFLAGS
= "-W4 -WX -wd4291 -wd4201 -wd4189 -wd4740 -wd4127 -fp:fast -GF -GS- -Zc:wchar_t- "
332 OS_LDFLAGS
+= "-MAP "
333 if config
.getDebug():
334 DEBUG_CXXFLAGS
= "-Od "
335 DEBUG_CFLAGS
= "-Od "
336 APP_CXXFLAGS
+= "-GR- -fp:fast -GS- -Zc:wchar_t- -Zc:forScope "
338 OPT_CXXFLAGS
= "-O2 -GR- "
340 OPT_CXXFLAGS
+= "-QR%s " % arm_arch
342 OPT_CXXFLAGS
+= "-QRfpe- " # compile to use hardware fpu
344 APP_CXXFLAGS
= "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
345 APP_CFLAGS
= "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
348 pass # 64 bit VC does NaN comparisons incorrectly with fp:fast
350 APP_CXXFLAGS
+= "-fp:fast "
351 APP_CFLAGS
+= "-fp:fast "
353 OS_LDFLAGS
+= "-MAP "
354 if config
.getDebug():
355 DEBUG_CXXFLAGS
= "-Od "
356 DEBUG_CFLAGS
= "-Od "
358 OPT_CXXFLAGS
= "-O2 -Ob1 -GR- "
359 OPT_CFLAGS
= "-O2 -Ob1 -GR- "
362 OPT_CXXFLAGS
+= "-Oy- -Zi "
364 DEBUG_CXXFLAGS
+= "-Zi "
365 DEBUG_CFLAGS
+= "-Zi "
366 DEBUG_LDFLAGS
+= "-DEBUG "
367 elif config
.getCompiler() == 'SunStudio':
368 APP_CXXFLAGS
= "-template=no%extdef -erroff"
369 OPT_CXXFLAGS
= "-xO2 "
370 DEBUG_CXXFLAGS
+= "-g "
372 raise Exception('Unrecognized compiler: ' + config
.getCompiler())
374 zlib_include_dir
= o
.getStringArg('zlib-include-dir')
375 if zlib_include_dir
is not None:
376 AVMSHELL_CPPFLAGS
+= "-I%s " % zlib_include_dir
378 zlib_lib
= o
.getStringArg('zlib-lib')
379 if zlib_lib
is not None:
380 AVMSHELL_LDFLAGS
= zlib_lib
382 AVMSHELL_LDFLAGS
= '$(call EXPAND_LIBNAME,zlib)'
384 sys_root_dir
= o
.getStringArg('sys-root-dir')
385 if sys_root_dir
is not None:
386 OS_LDFLAGS
+= " --sysroot=%s " % sys_root_dir
387 OPT_CXXFLAGS
+= " --sysroot=%s " % sys_root_dir
389 if the_os
== "darwin":
390 # Get machine's OS version number and trim off anything after '10.x'
391 p
= subprocess
.Popen('sw_vers -productVersion', shell
=True, stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
)
392 os_ver
= p
.stdout
.read()
393 parts
= os_ver
.split('.')
394 os_ver
= parts
[0] + '.' + parts
[1]
396 AVMSHELL_LDFLAGS
+= " -exported_symbols_list " + thisdir
+ "/platform/mac/avmshell/exports.exp"
397 MMGC_DEFINES
.update({'TARGET_API_MAC_CARBON': 1,
401 'TARGET_RT_MAC_MACHO': 1})
402 APP_CXXFLAGS
+= "-fpascal-strings -faltivec -fasm-blocks "
404 # If an sdk is selected align OS and gcc/g++ versions to it
405 if o
.mac_sdk_version
is not None:
406 os_ver
,sdk_number
= _setSDKParams(o
.mac_sdk_version
, os_ver
)
407 APP_CXXFLAGS
+= "-mmacosx-version-min=%s -isysroot /Developer/SDKs/MACOSX%s.sdk " % (os_ver
,sdk_number
)
409 APP_CXXFLAGS
+= "-mmacosx-version-min=%s " % os_ver
411 config
.subst("MACOSX_DEPLOYMENT_TARGET",os_ver
)
414 APP_CXXFLAGS
+= "-arch ppc64 "
415 APP_CFLAGS
+= "-arch ppc64 "
416 OS_LDFLAGS
+= "-arch ppc64 "
417 elif cpu
== 'x86_64':
418 APP_CXXFLAGS
+= "-arch x86_64 "
419 APP_CFLAGS
+= "-arch x86_64 "
420 OS_LDFLAGS
+= "-arch x86_64 "
422 elif the_os
== "windows" or the_os
== "cygwin":
423 MMGC_DEFINES
.update({'WIN32': None,
424 '_CRT_SECURE_NO_DEPRECATE': None})
425 OS_LDFLAGS
+= "-MAP "
427 APP_CPPFLAGS
+= "-DARM -D_ARM_ -DUNICODE -DUNDER_CE=1 -DMMGC_ARM "
429 APP_CPPFLAGS
+= "-DARMV6 -QRarch6 "
431 APP_CPPFLAGS
+= "-DARMV5 -QRarch5t "
432 OS_LIBS
.append('mmtimer corelibc coredll')
434 APP_CPPFLAGS
+= "-DWIN32_LEAN_AND_MEAN -D_CONSOLE "
435 OS_LIBS
.append('winmm')
436 OS_LIBS
.append('shlwapi')
437 OS_LIBS
.append('AdvAPI32')
438 elif the_os
== "linux":
439 MMGC_DEFINES
.update({'UNIX': None,
440 'AVMPLUS_UNIX': None})
441 OS_LIBS
.append('pthread')
442 # if cpu == "x86_64":
443 # # workaround https://bugzilla.mozilla.org/show_bug.cgi?id=467776
444 # OPT_CXXFLAGS += '-fno-schedule-insns2 '
445 if config
.getDebug():
447 elif the_os
== "android":
448 MMGC_DEFINES
.update({'AVMFEATURE_OVERRIDE_GLOBAL_NEW': 0,
449 'RTMFPUTIL_OVERRIDE_OPERATOR_NEW': None})
451 BASE_D_FLAGS
= "-DANDROID -DNETSCAPE -DDISABLE_DRM -DGENERIC_PLATFORM -DHAVE_SYS_UIO_H -Dlinux -DNEEDS_IN6_H -DUNIX -Dcompress=zlib_compress "
453 BASE_D_FLAGS
+= "-DDISABLE_RTMPE "
455 APP_CXXFLAGS
+= BASE_D_FLAGS
457 if config
.getDebug():
458 DEBUG_CXXFLAGS
+= "-DDEBUG -D_DEBUG -DASYNC_DEBUG -O0 -ggdb3 "
461 APP_CXXFLAGS
+= "-DNDEBUG -O3 -fomit-frame-pointer -fvisibility=hidden -finline-functions -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fvisibility-inlines-hidden "
463 elif the_os
== "sunos":
464 if config
.getCompiler() != 'GCC':
465 APP_CXXFLAGS
= "-template=no%extdef -erroff"
466 OPT_CXXFLAGS
= "-xO2 "
467 DEBUG_CXXFLAGS
= "-g "
468 MMGC_DEFINES
.update({'UNIX': None,
469 'AVMPLUS_UNIX': None,
471 OS_LIBS
.append('pthread')
473 APP_CPPFLAGS
+= '-DAVMPLUS_CDECL '
474 if config
.getDebug():
477 raise Exception("Unsupported OS")
480 if config
.getCompiler() == 'GCC' and the_os
== 'darwin':
481 #only mactel always has sse2
482 APP_CPPFLAGS
+= "-msse2 "
483 elif cpu
== "powerpc":
484 # we detect this in core/avmbuild.h and MMgc/*build.h
487 # we detect this in core/avmbuild.h and MMgc/*build.h
490 APP_CPPFLAGS
+= "-DAVMPLUS_SPARC "
491 elif cpu
== "x86_64":
492 # we detect this in core/avmbuild.h and MMgc/*build.h
495 # we detect this in core/avmbuild.h and MMgc/*build.h
498 # we detect this in core/avmbuild.h and MMgc/*build.h
501 # work around for a problem with tas.b instruction on some sh4 boards
502 APP_CPPFLAGS
+= "-DUSE_PTHREAD_MUTEX "
504 raise Exception("Unsupported CPU")
506 if o
.getBoolArg('perfm'):
507 APP_CPPFLAGS
+= "-DPERFM "
510 sys
.stdout
.write(o
.getHelp())
513 # Get the optional avm description string
514 # This is NOT supported on windows/cygwin due to cygwin-wrapper.sh
515 # not passing the string correctly to cl.exe
516 AVMPLUS_DESC
= o
.getStringArg('desc') or ''
517 if the_os
== "windows" or the_os
== "cygwin":
519 print('AVMPLUS_DESC is not supported on windows via cygwin make.'
520 ' Ignoring description.')
521 else: # all other platforms
522 # place in Makefile even if the value is empty so
523 # it can be updated by hand if desired
524 APP_CPPFLAGS
+= '-DAVMPLUS_DESC="${AVMPLUS_DESC}" '
525 config
.subst("AVMPLUS_DESC", AVMPLUS_DESC
)
527 # Append MMGC_DEFINES to APP_CPPFLAGS
528 APP_CPPFLAGS
+= ''.join(val
is None and ('-D%s ' % var
) or ('-D%s=%s ' % (var
, val
))
529 for (var
, val
) in MMGC_DEFINES
.iteritems())
531 config
.subst("APP_CPPFLAGS", APP_CPPFLAGS
)
532 config
.subst("APP_CXXFLAGS", APP_CXXFLAGS
)
533 config
.subst("OPT_CPPFLAGS", OPT_CPPFLAGS
)
534 config
.subst("OPT_CXXFLAGS", OPT_CXXFLAGS
)
535 config
.subst("DEBUG_CPPFLAGS", DEBUG_CPPFLAGS
)
536 config
.subst("DEBUG_CXXFLAGS", DEBUG_CXXFLAGS
)
537 config
.subst("DEBUG_LDFLAGS", DEBUG_LDFLAGS
)
538 config
.subst("OS_LIBS", " ".join(OS_LIBS
))
539 config
.subst("OS_LDFLAGS", OS_LDFLAGS
)
540 config
.subst("MMGC_CPPFLAGS", MMGC_CPPFLAGS
)
541 config
.subst("AVMSHELL_CPPFLAGS", AVMSHELL_CPPFLAGS
)
542 config
.subst("AVMSHELL_LDFLAGS", AVMSHELL_LDFLAGS
)
543 config
.subst("MMGC_DYNAMIC", MMGC_DYNAMIC
and 1 or '')
544 if the_os
== "android":
545 config
.subst("LFLAGS_HEADLESS", LFLAGS_HEADLESS
)
546 config
.subst("LDFLAGS", LDFLAGS
)
547 config
.subst("SEARCH_DIRS", SEARCH_DIRS
)
549 config
.generate("Makefile")