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