Update build scripts
[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 .PHONY: config-host-libbfd build-host-libbfd install-host-libbfd
358 config-host-libbfd: stmp-config-host-libbfd
359 LIBBFD_CONFIG_ARGS=--prefix=$(prefix) \
360         --target=${target_alias} --host=${host} --build=${build} \
361         $(baseargs) --disable-shared \
362         --enable-install-libbfd --with-included-gettext
363 stmp-config-host-libbfd: config.status
364         ([ -d libbfd-${BINUTILS_VERSION} ] || \
365           mkdir libbfd-${BINUTILS_VERSION}) && \
366         (cd libbfd-${BINUTILS_VERSION} ; \
367          $(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
368           $(LIBBFD_CONFIG_ARGS)) && \
369         $(STAMP) $@
370 build-host-libbfd: stmp-build-host-libbfd
371 stmp-build-host-libbfd: stmp-config-host-libbfd
372         $(MAKE) -C libbfd-${BINUTILS_VERSION} all-bfd all-libiberty && \
373         $(MAKE) -C libbfd-${BINUTILS_VERSION}/intl libintl.a && \
374         $(STAMP) $@
375 # Also include libintl.a.  We have to do this manully since the
376 # source of libintl in binutils is modified to not install the library.
377 # We build with -m32 always.  To avoid installing libiberty.a into /lib32,
378 # we need to manually install the archive.  This will need to be cleaned up.
379 install-host-libbfd: stmp-build-host-libbfd install-target-binutils
380         $(MAKE) -C libbfd-${BINUTILS_VERSION}/bfd install \
381                 bfdlibdir=$(libdir) bfdincludedir=$(includedir) && \
382         $(INSTALL_DATA) libbfd-${BINUTILS_VERSION}/intl/libintl.a \
383                 $(libdir) && \
384         $(INSTALL_DATA) libbfd-${BINUTILS_VERSION}/libiberty/libiberty.a \
385                 $(libdir)
386
387 # target gcc rules
388 .PHONY: config-target-gcc build-target-gcc install-target-gcc
389 .PHONY: install-target-gcc-gcc $(install-target-gcc-multilibs)
390 config-target-gcc: stmp-config-target-gcc
391
392 GCC_CONFIG_ARGS=--prefix=$(prefix) \
393           --target=${cur_target} --host=${cur_host} --build=${cur_build} \
394           --with-gnu-as --with-gnu-ld --enable-languages=c,c++
395
396 # For gcc versions 4.3.0 and later, gmp and mpfr are required.
397 # Also build libgcc is a seperate sub-target in 4.3.0+.
398 ifeq ($(GCC_MIN_VERSION_4_3_0),yes)
399 stmp-config-target-gcc: stmp-install-host-gmp stmp-install-host-mpfr
400 GCC_CONFIG_ARGS += --with-gmp=$(GMP_DIR) --with-mpfr=$(MPFR_DIR)
401 endif
402
403 # For gcc versions 4.5.0 and higher, mpc is required.
404 ifeq ($(GCC_MIN_VERSION_4_5_0),yes)
405 stmp-config-target-gcc: stmp-install-host-mpc
406 GCC_CONFIG_ARGS += --with-mpc=$(MPC_DIR)
407 endif
408
409 # For gcc 4.5+ with graphite optimization, cloog and ppl are required.
410 ifeq ($(ENABLE_GRAPHITE),yes)
411 GCC_CONFIG_ARGS += --with-cloog=${CLOOG_DIR} --with-ppl=${PPL_DIR} \
412         --disable-ppl-version-check --disable-cloog-version-check
413 # links to the static C++ runtime to avoid depending on the host version
414 GCC_CONFIG_ARGS += \
415         '--with-host-libstdcxx=-static-libgcc \
416          -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
417 else
418 # Disable ppl and cloog just in case the host have them install.
419 GCC_CONFIG_ARGS += --without-ppl --without-cloog
420 endif
421
422 # Add Android specific gcc options.
423 # FIXME: These should be overridable by configure options.
424
425
426 # Target indenpendent Android gcc options.
427 ifeq ($(BUILD_ANDROID_GCC),yes)
428 GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \
429         --enable-threads --disable-nls --disable-libmudflap --disable-libgomp \
430         --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared \
431         --disable-tls --disable-libitm
432
433 CFLAGS_FOR_TARGET += -DTARGET_POSIX_IO -fno-short-enums
434 # ARM specific options.
435 ifeq ($(target_cpu),arm)
436 GCC_CONFIG_ARGS += --with-float=soft --with-fpu=vfp --with-arch=armv5te \
437         --enable-target-optspace
438
439 ifneq ($(target_os),linux-androideabi)
440 GCC_CONFIG_ARGS += --with-abi=aapcs
441 endif
442 endif
443
444 endif
445
446 # We add the baseargs and the end so that they override any default args
447 GCC_CONFIG_ARGS += $(baseargs)
448
449 # Add user specified --enable-gold=xxx option to gcc
450 ifneq ($(ENABLE_GOLD),)
451 GCC_CONFIG_ARGS += $(ENABLE_GOLD)
452 endif
453
454 # We have to add -mandroid in target CFLAGS and CXXFLAGS
455 stmp-config-target-gcc: config.status stmp-build-target-binutils
456         ([ -d ${GCC_VERSION} ] || \
457           mkdir ${GCC_VERSION}) && \
458         ($(canadian_env) \
459          cd ${GCC_VERSION} ; \
460          $(TARGET_BINUTILS_EXPORTS) ; \
461          export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" ; \
462          export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" ; \
463          export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \
464          $(call find-package-srcdir, ${GCC_VERSION})/configure \
465            $(GCC_CONFIG_ARGS)) && \
466         $(STAMP) $@
467 build-target-gcc: stmp-build-target-gcc
468 stmp-build-target-gcc: stmp-config-target-gcc
469         ($(canadian_env) \
470          $(MAKE) -C ${GCC_VERSION} \
471                 CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
472                 CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
473                 LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \
474                 $(gcc_build_target)) \
475         && $(STAMP) $@
476 install-target-gcc-gcc: stmp-build-target-gcc
477         ($(canadian_env) \
478          $(MAKE) -C ${GCC_VERSION} $(gcc_install_target))
479 install-target-gcc: install-target-gcc-gcc $(install-target-gcc-multilibs)
480
481 # minimal gcc rules
482 # minimal gcc only builds the C and C++ compilers and libgcc
483 # We use the full gcc configure rules.
484 .PHONY: build-target-minimal-gcc install-target-minimal-gcc
485 ifeq ("$(GCC_MIN_VERSION_4_3_0)","yes")
486 MINIMAL_GCC_BUILD_TARGETS:= gcc target-libgcc 
487 else
488 MINIMAL_GCC_BUILD_TARGETS:= gcc
489 endif
490
491 build-target-minimal-gcc: stmp-build-target-minimal-gcc
492 stmp-build-target-minimal-gcc: stmp-config-target-gcc
493         ($(canadian_env) \
494          $(MAKE) -C ${GCC_VERSION} \
495                 $(call prefix-list, all-, $(MINIMAL_GCC_BUILD_TARGETS))) && \
496         $(STAMP) $@
497 install-target-minimal-gcc: stmp-build-target-minimal-gcc
498         ($(canadian_env) \
499          $(MAKE) -C ${GCC_VERSION} \
500                 $(call prefix-list, install-, $(MINIMAL_GCC_BUILD_TARGETS)))
501
502 # target newlib rules
503 .PHONY: config-target-newlib build-target-newlib install-target-newlib
504 config-target-newlib: stmp-config-target-newlib
505 NEWLIB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
506           --target=${cur_target} --host=${cur_host} --build=${cur_build}
507
508 stmp-config-target-newlib: stmp-build-target-binutils \
509                            stmp-build-target-minimal-gcc
510         ([ -d ${NEWLIB_VERSION} ] || \
511           mkdir ${NEWLIB_VERSION}) && \
512         ($(canadian_env) \
513          cd ${NEWLIB_VERSION} ; \
514          $(TARGET_BINUTILS_EXPORTS) ; \
515          $(TARGET_MINIMAL_GCC_EXPORTS) ; \
516          $(call find-package-srcdir, ${NEWLIB_VERSION})/configure \
517           $(NEWLIB_CONFIG_ARGS)) && \
518         $(STAMP) $@
519 stmp-build-target-newlib: stmp-config-target-newlib
520         ($(canadian_env) \
521          $(MAKE) -C ${NEWLIB_VERSION}) && $(STAMP) $@
522 install-target-newlib: stmp-build-target-newlib
523         ($(canadian_env) \
524          $(MAKE) -C ${NEWLIB_VERSION} install)
525
526 # host gmp rules
527 .PHONY: config-host-gmp build-host-gmp install-host-gmp
528 config-host-gmp: stmp-config-host-gmp
529 GMP_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
530           --host=${cur_host} --build=${cur_build}
531
532 ifeq ($(ENABLE_GRAPHITE),yes)
533 GMP_CONFIG_ARGS+= --enable-cxx
534 endif
535
536 stmp-config-host-gmp: config.status $(canadian_stmp)
537         ([ -d ${GMP_VERSION} ] || \
538           mkdir ${GMP_VERSION}) && \
539         ($(canadian_env) \
540          cd ${GMP_VERSION} ; \
541          $(call find-package-srcdir, ${GMP_VERSION})/configure \
542           $(GMP_CONFIG_ARGS)) && \
543         $(STAMP) $@
544 stmp-build-host-gmp: stmp-config-host-gmp
545         ($(canadian_env) \
546          $(MAKE) -C ${GMP_VERSION}) && $(STAMP) $@
547 build-host-gmp: stmp-build-host-gmp
548 # Need -j1 to avoid a race condition in building on OS X.
549 ifeq ($(HAVE_GMP),no)
550 stmp-install-host-gmp: stmp-build-host-gmp
551         $(MAKE) -C ${GMP_VERSION} install -j1 && $(STAMP) $@
552 else
553 stmp-install-host-gmp:
554 endif
555 install-host-gmp: stmp-install-host-gmp
556
557 # host mpfr rules
558 .PHONY: config-host-mpfr build-host-mpfr install-host-mpfr
559 config-host-mpfr: stmp-config-host-mpfr
560 MPFR_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
561           --host=${cur_host} --build=${cur_build} \
562           --with-gmp=$(GMP_DIR)
563 stmp-config-host-mpfr: config.status stmp-install-host-gmp
564         ([ -d ${MPFR_VERSION} ] || \
565           mkdir ${MPFR_VERSION}) && \
566         ($(canadian_env) \
567          cd ${MPFR_VERSION} ; \
568          $(call find-package-srcdir, ${MPFR_VERSION})/configure \
569           $(MPFR_CONFIG_ARGS)) && \
570         $(STAMP) $@
571 stmp-build-host-mpfr: stmp-config-host-mpfr
572         ($(canadian_env) \
573          $(MAKE) -C ${MPFR_VERSION}) && $(STAMP) $@
574 build-host-mpfr: stmp-build-host-mpfr
575 ifeq ($(HAVE_MPFR),no)
576 stmp-install-host-mpfr: stmp-build-host-mpfr
577         $(MAKE) -C ${MPFR_VERSION} install && $(STAMP) $@
578 else
579 stmp-install-host-mpfr:
580 endif
581 install-host-mpfr: stmp-install-host-mpfr
582
583 # host mpc rules
584 .PHONY: config-host-mpc build-host-mpc install-host-mpc
585 config-host-mpc: stmp-config-host-mpc
586 MPC_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
587          --host=${cur_host} --build=${cur_build} \
588          --with-gmp=$(GMP_DIR) --with-mpfr=$(MPFR_DIR)
589 stmp-config-host-mpc: config.status stmp-install-host-gmp stmp-install-host-mpfr
590         ([ -d ${MPC_VERSION} ] || \
591           mkdir ${MPC_VERSION}) && \
592         ($(canadian_env) \
593          cd ${MPC_VERSION} ; \
594          $(call find-package-srcdir, ${MPC_VERSION})/configure \
595           $(MPC_CONFIG_ARGS)) && \
596         $(STAMP) $@
597 stmp-build-host-mpc: stmp-config-host-mpc
598         ($(canadian_env) \
599          $(MAKE) -C ${MPC_VERSION}) && $(STAMP) $@
600 build-host-mpc: stmp-build-host-mpc
601 ifeq ($(HAVE_MPC),no)
602 stmp-install-host-mpc: stmp-build-host-mpc
603         $(MAKE) -C ${MPC_VERSION} install && $(STAMP) $@
604 else
605 stmp-install-host-mpc:
606 endif
607 install-host-mpc: stmp-install-host-mpc
608
609 # host ppl rules
610 .PHONY: config-host-ppl build-host-ppl install-host-ppl
611 config-host-ppl: stmp-config-host-ppl
612 PPL_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
613           --target=${target_alias} \
614           --host=${host} --build=${build} \
615           --disable-nls --with-gmp-prefix=$(GMP_DIR) \
616           --disable-watchdog \
617           --disable-ppl_lcdd --disable-ppl_lpsol --disable-ppl_pips
618 stmp-config-host-ppl: config.status stmp-install-host-gmp
619         ([ -d ${PPL_VERSION} ] || \
620          mkdir ${PPL_VERSION}) && \
621         ($(canadian_env) \
622          cd ${PPL_VERSION} ; \
623         $(call find-package-srcdir, ${PPL_VERSION})/configure \
624          $(PPL_CONFIG_ARGS)) && \
625         $(STAMP) $@
626 stmp-build-host-ppl: stmp-config-host-ppl
627         $(MAKE) -C ${PPL_VERSION} && $(STAMP) $@
628 build-host-ppl: stmp-build-host-ppl
629 stmp-install-host-ppl: stmp-build-host-ppl
630         $(MAKE) -C ${PPL_VERSION} install && \
631         $(STAMP) $@
632 install-host-ppl: stmp-install-host-ppl
633
634 # host cloog rules
635 .PHONY: config-host-cloog build-host-cloog install-host-cloog
636 config-host-cloog: stmp-config-host-cloog
637 CLOOG_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
638           --target=${target_alias} \
639           --host=${host} --build=${build} \
640           --disable-nls \
641           --with-gmp=$(GMP_DIR)
642 # for cloog-ppl version 0.15.x, ppl is required.
643 ifneq ($(findstring ppl-,$(CLOOG_VERSION)),)
644 stmp-config-host-cloog: config.status stmp-install-host-ppl \
645           stmp-install-host-ppl-workaround
646 stmp-install-host-ppl-workaround:
647         # cloog 0.15.9 is unable to detect newer versions of ppl.
648         # Thus we modify the version definition in header file to satisfy.
649         sed -i -e 's/PPL_VERSION_MINOR 11/PPL_VERSION_MINOR 10/' \
650           $(PPL_DIR)/include/ppl_c.h
651         $(STAMP) $@
652 CLOOG_CONFIG_ARGS+= --with-ppl=$(PPL_DIR)
653 endif
654 stmp-config-host-cloog: config.status stmp-install-host-gmp
655         ([ -d ${CLOOG_VERSION} ] || \
656          mkdir ${CLOOG_VERSION}) && \
657         ($(canadian_env) \
658          cd ${CLOOG_VERSION} ; \
659         $(call find-package-srcdir, ${CLOOG_VERSION})/configure \
660          $(CLOOG_CONFIG_ARGS)) && \
661         $(STAMP) $@
662 stmp-build-host-cloog: stmp-config-host-cloog
663         # Ignore the generation of cloog utilities
664         $(MAKE) -C ${CLOOG_VERSION} libcloog.la && \
665         $(STAMP) $@
666 build-host-cloog: stmp-build-host-cloog
667 stmp-install-host-cloog: stmp-build-host-cloog
668         $(MAKE) -C ${CLOOG_VERSION} install-libLTLIBRARIES \
669                 install-pkgincludeHEADERS && \
670         $(STAMP) $@
671 install-host-cloog: stmp-install-host-cloog
672
673 # host expat rules
674 .PHONY: config-host-expat build-host-expat install-host-expat
675 config-host-expat: stmp-config-host-expat
676 EXPAT_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
677         --host=${cur_host} --build=${cur_build}
678 stmp-config-host-expat: config.status  $(canadian_stmp)
679         ([ -d ${EXPAT_VERSION} ] || \
680           mkdir ${EXPAT_VERSION}) && \
681         ($(canadian_env) \
682          cd ${EXPAT_VERSION} ; \
683          $(call find-package-srcdir, ${EXPAT_VERSION})/configure \
684           $(EXPAT_CONFIG_ARGS)) && \
685         $(STAMP) $@
686 stmp-build-host-expat: stmp-config-host-expat
687         ($(canadian_env) \
688          $(MAKE) -C ${EXPAT_VERSION}) && $(STAMP) $@
689 build-host-expat: stmp_build-host-expat
690 ifeq ($(HAVE_EXPAT),no)
691 stmp-install-host-expat: stmp-build-host-expat
692         $(MAKE) -C ${EXPAT_VERSION} install -j1 && $(STAMP) $@
693 else
694 stmp-install-host-expat:
695 endif
696 install-host-expat: stmp-install-host-expat
697
698 # target gdb rules
699 .PHONY: config-target-gdb build-target-gdb install-target-gdb
700 ifeq ($(GDB_VERSION),gdb-none)
701 config-target-gdb:
702 build-target-gdb:
703 install-target-gdb:
704 else
705 config-target-gdb: stmp-config-target-gdb
706
707 GDB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
708         --target=$(GDB_TARGET) --host=${cur_host} --build=${cur_build} \
709         --disable-nls
710
711 # For gdb versions 7.2 and higher, expat is required.
712 ifeq ($(GDB_MIN_VERSION_7_2),yes)
713 stmp-config-target-gdb: stmp-install-host-expat
714 GDB_CONFIG_ARGS += --with-expat --with-libexpat-prefix=$(EXPAT_DIR)
715 endif
716
717 stmp-config-target-gdb: config.status $(canadian_stmp)
718         ([ -d ${GDB_VERSION} ] || \
719           mkdir ${GDB_VERSION}) && \
720         ($(canadian_env) \
721          cd ${GDB_VERSION} ; \
722          $(call find-package-srcdir, ${GDB_VERSION})/configure \
723           $(GDB_CONFIG_ARGS)) && \
724         $(STAMP) $@
725 build-target-gdb: stmp-build-target-gdb
726 stmp-build-target-gdb: stmp-config-target-gdb
727         ($(canadian_env) \
728          $(MAKE) -C ${GDB_VERSION}) && $(STAMP) $@
729 install-target-gdb: stmp-build-target-gdb
730         ($(canadian_env) \
731          $(MAKE) -C ${GDB_VERSION} install)
732 endif
733
734 # clean rules
735 .PHONY: clean
736 clean:
737         $(RM) -r $(TEMP_INSTALLDIR) stmp-build-* stmp-install-* && \
738         for sub in [ * ]; do \
739           if [ -f $$sub/Makefile ]; then \
740             $(MAKE) -C $$sub clean ; \
741           fi; \
742         done
743
744 .PHONY: distclean
745 distclean:
746         @$(RM) -r config.log config.status \
747                   $(TEMP_INSTALLDIR) temp-src \
748                   stmp-config-* stmp-build-* stmp-install-* && \
749         for sub in [ * ]; do \
750           if [ -f $$sub/config.status ]; then \
751             echo "Deleting " $$sub "..." && $(RM) -r $$sub ; \
752           fi; \
753         done
754         @$(RM) Makefile