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