forked from ReadyTalk/avian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
executable file
·2353 lines (2000 loc) · 72.6 KB
/
makefile
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
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MAKEFLAGS = -s
name = avian
version := $(shell grep version gradle.properties | cut -d'=' -f2)
java-version := $(shell $(JAVA_HOME)/bin/java -version 2>&1 \
| head -n 1 \
| sed 's/.*version "1.\([^.]*\).*/\1/')
build-arch := $(shell uname -m \
| sed 's/^i.86$$/i386/' \
| sed 's/^x86pc$$/i386/' \
| sed 's/amd64/x86_64/' \
| sed 's/^arm.*$$/arm/' \
| sed 's/aarch64/arm64/')
build-platform := \
$(shell uname -s | tr [:upper:] [:lower:] \
| sed \
-e 's/^mingw32.*$$/mingw32/' \
-e 's/^cygwin.*$$/cygwin/' \
-e 's/^darwin.*$$/macosx/')
arch = $(build-arch)
target-arch = $(arch)
bootimage-platform = \
$(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
platform = $(bootimage-platform)
codegen-targets = native
mode = fast
process = compile
ifneq ($(process),compile)
options := -$(process)
endif
ifneq ($(mode),fast)
options := $(options)-$(mode)
endif
ifneq ($(lzma),)
options := $(options)-lzma
endif
ifeq ($(bootimage),true)
options := $(options)-bootimage
ifeq ($(bootimage-test),true)
# this option indicates that we should AOT-compile the test
# classes as well as the class library
options := $(options)-test
endif
endif
ifeq ($(tails),true)
options := $(options)-tails
endif
ifeq ($(continuations),true)
options := $(options)-continuations
endif
ifeq ($(codegen-targets),all)
options := $(options)-all
endif
ifeq ($(filter debug debug-fast fast stress stress-major small,$(mode)),)
x := $(error "'$(mode)' is not a valid mode (choose one of: debug debug-fast fast stress stress-major small)")
endif
ifeq ($(filter compile interpret,$(process)),)
x := $(error "'$(process)' is not a valid process (choose one of: compile interpret)")
endif
ifeq ($(filter x86_64 i386 arm arm64,$(arch)),)
x := $(error "'$(arch)' is not a supported architecture (choose one of: x86_64 i386 arm arm64)")
endif
ifeq ($(platform),darwin)
x := $(error "please use 'platform=macosx' or 'platform=ios' instead of 'platform=$(platform)'")
endif
ifneq ($(ios),)
x := $(error "please use 'platform=ios' instead of 'ios=true'")
endif
ifeq ($(filter linux windows macosx ios freebsd,$(platform)),)
x := $(error "'$(platform)' is not a supported platform (choose one of: linux windows macosx ios freebsd)")
endif
ifeq ($(platform),macosx)
ifneq ($(filter arm arm64,$(arch)),)
x := $(error "please use ('arch=arm' or 'arch=arm64') 'platform=ios' to build for ios-arm")
endif
endif
ifeq ($(platform),ios)
ifeq ($(filter i386 x86_64 arm arm64,$(arch)),)
x := $(error "please specify 'arch=i386', 'arch=x86_64', 'arch=arm', or 'arch=arm64' with 'platform=ios'")
endif
endif
ifeq ($(bootimage-test),true)
ifneq ($(bootimage),true)
x := $(error "bootimage-test=true only works when bootimage=true")
endif
endif
aot-only = false
root := $(shell (cd .. && pwd))
build = build/$(platform)-$(arch)$(options)
host-build-root = $(build)/host
classpath-build = $(build)/classpath
test-build = $(build)/test
src = src
classpath-src = classpath
test = test
unittest = unittest
win32 ?= $(root)/win32
win64 ?= $(root)/win64
winrt ?= $(root)/winrt
wp8 ?= $(root)/wp8
classpath = avian
bootimage-classpath = $(classpath-build)
ifeq ($(bootimage-test),true)
bootimage-classpath = $(classpath-build):$(test-build)
endif
test-executable = $(shell pwd)/$(executable)
boot-classpath = $(classpath-build)
embed-prefix = /avian-embedded
native-path = echo
platform-kernel = $(subst macosx,darwin,$(subst ios,darwin,$1))
build-kernel = $(call platform-kernel,$(build-platform))
kernel = $(call platform-kernel,$(platform))
ifeq ($(build-platform),cygwin)
native-path = cygpath -m
endif
windows-path = echo
path-separator = :
ifneq (,$(filter mingw32 cygwin,$(build-platform)))
path-separator = ;
endif
target-path-separator = :
ifeq ($(platform),windows)
target-path-separator = ;
endif
library-path-variable = LD_LIBRARY_PATH
ifeq ($(build-kernel),darwin)
library-path-variable = DYLD_LIBRARY_PATH
endif
library-path = $(library-path-variable)=$(build)
ifneq ($(openjdk),)
openjdk-arch = $(arch)
ifeq ($(arch),x86_64)
openjdk-arch = amd64
endif
ifneq ($(android),)
x := $(error "android and openjdk are incompatible")
endif
ifneq ($(openjdk-src),)
include openjdk-src.mk
options := $(options)-openjdk-src
classpath-objects = $(openjdk-objects) $(openjdk-local-objects)
classpath-cflags = -DAVIAN_OPENJDK_SRC -DBOOT_JAVAHOME
openjdk-jar-dep = $(build)/openjdk-jar.dep
classpath-jar-dep = $(openjdk-jar-dep)
javahome = $(embed-prefix)/javahomeJar
javahome-files = lib/currency.data lib/security/java.security \
lib/security/java.policy lib/security/cacerts
ifneq (,$(wildcard $(openjdk)/jre/lib/zi))
javahome-files += lib/zi
endif
ifneq (,$(wildcard $(openjdk)/jre/lib/tzdb.dat))
javahome-files += lib/tzdb.dat
endif
local-policy = lib/security/local_policy.jar
ifneq (,$(wildcard $(openjdk)/jre/$(local-policy)))
javahome-files += $(local-policy)
endif
export-policy = lib/security/US_export_policy.jar
ifneq (,$(wildcard $(openjdk)/jre/$(export-policy)))
javahome-files += $(export-policy)
endif
ifeq ($(platform),windows)
javahome-files += lib/tzmappings
endif
javahome-object = $(build)/javahome-jar.o
boot-javahome-object = $(build)/boot-javahome.o
stub-sources = $(src)/openjdk/stubs.cpp
stub-objects = $(call cpp-objects,$(stub-sources),$(src),$(build))
else
soname-flag = -Wl,-soname -Wl,$(so-prefix)jvm$(so-suffix)
version-script-flag = -Wl,--version-script=openjdk.ld
options := $(options)-openjdk
test-executable = $(shell pwd)/$(executable-dynamic)
ifeq ($(build-kernel),darwin)
library-path = \
$(library-path-variable)=$(build):$(openjdk)/jre/lib
else
library-path = \
$(library-path-variable)=$(build):$(openjdk)/jre/lib/$(openjdk-arch)
endif
javahome = "$$($(native-path) "$(openjdk)/jre")"
endif
classpath = openjdk
boot-classpath := "$(boot-classpath)$(path-separator)$$($(native-path) "$(openjdk)/jre/lib/rt.jar")"
build-javahome = $(openjdk)/jre
endif
ifneq ($(android),)
options := $(options)-android
classpath-jar-dep = $(build)/android.dep
luni-native = $(android)/libcore/luni/src/main/native
classpath-cflags = -DBOOT_JAVAHOME
android-cflags = -I$(luni-native) \
-I$(android)/libnativehelper/include/nativehelper \
-I$(android)/libnativehelper \
-I$(android)/system/core/include \
-I$(android)/external/zlib \
-I$(android)/external/icu4c/i18n \
-I$(android)/external/icu4c/common \
-I$(android)/external/expat \
-I$(android)/external/openssl/include \
-I$(android)/external/openssl \
-I$(android)/libcore/include \
-I$(build)/android-src/external/fdlibm \
-I$(build)/android-src \
-fno-exceptions \
-D_FILE_OFFSET_BITS=64 \
-DOS_SHARED_LIB_FORMAT_STR="\"$(so-prefix)%s$(so-suffix)\"" \
-DJNI_JARJAR_PREFIX= \
-D__DARWIN_UNIX03=1 \
-D__PROVIDE_FIXMES \
-DSTATIC_LIB \
-D__STDC_FORMAT_MACROS=1 \
-g3 \
-Wno-shift-count-overflow
# on Windows (in MinGW-based build) there are neither __BEGIN_DECLS nor __END_DECLS
# defines; we don't want to patch every file that uses them, so we stub them in
# using CFLAGS mechanism
# Also we have off64_t defined in mingw-w64 headers, so let's tell that
ifeq ($(platform),windows)
android-cflags += "-D__BEGIN_DECLS=extern \"C\" {" "-D__END_DECLS=}" "-DHAVE_OFF64_T"
endif
luni-cpps := $(shell find $(luni-native) -name '*.cpp')
libziparchive-native := $(android)/system/core/libziparchive
libziparchive-ccs := $(libziparchive-native)/zip_archive.cc
libutils-native := $(android)/system/core/libutils
libutils-cpps := $(libutils-native)/FileMap.cpp
libnativehelper-native := $(android)/libnativehelper
libnativehelper-cpps := $(libnativehelper-native)/JniConstants.cpp \
$(libnativehelper-native)/toStringArray.cpp
crypto-native := $(android)/external/conscrypt/src/main/native
crypto-cpps := $(crypto-native)/org_conscrypt_NativeCrypto.cpp
ifeq ($(platform),windows)
android-cflags += -D__STDC_CONSTANT_MACROS -DHAVE_WIN32_FILEMAP -D__STDC_FORMAT_MACROS
blacklist = $(luni-native)/java_io_Console.cpp \
$(luni-native)/java_lang_ProcessManager.cpp
icu-libs := $(android)/external/icu4c/lib/libsicuin.a \
$(android)/external/icu4c/lib/libsicuuc.a \
$(android)/external/icu4c/lib/sicudt.a
platform-lflags := -lgdi32 -lshlwapi -lwsock32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
else
android-cflags += -fPIC -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP
blacklist =
icu-libs := $(android)/external/icu4c/lib/libicui18n.a \
$(android)/external/icu4c/lib/libicuuc.a \
$(android)/external/icu4c/lib/libicudata.a
endif
luni-cpps := $(filter-out $(blacklist),$(luni-cpps))
classpath-lflags := \
$(icu-libs) \
$(android)/external/fdlibm/libfdm.a \
$(android)/external/expat/.libs/libexpat.a \
$(android)/openssl-upstream/libssl.a \
$(android)/openssl-upstream/libcrypto.a \
$(platform-lflags) \
-lstdc++
ifeq ($(platform),linux)
android-cflags += -DHAVE_OFF64_T
classpath-lflags += -lrt
endif
classpath-objects = \
$(call cpp-objects,$(luni-cpps),$(luni-native),$(build)) \
$(call cpp-objects,$(crypto-cpps),$(crypto-native),$(build)) \
$(call cpp-objects,$(libnativehelper-cpps),$(libnativehelper-native),$(build)) \
$(call cc-objects,$(libziparchive-ccs),$(libziparchive-native),$(build)) \
$(call cpp-objects,$(libutils-cpps),$(libutils-native),$(build))
luni-java = $(android)/libcore/luni/src/main/java
luni-blacklist = \
$(luni-java)/libcore/reflect/AnnotationAccess.java
luni-javas := \
$(filter-out $(luni-blacklist),$(shell find $(luni-java) -name '*.java'))
luni-nonjavas := $(shell find $(luni-java) -not -type d -not -name '*.java')
luni-copied-nonjavas = $(call noop-files,$(luni-nonjavas),$(luni-java),)
crypto-java = $(android)/external/conscrypt/src/main/java
crypto-javas := $(shell find $(crypto-java) -name '*.java')
crypto-platform-java = $(android)/external/conscrypt/src/platform/java
crypto-platform-javas := $(shell find $(crypto-platform-java) -name '*.java')
dalvik-java = $(android)/libcore/dalvik/src/main/java
dalvik-javas := \
$(dalvik-java)/dalvik/system/DalvikLogHandler.java \
$(dalvik-java)/dalvik/system/CloseGuard.java \
$(dalvik-java)/dalvik/system/VMDebug.java \
$(dalvik-java)/dalvik/system/BlockGuard.java \
$(dalvik-java)/dalvik/system/SocketTagger.java \
$(dalvik-java)/dalvik/system/DalvikLogging.java \
libart-java = $(android)/libcore/libart/src/main/java
libart-javas := \
$(libart-java)/dalvik/system/VMRuntime.java \
$(libart-java)/dalvik/system/VMStack.java \
$(libart-java)/java/lang/Thread.java \
$(libart-java)/java/lang/ThreadGroup.java \
$(libart-java)/java/lang/Enum.java \
$(libart-java)/java/lang/String.java \
$(libart-java)/java/lang/ref/Reference.java \
$(libart-java)/java/lang/reflect/AccessibleObject.java \
xml-java = $(android)/libcore/xml/src/main/java
xml-javas := $(shell find $(xml-java) -name '*.java')
okhttp-android-java = $(android)/external/okhttp/android/main/java
okhttp-android-javas := $(shell find $(okhttp-android-java) -name '*.java')
okhttp-java = $(android)/external/okhttp/okhttp/src/main/java
okhttp-javas := $(shell find $(okhttp-java) -name '*.java')
okio-java = $(android)/external/okhttp/okio/src/main/java
okio-javas := $(shell find $(okio-java) -name '*.java')
bcpkix-java = $(android)/external/bouncycastle/bcpkix/src/main/java
bcpkix-javas := $(shell find $(bcpkix-java) -name '*.java')
bcprov-java = $(android)/external/bouncycastle/bcprov/src/main/java
bcprov-javas := $(shell find $(bcprov-java) -name '*.java')
android-classes = \
$(call java-classes,$(luni-javas),$(luni-java),$(build)/android) \
$(call java-classes,$(crypto-javas),$(crypto-java),$(build)/android) \
$(call java-classes,$(crypto-platform-javas),$(crypto-platform-java),$(build)/android) \
$(call java-classes,$(dalvik-javas),$(dalvik-java),$(build)/android) \
$(call java-classes,$(libart-javas),$(libart-java),$(build)/android) \
$(call java-classes,$(xml-javas),$(xml-java),$(build)/android) \
$(call java-classes,$(okhttp-javas),$(okhttp-java),$(build)/android) \
$(call java-classes,$(okhttp-android-javas),$(okhttp-android-java),$(build)/android) \
$(call java-classes,$(okio-javas),$(okio-java),$(build)/android) \
$(call java-classes,$(bcpkix-javas),$(bcpkix-java),$(build)/android) \
$(call java-classes,$(bcprov-javas),$(bcprov-java),$(build)/android)
classpath = android
javahome-files = tzdata
javahome-object = $(build)/javahome-jar.o
boot-javahome-object = $(build)/boot-javahome.o
build-javahome = $(android)/bionic/libc/zoneinfo
stub-sources = $(src)/android/stubs.cpp
stub-objects = $(call cpp-objects,$(stub-sources),$(src),$(build))
endif
ifeq ($(classpath),avian)
jni-sources := $(shell find $(classpath-src) -name '*.cpp')
jni-objects = $(call cpp-objects,$(jni-sources),$(classpath-src),$(build))
classpath-objects = $(jni-objects)
endif
input = List
ifeq ($(use-clang),true)
build-cxx = clang++ -std=c++11
build-cc = clang
else
build-cxx = g++
build-cc = gcc
endif
mflag =
ifneq ($(kernel),darwin)
ifeq ($(arch),i386)
mflag = -m32
endif
ifeq ($(arch),x86_64)
mflag = -m64
endif
endif
target-format = elf
cxx = $(build-cxx) $(mflag)
cc = $(build-cc) $(mflag)
ar = ar
ranlib = ranlib
dlltool = dlltool
vg = nice valgrind --num-callers=32 --db-attach=yes --freelist-vol=100000000
vg += --leak-check=full --suppressions=valgrind.supp
db = gdb --args
javac = "$(JAVA_HOME)/bin/javac" -encoding UTF-8
javah = "$(JAVA_HOME)/bin/javah"
jar = "$(JAVA_HOME)/bin/jar"
strip = strip
strip-all = --strip-all
rdynamic = -rdynamic
cflags_debug = -O0 -g3
cflags_debug_fast = -O0 -g3
cflags_stress = -O0 -g3
cflags_stress_major = -O0 -g3
ifeq ($(use-clang),true)
cflags_fast = -O3 -g3
cflags_small = -Oz -g3
else
cflags_fast = -O3 -g3
cflags_small = -Os -g3
endif
# note that we suppress the non-virtual-dtor warning because we never
# use the delete operator, which means we don't need virtual
# destructors:
warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
-Wno-non-virtual-dtor
target-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
common-cflags = $(warnings) -std=c++0x -fno-rtti -fno-exceptions -I$(classpath-src) \
"-I$(JAVA_HOME)/include" -I$(src) -I$(build) -Iinclude $(classpath-cflags) \
-D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
-DAVIAN_INFO="\"$(info)\"" \
-DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
-DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" $(target-cflags)
asmflags = $(target-cflags) -I$(src)
ifneq (,$(filter i386 x86_64,$(arch)))
ifeq ($(use-frame-pointer),true)
common-cflags += -fno-omit-frame-pointer -DAVIAN_USE_FRAME_POINTER
asmflags += -DAVIAN_USE_FRAME_POINTER
endif
endif
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
"-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
converter-cflags = -D__STDC_CONSTANT_MACROS -std=c++0x -Iinclude/ -Isrc/ \
-fno-rtti -fno-exceptions \
-DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \
-DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \
-Wall -Wextra -Werror -Wunused-parameter -Winit-self -Wno-non-virtual-dtor
cflags = $(build-cflags)
common-lflags = -lm -lz
ifeq ($(use-clang),true)
ifeq ($(build-kernel),darwin)
common-lflags += -Wl,-export_dynamic
else
ifneq ($(platform),windows)
common-lflags += -Wl,-E
else
common-lflags += -Wl,--export-all-symbols
endif
endif
endif
build-lflags = -lz -lpthread -ldl
lflags = $(common-lflags) -lpthread -ldl
build-system = posix
system = posix
asm = x86
pointer-size = 8
so-prefix = lib
so-suffix = .so
static-prefix = lib
static-suffix = .a
output = -o $(1)
asm-output = -o $(1)
asm-input = -c $(1)
asm-format = S
as = $(cc)
ld = $(cc)
build-ld = $(build-cc)
build-ld-cpp = $(build-cxx)
default-remote-test-host = localhost
default-remote-test-port = 22
ifeq ($(remote-test-host),)
remote-test-host = $(default-remote-test-host)
else
remote-test = true
endif
ifeq ($(remote-test-port),)
remote-test-port = $(default-remote-test-port)
else
remote-test = true
endif
remote-test-user = ${USER}
remote-test-dir = /tmp/avian-test-${USER}
static = -static
shared = -shared
rpath = -Wl,-rpath=\$$ORIGIN -Wl,-z,origin
openjdk-extra-cflags = -fvisibility=hidden
bootimage-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
bootimage-symbols = _binary_bootimage_bin_start:_binary_bootimage_bin_end
codeimage-symbols = _binary_codeimage_bin_start:_binary_codeimage_bin_end
developer-dir := $(shell if test -d /Developer/Platforms/$(target).platform/Developer/SDKs; then echo /Developer; \
else echo /Applications/Xcode.app/Contents/Developer; fi)
ifneq (,$(filter i386 arm,$(arch)))
pointer-size = 4
endif
ifneq (,$(filter arm arm64,$(arch)))
asm = arm
ifneq ($(platform),ios)
ifneq ($(arch),arm64)
no-psabi = -Wno-psabi
cflags += -marm $(no-psabi)
# By default, assume we can't use armv7-specific instructions on
# non-iOS platforms. Ideally, we'd detect this at runtime.
armv6=true
endif
endif
ifneq ($(arch),$(build-arch))
ifneq ($(kernel),darwin)
ifeq ($(arch),arm64)
cxx = aarch64-linux-gnu-g++
cc = aarch64-linux-gnu-gcc
ar = aarch64-linux-gnu-ar
ranlib = aarch64-linux-gnu-ranlib
strip = aarch64-linux-gnu-strip
else
cxx = arm-linux-gnueabi-g++
cc = arm-linux-gnueabi-gcc
ar = arm-linux-gnueabi-ar
ranlib = arm-linux-gnueabi-ranlib
strip = arm-linux-gnueabi-strip
endif
endif
endif
endif
ifeq ($(armv6),true)
cflags += -DAVIAN_ASSUME_ARMV6
endif
ifeq ($(platform),ios)
cflags += -DAVIAN_IOS
use-lto = false
endif
ifeq ($(build-kernel),darwin)
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
cflags += -Wno-deprecated-declarations
build-lflags += -framework CoreFoundation
endif
ifeq ($(platform),qnx)
cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
lflags = $(common-lflags) -lsocket
ifeq ($(build-platform),qnx)
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
build-lflags = $(common-lflags)
else
ifeq ($(arch),i386)
prefix = i486-pc-nto-qnx6.5.0-
else
prefix = arm-unknown-nto-qnx6.5.0-
endif
endif
cxx = $(prefix)g++
cc = $(prefix)gcc
ar = $(prefix)ar
ranlib = $(prefix)ranlib
strip = $(prefix)strip
rdynamic = -Wl,--export-dynamic
endif
ifeq ($(platform),freebsd)
# There is no -ldl on FreeBSD
build-lflags = $(common-lflags) -lz -lpthread
lflags = $(common-lflags) -lpthread
# include/freebsd instead of include/linux
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
"-I$(JAVA_HOME)/include/freebsd" -I$(src) -pthread
cflags = $(build-cflags)
endif
ifeq ($(platform),android)
ifeq ($(build-platform),cygwin)
ndk = "$$(cygpath -u "$(ANDROID_NDK)")"
else
ndk = $(ANDROID_NDK)
endif
ifeq ($(android-version),)
android-version = 5
endif
ifeq ($(android-toolchain),)
android-toolchain = 4.7
endif
ifeq ($(arch),arm)
android-toolchain-name = arm-linux-androideabi
android-toolchain-prefix = arm-linux-androideabi-
endif
ifeq ($(arch),i386)
android-toolchain-name = x86
android-toolchain-prefix = i686-linux-android-
endif
ifeq ($(android-arm-arch),)
android-arm-arch = armv5
endif
options := $(options)-api$(android-version)-$(android-toolchain)-$(android-arm-arch)
build-cflags = $(common-cflags) -I$(src)
build-lflags = -lz -lpthread
ifeq ($(subst cygwin,windows,$(subst mingw32,windows,$(build-platform))),windows)
toolchain-host-platform = $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
build-system = windows
build-cxx = i686-w64-mingw32-g++
build-cc = i686-w64-mingw32-gcc
sysroot = "$$(cygpath -w "$(ndk)/platforms/android-$(android-version)/arch-arm")"
build-cflags += "-I$(JAVA_HOME)/include/win32"
else
toolchain-host-platform = $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))-*
sysroot = $(ndk)/platforms/android-$(android-version)/arch-arm
build-cflags += "-I$(JAVA_HOME)/include/linux"
build-lflags += -ldl
endif
toolchain = $(ndk)/toolchains/$(android-toolchain-name)-$(android-toolchain)/prebuilt/$(toolchain-host-platform)
cflags = "-I$(sysroot)/usr/include" "-I$(JAVA_HOME)/include/linux" $(common-cflags) "-I$(src)" -std=c++11 $(no-psabi)
lflags = "-L$(sysroot)/usr/lib" $(common-lflags) -llog
target-format = elf
use-lto = false
ifeq ($(arch),arm)
cflags += -marm -march=$(android-arm-arch) -ftree-vectorize -ffast-math -mfloat-abi=softfp
endif
ifeq ($(arch),i386)
endif
cxx = $(toolchain)/bin/$(android-toolchain-prefix)g++ --sysroot="$(sysroot)"
cc = $(toolchain)/bin/$(android-toolchain-prefix)gcc --sysroot="$(sysroot)"
as = $(cxx)
ar = $(toolchain)/bin/$(android-toolchain-prefix)ar
ranlib = $(toolchain)/bin/$(android-toolchain-prefix)ranlib
strip = $(toolchain)/bin/$(android-toolchain-prefix)strip
endif
ifeq ($(kernel),darwin)
target-format = macho
ifeq (${OSX_SDK_SYSROOT},)
OSX_SDK_SYSROOT = 10.6u
endif
ifeq (${OSX_SDK_VERSION},)
OSX_SDK_VERSION = 10.6
endif
ifneq ($(build-kernel),darwin)
cxx = i686-apple-darwin8-g++ $(mflag)
cc = i686-apple-darwin8-gcc $(mflag)
ar = i686-apple-darwin8-ar
ranlib = i686-apple-darwin8-ranlib
strip = i686-apple-darwin8-strip
sysroot = /opt/mac/SDKs/MacOSX${OSX_SDK_SYSROOT}.sdk
cflags = -I$(sysroot)/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/ \
$(common-cflags) -fPIC -fvisibility=hidden -I$(src)
endif
ifneq ($(platform),ios)
platform-dir = $(developer-dir)/Platforms/MacOSX.platform
sdk-dir = $(platform-dir)/Developer/SDKs
mac-version := $(shell \
if test -d $(sdk-dir)/MacOSX10.9.sdk; then echo 10.9; \
elif test -d $(sdk-dir)/MacOSX10.8.sdk; then echo 10.8; \
elif test -d $(sdk-dir)/MacOSX10.7.sdk; then echo 10.7; \
elif test -d $(sdk-dir)/MacOSX10.6.sdk; then echo 10.6; \
else echo; fi)
sysroot = $(sdk-dir)/MacOSX$(mac-version).sdk
endif
soname-flag =
version-script-flag =
lflags = $(common-lflags) -ldl -framework CoreFoundation -framework Foundation
ifeq (,$(shell ld -v 2>&1 | grep cctools))
lflags += -Wl,-compatibility_version,1.0.0
endif
ifneq ($(platform),ios)
lflags += -framework CoreServices -framework SystemConfiguration \
-framework Security
endif
ifeq ($(bootimage),true)
bootimage-lflags = -Wl,-segprot,__RWX,rwx,rwx
endif
rdynamic =
strip-all = -S -x
so-suffix = .dylib
shared = -dynamiclib
rpath =
ifeq ($(platform),ios)
ifeq ($(sim),true)
target = iPhoneSimulator
sdk = iphonesimulator$(ios-version)
ifeq ($(arch),i386)
arch-flag = -arch i386
else
arch-flag = -arch x86_64
arch = x86_64
endif
release = Release-iphonesimulator
else
target = iPhoneOS
sdk = iphoneos$(ios-version)
ifeq ($(arch),arm)
arch-flag = -arch armv7
else
arch-flag = -arch arm64
arch = arm64
endif
release = Release-iphoneos
endif
platform-dir = $(developer-dir)/Platforms/$(target).platform
sdk-dir = $(platform-dir)/Developer/SDKs
ios-version := $(shell \
if test -L $(sdk-dir)/$(target)9.1.sdk; then echo 9.1; \
elif test -L $(sdk-dir)/$(target)9.0.sdk; then echo 9.0; \
elif test -d $(sdk-dir)/$(target)8.3.sdk; then echo 8.3; \
elif test -d $(sdk-dir)/$(target)8.2.sdk; then echo 8.2; \
elif test -d $(sdk-dir)/$(target)8.1.sdk; then echo 8.1; \
elif test -d $(sdk-dir)/$(target)8.0.sdk; then echo 8.0; \
elif test -d $(sdk-dir)/$(target)7.1.sdk; then echo 7.1; \
elif test -d $(sdk-dir)/$(target)7.0.sdk; then echo 7.0; \
elif test -d $(sdk-dir)/$(target)6.1.sdk; then echo 6.1; \
elif test -d $(sdk-dir)/$(target)6.0.sdk; then echo 6.0; \
elif test -d $(sdk-dir)/$(target)5.1.sdk; then echo 5.1; \
elif test -d $(sdk-dir)/$(target)5.0.sdk; then echo 5.0; \
elif test -d $(sdk-dir)/$(target)4.3.sdk; then echo 4.3; \
elif test -d $(sdk-dir)/$(target)4.2.sdk; then echo 4.2; \
else echo; fi)
ifeq ($(ios-version),)
x := $(error "couldn't find SDK")
endif
ios-bin = $(platform-dir)/Developer/usr/bin
found-gcc = $(shell if test -f $(ios-bin)/gcc; then echo true; else echo false; fi)
ifeq ($(found-gcc),false)
use-clang = true
endif
ifeq ($(use-clang),true)
cxx = clang -std=c++11
cc = clang
else
cxx = $(ios-bin)/g++
cc = $(ios-bin)/gcc
endif
flags = -isysroot $(sdk-dir)/$(target)$(ios-version).sdk \
$(arch-flag)
classpath-extra-cflags += $(flags)
cflags += $(flags)
asmflags += $(flags)
lflags += $(flags)
ios-version-min=$(ios-version)
ifdef ios_deployment_target
ios-version-min=ios_deployment_target
endif
ifeq ($(sim),true)
ifeq ($(arch),x86_64)
classpath-extra-cflags += \
-arch x86_64 -miphoneos-version-min=$(ios-version-min)
cflags += -arch x86_64 -miphoneos-version-min=$(ios-version-min)
asmflags += -arch x86_64 -miphoneos-version-min=$(ios-version-min)
lflags += -arch x86_64 -miphoneos-version-min=$(ios-version-min)
else
classpath-extra-cflags += \
-arch i386 -miphoneos-version-min=$(ios-version-min)
cflags += -arch i386 -miphoneos-version-min=$(ios-version-min)
asmflags += -arch i386 -miphoneos-version-min=$(ios-version-min)
lflags += -arch i386 -miphoneos-version-min=$(ios-version-min)
endif
else
ifeq ($(arch),arm64)
classpath-extra-cflags += \
-arch arm64 -miphoneos-version-min=$(ios-version-min)
cflags += -arch arm64 -miphoneos-version-min=$(ios-version-min)
asmflags += -arch arm64 -miphoneos-version-min=$(ios-version-min)
lflags += -arch arm64 -miphoneos-version-min=$(ios-version-min)
else
classpath-extra-cflags += \
-arch armv7 -miphoneos-version-min=$(ios-version-min)
cflags += -arch armv7 -miphoneos-version-min=$(ios-version-min)
asmflags += -arch armv7 -miphoneos-version-min=$(ios-version-min)
lflags += -arch armv7 -miphoneos-version-min=$(ios-version-min)
endif
endif
else # not ios
ifeq ($(arch),i386)
classpath-extra-cflags += \
-arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
endif
ifeq ($(arch),x86_64)
classpath-extra-cflags += -arch x86_64
cflags += -arch x86_64
asmflags += -arch x86_64
lflags += -arch x86_64
endif
endif
cflags += -I$(JAVA_HOME)/include/darwin
endif
openjdk-extra-cflags += $(classpath-extra-cflags)
find-tool = $(shell if ( command -v "$(1)$(2)" >/dev/null ); then (echo "$(1)$(2)") else (echo "$(2)"); fi)
ifeq ($(platform),windows)
target-format = pe
inc = "$(win32)/include"
lib = "$(win32)/lib"
embed-prefix = c:/avian-embedded
system = windows
so-prefix =
so-suffix = .dll
exe-suffix = .exe
rpath =
lflags = -L$(lib) $(common-lflags) -lws2_32 -liphlpapi -mconsole
cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500 -U__STRICT_ANSI__
ifeq (,$(filter mingw32 cygwin,$(build-platform)))
openjdk-extra-cflags += -I$(src)/openjdk/caseSensitive
prefix := $(shell i686-w64-mingw32-gcc --version >/dev/null 2>&1 \
&& echo i686-w64-mingw32- || echo x86_64-w64-mingw32-)
cxx = $(prefix)g++ -m32
cc = $(prefix)gcc -m32
dlltool = $(prefix)dlltool -mi386 --as-flags=--32
ar = $(prefix)ar
ranlib = $(prefix)ranlib
strip = $(prefix)strip --strip-all
else
build-system = windows
static-on-windows = -static
common-cflags += "-I$(JAVA_HOME)/include/win32"
build-cflags = $(common-cflags) -I$(src) -I$(inc) -mthreads \
-D_WIN32_WINNT=0x0500
openjdk-extra-cflags =
build-lflags = -L$(lib) $(common-lflags)
ifeq ($(build-platform),cygwin)
build-cxx = i686-w64-mingw32-g++
build-cc = i686-w64-mingw32-gcc
dlltool = i686-w64-mingw32-dlltool
ar = i686-w64-mingw32-ar
ranlib = i686-w64-mingw32-ranlib
strip = i686-w64-mingw32-strip
endif
endif
ifeq ($(arch),x86_64)
ifeq ($(build-platform),cygwin)
build-cxx = x86_64-w64-mingw32-g++
build-cc = x86_64-w64-mingw32-gcc
endif
cxx = x86_64-w64-mingw32-g++ $(mflag)
cc = x86_64-w64-mingw32-gcc $(mflag)
dlltool = $(call find-tool,x86_64-w64-mingw32-,dlltool)
ar = $(call find-tool,x86_64-w64-mingw32-,ar)
ranlib = $(call find-tool,x86_64-w64-mingw32-,ranlib)
strip = $(call find-tool,x86_64-w64-mingw32-,strip)
inc = "$(win64)/include"
lib = "$(win64)/lib"
else
shared += -Wl,--add-stdcall-alias
endif
embed = $(build-embed)/embed$(exe-suffix)
embed-loader = $(build-embed-loader)/embed-loader$(exe-suffix)
embed-loader-o = $(build-embed)/embed-loader.o
endif
ifeq ($(platform),wp8)
ifeq ($(shell uname -s | grep -i -c WOW64),1)
programFiles = Program Files (x86)
else
programFiles = Program Files
endif
ifeq ($(MSVS_ROOT),)
# Environment variable MSVS_ROOT not found. It should be something like
# "C:\$(programFiles)\Microsoft Visual Studio 11.0"
MSVS_ROOT = C:\$(programFiles)\Microsoft Visual Studio 11.0
endif
ifeq ($(MSVC_ROOT),)
# Environment variable MSVC_ROOT not found. It should be something like
# "C:\$(programFiles)\Microsoft Visual Studio 11.0\VC"
MSVC_ROOT = $(MSVS_ROOT)\VC
endif
ifeq ($(WP80_SDK),)
# Environment variable WP8_SDK not found. It should be something like
# "C:\Program Files[ (x86)]\Microsoft Visual Studio 11.0\VC\WPSDK\WP80"
# TODO: Lookup in SOFTWARE\Microsoft\Microsoft SDKs\WindowsPhone\v8.0
WP80_SDK = $(MSVS_ROOT)\VC\WPSDK\WP80
endif
ifeq ($(WP80_KIT),)
# Environment variable WP8_KIT not found. It should be something like
# "c:\Program Files[ (x86)]\Windows Phone Kits\8.0"
# TODO: Lookup in SOFTWARE\Microsoft\Microsoft SDKs\WindowsPhone\v8.0
WP80_KIT = C:\$(programFiles)\Windows Phone Kits\8.0
endif
ifeq ($(WIN8_KIT),)
# Environment variable WIN8_KIT not found. It should be something like
# "c:\Program Files[ (x86)]\Windows Kits\8.0"
WIN8_KIT = C:\$(programFiles)\Windows Kits\8.0
endif
ifeq ($(build-platform),cygwin)
windows-path = cygpath -w
else
windows-path = $(native-path)
endif
windows-java-home := $(shell $(windows-path) "$(JAVA_HOME)")
target-format = pe
ms_cl_compiler = wp8