-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.in
More file actions
961 lines (859 loc) · 32.4 KB
/
Makefile.in
File metadata and controls
961 lines (859 loc) · 32.4 KB
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
# -------------------------------
# Standard Autoconf-set variables
# -------------------------------
VPATH=@srcdir@
build_alias=@build_alias@
build_vendor=@build_vendor@
build_os=@build_os@
build=@build@
host_alias=@host_alias@
host_vendor=@host_vendor@
host_os=@host_os@
host=@host@
target_alias=@target_alias@
target_vendor=@target_vendor@
target_os=@target_os@
target_cpu=@target_cpu@
target=@target@
# Turn arm-unknown-linux-androideabi into the actually used arm-linux-androideabi
target_no_unknown=$(subst -unknown-,-,@target@)
program_transform_name = @program_transform_name@
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
abs_srcdir = @abs_srcdir@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
includedir = @includedir@
oldincludedir = @oldincludedir@
infodir = @infodir@
datarootdir = @datarootdir@
docdir = @docdir@
pdfdir = @pdfdir@
htmldir = @htmldir@
mandir = @mandir@
builddir = @builddir@
abs_builddir = @abs_builddir@
#
# miscellaneous variables
#
INSTALL:=@INSTALL@
INSTALL_DATA:=@INSTALL_DATA@
TOPLEVEL_CONFIGURE_ARGUMENTS:=@TOPLEVEL_CONFIGURE_ARGUMENTS@
baseargs = @baseargs@
GCC_MIN_VERSION_4_8_0:=@GCC_MIN_VERSION_4_8_0@
CLOOG_BACKEND:=@CLOOG_BACKEND@
ENABLE_GRAPHITE:=@ENABLE_GRAPHITE@
PACKAGE_TO_SRCDIR:=@package_to_srcdir@
BUILD_ANDROID_GCC:=@BUILD_ANDROID_GCC@
GDB_TARGET:=@GDB_TARGET@
# We need to figure out how to get to top level source directory from
# a package build directory.
# For host modules, accept cache file option, or specification as blank.
BINUTILS_VERSION=binutils-@BINUTILS_VERSION@
GOLD_VERSION=binutils-@GOLD_VERSION@
GCC_VERSION=gcc-@GCC_VERSION@
NEWLIB_VERSION=newlib-@NEWLIB_VERSION@
GMP_VERSION=gmp-@GMP_VERSION@
MPFR_VERSION=mpfr-@MPFR_VERSION@
MPC_VERSION=mpc-@MPC_VERSION@
PPL_VERSION=ppl-@PPL_VERSION@
CLOOG_VERSION=cloog-@CLOOG_VERSION@
ISL_VERSION=isl-@ISL_VERSION@
GDB_VERSION=gdb-@GDB_VERSION@
HAVE_MPC=@have_mpc@
HAVE_MPFR=@have_mpfr@
HAVE_GMP=@have_gmp@
HAVE_PPL=@have_ppl@
HAVE_CLOOG=@have_cloog@
HAVE_ISL=@have_isl@
STAMP=touch
TARGET_BINUTILS_BUILDDIR=$(abs_builddir)/$(BINUTILS_VERSION)
TARGET_GCC_BUILDDIR=$(abs_builddir)/$(GCC_VERSION)
TEMP_INSTALLDIR=$(abs_builddir)/temp-install
ifeq ($(HAVE_MPC),no)
MPC_DIR=$(TEMP_INSTALLDIR)
endif
ifeq ($(HAVE_MPFR),no)
MPFR_DIR=$(TEMP_INSTALLDIR)
endif
ifeq ($(HAVE_GMP),no)
GMP_DIR=$(TEMP_INSTALLDIR)
endif
ifeq ($(HAVE_PPL),no)
PPL_DIR=$(TEMP_INSTALLDIR)
endif
ifeq ($(HAVE_CLOOG),no)
CLOOG_DIR=$(TEMP_INSTALLDIR)
endif
ifeq ($(HAVE_ISL),no)
ISL_DIR=$(TEMP_INSTALLDIR)
endif
ifeq ($(BINUTILS_VERSION),binutils-2.20.1)
# gold 2.20.1 is too broken to link gcc 4.6's libgomp
FIND_TARGET_LD=ld
else
ifeq ($(BINUTILS_VERSION),binutils-20100303)
FIND_TARGET_LD=ld
else
# Figure out where to find the ld binary.
FIND_TARGET_LD=\
`[ -d $(TARGET_BINUTILS_BUILDDIR)/gold ] && echo "gold" || echo "ld"`
endif
endif
# We export these insteading when configuring target gcc and newlib
TARGET_BINUTILS_EXPORTS= \
export AS_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/gas/as-new \
LD_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/$(FIND_TARGET_LD)/ld-new \
AR_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ar \
NM_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/nm-new \
STRIP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/strip-new \
RANLIB_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ranlib \
OBJDUMP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/objdump
TARGET_MINIMAL_GCC_EXPORTS= \
export CC_FOR_TARGET="$(TARGET_GCC_BUILDDIR)/gcc/xgcc \
-B $(TARGET_GCC_BUILDDIR)/gcc \
-isystem $(TARGET_GCC_BUILDDIR)/gcc/include-fixed \
-isystem $(TARGET_GCC_BUILDDIR)/gcc/include"
#
# We need -Os as the overrides below interfere with --enable-target-optspace.
# We also need -mandroid for for target libraries to pass linking test
# in configuration.
#
# To build libstdc++ with RTTI and exceptions do:
#
#export CFLAGS_FOR_TARGET=-fexceptions
#export CXXFLAGS_FOR_TARGET=-frtti
#
CFLAGS_FOR_TARGET+= -O2 -Os -g
CXXFLAGS_FOR_TARGET+=$(CFLAGS_FOR_TARGET)
LDFLAGS_FOR_TARGET=
# Helper
prefix-list = $(foreach e, $(2), $(join $1, $e))
# find source directory for package. This can either be <srcdir>/<package>
# or <objdir>/temp-src/<package>
find-package-srcdir = $(shell \
if [ -f $(srcdir)/../$(firstword $(subst -, ,$1))/$(strip $1)/configure ]; then \
echo $(PACKAGE_TO_SRCDIR)/../$(firstword $(subst -, ,$1))/$(strip $1); \
elif [ -f $(abs_builddir)/temp-src/$(strip $1)/configure ]; then \
echo $(abs_builddir)/temp-src/$(strip $1) ; \
else \
echo 'error cannot find $(strip $1)' ; \
fi)
# Set effective <build>, <host> and <target>.
ifneq ($(build_alias),)
cur_build := $(build_alias)
else
cur_build := $(build)
endif
ifneq ($(host_alias),)
cur_host := $(host_alias)
else
cur_host := $(host)
endif
ifneq ($(target_alias),)
cur_target := $(target_alias)
else
cur_target := $(target)
endif
# Define environment variables for canadian cross build.
ifneq ($(cur_host),$(cur_build))
canadian_build_env := \
export CC_FOR_BUILD=$(cur_build)-gcc ; \
export CC=$(cur_build)-gcc ; \
export CXX=$(cur_build)-g++ ;
CANADIAN_ROOT := $(PWD)/host-${cur_build}
canadian_env := \
export CC_FOR_BUILD=$(cur_build)-gcc ; \
export CC=$(cur_host)-gcc ; \
export CXX=$(cur_host)-g++ ; \
export AR=$(cur_host)-ar ; \
export RANLIB=$(cur_host)-ranlib ; \
export PATH="$(CANADIAN_ROOT)/install/bin:${PATH}" ;
endif
#
# Make rules
#
.PHONY: all clean
all: build
# top level
ifeq ($(ENABLE_GRAPHITE),yes)
build: install-host-cloog
endif
ifneq (, $(findstring android,$(cur_target)))
# generic target matching our real target (e.g. arm-eabi for arm-linux-androideabi)
generic_target := $(subst linux-android,,$(cur_target))
ifeq ($(generic_target),aarch64-)
generic_target := aarch64-none-elf
endif
ifeq ($(generic_target),aarch64-unknown-)
generic_target := aarch64-none-elf
endif
build: build-target-binutils build-generic-target-binutils build-host-libbfd \
build-target-gcc build-generic-target-gcc \
build-target-gdb
install: install-target-binutils install-generic-target-binutils \
install-host-libbfd install-target-gcc install-generic-target-gcc \
install-target-gdb
else
build: build-target-binutils build-host-libbfd build-target-gcc \
build-target-gdb
install: install-target-binutils install-host-libbfd install-target-gcc \
install-target-gdb
endif
# To support canadian cross build we need to build build->target toolchain
# as well as final host->target toolchain.
ifneq ($(cur_host),$(cur_build))
.PHONY: config-canadian-tools build-canadian-tools install-canadian-tools
config-canadian-tools: stmp-config-canadian-tools
stmp-config-canadian-tools:
([ -d $(CANADIAN_ROOT) ] || \
mkdir $(CANADIAN_ROOT)) && \
($(canadian_build_env) \
cd $(CANADIAN_ROOT) && \
$(abs_srcdir)/configure $(baseargs) --build=$(cur_build) \
--host=$(cur_build) --target=$(cur_target)) && \
$(STAMP) $@
build-canadian-tools: stmp-build-canadian-tools
stmp-build-canadian-tools: stmp-config-canadian-tools
($(canadian_build_env) \
cd $(CANADIAN_ROOT) && \
$(MAKE)) && \
$(STAMP) $@
install-canadian-tools: stmp-install-canadian-tools
stmp-install-canadian-tools: stmp-build-canadian-tools
($(canadian_build_env) \
cd $(CANADIAN_ROOT) && \
$(MAKE) install prefix=$(CANADIAN_ROOT)/install) && \
$(STAMP) $@
# When building canadian cross toolchain we cannot build GCC target libraries.
# So we build the compilers only and copy the target libaries from
# $(CANADIAN_ROOT)/install/ installation.
gcc_build_target := all-gcc
gcc_install_target := install-gcc
install-target-gcc-multilibs: stmp-install-canadian-tools
mkdir -p $(prefix)/lib/gcc/
rsync -a $(CANADIAN_ROOT)/install/lib/gcc/ $(prefix)/lib/gcc/
install-target-gcc-multilibs := install-target-gcc-multilibs
# We add canadian_stmp dependency to rules that have no dependencies
# on other modules. This is to ensure that simple cross toolchain is built
# before canadian cross toolchain.
canadian_stmp := stmp-install-canadian-tools
else
gcc_build_target :=
gcc_install_target := install
install-target-gcc-multilibs :=
canadian_stmp :=
endif
ifneq ($(BINUTILS_VERSION), $(GOLD_VERSION))
build: build-target-gold
install: install-target-gold
endif
# target binutils rules
.PHONY: config-target-binutils build-target-binutils install-target-binutils
config-target-binutils: stmp-config-target-binutils
# We do not want to enable shared libraries in binutils
BINUTILS_CONFIG_ARGS=--prefix=$(prefix) \
--host=${cur_host} --build=${cur_build} \
$(baseargs) --disable-shared --disable-werror --disable-ppl-version-check --enable-plugins
ifeq ($(BINUTILS_VERSION),binutils-2.20.1)
BINUTILS_CONFIG_ARGS+= --enable-gold=both/gold
else
ifeq ($(BINUTILS_VERSION),binutils-20100303)
BINUTILS_CONFIG_ARGS+= --enable-gold=both/gold
else
ifeq ($(target_cpu),aarch64)
# Gold hasn't been ported to aarch64 yet
BINUTILS_CONFIG_ARGS+= --enable-ld=default --disable-gold
else
BINUTILS_CONFIG_ARGS+= --enable-gold=default
endif
endif
endif
ifeq ($(ENABLE_GRAPHITE),yes)
# binutils doesn't use isl, but its configure script fails if it sees
# a newer version than 0.12 in a directory specified by --with-isl.
# We're fine if binutils gets built --without-isl as long as gcc's
# configure script knows better.
BINUTILS_CONFIG_ARGS+= --with-cloog=${CLOOG_DIR} --without-isl --with-gmp=${GMP_DIR} \
--disable-cloog-version-check $(CLOOG_BACKEND) \
--enable-plugins --enable-threads
# link to the static C++ runtime to avoid depending on the host version
BINUTILS_CONFIG_ARGS+= \
'--with-host-libstdcxx=-static-libgcc -lstdc++ -lm'
endif
stmp-config-target-binutils: config.status stmp-install-host-ppl stmp-install-host-isl $(canadian_stmp)
([ -d ${BINUTILS_VERSION} ] || \
mkdir ${BINUTILS_VERSION}) && \
($(canadian_env) \
cd ${BINUTILS_VERSION} ; \
if which g++-$(HOSTGCC); then export CC=gcc-$(HOSTGCC); export CXX=g++-$(HOSTGCC); fi ; \
$(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
--target=$(cur_target) \
$(BINUTILS_CONFIG_ARGS)) && \
$(STAMP) $@
build-target-binutils: stmp-build-target-binutils
stmp-build-target-binutils: stmp-config-target-binutils
($(canadian_env) \
if which g++-$(HOSTGCC); then export CC=gcc-$(HOSTGCC); export CXX=g++-$(HOSTGCC); fi ; \
$(MAKE) -C ${BINUTILS_VERSION}) && $(STAMP) $@
install-target-binutils: stmp-build-target-binutils
($(canadian_env) \
if which g++-$(HOSTGCC); then export CC=gcc-$(HOSTGCC); export CXX=g++-$(HOSTGCC); fi ; \
$(MAKE) -C ${BINUTILS_VERSION} install)
stmp-config-generic-target-binutils: config.status $(canadian_stmp)
([ -d generic-${BINUTILS_VERSION} ] || \
mkdir generic-${BINUTILS_VERSION}) && \
($(canadian_env) \
cd generic-${BINUTILS_VERSION} ; \
if which g++-$(HOSTGCC); then export CC=gcc-$(HOSTGCC); export CXX=g++-$(HOSTGCC); fi ; \
$(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
--target=$(generic_target) \
$(BINUTILS_CONFIG_ARGS)) && \
$(STAMP) $@
build-generic-target-binutils: stmp-build-generic-target-binutils
stmp-build-generic-target-binutils: stmp-config-generic-target-binutils
($(canadian_env) \
$(MAKE) -C generic-${BINUTILS_VERSION}) && $(STAMP) $@
install-generic-target-binutils: stmp-build-generic-target-binutils
($(canadian_env) \
$(MAKE) -C generic-${BINUTILS_VERSION} install)
# target gold rules. We need these only if BINUTILS_VERSION != GOLD_VERSION
ifneq ($(BINUTILS_VERSION), $(GOLD_VERSION))
.PHONY: config-target-gold build-target-gold install-target-gold
config-target-gold: stmp-config-target-gold
# We do not want to enable shared libraries in gold
GOLD_CONFIG_ARGS=--prefix=$(prefix) \
--target=${target_alias} --host=${host} --build=${build} \
$(baseargs) --disable-shared
stmp-config-target-gold: config.status
([ -d ${GOLD_VERSION} ] || \
mkdir ${GOLD_VERSION}) && \
(cd ${GOLD_VERSION} ; \
$(call find-package-srcdir, ${GOLD_VERSION})/configure \
$(GOLD_CONFIG_ARGS)) && \
$(STAMP) $@
build-target-gold: stmp-build-target-gold
stmp-build-target-gold: stmp-config-target-gold
($(canadian_env) \
$(MAKE) -C ${GOLD_VERSION} && $(STAMP) $@)
# If we use a different binutils version of gold, we build gold twice. We
# first build everything, including gold with the main binutils version and
# then install it. Then we build the gold-only binutils version and install
# just gold. We don't bother to skip building the first gold to simplify
# handling of all combinations of --enable-gold[=*]
install-target-gold: stmp-build-target-gold install-target-binutils
($(canadian_env) \
make -C $(GOLD_VERSION)/gold install)
endif
# build libbfd for host. We configure with all targets, so this is built
# separately from the same source.
.PHONY: config-host-libbfd build-host-libbfd install-host-libbfd
config-host-libbfd: stmp-config-host-libbfd
LIBBFD_CONFIG_ARGS=--prefix=$(prefix) \
--host=${host} --build=${build} \
$(baseargs) --disable-shared \
--enable-install-libbfd --with-included-gettext \
--disable-werror
stmp-config-host-libbfd: config.status
([ -d libbfd-${BINUTILS_VERSION} ] || \
mkdir libbfd-${BINUTILS_VERSION}) && \
(cd libbfd-${BINUTILS_VERSION} ; \
$(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
$(LIBBFD_CONFIG_ARGS)) && \
$(STAMP) $@
build-host-libbfd: stmp-build-host-libbfd
stmp-build-host-libbfd: stmp-config-host-libbfd
$(MAKE) -C libbfd-${BINUTILS_VERSION} all-bfd all-libiberty && \
$(MAKE) -C libbfd-${BINUTILS_VERSION}/intl libintl.a && \
$(STAMP) $@
# Also include libintl.a. We have to do this manully since the
# source of libintl in binutils is modified to not install the library.
install-host-libbfd: stmp-build-host-libbfd install-target-binutils
$(MAKE) -C libbfd-${BINUTILS_VERSION}/bfd install \
bfdlibdir=$(libdir) bfdincludedir=$(includedir) && \
$(INSTALL_DATA) libbfd-${BINUTILS_VERSION}/intl/libintl.a \
$(libdir) && \
$(INSTALL_DATA) libbfd-${BINUTILS_VERSION}/libiberty/libiberty.a \
$(libdir)
# target gcc rules
.PHONY: config-target-gcc build-target-gcc install-target-gcc
.PHONY: install-target-gcc-gcc $(install-target-gcc-multilibs)
config-target-gcc: stmp-install-host-gmp stmp-install-host-mpfr stmp-install-host-mpc stmp-config-target-gcc
GCC_CONFIG_ARGS=--prefix=$(prefix) \
--host=${cur_host} --build=${cur_build} \
--with-gnu-as --with-gnu-ld --enable-languages=c,c++ \
--with-gmp=$(GMP_DIR) --with-mpfr=$(MPFR_DIR) \
--with-mpc=$(MPC_DIR) --with-isl=${ISL_DIR}
ifeq ($(ENABLE_GRAPHITE),yes)
GCC_CONFIG_ARGS += --with-cloog=${CLOOG_DIR} --with-isl=${ISL_DIR} --with-ppl=${PPL_DIR} \
--disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check $(CLOOG_BACKEND)
# link to the static C++ runtime to avoid depending on the host version
GCC_CONFIG_ARGS += \
'--with-host-libstdcxx=-static-libgcc -lstdc++ -lm'
endif
# Add Android specific gcc options.
# FIXME: These should be overridable by configure options.
# Target indenpendent Android gcc options.
ifeq ($(BUILD_ANDROID_GCC),yes)
GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \
--disable-nls --disable-libmudflap \
--disable-shared --disable-sjlj-exceptions \
--disable-libquadmath --disable-libitm \
--disable-libsanitizer
CFLAGS_FOR_TARGET += -DTARGET_POSIX_IO -fno-short-enums
ifeq ($(target_cpu),aarch64)
TARGET_PLATFORM := arm64
else
TARGET_PLATFORM := $(target_cpu)
endif
# We need to find pthread.h to build libgcc with threading support.
# -include .../sys/limits.h is a workaround for Bionic's ptherad.h requiring
# LONG_BIT, which usually comes in through limits.h -- but gcc has its own
# version of that which fails to include sys/limits.h
CFLAGS_FOR_TARGET += -isystem $(abs_srcdir)/../ndk/current/platforms/android-21/arch-$(TARGET_PLATFORM)/usr/include -B$(abs_srcdir)/../ndk/current/platforms/android-21/arch-$(TARGET_PLATFORM)/usr/lib -include $(abs_srcdir)/../ndk/current/platforms/android-21/arch-$(TARGET_PLATFORM)/usr/include/sys/limits.h
# ARM specific options.
ifeq ($(target_cpu),arm)
# Best -mfpu-option for common ARMv7 CPUs:
# Cortex-A5: neon-fp16
# Cortex-A7: neon-vfpv4
# Cortex-A8: neon
# Cortex-A9: neon-fp16
# Cortex-A15: neon-vfpv4
GCC_CONFIG_ARGS += --with-float=softfp --with-fpu=neon --with-arch=armv7-a \
--enable-target-optspace
ifneq ($(target_os),linux-androideabi)
GCC_CONFIG_ARGS += --with-abi=aapcs
endif
endif
endif
# We add the baseargs and the end so that they override any default args
GCC_CONFIG_ARGS += $(baseargs)
# Usage: $(call config-gcc,TYPE,CONFIGURE_ARGS[,TARGET])
# Where
# TYPE aka $(1) is bootstrap or target
# CONFIGURE_ARGS aka $(2) is extra arguments passed to configure
# TARGET aka $(3) is the target platform, e.g. arm-eabi- (default: $(cur_target))
define config-gcc =
[ -n "$(3)" ] && TARGET="$(3)" || TARGET="$(cur_target)" ; \
echo "Building gcc for $$TARGET with cur_target $(cur_target), generic_target $(generic_target)"; \
([ -d gcc-$(1)-$(GCC_VERSION) ] || \
mkdir gcc-$(1)-$(GCC_VERSION)) && \
($(canadian_env) \
cd gcc-$(1)-${GCC_VERSION} ; \
$(TARGET_BINUTILS_EXPORTS) ; \
export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" ; \
export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" ; \
export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \
export CFLAGS="-O2" ; \
export CXXFLAGS="-O2" ; \
$(call find-package-srcdir, $(GCC_VERSION))/configure \
$(GCC_CONFIG_ARGS) --target=$$TARGET --enable-threads --enable-tls $(2)) && \
$(STAMP) $@
endef
# Usage: $(call build-gcc,TYPE)
# Where
# TYPE aka $(1) is bootstrap or target
define build-gcc =
($(canadian_env) \
$(MAKE) -C gcc-$(1)-$(GCC_VERSION) \
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \
$(gcc_build_target)) && \
$(STAMP) $@
endef
# Usage: $(call install-gcc,TYPE)
# Where
# TYPE aka $(1) is bootstrap or target
define install-gcc =
echo install-gcc running for gcc-$(1)-$(GCC_VERSION) $(gcc_install_target)
($(canadian_env) \
$(MAKE) -C gcc-$(1)-$(GCC_VERSION) $(gcc_install_target))
endef
patch-libgomp-for-android: config.status
cd temp-src && \
grep -q sys/mman.h $(call find-package-srcdir, ${GCC_VERSION})/libgomp/env.c || sed -i -e '/#include <limits.h>/i#include <sys/mman.h>' $(call find-package-srcdir, ${GCC_VERSION})/libgomp/env.c
stmp-patch-libgomp-for-android: patch-libgomp-for-android
$(STAMP) $@
# Target compiler: The real compiler, may have libc dependencies
.PHONY: build-target-gcc install-target-gcc-gcc install-target-gcc
stmp-config-target-gcc: config.status stmp-install-host-ppl stmp-install-host-gmp stmp-install-host-mpfr stmp-install-host-mpc stmp-install-host-isl stmp-patch-libgomp-for-android stmp-build-target-binutils
# We should just call
# $(call config-gcc,target,--enable-libgomp)
# Unfortunately, the version on make on android-build
# is really broken (the call statement works fine
# w/ make 3.82), so we have to do it manually:
TARGET="$(cur_target)" ; \
([ -d gcc-target-$(GCC_VERSION) ] || \
mkdir gcc-target-$(GCC_VERSION)) && \
($(canadian_env) \
cd gcc-target-${GCC_VERSION} ; \
$(TARGET_BINUTILS_EXPORTS) ; \
export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET) -fexceptions" ; \
export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET) -frtti" ; \
export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \
export CFLAGS="-O2" ; \
export CXXFLAGS="-O2" ; \
$(call find-package-srcdir, $(GCC_VERSION))/configure \
$(GCC_CONFIG_ARGS) --target=$$TARGET --enable-threads --enable-tls --enable-libgomp --disable-libitm --disable-libsanitizer --enable-libatomic --disable-libstdc__-v3) && \
$(STAMP) $@
build-target-gcc: stmp-build-target-gcc
stmp-build-target-gcc: stmp-config-target-gcc
# We should just call
# $(call build-gcc,target)
# Unfortunately, the version on make on android-build
# is really broken (the call statement works fine
# w/ make 3.82), so we have to do it manually:
# Workaround for build-gcc seemingly not working
# inside android-build: Broken version of make?
($(canadian_env) \
$(MAKE) -C gcc-target-$(GCC_VERSION) \
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET) -fexceptions" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET) -frtti" \
LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \
$(gcc_build_target)) && \
$(STAMP) $@
install-target-gcc-gcc: stmp-build-target-gcc
# We should just call
# $(call install-gcc,target)
# Unfortunately, the version on make on android-build
# is really broken (the call statement works fine
# w/ make 3.82), so we have to do it manually:
# Workaround for build-gcc seemingly not working
# inside android-build: Broken version of make?
($(canadian_env) \
$(MAKE) -C gcc-target-$(GCC_VERSION) $(gcc_install_target))
(cd $(prefix)/libexec/gcc/$(target_no_unknown) && cd `ls -1` && ln -s ../../../../bin/$(cur_target)-ld real-ld)
install-target-gcc: install-target-gcc-gcc $(install-target-gcc-multilibs)
ifneq ($(generic_target),)
# Generic target compiler: OS independent bare compiler (e.g. arm-eabi-gcc)
# Since this compiler cannot make any assumptions about the OS, it is by
# nature not dependent on any libc bits - so we don't need to go through
# the steps of building a bootstrap compiler first.
.PHONY: build-generic-target-gcc install-generic-target-gcc install-generic-target-gcc-gcc
stmp-config-generic-target-gcc: config.status stmp-install-host-ppl stmp-build-target-binutils
# We should just call
# $(call config-gcc,generic-target,--disable-libgomp,$(generic_target))
# Unfortunately, the version on make on android-build
# is really broken (the call statement works fine
# w/ make 3.82), so we have to do it manually:
TARGET="$(generic_target)" ; \
([ -d gcc-generic-target-$(GCC_VERSION) ] || \
mkdir gcc-generic-target-$(GCC_VERSION)) && \
($(canadian_env) \
cd gcc-generic-target-${GCC_VERSION} ; \
$(TARGET_BINUTILS_EXPORTS) ; \
export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" ; \
export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" ; \
export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \
export CFLAGS="-O2" ; \
export CXXFLAGS="-O2" ; \
$(call find-package-srcdir, $(GCC_VERSION))/configure \
$(GCC_CONFIG_ARGS) --target=$$TARGET --enable-threads --enable-tls --disable-libgomp --disable-libstdc__-v3 --disable-libitm --disable-libsanitizer --disable-libatomic) && \
$(STAMP) $@
build-generic-target-gcc: stmp-build-generic-target-gcc
stmp-build-generic-target-gcc: stmp-config-generic-target-gcc
# We should just call
# $(call build-gcc,generic-target)
# Unfortunately, the version on make on android-build
# is really broken (the call statement works fine
# w/ make 3.82), so we have to do it manually:
# Workaround for build-gcc seemingly not working
# inside android-build: Broken version of make?
($(canadian_env) \
$(MAKE) -C gcc-generic-target-$(GCC_VERSION) \
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \
$(gcc_build_target)) && \
$(STAMP) $@
install-generic-target-gcc-gcc: stmp-build-generic-target-gcc
# We should just call
# $(call install-gcc,generic-target)
# Unfortunately, the version on make on android-build
# is really broken (the call statement works fine
# w/ make 3.82), so we have to do it manually:
# Workaround for build-gcc seemingly not working
# inside android-build: Broken version of make?
($(canadian_env) \
$(MAKE) -C gcc-generic-target-$(GCC_VERSION) $(gcc_install_target))
install-generic-target-gcc: install-generic-target-gcc-gcc
endif
# minimal gcc rules
# minimal gcc only builds the C and C++ compilers and libgcc
# We use the full gcc configure rules.
.PHONY: build-target-minimal-gcc install-target-minimal-gcc
MINIMAL_GCC_BUILD_TARGETS:= gcc target-libgcc
build-target-minimal-gcc: stmp-build-target-minimal-gcc
stmp-build-target-minimal-gcc: stmp-config-target-gcc
($(canadian_env) \
$(MAKE) -C ${GCC_VERSION} \
$(call prefix-list, all-, $(MINIMAL_GCC_BUILD_TARGETS))) && \
$(STAMP) $@
install-target-minimal-gcc: stmp-build-target-minimal-gcc
($(canadian_env) \
$(MAKE) -C ${GCC_VERSION} \
$(call prefix-list, install-, $(MINIMAL_GCC_BUILD_TARGETS)))
# target newlib rules
.PHONY: config-target-newlib build-target-newlib install-target-newlib
config-target-newlib: stmp-config-target-newlib
NEWLIB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
--target=${cur_target} --host=${cur_host} --build=${cur_build}
stmp-config-target-newlib: stmp-build-target-binutils \
stmp-build-target-minimal-gcc
([ -d ${NEWLIB_VERSION} ] || \
mkdir ${NEWLIB_VERSION}) && \
($(canadian_env) \
cd ${NEWLIB_VERSION} ; \
$(TARGET_BINUTILS_EXPORTS) ; \
$(TARGET_MINIMAL_GCC_EXPORTS) ; \
$(call find-package-srcdir, ${NEWLIB_VERSION})/configure \
$(NEWLIB_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-target-newlib: stmp-config-target-newlib
($(canadian_env) \
$(MAKE) -C ${NEWLIB_VERSION}) && $(STAMP) $@
install-target-newlib: stmp-build-target-newlib
($(canadian_env) \
$(MAKE) -C ${NEWLIB_VERSION} install)
# host gmp rules
.PHONY: config-host-gmp build-host-gmp install-host-gmp
config-host-gmp: stmp-config-host-gmp
GMP_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
--host=${cur_host} --build=${cur_build}
ifeq ($(ENABLE_GRAPHITE),yes)
GMP_CONFIG_ARGS+= --enable-cxx
endif
stmp-config-host-gmp: config.status $(canadian_stmp)
([ -d ${GMP_VERSION} ] || \
mkdir ${GMP_VERSION}) && \
($(canadian_env) \
cd ${GMP_VERSION} ; \
$(call find-package-srcdir, ${GMP_VERSION})/configure \
$(GMP_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-host-gmp: stmp-config-host-gmp
($(canadian_env) \
$(MAKE) -C ${GMP_VERSION}) && $(STAMP) $@
build-host-gmp: stmp-build-host-gmp
# Need -j1 to avoid a race condition in building on OS X.
ifeq ($(HAVE_GMP),no)
stmp-install-host-gmp: stmp-build-host-gmp
$(MAKE) -C ${GMP_VERSION} install -j1 && $(STAMP) $@
else
stmp-install-host-gmp:
endif
install-host-gmp: stmp-install-host-gmp
# host mpfr rules
.PHONY: config-host-mpfr build-host-mpfr install-host-mpfr
config-host-mpfr: stmp-config-host-mpfr
MPFR_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
--host=${cur_host} --build=${cur_build} \
--with-gmp=$(GMP_DIR)
stmp-config-host-mpfr: config.status stmp-install-host-gmp
([ -d ${MPFR_VERSION} ] || \
mkdir ${MPFR_VERSION}) && \
($(canadian_env) \
cd ${MPFR_VERSION} ; \
$(call find-package-srcdir, ${MPFR_VERSION})/configure \
$(MPFR_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-host-mpfr: stmp-config-host-mpfr
($(canadian_env) \
$(MAKE) -C ${MPFR_VERSION}) && $(STAMP) $@
build-host-mpfr: stmp-build-host-mpfr
ifeq ($(HAVE_MPFR),no)
stmp-install-host-mpfr: stmp-build-host-mpfr
$(MAKE) -C ${MPFR_VERSION} install && $(STAMP) $@
else
stmp-install-host-mpfr:
endif
install-host-mpfr: stmp-install-host-mpfr
# host mpc rules
.PHONY: config-host-mpc build-host-mpc install-host-mpc
config-host-mpc: stmp-config-host-mpc
MPC_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
--host=${cur_host} --build=${cur_build} \
--with-gmp=$(GMP_DIR) --with-mpfr=$(MPFR_DIR)
stmp-config-host-mpc: config.status stmp-install-host-gmp stmp-install-host-mpfr
([ -d ${MPC_VERSION} ] || \
mkdir ${MPC_VERSION}) && \
($(canadian_env) \
cd ${MPC_VERSION} ; \
$(call find-package-srcdir, ${MPC_VERSION})/configure \
$(MPC_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-host-mpc: stmp-config-host-mpc
($(canadian_env) \
$(MAKE) -C ${MPC_VERSION}) && $(STAMP) $@
build-host-mpc: stmp-build-host-mpc
ifeq ($(HAVE_MPC),no)
stmp-install-host-mpc: stmp-build-host-mpc
$(MAKE) -C ${MPC_VERSION} install && $(STAMP) $@
else
stmp-install-host-mpc:
endif
install-host-mpc: stmp-install-host-mpc
# host ppl rules
.PHONY: config-host-ppl build-host-ppl install-host-ppl
ifeq ($(ENABLE_GRAPHITE),yes)
config-host-ppl: stmp-config-host-ppl
PPL_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
--target=${target_alias} \
--host=${host} --build=${build} \
--disable-nls --with-libgmp-prefix=$(GMP_DIR) \
--disable-watchdog --without-java \
--disable-ppl_lcdd --disable-ppl_lpsol --disable-ppl_pips
stmp-config-host-ppl: config.status stmp-install-host-gmp
([ -d ${PPL_VERSION} ] || \
mkdir ${PPL_VERSION}) && \
($(canadian_env) \
cd ${PPL_VERSION} ; \
aclocal ; automake -a ; \
export CFLAGS="${CFLAGS} -I$(GMP_DIR)/include -L$(GMP_DIR)/lib" ; \
export CXXFLAGS="${CFLAGS} -I$(GMP_DIR)/include -L$(GMP_DIR)/lib" ; \
$(call find-package-srcdir, ${PPL_VERSION})/configure \
$(PPL_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-host-ppl: stmp-config-host-ppl
$(MAKE) -C ${PPL_VERSION} && $(STAMP) $@
build-host-ppl: stmp-build-host-ppl
stmp-install-host-ppl: stmp-build-host-ppl
$(MAKE) -C ${PPL_VERSION} install && \
$(STAMP) $@
install-host-ppl: stmp-install-host-ppl
# host isl rules
.PHONY: config-host-isl build-host-isl install-host-isl
config-host-isl: stmp-config-host-isl
ISL_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
--target=${target_alias} \
--host=${host} --build=${build} \
--disable-nls
stmp-config-host-isl: config.status stmp-install-host-gmp
([ -d ${ISL_VERSION} ] || \
mkdir ${ISL_VERSION}) && \
($(canadian_env) \
cd ${ISL_VERSION} ; \
export CFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
export CXXFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
export LDFLAGS="${LDFLAGS} -L$(GMP_DIR)/lib" ; \
$(call find-package-srcdir, ${ISL_VERSION})/configure \
$(ISL_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-host-isl: stmp-config-host-isl
$(MAKE) -C ${ISL_VERSION} && $(STAMP) $@
build-host-isl: stmp-build-host-isl
ifeq ($(ENABLE_GRAPHITE)$(GCC_MIN_VERSION_4_8_0),yesyes)
stmp-install-host-isl: stmp-build-host-isl
$(MAKE) -C ${ISL_VERSION} install && \
$(STAMP) $@
else
stmp-install-host-isl:
$(STAMP) $@
endif
install-host-isl: stmp-install-host-isl
# host cloog rules
.PHONY: config-host-cloog build-host-cloog install-host-cloog
config-host-cloog: stmp-config-host-cloog
CLOOG_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
--target=${target_alias} \
--host=${host} --build=${build} \
--disable-nls
CLOOG_TARGET = libcloog-isl.la
CLOOG_CONFIG_ARGS+= --with-gmp-prefix=$(GMP_DIR)
stmp-config-host-cloog: config.status stmp-install-host-gmp
([ -d ${CLOOG_VERSION} ] || \
mkdir ${CLOOG_VERSION}) && \
($(canadian_env) \
cd ${CLOOG_VERSION} ; \
$(call find-package-srcdir, ${CLOOG_VERSION})/configure \
$(CLOOG_CONFIG_ARGS)) && \
$(STAMP) $@
stmp-build-host-cloog: stmp-config-host-cloog
# Ignore the generation of cloog utilities
$(MAKE) -C ${CLOOG_VERSION} $(CLOOG_TARGET) && \
$(STAMP) $@
build-host-cloog: stmp-build-host-cloog
stmp-install-host-cloog: stmp-build-host-cloog
$(MAKE) -C ${CLOOG_VERSION} install-libLTLIBRARIES \
install-pkgincludeHEADERS
$(MAKE) -C ${CLOOG_VERSION}/isl install-libLTLIBRARIES \
install-pkgincludeHEADERS
cp -a $(call find-package-srcdir, ${CLOOG_VERSION})/include/cloog/isl $(TEMP_INSTALLDIR)/include/cloog/
$(STAMP) $@
install-host-cloog: stmp-install-host-cloog
else
config-host-ppl:
stmp-config-host-ppl:
stmp-build-host-ppl:
build-host-ppl:
stmp-install-host-ppl:
install-host-ppl:
config-host-cloog:
stmp-config-host-cloog:
stmp-build-host-cloog:
build-host-cloog:
stmp-install-host-cloog:
install-host-cloog:
stmp-config-host-isl:
stmp-build-host-isl:
stmp-install-host-isl:
config-host-isl:
build-host-isl:
install-host-isl:
endif
# target gdb rules
.PHONY: config-target-gdb build-target-gdb install-target-gdb
ifeq ($(GDB_VERSION),gdb-none)
config-target-gdb:
build-target-gdb:
install-target-gdb:
else
config-target-gdb: stmp-config-target-gdb
GDB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
--target=$(GDB_TARGET) --host=${cur_host} --build=${cur_build} \
--disable-nls \
--disable-werror
stmp-config-target-gdb: config.status $(canadian_stmp)
([ -d ${GDB_VERSION} ] || \
mkdir ${GDB_VERSION}) && \
($(canadian_env) \
cd ${GDB_VERSION} ; \
$(call find-package-srcdir, ${GDB_VERSION})/configure \
$(GDB_CONFIG_ARGS)) && \
$(STAMP) $@
build-target-gdb: stmp-build-target-gdb
stmp-build-target-gdb: stmp-config-target-gdb
($(canadian_env) \
$(MAKE) -C ${GDB_VERSION}) && $(STAMP) $@
install-target-gdb: stmp-build-target-gdb
($(canadian_env) \
$(MAKE) -C ${GDB_VERSION} install)
endif
# clean rules
.PHONY: clean
clean:
$(RM) -r $(TEMP_INSTALLDIR) stmp-build-* stmp-install-* && \
for sub in [ * ]; do \
if [ -f $$sub/Makefile ]; then \
$(MAKE) -C $$sub clean ; \
fi; \
done
.PHONY: distclean
distclean:
@$(RM) -r config.log config.status \
$(TEMP_INSTALLDIR) temp-src \
stmp-config-* stmp-build-* stmp-install-* && \
for sub in [ * ]; do \
if [ -f $$sub/config.status ]; then \
echo "Deleting " $$sub "..." && $(RM) -r $$sub ; \
fi; \
done
@$(RM) Makefile