Switch x86/x86-64 -mtune from "atom" to more generic "intel"
[android/toolchain/build.git] / Makefile.in
1 # -------------------------------
2 # Standard Autoconf-set variables
3 # -------------------------------
4 VPATH=@srcdir@
5
6 build_alias=@build_alias@
7 build_vendor=@build_vendor@
8 build_os=@build_os@
9 build=@build@
10 host_alias=@host_alias@
11 host_vendor=@host_vendor@
12 host_os=@host_os@
13 host=@host@
14 target_alias=@target_alias@
15 target_vendor=@target_vendor@
16 target_os=@target_os@
17 target_cpu=@target_cpu@
18 target=@target@
19
20 program_transform_name = @program_transform_name@
21
22 prefix = @prefix@
23 exec_prefix = @exec_prefix@
24
25 srcdir = @srcdir@
26 abs_srcdir = @abs_srcdir@
27
28 bindir = @bindir@
29 sbindir = @sbindir@
30 libexecdir = @libexecdir@
31 datadir = @datadir@
32 sysconfdir = @sysconfdir@
33 sharedstatedir = @sharedstatedir@
34 localstatedir = @localstatedir@
35 libdir = @libdir@
36 includedir = @includedir@
37 oldincludedir = @oldincludedir@
38 infodir = @infodir@
39 datarootdir = @datarootdir@
40 docdir = @docdir@
41 pdfdir = @pdfdir@
42 htmldir = @htmldir@
43 mandir = @mandir@
44
45 builddir = @builddir@
46 abs_builddir = @abs_builddir@
47
48 INSTALL=@INSTALL@
49
50 #
51 # miscellaneous variables
52 #
53 INSTALL:=@INSTALL@
54 INSTALL_DATA:=@INSTALL_DATA@
55 TOPLEVEL_CONFIGURE_ARGUMENTS:=@TOPLEVEL_CONFIGURE_ARGUMENTS@
56 baseargs = @baseargs@
57 host_baseargs = @host_baseargs@
58 GCC_MIN_VERSION_4_3_0:=@GCC_MIN_VERSION_4_3_0@
59 GCC_MIN_VERSION_4_5_0:=@GCC_MIN_VERSION_4_5_0@
60 GCC_MIN_VERSION_4_8_0:=@GCC_MIN_VERSION_4_8_0@
61 GDB_MIN_VERSION_7_2:=@GDB_MIN_VERSION_7_2@
62 BINUTILS_MIN_VERSION_2_21:=@BINUTILS_MIN_VERSION_2_21@
63 GOLD_MIN_VERSION_2_21:=@GOLD_MIN_VERSION_2_21@
64 CLOOG_BACKEND:=@CLOOG_BACKEND@
65 ENABLE_GRAPHITE:=@ENABLE_GRAPHITE@
66 PACKAGE_TO_SRCDIR:=@package_to_srcdir@
67 BUILD_ANDROID_GCC:=@BUILD_ANDROID_GCC@
68 GDB_TARGET:=@GDB_TARGET@
69
70 # We need to figure out how to get to top level source directory from
71 # a package build directory. 
72 # For host modules, accept cache file option, or specification as blank.
73
74
75 BINUTILS_VERSION=binutils-@BINUTILS_VERSION@
76 GOLD_VERSION=binutils-@GOLD_VERSION@
77 GCC_VERSION=gcc-@GCC_VERSION@
78 NEWLIB_VERSION=newlib-@NEWLIB_VERSION@
79 GMP_VERSION=gmp-@GMP_VERSION@
80 MPFR_VERSION=mpfr-@MPFR_VERSION@
81 MPC_VERSION=mpc-@MPC_VERSION@
82 PPL_VERSION=ppl-@PPL_VERSION@
83 CLOOG_VERSION=cloog-@CLOOG_VERSION@
84 ISL_VERSION=isl-@ISL_VERSION@
85 GDB_VERSION=gdb-@GDB_VERSION@
86 EXPAT_VERSION=expat-@EXPAT_VERSION@
87 WITH_PYTHON=@WITH_PYTHON@
88 HAVE_MPC=@have_mpc@
89 HAVE_MPFR=@have_mpfr@
90 HAVE_GMP=@have_gmp@
91 HAVE_PPL=@have_ppl@
92 HAVE_CLOOG=@have_cloog@
93 HAVE_ISL=@have_isl@
94 HAVE_EXPAT=@have_expat@
95 ENABLE_GOLD=@enable_gold@
96 ENABLE_LD_DEFAULT=@enable_ld_default@
97 STAMP=touch
98
99 TARGET_BINUTILS_BUILDDIR=$(abs_builddir)/$(BINUTILS_VERSION)
100 TARGET_GCC_BUILDDIR=$(abs_builddir)/$(GCC_VERSION)
101 TEMP_INSTALLDIR=$(abs_builddir)/temp-install
102
103 ifeq ($(HAVE_MPC),no)
104   MPC_DIR=$(TEMP_INSTALLDIR)
105 endif
106
107 ifeq ($(HAVE_MPFR),no)
108   MPFR_DIR=$(TEMP_INSTALLDIR)
109 endif
110
111 ifeq ($(HAVE_GMP),no)
112   GMP_DIR=$(TEMP_INSTALLDIR)
113 endif
114
115 ifeq ($(HAVE_PPL), no)
116   PPL_DIR=$(TEMP_INSTALLDIR)
117 endif
118
119 ifeq ($(HAVE_CLOOG), no)
120   CLOOG_DIR=$(TEMP_INSTALLDIR)
121 endif
122
123 ifeq ($(HAVE_ISL), no)
124   ISL_DIR=$(TEMP_INSTALLDIR)
125 endif
126
127 ifeq ($(HAVE_EXPAT),no)
128   EXPAT_DIR=$(TEMP_INSTALLDIR)
129 endif
130
131 ifneq ($(WITH_PYTHON),)
132   WITH_PYTHON:=--with-python=$(WITH_PYTHON)
133 endif
134
135 # Figure out where to find the ld binary.
136 FIND_TARGET_LD=\
137         `[ -d $(TARGET_BINUTILS_BUILDDIR)/gold ] && echo "gold" || echo "ld"`
138
139 # We export these insteading when configuring target gcc and newlib
140 TARGET_BINUTILS_EXPORTS= \
141 export  AS_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/gas/as-new \
142         LD_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/$(FIND_TARGET_LD)/ld-new \
143         AR_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ar \
144         NM_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/nm-new \
145         STRIP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/strip-new \
146         RANLIB_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ranlib \
147         OBJDUMP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/objdump \
148         READELF_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/readelf
149
150 TARGET_MINIMAL_GCC_EXPORTS= \
151 export  CC_FOR_TARGET="$(TARGET_GCC_BUILDDIR)/gcc/xgcc \
152                       -B $(TARGET_GCC_BUILDDIR)/gcc \
153                       -isystem $(TARGET_GCC_BUILDDIR)/gcc/include-fixed \
154                       -isystem $(TARGET_GCC_BUILDDIR)/gcc/include"
155 #
156 # We need -Os as the overrides below interfere with --enable-target-optspace.
157 # We also need -mandroid for for target libraries to pass linking test
158 # in configuration.
159
160 # To build libstdc++ with RTTI and exceptions do:
161 #
162 #export CFLAGS_FOR_TARGET=-fexceptions
163 #export CXXFLAGS_FOR_TARGET=-frtti
164 #
165 CFLAGS_FOR_TARGET+= -O2 -Os -g
166 CXXFLAGS_FOR_TARGET+=$(CFLAGS_FOR_TARGET)
167 LDFLAGS_FOR_TARGET=
168
169 # Helper
170 prefix-list = $(foreach e, $(2), $(join $1, $e))
171
172 # find source directory for package. This can either be <srcdir>/<package>
173 # or <objdir>/temp-src/<package>
174
175 find-package-srcdir = $(shell \
176   if [ -f $(srcdir)/../$(firstword $(subst -, ,$1))/$(strip $1)/configure ]; then \
177      echo $(PACKAGE_TO_SRCDIR)/../$(firstword $(subst -, ,$1))/$(strip $1); \
178   elif [ -f $(abs_builddir)/temp-src/$(strip $1)/configure ]; then \
179     echo $(abs_builddir)/temp-src/$(strip $1) ; \
180   else \
181     echo 'error cannot find $(strip $1)' ; \
182   fi)
183
184 # Set effective <build>, <host> and <target>.
185
186 ifneq ($(build_alias),)
187 cur_build := $(build_alias)
188 else
189 cur_build := $(build)
190 endif
191
192 ifneq ($(host_alias),)
193 cur_host := $(host_alias)
194 else
195 cur_host := $(host)
196 endif
197
198 ifneq ($(target_alias),)
199 cur_target := $(target_alias)
200 else
201 cur_target := $(target)
202 endif
203
204 # Define environment variables for canadian cross build.
205 ifneq ($(cur_host),$(cur_build))
206 CFLAGS_FOR_BUILD ?= $(CFLAGS)
207 LDFLAGS_FOR_BUILD ?= $(LDFLAGS)
208 canadian_build_env := \
209         export CC_FOR_BUILD=$(cur_build)-gcc ; \
210         export CXX_FOR_BUILD=$(cur_build)-g++ ; \
211         export CC=$(cur_build)-gcc ; \
212         export CXX=$(cur_build)-g++ ; \
213         export CFLAGS="$(CFLAGS_FOR_BUILD)" ; \
214         export LDFLAGS="$(LDFLAGS_FOR_BUILD)" ;
215
216 CANADIAN_ROOT := $(PWD)/host-${cur_build}
217 canadian_env := \
218         export CC_FOR_BUILD=$(cur_build)-gcc ; \
219         export CXX_FOR_BUILD=$(cur_build)-g++ ; \
220         export CC=$(cur_host)-gcc ; \
221         export CXX=$(cur_host)-g++ ; \
222         export AR=$(cur_host)-ar ; \
223         export RANLIB=$(cur_host)-ranlib ; \
224         export PATH="$(CANADIAN_ROOT)/install/bin:${PATH}" ;
225 endif
226
227 #
228 # Make rules
229 #
230
231 .PHONY: all clean
232
233 all: build
234
235 # top level
236 ifeq ($(ENABLE_GRAPHITE),yes)
237 build: install-host-cloog
238 endif
239 build: build-target-binutils build-host-libbfd build-target-gcc \
240         build-target-gdb
241
242 install: install-target-binutils install-host-libbfd install-target-gcc \
243         install-target-gdb
244
245 # To support canadian cross build we need to build build->target toolchain
246 # as well as final host->target toolchain.
247 ifneq ($(cur_host),$(cur_build))
248 .PHONY: config-canadian-tools build-canadian-tools install-canadian-tools
249
250 config-canadian-tools: stmp-config-canadian-tools
251 stmp-config-canadian-tools:
252         ([ -d $(CANADIAN_ROOT) ] || \
253           mkdir $(CANADIAN_ROOT)) && \
254         ($(canadian_build_env) \
255          cd $(CANADIAN_ROOT) && \
256          $(abs_srcdir)/configure $(baseargs) --with-gdb-version=none --build=$(cur_build) \
257                 --host=$(cur_build) --target=$(cur_target))  && \
258         $(STAMP) $@
259
260 build-canadian-tools: stmp-build-canadian-tools
261 stmp-build-canadian-tools: stmp-config-canadian-tools
262         ($(canadian_build_env) \
263          cd $(CANADIAN_ROOT) && \
264          $(MAKE)) && \
265         $(STAMP) $@
266
267 install-canadian-tools: stmp-install-canadian-tools
268 stmp-install-canadian-tools: stmp-build-canadian-tools
269         ($(canadian_build_env) \
270          cd $(CANADIAN_ROOT) && \
271          $(MAKE) -j1 install prefix=$(CANADIAN_ROOT)/install) && \
272         $(STAMP) $@
273
274 # When building canadian cross toolchain we cannot build GCC target libraries.
275 # So we build the compilers only and copy the target libaries from
276 # $(CANADIAN_ROOT)/install/ installation.
277 gcc_build_target := all-gcc
278 gcc_install_target := install-gcc
279 install-target-gcc-multilibs: stmp-install-canadian-tools
280         mkdir -p $(prefix)/lib/gcc/
281         rsync -a $(CANADIAN_ROOT)/install/lib/gcc/ $(prefix)/lib/gcc/
282 install-target-gcc-multilibs := install-target-gcc-multilibs
283
284 # We add canadian_stmp dependency to rules that have no dependencies
285 # on other modules.  This is to ensure that simple cross toolchain is built
286 # before canadian cross toolchain.
287 canadian_stmp := stmp-install-canadian-tools
288 else
289 gcc_build_target :=
290 gcc_install_target := install
291 install-target-gcc-multilibs :=
292 canadian_stmp :=
293 endif
294
295 ifneq ($(BINUTILS_VERSION), $(GOLD_VERSION))
296 build: build-target-gold
297 install: install-target-gold
298 endif
299
300 # target binutils rules
301 .PHONY: config-target-binutils build-target-binutils install-target-binutils
302 config-target-binutils: stmp-config-target-binutils
303 # We do not want to enable shared libraries in binutils
304 BINUTILS_CONFIG_ARGS=--prefix=$(prefix) \
305         --target=${cur_target} --host=${cur_host} --build=${cur_build} \
306         $(baseargs) --disable-shared --disable-nls
307 ifeq ($(ENABLE_GRAPHITE),yes)
308 BINUTILS_CONFIG_ARGS+= --with-cloog=${CLOOG_DIR} --with-isl=${ISL_DIR} --with-isl=${ISL_DIR} --with-gmp=${GMP_DIR} \
309         --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check $(CLOOG_BACKEND)
310 # links to the static C++ runtime to avoid depending on the host version
311 ifneq ($(host_os),darwin)
312 BINUTILS_CONFIG_ARGS+= \
313         '--with-host-libstdcxx=-static-libgcc \
314          -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
315          --with-gold-ldflags='-static-libgcc -static-libstdc++'
316 else
317 # In darwin ld doesn't allow both -static and -dynamic.  Instead, we rely on explicit
318 # "-isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)" to establish
319 # minimal sdk version toolchain will run
320 GCC_CONFIG_ARGS += '--with-host-libstdcxx=-static-libgcc -lstdc++ -lm'
321 endif
322 endif
323 # Enable dual linker support and make gold as default linker when gold is
324 # enabled. Notice that our binutils take different --enable-gold=xxx options.
325 ifneq ($(ENABLE_GOLD),)
326 ifeq ($(BINUTILS_MIN_VERSION_2_21),yes)
327 ifeq ($(ENABLE_LD_DEFAULT),)
328 BINUTILS_CONFIG_ARGS += --enable-gold=default
329 endif
330 else
331 ifeq ($(ENABLE_LD_DEFAULT),)
332 BINUTILS_CONFIG_ARGS += --enable-gold=both/gold
333 else
334 BINUTILS_CONFIG_ARGS += --enable-gold=both/ld
335 endif
336 endif
337 endif
338 stmp-config-target-binutils: config.status stmp-install-host-ppl stmp-install-host-isl $(canadian_stmp)
339         ([ -d ${BINUTILS_VERSION} ] || \
340           mkdir ${BINUTILS_VERSION}) && \
341         ($(canadian_env) \
342          cd ${BINUTILS_VERSION} ; \
343          $(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
344           $(BINUTILS_CONFIG_ARGS)) && \
345         $(STAMP) $@
346 build-target-binutils: stmp-build-target-binutils
347 stmp-build-target-binutils: stmp-config-target-binutils
348         ($(canadian_env) \
349          $(MAKE) -C ${BINUTILS_VERSION}) && $(STAMP) $@
350 install-target-binutils: stmp-build-target-binutils
351         ($(canadian_env) \
352          $(MAKE) -C ${BINUTILS_VERSION} install)
353
354 # target gold rules.  We need these only if BINUTILS_VERSION != GOLD_VERSION
355 ifneq ($(BINUTILS_VERSION), $(GOLD_VERSION))
356 .PHONY: config-target-gold build-target-gold install-target-gold
357 config-target-gold: stmp-config-target-gold
358 # We do not want to enable shared libraries in gold
359 GOLD_CONFIG_ARGS=--prefix=$(prefix) \
360         --target=${target_alias} --host=${host} --build=${build} \
361         $(baseargs) --disable-shared
362 ifeq ($(GOLD_MIN_VERSION_2_21),yes)
363         GOLD_CONFIG_ARGS += --enable-gold=default
364 else
365         GOLD_CONFIG_ARGS += --enable-gold=both/gold
366 endif
367 stmp-config-target-gold: config.status
368         ([ -d ${GOLD_VERSION} ] || \
369           mkdir ${GOLD_VERSION}) && \
370         (cd ${GOLD_VERSION} ; \
371          $(call find-package-srcdir, ${GOLD_VERSION})/configure \
372           $(GOLD_CONFIG_ARGS)) && \
373         $(STAMP) $@
374 build-target-gold: stmp-build-target-gold
375 stmp-build-target-gold: stmp-config-target-gold
376         ($(canadian_env) \
377      $(MAKE) -C ${GOLD_VERSION} && $(STAMP) $@)
378
379 # If we use a different binutils version of gold, we build gold twice.  We
380 # first build everything, including gold with the main binutils version and
381 # then install it.  Then we build the gold-only binutils version and install
382 # just gold.  We don't bother to skip building the first gold to simplify
383 # handling of all combinations of --enable-gold[=*]
384
385 install-target-gold: stmp-build-target-gold install-target-binutils
386         ($(canadian_env) \
387      make -C $(GOLD_VERSION)/gold install)
388
389 endif
390
391 # build libbfd for host.  We configure with all targets, so this is built
392 # separately from the same source.
393 # Required by Android build, we always build 32bit host libraries, and
394 # put the 32bit host libraries into /lib32.
395 .PHONY: config-host-libbfd build-host-libbfd install-host-libbfd
396 config-host-libbfd: stmp-config-host-libbfd
397 LIBBFD_CONFIG_ARGS=--prefix=$(prefix) \
398         --target=${target_alias} --host=${host} --build=${build} \
399         $(host_baseargs) --disable-shared \
400         --enable-install-libbfd --with-included-gettext
401 stmp-config-host-libbfd: config.status
402         ([ -d libbfd-${BINUTILS_VERSION} ] || \
403           mkdir libbfd-${BINUTILS_VERSION}) && \
404         (cd libbfd-${BINUTILS_VERSION} ; \
405          export CFLAGS="$(CFLAGS) -m32" ; \
406          $(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
407           $(LIBBFD_CONFIG_ARGS)) && \
408         $(STAMP) $@
409 build-host-libbfd: stmp-build-host-libbfd
410 stmp-build-host-libbfd: stmp-config-host-libbfd
411         $(MAKE) -C libbfd-${BINUTILS_VERSION} all-bfd all-libiberty && \
412         $(MAKE) -C libbfd-${BINUTILS_VERSION}/intl libintl.a && \
413         $(STAMP) $@
414 # Also include libintl.a.  We have to do this manully since the
415 # source of libintl in binutils is modified to not install the library.
416 # We build with -m32 always, and install host libs into /lib32.
417 LIB32DIR=$(libdir)32
418 install-host-libbfd: stmp-build-host-libbfd install-target-binutils
419         $(MAKE) -C libbfd-${BINUTILS_VERSION}/bfd install \
420                 bfdlibdir=$(LIB32DIR) bfdincludedir=$(includedir) && \
421         $(INSTALL_DATA) libbfd-${BINUTILS_VERSION}/intl/libintl.a \
422                 $(LIB32DIR) && \
423         $(INSTALL_DATA) libbfd-${BINUTILS_VERSION}/libiberty/libiberty.a \
424                 $(LIB32DIR)
425
426 # target gcc rules
427 .PHONY: config-target-gcc build-target-gcc install-target-gcc
428 .PHONY: install-target-gcc-gcc $(install-target-gcc-multilibs)
429 config-target-gcc: stmp-config-target-gcc
430
431 GCC_CONFIG_ARGS=--prefix=$(prefix) \
432           --target=${cur_target} --host=${cur_host} --build=${cur_build} \
433           --with-gnu-as --with-gnu-ld --enable-languages=c,c++
434
435 # For gcc versions 4.3.0 and later, gmp and mpfr are required.
436 # Also build libgcc is a seperate sub-target in 4.3.0+.
437 ifeq ($(GCC_MIN_VERSION_4_3_0),yes)
438 stmp-config-target-gcc: stmp-install-host-gmp stmp-install-host-mpfr
439 GCC_CONFIG_ARGS += --with-gmp=$(GMP_DIR) --with-mpfr=$(MPFR_DIR)
440 endif
441
442 # For gcc versions 4.5.0 and higher, mpc is required.
443 ifeq ($(GCC_MIN_VERSION_4_5_0),yes)
444 stmp-config-target-gcc: stmp-install-host-mpc
445 GCC_CONFIG_ARGS += --with-mpc=$(MPC_DIR)
446 endif
447
448 # For gcc 4.5 and 4.6 with graphite optimization, cloog and ppl are required.
449 # For gcc 4.8+ with graphite optimization, cloog and isl are required.
450 ifeq ($(ENABLE_GRAPHITE),yes)
451 GCC_CONFIG_ARGS += --with-cloog=${CLOOG_DIR} --with-isl=${ISL_DIR} --with-ppl=${PPL_DIR} \
452         --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check $(CLOOG_BACKEND)
453 # links to the static C++ runtime to avoid depending on the host version
454 ifneq ($(host_os),darwin)
455 GCC_CONFIG_ARGS += \
456         '--with-host-libstdcxx=-static-libgcc \
457          -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
458 else
459 # In darwin ld doesn't allow both -static and -dynamic.  Instead, we rely on explicit
460 # "-isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)" to establish
461 # minimal sdk version toolchain will run
462 GCC_CONFIG_ARGS += '--with-host-libstdcxx=-static-libgcc -lstdc++ -lm'
463 endif
464 else
465 # Disable ppl, isl and cloog just in case the host have them install.
466 GCC_CONFIG_ARGS += --without-ppl --without-cloog --without-isl
467 endif
468
469 # Add Android specific gcc options.
470 # FIXME: These should be overridable by configure options.
471
472
473 # Target indenpendent Android gcc options.
474 ifeq ($(BUILD_ANDROID_GCC),yes)
475 GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \
476         --enable-threads --disable-nls --disable-libmudflap --disable-libgomp \
477         --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared \
478         --disable-tls --disable-libitm
479
480 CFLAGS_FOR_TARGET += -DTARGET_POSIX_IO -fno-short-enums
481
482 ifeq ($(target_cpu),i686)
483 GCC_CONFIG_ARGS += --with-arch=i686 --with-tune=intel --with-fpmath=sse
484 endif
485
486 ifeq ($(target_cpu),x86_64)
487 GCC_CONFIG_ARGS += --with-arch=x86-64 --with-tune=intel --with-fpmath=sse \
488                    --with-multilib-list=m32,m64,mx32
489 endif
490
491 # ARM specific options.
492 ifeq ($(target_cpu),arm)
493 GCC_CONFIG_ARGS += --with-float=soft --with-fpu=vfp --with-arch=armv5te \
494         --enable-target-optspace
495
496 ifneq ($(target_os),linux-androideabi)
497 GCC_CONFIG_ARGS += --with-abi=aapcs
498 endif
499 endif
500
501 endif
502
503 # We add the baseargs and the end so that they override any default args
504 GCC_CONFIG_ARGS += $(baseargs)
505
506 # Add user specified --enable-gold=xxx option to gcc
507 ifneq ($(ENABLE_GOLD),)
508 GCC_CONFIG_ARGS += $(ENABLE_GOLD)
509 endif
510
511 # We have to add -mandroid in target CFLAGS and CXXFLAGS
512 stmp-config-target-gcc: config.status stmp-install-host-ppl stmp-install-host-isl stmp-install-host-cloog stmp-build-target-binutils
513         ([ -d ${GCC_VERSION} ] || \
514           mkdir ${GCC_VERSION}) && \
515         ($(canadian_env) \
516          cd ${GCC_VERSION} ; \
517          $(TARGET_BINUTILS_EXPORTS) ; \
518          export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" ; \
519          export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" ; \
520          export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \
521          $(call find-package-srcdir, ${GCC_VERSION})/configure \
522            $(GCC_CONFIG_ARGS)) && \
523         $(STAMP) $@
524 build-target-gcc: stmp-build-target-gcc
525 stmp-build-target-gcc: stmp-config-target-gcc
526         ($(canadian_env) \
527          $(MAKE) -C ${GCC_VERSION} \
528                 CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
529                 CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
530                 LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \
531                 $(gcc_build_target)) \
532         && $(STAMP) $@
533 install-target-gcc-gcc: stmp-build-target-gcc
534         ($(canadian_env) \
535          $(MAKE) -C ${GCC_VERSION} $(gcc_install_target))
536 install-target-gcc: install-target-gcc-gcc $(install-target-gcc-multilibs)
537
538 # minimal gcc rules
539 # minimal gcc only builds the C and C++ compilers and libgcc
540 # We use the full gcc configure rules.
541 .PHONY: build-target-minimal-gcc install-target-minimal-gcc
542 ifeq ("$(GCC_MIN_VERSION_4_3_0)","yes")
543 MINIMAL_GCC_BUILD_TARGETS:= gcc target-libgcc 
544 else
545 MINIMAL_GCC_BUILD_TARGETS:= gcc
546 endif
547
548 build-target-minimal-gcc: stmp-build-target-minimal-gcc
549 stmp-build-target-minimal-gcc: stmp-config-target-gcc
550         ($(canadian_env) \
551          $(MAKE) -C ${GCC_VERSION} \
552                 $(call prefix-list, all-, $(MINIMAL_GCC_BUILD_TARGETS))) && \
553         $(STAMP) $@
554 install-target-minimal-gcc: stmp-build-target-minimal-gcc
555         ($(canadian_env) \
556          $(MAKE) -C ${GCC_VERSION} \
557                 $(call prefix-list, install-, $(MINIMAL_GCC_BUILD_TARGETS)))
558
559 # target newlib rules
560 .PHONY: config-target-newlib build-target-newlib install-target-newlib
561 config-target-newlib: stmp-config-target-newlib
562 NEWLIB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
563           --target=${cur_target} --host=${cur_host} --build=${cur_build}
564
565 stmp-config-target-newlib: stmp-build-target-binutils \
566                            stmp-build-target-minimal-gcc
567         ([ -d ${NEWLIB_VERSION} ] || \
568           mkdir ${NEWLIB_VERSION}) && \
569         ($(canadian_env) \
570          cd ${NEWLIB_VERSION} ; \
571          $(TARGET_BINUTILS_EXPORTS) ; \
572          $(TARGET_MINIMAL_GCC_EXPORTS) ; \
573          $(call find-package-srcdir, ${NEWLIB_VERSION})/configure \
574           $(NEWLIB_CONFIG_ARGS)) && \
575         $(STAMP) $@
576 stmp-build-target-newlib: stmp-config-target-newlib
577         ($(canadian_env) \
578          $(MAKE) -C ${NEWLIB_VERSION}) && $(STAMP) $@
579 install-target-newlib: stmp-build-target-newlib
580         ($(canadian_env) \
581          $(MAKE) -C ${NEWLIB_VERSION} install)
582
583 # host gmp rules
584 .PHONY: config-host-gmp build-host-gmp install-host-gmp
585 config-host-gmp: stmp-config-host-gmp
586 GMP_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
587           --host=${cur_host} --build=${cur_build}
588
589 ifeq ($(ENABLE_GRAPHITE),yes)
590 GMP_CONFIG_ARGS+= --enable-cxx
591 endif
592
593 stmp-config-host-gmp: config.status $(canadian_stmp)
594         ([ -d ${GMP_VERSION} ] || \
595           mkdir ${GMP_VERSION}) && \
596         ($(canadian_env) \
597          cd ${GMP_VERSION} ; \
598          $(call find-package-srcdir, ${GMP_VERSION})/configure \
599           $(GMP_CONFIG_ARGS)) && \
600         $(STAMP) $@
601 stmp-build-host-gmp: stmp-config-host-gmp
602         ($(canadian_env) \
603          $(MAKE) -C ${GMP_VERSION}) && $(STAMP) $@
604 build-host-gmp: stmp-build-host-gmp
605 # Need -j1 to avoid a race condition in building on OS X.
606 ifeq ($(HAVE_GMP),no)
607 stmp-install-host-gmp: stmp-build-host-gmp
608         $(MAKE) -C ${GMP_VERSION} install -j1 && $(STAMP) $@
609 else
610 stmp-install-host-gmp:
611 endif
612 install-host-gmp: stmp-install-host-gmp
613
614 # host mpfr rules
615 .PHONY: config-host-mpfr build-host-mpfr install-host-mpfr
616 config-host-mpfr: stmp-config-host-mpfr
617 MPFR_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
618           --host=${cur_host} --build=${cur_build} \
619           --with-gmp=$(GMP_DIR)
620 stmp-config-host-mpfr: config.status stmp-install-host-gmp
621         ([ -d ${MPFR_VERSION} ] || \
622           mkdir ${MPFR_VERSION}) && \
623         ($(canadian_env) \
624          cd ${MPFR_VERSION} ; \
625          $(call find-package-srcdir, ${MPFR_VERSION})/configure \
626           $(MPFR_CONFIG_ARGS)) && \
627         $(STAMP) $@
628 stmp-build-host-mpfr: stmp-config-host-mpfr
629         ($(canadian_env) \
630          $(MAKE) -C ${MPFR_VERSION}) && $(STAMP) $@
631 build-host-mpfr: stmp-build-host-mpfr
632 ifeq ($(HAVE_MPFR),no)
633 stmp-install-host-mpfr: stmp-build-host-mpfr
634         $(MAKE) -C ${MPFR_VERSION} install && $(STAMP) $@
635 else
636 stmp-install-host-mpfr:
637 endif
638 install-host-mpfr: stmp-install-host-mpfr
639
640 # host mpc rules
641 .PHONY: config-host-mpc build-host-mpc install-host-mpc
642 config-host-mpc: stmp-config-host-mpc
643 MPC_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
644          --host=${cur_host} --build=${cur_build} \
645          --with-gmp=$(GMP_DIR) --with-mpfr=$(MPFR_DIR)
646 stmp-config-host-mpc: config.status stmp-install-host-gmp stmp-install-host-mpfr
647         ([ -d ${MPC_VERSION} ] || \
648           mkdir ${MPC_VERSION}) && \
649         ($(canadian_env) \
650          cd ${MPC_VERSION} ; \
651          $(call find-package-srcdir, ${MPC_VERSION})/configure \
652           $(MPC_CONFIG_ARGS)) && \
653         $(STAMP) $@
654 stmp-build-host-mpc: stmp-config-host-mpc
655         ($(canadian_env) \
656          $(MAKE) -C ${MPC_VERSION}) && $(STAMP) $@
657 build-host-mpc: stmp-build-host-mpc
658 ifeq ($(HAVE_MPC),no)
659 stmp-install-host-mpc: stmp-build-host-mpc
660         $(MAKE) -C ${MPC_VERSION} install && $(STAMP) $@
661 else
662 stmp-install-host-mpc:
663 endif
664 install-host-mpc: stmp-install-host-mpc
665
666 # host ppl rules
667 .PHONY: config-host-ppl build-host-ppl install-host-ppl
668 config-host-ppl: stmp-config-host-ppl
669 PPL_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
670           --target=${target_alias} \
671           --host=${host} --build=${build} \
672           --disable-nls \
673           --disable-watchdog --without-java \
674           --disable-ppl_lcdd --disable-ppl_lpsol --disable-ppl_pips
675 stmp-config-host-ppl: config.status stmp-install-host-gmp
676         ([ -d ${PPL_VERSION} ] || \
677          mkdir ${PPL_VERSION}) && \
678         ($(canadian_env) \
679          cd ${PPL_VERSION} ; \
680          export CFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
681          export CXXFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
682          export LDFLAGS="${LDFLAGS} -L$(GMP_DIR)/lib" ; \
683         $(call find-package-srcdir, ${PPL_VERSION})/configure \
684          $(PPL_CONFIG_ARGS)) && \
685         $(STAMP) $@
686 stmp-build-host-ppl: stmp-config-host-ppl
687         $(MAKE) -C ${PPL_VERSION} && $(STAMP) $@
688 build-host-ppl: stmp-build-host-ppl
689
690 ifeq ($(ENABLE_GRAPHITE),yes)
691 stmp-install-host-ppl: stmp-build-host-ppl
692         $(MAKE) -C ${PPL_VERSION} install && \
693         $(STAMP) $@
694 else
695 stmp-install-host-ppl:
696         $(STAMP) $@
697 endif
698 install-host-ppl: stmp-install-host-ppl
699
700 # host isl rules
701 .PHONY: config-host-isl build-host-isl install-host-isl
702 config-host-isl: stmp-config-host-isl
703 ISL_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
704           --target=${target_alias} \
705           --host=${host} --build=${build} \
706           --disable-nls
707 stmp-config-host-isl: config.status stmp-install-host-gmp
708         ([ -d ${ISL_VERSION} ] || \
709          mkdir ${ISL_VERSION}) && \
710         ($(canadian_env) \
711          cd ${ISL_VERSION} ; \
712          export CFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
713          export CXXFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
714          export LDFLAGS="${LDFLAGS} -L$(GMP_DIR)/lib" ; \
715         $(call find-package-srcdir, ${ISL_VERSION})/configure \
716          $(ISL_CONFIG_ARGS)) && \
717         $(STAMP) $@
718 stmp-build-host-isl: stmp-config-host-isl
719         $(MAKE) -C ${ISL_VERSION} && $(STAMP) $@
720 build-host-isl: stmp-build-host-isl
721
722 ifeq ($(ENABLE_GRAPHITE)$(GCC_MIN_VERSION_4_8_0),yesyes)
723 stmp-install-host-isl: stmp-build-host-isl
724         $(MAKE) -C ${ISL_VERSION} install && \
725         $(STAMP) $@
726 else
727 stmp-install-host-isl:
728         $(STAMP) $@
729 endif
730 install-host-isl: stmp-install-host-isl
731
732 # host cloog rules
733 .PHONY: config-host-cloog build-host-cloog install-host-cloog
734 config-host-cloog: stmp-config-host-cloog
735 CLOOG_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
736           --target=${target_alias} \
737           --host=${host} --build=${build} \
738           --disable-nls
739 # for cloog-ppl version 0.15.x, ppl is required.
740 ifneq ($(findstring ppl-,$(CLOOG_VERSION)),)
741 CLOOG_TARGET = libcloog.la
742 stmp-config-host-cloog: config.status stmp-install-host-ppl \
743           stmp-install-host-ppl-workaround
744 stmp-install-host-ppl-workaround:
745         # cloog 0.15.9 is unable to detect newer versions of ppl.
746         # Thus we modify the version definition in header file to satisfy.
747         sed -i -e 's/PPL_VERSION_MINOR 11/PPL_VERSION_MINOR 10/' \
748           $(PPL_DIR)/include/ppl_c.h
749         $(STAMP) $@
750 CLOOG_CONFIG_ARGS+= --with-gmp=$(GMP_DIR) --with-ppl=$(PPL_DIR)
751 else
752 CLOOG_TARGET = libcloog-isl.la
753 CLOOG_CONFIG_ARGS+= --with-gmp-prefix=$(GMP_DIR)
754 endif
755 stmp-config-host-cloog: config.status stmp-install-host-gmp
756         ([ -d ${CLOOG_VERSION} ] || \
757          mkdir ${CLOOG_VERSION}) && \
758         ($(canadian_env) \
759          cd ${CLOOG_VERSION} ; \
760         $(call find-package-srcdir, ${CLOOG_VERSION})/configure \
761          $(CLOOG_CONFIG_ARGS)) && \
762         $(STAMP) $@
763 stmp-build-host-cloog: stmp-config-host-cloog
764         # Ignore the generation of cloog utilities
765         $(MAKE) -C ${CLOOG_VERSION} $(CLOOG_TARGET) && \
766         $(STAMP) $@
767 build-host-cloog: stmp-build-host-cloog
768
769 ifeq ($(ENABLE_GRAPHITE),yes)
770 stmp-install-host-cloog: stmp-build-host-cloog
771         $(MAKE) -C ${CLOOG_VERSION} install-libLTLIBRARIES \
772                 install-pkgincludeHEADERS
773 ifeq ($(findstring ppl-,$(CLOOG_VERSION)),)
774         $(MAKE) -C ${CLOOG_VERSION}/isl install-libLTLIBRARIES \
775                 install-pkgincludeHEADERS
776 endif
777 ifeq ($(GCC_MIN_VERSION_4_8_0),yes)
778         $(MAKE) -C ${CLOOG_VERSION} install
779 endif
780         $(STAMP) $@
781 else
782 stmp-install-host-cloog:
783         $(STAMP) $@
784 endif
785 install-host-cloog: stmp-install-host-cloog
786
787 # host expat rules
788 .PHONY: config-host-expat build-host-expat install-host-expat
789 config-host-expat: stmp-config-host-expat
790 EXPAT_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
791         --host=${cur_host} --build=${cur_build}
792 stmp-config-host-expat: config.status  $(canadian_stmp)
793         ([ -d ${EXPAT_VERSION} ] || \
794           mkdir ${EXPAT_VERSION}) && \
795         ($(canadian_env) \
796          cd ${EXPAT_VERSION} ; \
797          $(call find-package-srcdir, ${EXPAT_VERSION})/configure \
798           $(EXPAT_CONFIG_ARGS)) && \
799         $(STAMP) $@
800 stmp-build-host-expat: stmp-config-host-expat
801         ($(canadian_env) \
802          $(MAKE) -C ${EXPAT_VERSION}) && $(STAMP) $@
803 build-host-expat: stmp_build-host-expat
804 ifeq ($(HAVE_EXPAT),no)
805 stmp-install-host-expat: stmp-build-host-expat
806         $(MAKE) -C ${EXPAT_VERSION} install -j1 && $(STAMP) $@
807 else
808 stmp-install-host-expat:
809 endif
810 install-host-expat: stmp-install-host-expat
811
812 # target gdb rules
813 .PHONY: config-target-gdb build-target-gdb install-target-gdb
814 ifeq ($(GDB_VERSION),gdb-none)
815 config-target-gdb:
816 build-target-gdb:
817 install-target-gdb:
818 else
819 config-target-gdb: stmp-config-target-gdb
820
821 GDB_CONFIG_ARGS=$(host_baseargs) --prefix=$(prefix) \
822         --target=$(GDB_TARGET) --host=${cur_host} --build=${cur_build} \
823         $(WITH_PYTHON) --disable-nls
824
825 # For gdb versions 7.2 and higher, expat is required.
826 ifeq ($(GDB_MIN_VERSION_7_2),yes)
827 stmp-config-target-gdb: stmp-install-host-expat
828 GDB_CONFIG_ARGS += --with-expat --with-libexpat-prefix=$(EXPAT_DIR)
829 endif
830
831 stmp-config-target-gdb: config.status $(canadian_stmp)
832         ([ -d ${GDB_VERSION} ] || \
833           mkdir ${GDB_VERSION}) && \
834         ($(canadian_env) \
835          cd ${GDB_VERSION} ; \
836          $(call find-package-srcdir, ${GDB_VERSION})/configure \
837           $(GDB_CONFIG_ARGS)) && \
838         $(STAMP) $@
839 build-target-gdb: stmp-build-target-gdb
840 stmp-build-target-gdb: stmp-config-target-gdb
841         ($(canadian_env) \
842          $(MAKE) -C ${GDB_VERSION}) && $(STAMP) $@
843 install-target-gdb: stmp-build-target-gdb
844         ($(canadian_env) \
845          $(MAKE) -C ${GDB_VERSION} install)
846 endif
847
848 # clean rules
849 .PHONY: clean
850 clean:
851         $(RM) -r $(TEMP_INSTALLDIR) stmp-build-* stmp-install-* && \
852         for sub in [ * ]; do \
853           if [ -f $$sub/Makefile ]; then \
854             $(MAKE) -C $$sub clean ; \
855           fi; \
856         done
857
858 .PHONY: distclean
859 distclean:
860         @$(RM) -r config.log config.status \
861                   $(TEMP_INSTALLDIR) temp-src \
862                   stmp-config-* stmp-build-* stmp-install-* && \
863         for sub in [ * ]; do \
864           if [ -f $$sub/config.status ]; then \
865             echo "Deleting " $$sub "..." && $(RM) -r $$sub ; \
866           fi; \
867         done
868         @$(RM) Makefile