Fix two configure bugs on checking gcc version and configuring mpc.
[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
27 bindir = @bindir@
28 sbindir = @sbindir@
29 libexecdir = @libexecdir@
30 datadir = @datadir@
31 sysconfdir = @sysconfdir@
32 sharedstatedir = @sharedstatedir@
33 localstatedir = @localstatedir@
34 libdir = @libdir@
35 includedir = @includedir@
36 oldincludedir = @oldincludedir@
37 infodir = @infodir@
38 datarootdir = @datarootdir@
39 docdir = @docdir@
40 pdfdir = @pdfdir@
41 htmldir = @htmldir@
42 mandir = @mandir@
43
44 builddir = @builddir@
45 abs_builddir = @abs_builddir@
46 #
47 # miscellaneous variables
48 #
49 TOPLEVEL_CONFIGURE_ARGUMENTS:=@TOPLEVEL_CONFIGURE_ARGUMENTS@
50 baseargs = @baseargs@
51 GCC_MIN_VERSION_4_3_0:=@GCC_MIN_VERSION_4_3_0@
52 GCC_MIN_VERSION_4_5_0:=@GCC_MIN_VERSION_4_5_0@
53 PACKAGE_TO_SRCDIR:=@package_to_srcdir@
54 BUILD_ANDROID_GCC:=@BUILD_ANDROID_GCC@
55 GDB_TARGET:=@GDB_TARGET@
56
57 # We need to figure out how to get to top level source directory from
58 # a package build directory. 
59 # For host modules, accept cache file option, or specification as blank.
60
61
62 BINUTILS_VERSION=binutils-@BINUTILS_VERSION@
63 GCC_VERSION=gcc-@GCC_VERSION@
64 NEWLIB_VERSION=newlib-@NEWLIB_VERSION@
65 GMP_VERSION=gmp-@GMP_VERSION@
66 MPFR_VERSION=mpfr-@MPFR_VERSION@
67 MPC_VERSION=mpc-@MPC_VERSION@
68 GDB_VERSION=gdb-@GDB_VERSION@
69 STAMP=touch
70
71 TARGET_BINUTILS_BUILDDIR=$(abs_builddir)/$(BINUTILS_VERSION)
72 TARGET_GCC_BUILDDIR=$(abs_builddir)/$(GCC_VERSION)
73 TEMP_INSTALLDIR=$(abs_builddir)/temp-install
74
75 # We export these insteading when configuring target gcc and newlib
76 TARGET_BINUTILS_EXPORTS= \
77 export  AS_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/gas/as-new \
78         LD_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/ld/ld-new \
79         AR_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ar \
80         NM_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/nm-new \
81         STRIP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/strip-new \
82         RANLIB_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ranlib
83
84 TARGET_MINIMAL_GCC_EXPORTS= \
85 export  CC_FOR_TARGET="$(TARGET_GCC_BUILDDIR)/gcc/xgcc \
86                       -B $(TARGET_GCC_BUILDDIR)/gcc \
87                       -isystem $(TARGET_GCC_BUILDDIR)/gcc/include-fixed \
88                       -isystem $(TARGET_GCC_BUILDDIR)/gcc/include"
89 #
90 # We need -Os as the overrides below interfere with --enable-target-optspace.
91 # We also need -mandroid for for target libraries to pass linking test
92 # in configuration.
93
94 # To build libstdc++ with RTTI and exceptions do:
95 #
96 # CFLAGS_FOR_TARGET= -O2 -Os -g -fexceptions
97 # CXXFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) -frtti
98
99 CFLAGS_FOR_TARGET= -O2 -Os -g
100 CXXFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)
101 LDFLAGS_FOR_TARGET=-mandroid
102
103 # Helper
104 prefix-list = $(foreach e, $(2), $(join $1, $e))
105
106 # find source directory for package. This can either be <srcdir>/<package>
107 # or <objdir>/temp-src/<package>
108
109 find-package-srcdir = $(shell \
110   if [ -f $(srcdir)/../$(firstword $(subst -, ,$1))/$(strip $1)/configure ]; then \
111      echo $(PACKAGE_TO_SRCDIR)/../$(firstword $(subst -, ,$1))/$(strip $1); \
112   elif [ -f $(abs_builddir)/temp-src/$(strip $1)/configure ]; then \
113     echo $(abs_builddir)/temp-src/$(strip $1) ; \
114   else \
115     echo 'error cannot find $(strip $1)' ; \
116   fi)
117
118 #
119 # Make rules
120 #
121
122 .PHONY: all clean
123
124 all: build
125
126 # top level
127 build: build-target-binutils build-target-gcc build-target-gdb
128
129 install: install-target-binutils install-target-gcc install-target-gdb
130
131 # target binutils rules
132 .PHONY: config-target-binutils build-target-binutils install-target-binutils
133 config-target-binutils: stmp-config-target-binutils
134 # We do not want to enable shared libraries in binutils
135 BINUTILS_CONFIG_ARGS=--prefix=$(prefix) \
136         --target=${target_alias} --host=${host} --build=${build} \
137         $(baseargs) --disable-shared
138 stmp-config-target-binutils: config.status
139         ([ -d ${BINUTILS_VERSION} ] || \
140           mkdir ${BINUTILS_VERSION}) && \
141         (cd ${BINUTILS_VERSION} ; \
142          $(call find-package-srcdir, ${BINUTILS_VERSION})/configure \
143           $(BINUTILS_CONFIG_ARGS)) && \
144         $(STAMP) $@
145 build-target-binutils: stmp-build-target-binutils
146 stmp-build-target-binutils: stmp-config-target-binutils
147         $(MAKE) -C ${BINUTILS_VERSION} && $(STAMP) $@
148 install-target-binutils: stmp-build-target-binutils
149         $(MAKE) -C ${BINUTILS_VERSION} install
150
151 # target gcc rules
152 .PHONY: config-target-gcc build-target-gcc install-target-gcc
153 config-target-gcc: stmp-config-target-gcc
154
155 GCC_CONFIG_ARGS=--prefix=$(prefix) \
156           --target=${target_alias} --host=${host} --build=${build} \
157           --enable-languages=c,c++
158
159 # For gcc versions 4.3.0 and later, gmp and mpfr are required.
160 # Also build libgcc is a seperate sub-target in 4.3.0+.
161 ifeq ($(GCC_MIN_VERSION_4_3_0),yes)
162 stmp-config-target-gcc: stmp-install-host-gmp stmp-install-host-mpfr
163 GCC_CONFIG_ARGS += --with-gmp=$(TEMP_INSTALLDIR) --with-mpfr=$(TEMP_INSTALLDIR)
164 endif
165
166 # For gcc versions 4.5.0 and higher, mpc is required.
167 ifeq ($(GCC_MIN_VERSION_4_5_0),yes)
168 stmp-config-target-gcc: stmp-install-host-mpc
169 GCC_CONFIG_ARGS += --with-mpc=$(TEMP_INSTALLDIR)
170 endif
171
172 # Add Android specific gcc options.
173 # FIXME: These should be overridable by configure options.
174
175
176 # Target indenpendent Android gcc options.
177 ifeq ($(BUILD_ANDROID_GCC),yes)
178 GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \
179         --enable-threads --disable-nls --disable-libmudflap --disable-libgomp \
180         --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared \
181         --disable-tls
182 CFLAGS_FOR_TARGET += -DTARGET_POSIX_IO -fno-short-enums
183 # ARM specific options.
184 ifeq ($(target_cpu),arm)
185 GCC_CONFIG_ARGS += --with-float=soft --with-fpu=vfp --with-arch=armv5te \
186         --enable-target-optspace --with-abi=aapcs
187 endif
188
189 endif
190
191 # We add the baseargs and the end so that they override any default args
192 GCC_CONFIG_ARGS += $(baseargs)
193
194 # We have to add -mandroid in target CFLAGS and CXXFLAGS
195 stmp-config-target-gcc: config.status stmp-build-target-binutils
196         ([ -d ${GCC_VERSION} ] || \
197           mkdir ${GCC_VERSION}) && \
198         (cd ${GCC_VERSION} ; \
199          $(TARGET_BINUTILS_EXPORTS) ; \
200          export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" ; \
201          export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" ; \
202          export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \
203          $(call find-package-srcdir, ${GCC_VERSION})/configure \
204            $(GCC_CONFIG_ARGS)) && \
205         $(STAMP) $@
206 build-target-gcc: stmp-build-target-gcc
207 stmp-build-target-gcc: stmp-config-target-gcc
208         $(MAKE) -C ${GCC_VERSION} \
209                 CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
210                 CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
211                 LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \
212         && $(STAMP) $@
213 install-target-gcc: stmp-build-target-gcc
214         $(MAKE) -C ${GCC_VERSION} install
215
216 # minimal gcc rules
217 # minimal gcc only builds the C and C++ compilers and libgcc
218 # We use the full gcc configure rules.
219 .PHONY: build-target-minimal-gcc install-target-minimal-gcc
220 ifeq ("$(GCC_MIN_VERSION_4_3_0)","yes")
221 MINIMAL_GCC_BUILD_TARGETS:= gcc target-libgcc 
222 else
223 MINIMAL_GCC_BUILD_TARGETS:= gcc
224 endif
225
226 build-target-minimal-gcc: stmp-build-target-minimal-gcc
227 stmp-build-target-minimal-gcc: stmp-config-target-gcc
228         $(MAKE) -C ${GCC_VERSION} \
229                 $(call prefix-list, all-, $(MINIMAL_GCC_BUILD_TARGETS)) && \
230         $(STAMP) $@
231 install-target-minimal-gcc: stmp-build-target-minimal-gcc
232         $(MAKE) -C ${GCC_VERSION} \
233                 $(call prefix-list, install-, $(MINIMAL_GCC_BUILD_TARGETS))
234
235 # target newlib rules
236 .PHONY: config-target-newlib build-target-newlib install-target-newlib
237 config-target-newlib: stmp-config-target-newlib
238 NEWLIB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
239           --target=${target_alias} --host=${host} --build=${build}
240
241 stmp-config-target-newlib: stmp-build-target-binutils \
242                            stmp-build-target-minimal-gcc
243         ([ -d ${NEWLIB_VERSION} ] || \
244           mkdir ${NEWLIB_VERSION}) && \
245         (cd ${NEWLIB_VERSION} ; \
246          $(TARGET_BINUTILS_EXPORTS) ; \
247          $(TARGET_MINIMAL_GCC_EXPORTS) ; \
248          $(call find-package-srcdir, ${NEWLIB_VERSION})/configure \
249           $(NEWLIB_CONFIG_ARGS)) && \
250         $(STAMP) $@
251 stmp-build-target-newlib: stmp-config-target-newlib
252         $(MAKE) -C ${NEWLIB_VERSION} && $(STAMP) $@
253 install-target-newlib: stmp-build-target-newlib
254         $(MAKE) -C ${NEWLIB_VERSION} install
255
256 # host gmp rules
257 .PHONY: config-host-gmp build-host-gmp install-host-gmp
258 config-host-gmp: stmp-config-host-gmp
259 GMP_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
260           --host=${host} --build=${build}
261 stmp-config-host-gmp: config.status
262         ([ -d ${GMP_VERSION} ] || \
263           mkdir ${GMP_VERSION}) && \
264         (cd ${GMP_VERSION} ; \
265          $(call find-package-srcdir, ${GMP_VERSION})/configure \
266           $(GMP_CONFIG_ARGS)) && \
267         $(STAMP) $@
268 stmp-build-host-gmp: stmp-config-host-gmp
269         $(MAKE) -C ${GMP_VERSION} && $(STAMP) $@
270 build-host-gmp: stmp-build-host-gmp
271 # Need -j1 to avoid a race condition in building on OS X.
272 stmp-install-host-gmp: stmp-build-host-gmp
273         $(MAKE) -C ${GMP_VERSION} install -j1 && \
274         $(STAMP) $@
275 install-host-gmp: stmp-install-host-gmp
276
277 # host mpfr rules
278 .PHONY: config-host-mpfr build-host-mpfr install-host-mpfr
279 config-host-mpfr: stmp-config-host-mpfr
280 MPFR_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
281           --host=${host} --build=${build} --with-gmp=$(TEMP_INSTALLDIR)
282 stmp-config-host-mpfr: config.status stmp-install-host-gmp
283         ([ -d ${MPFR_VERSION} ] || \
284           mkdir ${MPFR_VERSION}) && \
285         (cd ${MPFR_VERSION} ; \
286          $(call find-package-srcdir, ${MPFR_VERSION})/configure \
287           $(MPFR_CONFIG_ARGS)) && \
288         $(STAMP) $@
289 stmp-build-host-mpfr: stmp-config-host-mpfr
290         $(MAKE) -C ${MPFR_VERSION} && $(STAMP) $@
291 build-host-mpfr: stmp-build-host-mpfr
292 stmp-install-host-mpfr: stmp-build-host-mpfr
293         $(MAKE) -C ${MPFR_VERSION} install && \
294         $(STAMP) $@
295 install-host-mpfr: stmp-install-host-mpfr
296
297 # host mpc rules
298 .PHONY: config-host-mpc build-host-mpc install-host-mpc
299 config-host-mpc: stmp-config-host-mpc
300 MPC_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
301          --host=${host} --build=${build} --with-gmp=$(TEMP_INSTALLDIR) \
302          --with-mpfr=$(TEMP_INSTALLDIR)
303 stmp-config-host-mpc: config.status stmp-install-host-gmp stmp-install-host-mpfr
304         ([ -d ${MPC_VERSION} ] || \
305           mkdir ${MPC_VERSION}) && \
306         (cd ${MPC_VERSION} ; \
307          $(call find-package-srcdir, ${MPC_VERSION})/configure \
308           $(MPC_CONFIG_ARGS)) && \
309         $(STAMP) $@
310 stmp-build-host-mpc: stmp-config-host-mpc
311         $(MAKE) -C ${MPC_VERSION} && $(STAMP) $@
312 build-host-mpc: stmp-build-host-mpc
313 stmp-install-host-mpc: stmp-build-host-mpc
314         $(MAKE) -C ${MPC_VERSION} install && \
315         $(STAMP) $@
316 install-host-mpc: stmp-install-host-mpc
317
318 # target gdb rules
319 .PHONY: config-target-gdb build-target-gdb install-target-gdb
320 config-target-gdb: stmp-config-target-gdb
321
322 GDB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \
323           --target=$(GDB_TARGET) --host=${host} --build=${build}
324
325 stmp-config-target-gdb: config.status
326         ([ -d ${GDB_VERSION} ] || \
327           mkdir ${GDB_VERSION}) && \
328         (cd ${GDB_VERSION} ; \
329          $(call find-package-srcdir, ${GDB_VERSION})/configure \
330           $(GDB_CONFIG_ARGS)) && \
331         $(STAMP) $@
332 build-target-gdb: stmp-build-target-gdb
333 stmp-build-target-gdb: stmp-config-target-gdb
334         $(MAKE) -C ${GDB_VERSION} && $(STAMP) $@
335 install-target-gdb: stmp-build-target-gdb
336         $(MAKE) -C ${GDB_VERSION} install
337
338 # clean rules
339 .PHONY: clean
340 clean:
341         $(RM) -r $(TEMP_INSTALLDIR) stmp-build-* stmp-install-* && \
342         for sub in [ * ]; do \
343           if [ -f $$sub/Makefile ]; then \
344             $(MAKE) -C $$sub clean ; \
345           fi; \
346         done