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