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