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