This repository has been archived by the owner on Jan 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
configure.py
executable file
·714 lines (631 loc) · 29.6 KB
/
configure.py
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil -*-
# vi: set ts=4 sw=4 expandtab:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This script runs just like a traditional configure script, to do configuration
# testing and makefile generation.
#****************************************************************************
# If you're building android the android public sdk/ndk must be set up on your
# build machine. # See the wiki page here for instructions on how to create
# the android public sdk/ndk:
# https://zerowing.corp.adobe.com/display/FlashPlayer/android+tamarin+shell+support
#
# Before building edit the /android-public/android-vars.sh script
# and check that the ANDROIDTOP variable is set correctly. Then run the script
# before invoking configure.py:
# . /android-public/android-vars.sh
#
#****************************************************************************
import os
import os.path
import sys
import build.process
import re
import string
import subprocess
thisdir = os.path.dirname(os.path.abspath(__file__))
# Look for additional modules in our build/ directory.
sys.path.append(thisdir)
from build.configuration import *
import build.getopt
import build.avmfeatures
# Used to set the mac SDK parameters
def _setSDKParams(sdk_version, os_ver, xcode_version):
if sdk_version is None:
# Infer SDK version from the current OS version
if os_ver == '10.4':
sdk_version = '104u'
else:
sdk_version = os_ver.translate(None, string.punctuation)
# 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
# Infer xcode version from the SDK version if not directly specified
if sdk_version == '104u':
os_ver,sdk_number = '10.4','10.4u'
config._acvars['CXX'] = 'g++-4.0'
config._acvars['CC'] = 'gcc-4.0'
if xcode_version is None:
xcode_version = '3'
elif sdk_version == '105':
os_ver,sdk_number = '10.5','10.5'
if xcode_version is None:
xcode_version = '3'
elif sdk_version == '106':
os_ver,sdk_number = '10.6','10.6'
if xcode_version is None:
xcode_version = '3'
elif sdk_version == '107':
os_ver,sdk_number = '10.7','10.7'
if xcode_version is None:
xcode_version = '4'
elif sdk_version == '108':
os_ver,sdk_number = '10.8','10.8'
if xcode_version is None:
xcode_version = '4'
elif sdk_version == '109':
os_ver,sdk_number = '10.9','10.9'
if xcode_version is None:
xcode_version = '6'
elif sdk_version == '1010':
os_ver,sdk_number = '10.10','10.11'
if xcode_version is None:
xcode_version = '7'
elif sdk_version == '1011':
os_ver,sdk_number = '10.11','10.11'
if xcode_version is None:
xcode_version = '7'
else:
print'Unknown SDK version -> %s. Expected values are 104u, 105, 106, 107, 108, 109 or 1010.' % sdk_version
sys.exit(2)
sdk_prefix = None
if xcode_version is not None:
xcode_major_version = xcode_version.split(".")[0]
if int(xcode_major_version) >= 4:
#matz: post xcode 4.5 can install xcode anyplace
#hence may need to use xcode-select to find right install of xcode
sdk_prefix = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX"
if not os.path.exists(sdk_prefix):
p = subprocess.Popen('xcode-select -print-path', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
pth = p.stdout.read().strip()
#print "xcode-select --print-path says", pth.strip()
sdk_prefix = pth.strip() + "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX"
if sdk_prefix is None:
sdk_prefix = "/Developer/SDKs/MacOSX"
sdk_path = sdk_prefix + sdk_number + ".sdk"
if not os.path.exists(sdk_path):
print'Could not find %s' % sdk_path
sys.exit(2)
else:
return os_ver,sdk_path
def _setGCCVersionedFlags(FLAGS, MAJOR_VERSION, MINOR_VERSION, current_cpu, clang_compiler):
# warnings have been updated to try to include all those enabled by current Flash/AIR builds -- disable with caution, or risk integration pain
if MAJOR_VERSION >= 4:
if not clang_compiler:
FLAGS += "-Wstrict-null-sentinel "
if current_cpu == 'mips':
FLAGS += "-Wstrict-aliasing=0 "
elif (MAJOR_VERSION == 4 and MINOR_VERSION <= 2): # 4.0 - 4.2
# Bugzilla 654996: -Werror for gcc prior to 4.3 can _usually_ be
# turned on; see core/manifest.mk for Interpreter.cpp workaround.
FLAGS += "-Wstrict-aliasing=0 -Werror "
elif (MAJOR_VERSION == 4 and MINOR_VERSION == 4): # 4.4
FLAGS += "-Werror -Wempty-body -Wno-logical-op -Wmissing-field-initializers -Wstrict-aliasing=0 -Wno-array-bounds -Wno-clobbered -Wstrict-overflow=0 -funit-at-a-time "
elif (MAJOR_VERSION >= 5 and clang_compiler): # clang 5.0 and above, TODO - Fix these warnings and reduce the flags.
FLAGS += "-Wno-undef -Wno-unused-macros -Wno-documentation -Wno-c++11-extensions -Wno-sign-conversion -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare "
FLAGS += "-Wno-shadow -Wno-cast-align -Wno-compare-distinct-pointer-types -Wno-null-conversion -Wno-invalid-offsetof -Wno-non-literal-null-conversion "
FLAGS += "-Wno-padded -Wno-global-constructors -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-exit-time-destructors -Wno-format-nonliteral -Wno-unused-private-field "
FLAGS += "-Wmissing-field-initializers -Wno-array-bounds -Wstrict-overflow=0 -funit-at-a-time "
else: # gcc 4.5 or later
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 "
if (MAJOR_VERSION == 4 and MINOR_VERSION == 6): # 4.6
FLAGS += "-Wno-psabi -Wno-unused-variable -Wno-unused-but-set-variable "
return FLAGS
def getLlvmFlags(llvm_config_flags, llvm_dir):
"given an installed llvm build (aka llvm sdk), exec llvm-config --flags to get the -I (or ld, or cpp, etc) flags to use to compile llvm code"
if not os.path.exists(llvm_dir):
print 'llvm value %s does not exist' % llvm_dir
return None
if not os.path.isdir(llvm_dir):
print 'llvm value %s not a directory' % llvm_dir
return None
llvm_bin_dir = os.path.join(llvm_dir, "bin")
if not os.path.exists(llvm_bin_dir):
print 'are you sure %s is a llvm installed "sdk"? Cannot find %s' % (llvm_dir, llvm_bin_dir)
return None
# llvm-config is a clever tool installed by llvm that knows paths to libs and includes
# and other stuff that helps users
llvm_config = os.path.join(llvm_bin_dir, "llvm-config")
if not os.path.isfile(llvm_config):
print 'are you sure %s is a llvm installed "sdk"? Cannot find %s' % (llvm_dir, llvm_config)
return None
else:
llvm_config_cmd = llvm_config + " " + llvm_config_flags
p = subprocess.Popen(llvm_config_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
llvm_config_out = p.stdout.read()
cxxflags = llvm_config_out.strip()
#how to find out exit code from process library??
if not cxxflags.startswith("-") and not cxxflags.startswith("/") and not llvm_config_flags.startswith("--libs"):
print "'%s' looks like an incorrect llvm-config command because output doesn't start with - %s" % (llvm_config_cmd, llvm_config_out)
return None
return llvm_config_out
o = build.getopt.Options()
config = Configuration(thisdir, options = o,
sourcefile = 'core/avmplus.h')
the_os, cpu = config.getTarget()
arm_fpu = o.getBoolArg("arm-fpu", False)
arm_neon = o.getBoolArg("arm-neon", False)
arm_thumb = False
if cpu == "thumb2":
arm_thumb = True
else:
arm_thumb = o.getBoolArg("arm-thumb",False)
arm_hard_float = o.getBoolArg("arm-hard-float", False)
arm_arch = o.arm_arch
if arm_arch == None and cpu == "thumb2":
arm_arch = "armv7-a"
# matz: the ENABLE_ make macros are a private arrangement
# between the code here and conditional code in the
# (We could generate them into the makefile automatically for all enabled features)
# In makefiles, use ifeq (1,$(ENABLE_XXXX)) to conditionally build features
buildTamarin = o.getBoolArg('tamarin', True)
if buildTamarin:
config.subst("ENABLE_TAMARIN", 1)
buildShell = o.getBoolArg("shell", True)
if (buildShell):
config.subst("ENABLE_SHELL", 1)
buildAot = o.peekBoolArg("aot", False)
if buildAot:
config.subst("ENABLE_AOT", 1)
if o.peekBoolArg("halfmoon-aot-runtime", False):
config.subst("ENABLE_HALFMOON_AOT_RUNTIME", 1)
if o.peekBoolArg("halfmoon-aot-compiler", False):
config.subst("ENABLE_HALFMOON_AOT_COMPILER", 1)
# imitating the clang configure script, we accept --enable-llvm=dir which points at the build output of the llvm build we want to use.
#
llvm_dir = o.getStringArg("llvm")
if llvm_dir :
llvm_cpp_flags = getLlvmFlags("--cppflags", llvm_dir)
if llvm_cpp_flags == None :
print "running llvm-config --cppflags to obtain C preprocessor flags from %s has failed." % llvm_dir
sys.exit(2)
else:
#release llvm-config include -UNDEBUG though it doesn't need to.. and it clashes with our NDEBUG
print "configure.py removing -UNDEBUG from llvm-config --cppflags output"
llvm_cpp_flags = llvm_cpp_flags.replace(" -UNDEBUG", "")
llvm_cxx_flags = getLlvmFlags("--cxxflags", llvm_dir)
#print llvm_cxx_flags
if llvm_cxx_flags == None :
print "running llvm-config --cxxflags to obtain compiler flags from %s has failed." % llvm_dir
sys.exit(2)
else:
#release llvm-config include -UNDEBUG though it doesn't need to.. and it clashes with our NDEBUG
print "configure.py removing -UNDEBUG from llvm-config --cxxflags output"
llvm_cxx_flags = llvm_cxx_flags.replace(" -UNDEBUG", "")
llvm_ld_flags = getLlvmFlags("--ldflags", llvm_dir)
#print llvm_ld_flags
if llvm_ld_flags == None :
print "running llvm-config --ldflags to obtain compiler flags from %s has failed." % llvm_dir
sys.exit(2)
#TODO: llvm-config shouldn't need the specialized components.
llvm_libs_flags = getLlvmFlags("--libs all-targets codegen ipo ipa bitwriter", llvm_dir)
#print llvm_libs_flags
if llvm_libs_flags == None :
print "running llvm-config --libs to obtain list of llvm libs from %s has failed." % llvm_dir
sys.exit(2)
config.subst("ENABLE_LLVM", 1)
config.subst("LLVM_DIR", llvm_dir)
config.subst("LLVM_CPPFLAGS", llvm_cpp_flags)
config.subst("LLVM_CXXFLAGS", llvm_cxx_flags)
config.subst("LLVM_LDFLAGS", llvm_ld_flags)
config.subst("LLVM_LIBS", llvm_libs_flags)
APP_CPPFLAGS = "-DAVMSHELL_BUILD "
APP_CXXFLAGS = ""
APP_CFLAGS = ""
OPT_CXXFLAGS = "-O3 "
OPT_CPPFLAGS = ""
DEBUG_CPPFLAGS = "-DDEBUG -D_DEBUG "
DEBUG_CXXFLAGS = ""
DEBUG_CFLAGS = ""
DEBUG_LDFLAGS = ""
OS_LIBS = []
OS_LDFLAGS = ""
LDFLAGS = config._acvars['LDFLAGS']
MMGC_CPPFLAGS = "-DAVMSHELL_BUILD "
AVMSHELL_CPPFLAGS = ""
AVMSHELL_LDFLAGS = ""
MMGC_DEFINES = {}
NSPR_INCLUDES = ""
NSPR_LDOPTS = ""
DISABLE_RTMPE = None
ANDROIDPLATFORMVER = "android-9"
ARM_EABI_VER = '4.4.3'
ARM_EABI = 'arm-linux-androideabi'
if 'APP_CPPFLAGS' in os.environ:
APP_CPPFLAGS += os.environ['APP_CPPFLAGS'] + " "
if 'APP_CXXFLAGS' in os.environ:
APP_CXXFLAGS += os.environ['APP_CXXFLAGS'] + " "
if 'APP_CFLAGS' in os.environ:
APP_CFLAGS += os.environ['APP_CFLAGS'] + " "
if 'OPT_CXXFLAGS' in os.environ:
OPT_CXXFLAGS += os.environ['OPT_CXXFLAGS'] + " "
if 'OPT_CPPFLAGS' in os.environ:
OPT_CPPFLAGS += os.environ['OPT_CPPFLAGS'] + " "
if 'DEBUG_CPPFLAGS' in os.environ:
DEBUG_CPPFLAGS += os.environ['DEBUG_CPPFLAGS'] + " "
if 'DEBUG_CXXFLAGS' in os.environ:
DEBUG_CXXFLAGS += os.environ['DEBUG_CXXFLAGS'] + " "
if 'DEBUG_CFLAGS' in os.environ:
DEBUG_CFLAGS += os.environ['DEBUG_CFLAGS'] + " "
if 'DEBUG_LDFLAGS' in os.environ:
DEBUG_LDFLAGS += os.environ['DEBUG_LDFLAGS'] + " "
if 'OS_LDFLAGS' in os.environ:
OS_LDFLAGS += os.environ['OS_LDFLAGS'] + " "
if 'MMGC_CPPFLAGS' in os.environ:
MMGC_CPPFLAGS += os.environ['MMGC_CPPFLAGS'] + " "
if 'AVMSHELL_CPPFLAGS' in os.environ:
AVMSHELL_CPPFLAGS += os.environ['AVMSHELL_CPPFLAGS'] + " "
if 'ARM_EABI' in os.environ:
ARM_EABI = os.environ['ARM_EABI']
if 'ARM_EABI_VER' in os.environ:
ARM_EABI_VER = os.environ['ARM_EABI_VER']
if 'AVMSHELL_LDFLAGS' in os.environ:
AVMSHELL_LDFLAGS += os.environ['AVMSHELL_LDFLAGS'] + " "
if 'NSPR_INCLUDES' in os.environ:
NSPR_INCLUDES += os.environ['NSPR_INCLUDES'] + " "
if 'NSPR_LDOPTS' in os.environ:
NSPR_LDOPTS += os.environ['NSPR_LDOPTS'] + " "
if 'DISABLE_RTMPE' in os.environ:
DISABLE_RTMPE += os.environ['DISABLE_RTMPE'] + " "
if o.getBoolArg('valgrind', False, False):
OPT_CXXFLAGS = "-O1 -g "
if (o.peekBoolArg("aot") or o.peekBoolArg("halfmoon-aot") or
o.peekBoolArg("aot-compiler")) and config.getCompiler() != "VS":
APP_CXXFLAGS += "-fvisibility-inlines-hidden "
valinc = '$(topsrcdir)/other-licenses'
if 'VALGRIND_HOME' in os.environ:
valinc = os.environ['VALGRIND_HOME'] + '/include'
APP_CPPFLAGS += '-I' + valinc + ' '
# builtinBuildFlags() must be called first, featureSettings() will clear the features!
config.subst("BUILTIN_BUILDFLAGS",build.avmfeatures.builtinBuildFlags(o));
# See build/avmfeatures.py for the code that processes switches for
# standard feature names.
APP_CPPFLAGS += build.avmfeatures.featureSettings(o)
if not o.getBoolArg("methodenv-impl32", True):
APP_CPPFLAGS += "-DVMCFG_METHODENV_IMPL32=0 "
memoryProfiler = o.getBoolArg("memory-profiler", False)
if memoryProfiler:
APP_CPPFLAGS += "-DMMGC_MEMORY_PROFILER "
MMGC_INTERIOR_PTRS = o.getBoolArg('mmgc-interior-pointers', False)
if MMGC_INTERIOR_PTRS:
MMGC_DEFINES['MMGC_INTERIOR_PTRS'] = None
MMGC_DYNAMIC = o.getBoolArg('mmgc-shared', False)
if MMGC_DYNAMIC:
MMGC_DEFINES['MMGC_DLL'] = None
MMGC_CPPFLAGS += "-DMMGC_IMPL "
# For -Wreorder, see https://bugzilla.mozilla.org/show_bug.cgi?id=475750
if config.getCompiler() == 'GCC':
if 'CXX' in os.environ:
rawver = build.process.run_for_output(['$CXX', '--version'])
else:
rawver = build.process.run_for_output(['gcc', '--version'])
vre = re.compile(".* ([3-9]\.[0-9]+\.?[0-9]*)[ \n]")
ver = vre.match(rawver).group(1)
ver_arr = ver.split('.')
GCC_MAJOR_VERSION = int(ver_arr[0])
GCC_MINOR_VERSION = int(ver_arr[1])
clang_compiler = (rawver.find("clang") != -1 )
if the_os == 'android':
try:
ANDROID_TOOLCHAIN = os.environ['ANDROID_TOOLCHAIN']
ANDROID_NDK = os.environ['ANDROID_NDK']
ANDROID_NDK_BIN = os.environ['ANDROID_NDK_BIN']
ANDROID_SDK = os.environ['ANDROID_SDK']
except:
print('\nANDROID_ variables not found in environment\nPlease run /android-public/android-vars.sh')
exit(0)
ANDROID_INCLUDES = "-I$(topsrcdir)/other-licenses/zlib "\
"-I$(ANDROID_NDK)/platforms/%s/arch-arm/usr/include "\
"-I$(ANDROID_NDK_BIN) "\
"-I$(ANDROID_SDK) "\
"-I$(ANDROID_NDK)/sources/cxx-stl/stlport/stlport "\
"-I$(ANDROID_TOOLCHAIN)/openssl/include "\
"-I$(ANDROID_TOOLCHAIN)/frameworks/base/opengl/include " % (ANDROIDPLATFORMVER)
# These flags are shared with some of the other builds such as ARM, but better to keep them separate here for flexibility
COMMON_CXX_FLAGS = "-Wall -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof " \
"-Wno-switch -Wpointer-arith -Wwrite-strings -Woverloaded-virtual -Wsign-promo " \
"-fmessage-length=0 -fno-exceptions -fno-rtti -fsigned-char -fno-inline-functions-called-once -ffunction-sections -fdata-sections -Wno-ctor-dtor-privacy "
# Additional flags used by android
APP_CXX_FLAGS = "%s -Wno-ctor-dtor-privacy -Wlogical-op -Wstrict-overflow=1 " \
"-Wmissing-include-dirs -Wno-missing-field-initializers -Wno-type-limits -Wno-unused-parameter " \
"-Wnon-virtual-dtor -Wstrict-null-sentinel -Wno-missing-braces -Wno-multichar -Wno-psabi -Wno-reorder " \
"-fno-short-enums -fno-strict-aliasing -fpic -funwind-tables -fstack-protector -finline-limit=200 -ftree-vectorize " \
"-feliminate-unused-debug-symbols -feliminate-unused-debug-types -MD -fwrapv " % COMMON_CXX_FLAGS
APP_CXXFLAGS += _setGCCVersionedFlags(APP_CXX_FLAGS, GCC_MAJOR_VERSION, GCC_MINOR_VERSION, cpu, clang_compiler)
# LFLAGS_HEADLESS gets picked up in configuration.py by MKPROGRAM
LFLAGS_HEADLESS = "-nostdlib -Bdynamic -Wl,-T,"\
"$(ANDROID_NDK_BIN)/../%s/lib/ldscripts/armelf_linux_eabi.x "\
"-Wl,-dynamic-linker,/system/bin/linker "\
"-Wl,-z,nocopyreloc "\
"-L$(ANDROID_NDK)/platforms/%s/arch-arm/usr/lib "\
"-L$(ANDROID_NDK)/sources/cxx-stl/stlport/libs/armeabi "\
"-Wl,-rpath-link=$(ANDROID_NDK)/platforms/%s/arch-arm/usr/lib "\
"$(ANDROID_NDK)/platforms/%s/arch-arm/usr/lib/crtbegin_dynamic.o "\
"$(ANDROID_NDK)/platforms/%s/arch-arm/usr/lib/crtend_android.o " % (ARM_EABI,ANDROIDPLATFORMVER,ANDROIDPLATFORMVER,ANDROIDPLATFORMVER,ANDROIDPLATFORMVER)
LDFLAGS += "$(ANDROID_TOOLCHAIN)/openssl/libcrypto.a $(ANDROID_TOOLCHAIN)/openssl/libssl.a"
# SEARCH_DIRS gets picked up in configuration.py by MKPROGRAM
SEARCH_DIRS = "-L."
BASE_M_FLAGS = "-mlong-calls -mthumb-interwork "
if arm_arch == "armv7-a" or arm_arch == None:
BASE_CXX_FLAGS = "%s -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mno-thumb -fno-section-anchors -D__ARM_ARCH__=7 " \
"-DARMV6_ASSEMBLY " % BASE_M_FLAGS
APP_CXXFLAGS += BASE_CXX_FLAGS
elif arm_arch == "armv6":
BASE_CXX_FLAGS = "%s -march=armv6 -mfloat-abi=soft -D__ARM_ARCH__=6 -DARMV5_ASSEMBLY -DARMV6_ASSEMBLY " % BASE_M_FLAGS
APP_CXXFLAGS += BASE_CXX_FLAGS
LFLAGS_HEADLESS += "-Wl,--no-enum-size-warning"
elif arm_arch == "armv5":
BASE_CXX_FLAGS = "%s -march=armv5te -mfloat-abi=soft -mtune=xscale -D__ARM_ARCH__=5 -DARMV5_ASSEMBLY " % BASE_M_FLAGS
APP_CXXFLAGS += BASE_CXX_FLAGS
LFLAGS_HEADLESS += "-Wl,--no-enum-size-warning"
else:
raise Exception('Unrecognized architecture: %s' % arm_arch)
APP_CPPFLAGS += "-DAVMPLUS_UNIX -DUNIX -Dlinux -DUSE_PTHREAD_MUTEX -DGTEST_USE_OWN_TR1_TUPLE=1 -DHAVE_STDARG -DAVMPLUS_ARM %s" % ANDROID_INCLUDES
else:
APP_CXXFLAGS += "-Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof -Wno-switch "\
"-Wparentheses -Wpointer-arith -Wreorder -Wsign-compare -Wunused-parameter -Wwrite-strings -Wno-ctor-dtor-privacy -Wno-unused-local-typedefs -Woverloaded-virtual "\
"-Wsign-promo -Wno-char-subscripts -fmessage-length=0 -fno-exceptions -fsigned-char "
APP_CXXFLAGS += _setGCCVersionedFlags(APP_CXXFLAGS, GCC_MAJOR_VERSION, GCC_MINOR_VERSION, cpu, clang_compiler)
if clang_compiler:
pass
#APP_CXXFLAGS += "-no-integrated-as "
else:
APP_CXXFLAGS += "-fno-check-new -fno-rtti -fstrict-aliasing "
if cpu == 'sh4':
APP_CXXFLAGS += "-mieee -Wno-cast-align "
if cpu == 'arm' or cpu == 'thumb2':
APP_CXXFLAGS += "-Wno-cast-align "
APP_CFLAGS += "-Wno-cast-align "
FLOAT_ABI = None;
EXTRA_CFLAGS = "";
if arm_fpu:
FLOAT_ABI = "-mfloat-abi=softfp "
EXTRA_CFLAGS = "-mfpu=vfp -march=%s " % arm_arch # compile to use hardware fpu
if arm_hard_float:
FLOAT_ABI = "-mfloat-abi=hard -march=%s " % arm_arch # compile to use neon vfp
AVMSHELL_LDFLAGS += "-static "
if arm_neon:
if FLOAT_ABI == None:
FLOAT_ABI = "-mfloat-abi=softfp "
EXTRA_CFLAGS = "-mfpu=neon -march=%s -DTARGET_NEON " % arm_arch # compile to use neon vfp
if arm_thumb:
EXTRA_CFLAGS += "-mthumb -DTARGET_THUMB2 "
if arm_thumb != False and arm_arch == "armv7-a":
EXTRA_CFLAGS += "-mtune=cortex-a8 "
#if arm_arch:
#OPT_CXXFLAGS += "-march=%s " % arm_arch
#DEBUG_CXXFLAGS += "-march=%s " % arm_arch
if EXTRA_CFLAGS != None:
APP_CXXFLAGS += EXTRA_CFLAGS
APP_CFLAGS += EXTRA_CFLAGS
if FLOAT_ABI != None:
APP_CXXFLAGS += FLOAT_ABI
APP_CFLAGS += FLOAT_ABI
AVMSHELL_LDFLAGS += FLOAT_ABI
if config.getDebug():
APP_CXXFLAGS += ""
else:
APP_CXXFLAGS += "-Wuninitialized "
DEBUG_CXXFLAGS += "-g "
DEBUG_LDFLAGS += "-g "
elif config.getCompiler() == 'VS':
if cpu == "arm":
APP_CXXFLAGS = "-W4 -WX -wd4291 -wd4201 -wd4189 -wd4740 -wd4127 -fp:fast -GF -GS- -Zc:wchar_t- "
OS_LDFLAGS += "-MAP "
if config.getDebug():
DEBUG_CXXFLAGS = "-Od "
DEBUG_CFLAGS = "-Od "
APP_CXXFLAGS += "-GR- -fp:fast -GS- -Zc:wchar_t- -Zc:forScope "
else:
OPT_CXXFLAGS = "-O2 -GR- "
if arm_arch:
OPT_CXXFLAGS += "-QR%s " % arm_arch
if arm_fpu:
OPT_CXXFLAGS += "-QRfpe- " # compile to use hardware fpu
else:
APP_CXXFLAGS = "-W4 -wd4291 -wd4510 -wd4610 -wd4062 -GF -GS- -Zc:wchar_t "
APP_CFLAGS = "-W3 -wd4291 -GF -GS- -Zc:wchar_t "
if cpu == 'x86_64':
pass # 64 bit VC does NaN comparisons incorrectly with fp:fast
else:
APP_CXXFLAGS += "-fp:fast "
APP_CFLAGS += "-fp:fast "
OS_LDFLAGS += "-MAP "
if config.getDebug():
DEBUG_CXXFLAGS = "-Od "
DEBUG_CFLAGS = "-Od "
else:
OPT_CXXFLAGS = "-O2 -Ob1 -GR- "
OPT_CFLAGS = "-O2 -Ob1 -GR- "
if memoryProfiler:
OPT_CXXFLAGS += "-Oy- -Zi "
DEBUG_CXXFLAGS += "-Zi "
DEBUG_CFLAGS += "-Zi "
DEBUG_LDFLAGS += "-DEBUG "
elif config.getCompiler() == 'SunStudio':
APP_CXXFLAGS = "-template=no%extdef -erroff"
OPT_CXXFLAGS = "-xO2 "
DEBUG_CXXFLAGS += "-g "
else:
raise Exception('Unrecognized compiler: ' + config.getCompiler())
zlib_include_dir = o.getStringArg('zlib-include-dir')
if zlib_include_dir is not None:
AVMSHELL_CPPFLAGS += "-I%s " % zlib_include_dir
zlib_lib = o.getStringArg('zlib-lib')
if zlib_lib is None:
zlib_lib = '$(call EXPAND_LIBNAME,zlib)'
lzma_lib = o.getStringArg('lzma-lib')
if lzma_lib is None:
lzma_lib = '$(call EXPAND_LIBNAME,lzma)'
AVMSHELL_LDFLAGS += zlib_lib + ' ' + lzma_lib
sys_root_dir = o.getStringArg('sys-root-dir')
if sys_root_dir is not None:
OS_LDFLAGS += " --sysroot=%s " % sys_root_dir
OPT_CXXFLAGS += " --sysroot=%s " % sys_root_dir
if the_os == "darwin":
# Get machine's OS version number and trim off anything after '10.x'
p = subprocess.Popen('sw_vers -productVersion', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os_ver = p.stdout.read()
parts = os_ver.split('.')
os_ver = parts[0] + '.' + parts[1]
AVMSHELL_LDFLAGS += " -exported_symbols_list $(topsrcdir)/platform/mac/avmshell/exports.exp"
MMGC_DEFINES.update({'TARGET_API_MAC_CARBON': 1,
'DARWIN': 1,
'_MAC': None,
'AVMPLUS_MAC': None,
'TARGET_RT_MAC_MACHO': 1})
APP_CXXFLAGS += "-fpascal-strings -fasm-blocks "
if not clang_compiler:
APP_CXXFLAGS += "-faltivec "
# If an sdk is selected align OS and gcc/g++ versions to it
os_ver,sdk_path = _setSDKParams(o.mac_sdk, os_ver, o.mac_xcode)
APP_CXXFLAGS += "-mmacosx-version-min=%s -isysroot %s " % (os_ver,sdk_path)
if not 'MACOSX_DEPLOYMENT_TARGET' in os.environ:
config.subst("MACOSX_DEPLOYMENT_TARGET",os_ver)
if cpu == 'ppc64':
APP_CXXFLAGS += "-arch ppc64 "
APP_CFLAGS += "-arch ppc64 "
OS_LDFLAGS += "-arch ppc64 "
elif cpu == 'x86_64':
APP_CXXFLAGS += "-arch x86_64 "
APP_CFLAGS += "-arch x86_64 "
OS_LDFLAGS += "-arch x86_64 "
elif the_os == "windows" or the_os == "cygwin":
MMGC_DEFINES.update({'WIN32': None,
'_CRT_SECURE_NO_DEPRECATE': None})
OS_LDFLAGS += "-MAP "
if cpu == "arm":
APP_CPPFLAGS += "-DARM -D_ARM_ -DUNICODE -DUNDER_CE=1 -DMMGC_ARM "
if arm_fpu:
APP_CPPFLAGS += "-DARMV6 -QRarch6 "
else:
APP_CPPFLAGS += "-DARMV5 -QRarch5t "
OS_LIBS.append('mmtimer corelibc coredll')
elif cpu == "thumb2":
APP_CPPFLAGS += "-DARMv7 -D_ARM_ -DTARGET_THUMB2 -DUNICODE -DUNDER_RT=1 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE "
OS_LIBS.append('winmm')
OS_LIBS.append('shlwapi')
OS_LIBS.append('AdvAPI32')
else:
APP_CPPFLAGS += "-DWIN32_LEAN_AND_MEAN -D_CONSOLE "
OS_LIBS.append('winmm')
OS_LIBS.append('shlwapi')
OS_LIBS.append('AdvAPI32')
elif the_os == "linux":
MMGC_DEFINES.update({'UNIX': None,
'AVMPLUS_UNIX': None})
OS_LIBS.append('pthread')
if cpu == "i686":
APP_CPPFLAGS += "-m32 -march=i686 "
OS_LDFLAGS += "-m32 "
# if cpu == "x86_64":
# # workaround https://bugzilla.mozilla.org/show_bug.cgi?id=467776
# OPT_CXXFLAGS += '-fno-schedule-insns2 '
if config.getDebug():
OS_LIBS.append("dl")
elif the_os == "android":
BASE_D_FLAGS = "-DANDROID -DHAVE_SYS_UIO_H -Dlinux -DUNIX -Dcompress=zlib_compress "
APP_CXXFLAGS += BASE_D_FLAGS
if config.getDebug():
DEBUG_CXXFLAGS += "-DDEBUG -D_DEBUG -DASYNC_DEBUG -O0 -ggdb3 "
DEBUG_CPPFLAGS = ""
else:
APP_CXXFLAGS += "-DNDEBUG -O3 -fomit-frame-pointer -fvisibility=hidden -finline-functions -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fvisibility-inlines-hidden "
DEBUG_CPPFLAGS = ""
elif the_os == "sunos":
if config.getCompiler() != 'GCC':
APP_CXXFLAGS = "-template=no%extdef -erroff"
OPT_CXXFLAGS = "-xO2 "
DEBUG_CXXFLAGS = "-g "
MMGC_DEFINES.update({'UNIX': None,
'AVMPLUS_UNIX': None,
'SOLARIS': None})
OS_LIBS.append('pthread')
OS_LIBS.append('rt')
OS_LIBS.append('Cstd')
APP_CPPFLAGS += '-DAVMPLUS_CDECL '
if config.getDebug():
OS_LIBS.append("dl")
else:
raise Exception("Unsupported OS")
if cpu == "i686":
if config.getCompiler() == 'GCC' :
# we require sse2
APP_CPPFLAGS += "-msse2 "
elif cpu == "powerpc":
# we detect this in core/avmbuild.h and MMgc/*build.h
None
elif cpu == "ppc64":
# we detect this in core/avmbuild.h and MMgc/*build.h
None
elif cpu == "sparc":
APP_CPPFLAGS += "-DAVMPLUS_SPARC "
elif cpu == "x86_64":
# we detect this in core/avmbuild.h and MMgc/*build.h
None
elif cpu == "thumb2":
# we detect this in core/avmbuild.h and MMgc/*build.h
None
elif cpu == "arm":
# we detect this in core/avmbuild.h and MMgc/*build.h
None
elif cpu == "mips":
# we detect this in core/avmbuild.h and MMgc/*build.h
None
elif cpu == "sh4":
# work around for a problem with tas.b instruction on some sh4 boards
APP_CPPFLAGS += "-DUSE_PTHREAD_MUTEX "
else:
raise Exception("Unsupported CPU")
if o.getBoolArg('perfm'):
APP_CPPFLAGS += "-DPERFM "
if o.help:
sys.stdout.write(o.getHelp())
sys.exit(1)
# Get the optional avm description string
# This is NOT supported on windows/cygwin due to cygwin-wrapper.sh
# not passing the string correctly to cl.exe
AVMPLUS_DESC = o.getStringArg('desc') or ''
if the_os == "windows" or the_os == "cygwin":
if AVMPLUS_DESC:
print('AVMPLUS_DESC is not supported on windows via cygwin make.'
' Ignoring description.')
else: # all other platforms
# place in Makefile even if the value is empty so
# it can be updated by hand if desired
APP_CPPFLAGS += '-DAVMPLUS_DESC="${AVMPLUS_DESC}" '
config.subst("AVMPLUS_DESC", AVMPLUS_DESC)
# Append MMGC_DEFINES to APP_CPPFLAGS
APP_CPPFLAGS += ''.join(val is None and ('-D%s ' % var) or ('-D%s=%s ' % (var, val))
for (var, val) in MMGC_DEFINES.iteritems())
config.subst("APP_CPPFLAGS", APP_CPPFLAGS)
config.subst("APP_CXXFLAGS", APP_CXXFLAGS)
config.subst("APP_CFLAGS", APP_CFLAGS)
config.subst("OPT_CPPFLAGS", OPT_CPPFLAGS)
config.subst("OPT_CXXFLAGS", OPT_CXXFLAGS)
config.subst("DEBUG_CPPFLAGS", DEBUG_CPPFLAGS)
config.subst("DEBUG_CXXFLAGS", DEBUG_CXXFLAGS)
config.subst("DEBUG_LDFLAGS", DEBUG_LDFLAGS)
config.subst("OS_LIBS", " ".join(OS_LIBS))
config.subst("OS_LDFLAGS", OS_LDFLAGS)
config.subst("MMGC_CPPFLAGS", MMGC_CPPFLAGS)
config.subst("AVMSHELL_CPPFLAGS", AVMSHELL_CPPFLAGS)
config.subst("AVMSHELL_LDFLAGS", AVMSHELL_LDFLAGS)
config.subst("MMGC_DYNAMIC", MMGC_DYNAMIC and 1 or '')
if the_os == "android":
config.subst("LFLAGS_HEADLESS", LFLAGS_HEADLESS)
config.subst("LDFLAGS", LDFLAGS)
config.subst("SEARCH_DIRS", SEARCH_DIRS)
config.generate("Makefile")
o.finish()