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