Created
March 3, 2011 05:23
-
-
Save redstar3894/852376 to your computer and use it in GitHub Desktop.
android toolchain Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------- | |
# Standard Autoconf-set variables | |
# ------------------------------- | |
VPATH=../build | |
build_alias= | |
build_vendor=unknown | |
build_os=linux-gnu | |
build=x86_64-unknown-linux-gnu | |
host_alias= | |
host_vendor=unknown | |
host_os=linux-gnu | |
host=x86_64-unknown-linux-gnu | |
target_alias=arm-eabi | |
target_vendor=unknown | |
target_os=eabi | |
target_cpu=arm | |
target=arm-unknown-eabi | |
program_transform_name = s&^&arm-eabi-& | |
prefix = /home/redstar/Droid/andtoolchain/install2 | |
exec_prefix = ${prefix} | |
srcdir = ../build | |
bindir = ${exec_prefix}/bin | |
sbindir = ${exec_prefix}/sbin | |
libexecdir = ${exec_prefix}/libexec | |
datadir = ${datarootdir} | |
sysconfdir = ${prefix}/etc | |
sharedstatedir = ${prefix}/com | |
localstatedir = ${prefix}/var | |
libdir = ${exec_prefix}/lib | |
includedir = ${prefix}/include | |
oldincludedir = /usr/include | |
infodir = ${datarootdir}/info | |
datarootdir = ${prefix}/share | |
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} | |
pdfdir = ${docdir} | |
htmldir = ${docdir} | |
mandir = ${datarootdir}/man | |
builddir = . | |
abs_builddir = /home/redstar/Droid/andtoolchain/objdir | |
# | |
# miscellaneous variables | |
# | |
TOPLEVEL_CONFIGURE_ARGUMENTS:=eabi | |
baseargs = '--prefix=/home/redstar/Droid/andtoolchain/install2' '--with-pkgversion=Redstar Helios 2011.03-1' '--with-binutils-version=2.21' '--enable-gold' '--with-gcc-version=4.4.6' '--with-gmp-version=5.0.1' '--with-mpfr-version=2.4.2' '--with-cloog-version=0.15.10' '--with-ppl-version=0.11.2' '--with-multilib-list=mthumb-interwork,mandroid' '--with-sysroot=/home/redstar/Droid/andtoolchain/sysroot' --program-transform-name='s&^&arm-eabi-&' | |
GCC_MIN_VERSION_4_3_0:=yes | |
GCC_MIN_VERSION_4_5_0:=no | |
PACKAGE_TO_SRCDIR:=../../build | |
BUILD_ANDROID_GCC:=yes | |
GDB_TARGET:=arm-elf-linux | |
# We need to figure out how to get to top level source directory from | |
# a package build directory. | |
# For host modules, accept cache file option, or specification as blank. | |
BINUTILS_VERSION=binutils-2.21 | |
GCC_VERSION=gcc-4.4.6 | |
NEWLIB_VERSION=newlib- | |
GMP_VERSION=gmp-5.0.1 | |
MPFR_VERSION=mpfr-2.4.2 | |
MPC_VERSION=mpc- | |
PPL_VERSION=ppl-0.11.2 | |
CLOOG_VERSION=cloog-ppl-0.15.10 | |
GDB_VERSION=gdb-7.1.x | |
STAMP=touch | |
TARGET_BINUTILS_BUILDDIR=$(abs_builddir)/$(BINUTILS_VERSION) | |
TARGET_GCC_BUILDDIR=$(abs_builddir)/$(GCC_VERSION) | |
TEMP_INSTALLDIR=$(abs_builddir)/temp-install | |
# Figure out where to find the ld binary. | |
FIND_TARGET_LD=\ | |
`[ -d $(TARGET_BINUTILS_BUILDDIR)/gold ] && echo "gold" || echo "ld"` | |
# We export these insteading when configuring target gcc and newlib | |
TARGET_BINUTILS_EXPORTS= \ | |
export AS_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/gas/as-new \ | |
LD_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/$(FIND_TARGET_LD)/ld-new \ | |
AR_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ar \ | |
NM_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/nm-new \ | |
STRIP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/strip-new \ | |
RANLIB_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/ranlib \ | |
OBJDUMP_FOR_TARGET=$(TARGET_BINUTILS_BUILDDIR)/binutils/objdump | |
TARGET_MINIMAL_GCC_EXPORTS= \ | |
export CC_FOR_TARGET="$(TARGET_GCC_BUILDDIR)/gcc/xgcc \ | |
-B $(TARGET_GCC_BUILDDIR)/gcc \ | |
-isystem $(TARGET_GCC_BUILDDIR)/gcc/include-fixed \ | |
-isystem $(TARGET_GCC_BUILDDIR)/gcc/include" | |
# | |
# We need -Os as the overrides below interfere with --enable-target-optspace. | |
# We also need -mandroid for for target libraries to pass linking test | |
# in configuration. | |
# | |
# To build libstdc++ with RTTI and exceptions do: | |
# | |
#export CFLAGS_FOR_TARGET=-fexceptions | |
#export CXXFLAGS_FOR_TARGET=-frtti | |
# | |
CFLAGS_FOR_TARGET+= -O2 -Os -g | |
CXXFLAGS_FOR_TARGET+=$(CFLAGS_FOR_TARGET) | |
LDFLAGS_FOR_TARGET= | |
# Helper | |
prefix-list = $(foreach e, $(2), $(join $1, $e)) | |
# find source directory for package. This can either be <srcdir>/<package> | |
# or <objdir>/temp-src/<package> | |
find-package-srcdir = $(shell \ | |
if [ -f $(srcdir)/../$(firstword $(subst -, ,$1))/$(strip $1)/configure ]; then \ | |
echo $(PACKAGE_TO_SRCDIR)/../$(firstword $(subst -, ,$1))/$(strip $1); \ | |
elif [ -f $(abs_builddir)/temp-src/$(strip $1)/configure ]; then \ | |
echo $(abs_builddir)/temp-src/$(strip $1) ; \ | |
else \ | |
echo 'error cannot find $(strip $1)' ; \ | |
fi) | |
# | |
# Make rules | |
# | |
.PHONY: all clean | |
all: build | |
# top level | |
build: build-target-binutils build-target-gcc build-target-gdb | |
install: install-target-binutils install-target-gcc install-target-gdb | |
# target binutils rules | |
.PHONY: config-target-binutils build-target-binutils install-target-binutils | |
config-target-binutils: stmp-config-target-binutils | |
# We do not want to enable shared libraries in binutils | |
BINUTILS_CONFIG_ARGS=--prefix=$(prefix) \ | |
--target=${target_alias} --host=${host} --build=${build} \ | |
$(baseargs) --disable-shared \ | |
--disable-nls | |
stmp-config-target-binutils: config.status | |
([ -d ${BINUTILS_VERSION} ] || \ | |
mkdir ${BINUTILS_VERSION}) && \ | |
(cd ${BINUTILS_VERSION} ; \ | |
$(call find-package-srcdir, ${BINUTILS_VERSION})/configure \ | |
$(BINUTILS_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
build-target-binutils: stmp-build-target-binutils | |
stmp-build-target-binutils: stmp-config-target-binutils | |
$(MAKE) -C ${BINUTILS_VERSION} && $(STAMP) $@ | |
install-target-binutils: stmp-build-target-binutils | |
$(MAKE) -C ${BINUTILS_VERSION} install | |
# target gcc rules | |
.PHONY: config-target-gcc build-target-gcc install-target-gcc | |
config-target-gcc: stmp-config-target-gcc | |
GCC_CONFIG_ARGS=--prefix=$(prefix) \ | |
--target=${target_alias} --host=${host} --build=${build} \ | |
--enable-languages=c,c++ \ | |
--with-pkgversion='Redstar Helios 2011.03-1' | |
# For gcc versions 4.3.0 and later, gmp and mpfr are required. | |
# Also build libgcc is a seperate sub-target in 4.3.0+. | |
ifeq ($(GCC_MIN_VERSION_4_3_0),yes) | |
stmp-config-target-gcc: stmp-install-host-gmp stmp-install-host-mpfr \ | |
stmp-install-host-ppl stmp-install-host-cloog | |
GCC_CONFIG_ARGS += --with-gmp=$(TEMP_INSTALLDIR) --with-mpfr=$(TEMP_INSTALLDIR) \ | |
--with-ppl=$(TEMP_INSTALLDIR) --with-cloog=$(TEMP_INSTALLDIR) | |
endif | |
# For gcc versions 4.5.0 and higher, mpc is required. | |
ifeq ($(GCC_MIN_VERSION_4_5_0),yes) | |
stmp-config-target-gcc: stmp-install-host-mpc | |
GCC_CONFIG_ARGS += --with-mpc=$(TEMP_INSTALLDIR) | |
endif | |
# Add Android specific gcc options. | |
# FIXME: These should be overridable by configure options. | |
# Target indenpendent Android gcc options. | |
ifeq ($(BUILD_ANDROID_GCC),yes) | |
GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \ | |
--enable-threads --disable-nls --disable-libmudflap --disable-libgomp \ | |
--disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared \ | |
--disable-tls | |
CFLAGS_FOR_TARGET += -DTARGET_POSIX_IO -fno-short-enums | |
# ARM specific options. | |
ifeq ($(target_cpu),arm) | |
GCC_CONFIG_ARGS += --with-float=hard --with-fpu=neon --with-arch=armv7-a \ | |
--enable-target-optspace | |
ifneq ($(target_os),linux-androideabi) | |
GCC_CONFIG_ARGS += --with-abi=aapcs | |
endif | |
endif | |
endif | |
# We add the baseargs and the end so that they override any default args | |
GCC_CONFIG_ARGS += $(baseargs) | |
# We have to add -mandroid in target CFLAGS and CXXFLAGS | |
stmp-config-target-gcc: config.status stmp-build-target-binutils | |
([ -d ${GCC_VERSION} ] || \ | |
mkdir ${GCC_VERSION}) && \ | |
(cd ${GCC_VERSION} ; \ | |
$(TARGET_BINUTILS_EXPORTS) ; \ | |
export CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" ; \ | |
export CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" ; \ | |
export LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" ; \ | |
$(call find-package-srcdir, ${GCC_VERSION})/configure \ | |
$(GCC_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
build-target-gcc: stmp-build-target-gcc | |
stmp-build-target-gcc: stmp-config-target-gcc | |
$(MAKE) -j10 -C ${GCC_VERSION} \ | |
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \ | |
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ | |
LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" \ | |
&& $(STAMP) $@ | |
install-target-gcc: stmp-build-target-gcc | |
$(MAKE) -C ${GCC_VERSION} install | |
# minimal gcc rules | |
# minimal gcc only builds the C and C++ compilers and libgcc | |
# We use the full gcc configure rules. | |
.PHONY: build-target-minimal-gcc install-target-minimal-gcc | |
ifeq ("$(GCC_MIN_VERSION_4_3_0)","yes") | |
MINIMAL_GCC_BUILD_TARGETS:= gcc target-libgcc | |
else | |
MINIMAL_GCC_BUILD_TARGETS:= gcc | |
endif | |
build-target-minimal-gcc: stmp-build-target-minimal-gcc | |
stmp-build-target-minimal-gcc: stmp-config-target-gcc | |
$(MAKE) -j10 -C ${GCC_VERSION} \ | |
$(call prefix-list, all-, $(MINIMAL_GCC_BUILD_TARGETS)) && \ | |
$(STAMP) $@ | |
install-target-minimal-gcc: stmp-build-target-minimal-gcc | |
$(MAKE) -C ${GCC_VERSION} \ | |
$(call prefix-list, install-, $(MINIMAL_GCC_BUILD_TARGETS)) | |
# target newlib rules | |
.PHONY: config-target-newlib build-target-newlib install-target-newlib | |
config-target-newlib: stmp-config-target-newlib | |
NEWLIB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \ | |
--target=${target_alias} --host=${host} --build=${build} | |
stmp-config-target-newlib: stmp-build-target-binutils \ | |
stmp-build-target-minimal-gcc | |
([ -d ${NEWLIB_VERSION} ] || \ | |
mkdir ${NEWLIB_VERSION}) && \ | |
(cd ${NEWLIB_VERSION} ; \ | |
$(TARGET_BINUTILS_EXPORTS) ; \ | |
$(TARGET_MINIMAL_GCC_EXPORTS) ; \ | |
$(call find-package-srcdir, ${NEWLIB_VERSION})/configure \ | |
$(NEWLIB_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
stmp-build-target-newlib: stmp-config-target-newlib | |
$(MAKE) -j10 -C ${NEWLIB_VERSION} && $(STAMP) $@ | |
install-target-newlib: stmp-build-target-newlib | |
$(MAKE) -C ${NEWLIB_VERSION} install | |
# host gmp rules | |
.PHONY: config-host-gmp build-host-gmp install-host-gmp | |
config-host-gmp: stmp-config-host-gmp | |
GMP_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \ | |
--host=${host} --build=${build} \ | |
--enable-cxx | |
stmp-config-host-gmp: config.status | |
([ -d ${GMP_VERSION} ] || \ | |
mkdir ${GMP_VERSION}) && \ | |
(cd ${GMP_VERSION} ; \ | |
$(call find-package-srcdir, ${GMP_VERSION})/configure \ | |
$(GMP_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
stmp-build-host-gmp: stmp-config-host-gmp | |
$(MAKE) -j10 -C ${GMP_VERSION} && $(STAMP) $@ | |
build-host-gmp: stmp-build-host-gmp | |
# Need -j1 to avoid a race condition in building on OS X. | |
stmp-install-host-gmp: stmp-build-host-gmp | |
$(MAKE) -C ${GMP_VERSION} install -j1 && \ | |
$(STAMP) $@ | |
install-host-gmp: stmp-install-host-gmp | |
# host mpfr rules | |
.PHONY: config-host-mpfr build-host-mpfr install-host-mpfr | |
config-host-mpfr: stmp-config-host-mpfr | |
MPFR_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \ | |
--host=${host} --build=${build} --with-gmp=$(TEMP_INSTALLDIR) | |
stmp-config-host-mpfr: config.status stmp-install-host-gmp | |
([ -d ${MPFR_VERSION} ] || \ | |
mkdir ${MPFR_VERSION}) && \ | |
(cd ${MPFR_VERSION} ; \ | |
$(call find-package-srcdir, ${MPFR_VERSION})/configure \ | |
$(MPFR_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
stmp-build-host-mpfr: stmp-config-host-mpfr | |
$(MAKE) -j10 -C ${MPFR_VERSION} && $(STAMP) $@ | |
build-host-mpfr: stmp-build-host-mpfr | |
stmp-install-host-mpfr: stmp-build-host-mpfr | |
$(MAKE) -C ${MPFR_VERSION} install && \ | |
$(STAMP) $@ | |
install-host-mpfr: stmp-install-host-mpfr | |
# host mpc rules | |
.PHONY: config-host-mpc build-host-mpc install-host-mpc | |
config-host-mpc: stmp-config-host-mpc | |
MPC_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \ | |
--host=${host} --build=${build} --with-gmp=$(TEMP_INSTALLDIR) \ | |
--with-mpfr=$(TEMP_INSTALLDIR) | |
stmp-config-host-mpc: config.status stmp-install-host-gmp stmp-install-host-mpfr | |
([ -d ${MPC_VERSION} ] || \ | |
mkdir ${MPC_VERSION}) && \ | |
(cd ${MPC_VERSION} ; \ | |
$(call find-package-srcdir, ${MPC_VERSION})/configure \ | |
$(MPC_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
stmp-build-host-mpc: stmp-config-host-mpc | |
$(MAKE) -j10 -C ${MPC_VERSION} && $(STAMP) $@ | |
build-host-mpc: stmp-build-host-mpc | |
stmp-install-host-mpc: stmp-build-host-mpc | |
$(MAKE) -C ${MPC_VERSION} install && \ | |
$(STAMP) $@ | |
install-host-mpc: stmp-install-host-mpc | |
# host ppl rules | |
.PHONY: config-host-ppl build-host-ppl install-host-ppl | |
config-host-ppl: stmp-config-host-ppl | |
PPL_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \ | |
--target=${target_alias} \ | |
--host=${host} --build=${build} \ | |
--disable-nls --with-gmp-prefix=$(TEMP_INSTALLDIR) | |
stmp-config-host-ppl: config.status stmp-install-host-ppl stmp-install-host-ppl | |
([ -d ${PPL_VERSION} ] || \ | |
mkdir ${PPL_VERSION}) && \ | |
(cd ${PPL_VERSION} ; \ | |
$(call find-package-srcdir, ${PPL_VERSION})/configure \ | |
$(PPL_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
stmp-build-host-ppl: stmp-config-host-ppl | |
$(MAKE) -j10 -C ${PPL_VERSION} && $(STAMP) $@ | |
build-host-ppl: stmp-build-host-ppl | |
stmp-install-host-ppl: stmp-build-host-ppl | |
$(MAKE) -C ${PPL_VERSION} install && \ | |
$(STAMP) $@ | |
install-host-ppl: stmp-install-host-ppl | |
# host cloog rules | |
.PHONY: config-host-cloog build-host-cloog install-host-cloog | |
config-host-cloog: stmp-config-host-cloog | |
CLOOG_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \ | |
--target=${target_alias} \ | |
--host=${host} --build=${build} \ | |
--disable-nls \ | |
--with-ppl=$(TEMP_INSTALLDIR) --with-gmp=$(TEMP_INSTALLDIR) \ | |
--with-bits=32 | |
stmp-config-host-cloog: config.status stmp-install-host-cloog stmp-install-host-cloog | |
([ -d ${CLOOG_VERSION} ] || \ | |
mkdir ${CLOOG_VERSION}) && \ | |
(cd ${CLOOG_VERSION} ; \ | |
sed -i -e 's/PPL_VERSION_MINOR 11/PPL_VERSION_MINOR 10/' \ | |
$(TEMP_INSTALLDIR)/include/ppl_c.h ; \ | |
$(call find-package-srcdir, ${CLOOG_VERSION})/configure \ | |
$(CLOOG_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
stmp-build-host-cloog: stmp-config-host-cloog | |
$(MAKE) -j10 -C ${PPL_VERSION} && $(STAMP) $@ | |
build-host-cloog: stmp-build-host-cloog | |
stmp-install-host-cloog: stmp-build-host-cloog | |
$(MAKE) -C ${PPL_VERSION} install && \ | |
$(STAMP) $@ | |
install-host-cloog: stmp-install-host-cloog | |
# target gdb rules | |
.PHONY: config-target-gdb build-target-gdb install-target-gdb | |
config-target-gdb: stmp-config-target-gdb | |
GDB_CONFIG_ARGS=$(baseargs) --prefix=$(prefix) \ | |
--target=$(GDB_TARGET) --host=${host} --build=${build} \ | |
--disable-nls \ | |
--disable-sim --disable-tui | |
stmp-config-target-gdb: config.status | |
([ -d ${GDB_VERSION} ] || \ | |
mkdir ${GDB_VERSION}) && \ | |
(cd ${GDB_VERSION} ; \ | |
$(call find-package-srcdir, ${GDB_VERSION})/configure \ | |
$(GDB_CONFIG_ARGS)) && \ | |
$(STAMP) $@ | |
build-target-gdb: stmp-build-target-gdb | |
stmp-build-target-gdb: stmp-config-target-gdb | |
$(MAKE) -j10 -C ${GDB_VERSION} && $(STAMP) $@ | |
install-target-gdb: stmp-build-target-gdb | |
$(MAKE) -C ${GDB_VERSION} install | |
# clean rules | |
.PHONY: clean | |
clean: | |
$(RM) -r $(TEMP_INSTALLDIR) stmp-build-* stmp-install-* && \ | |
for sub in [ * ]; do \ | |
if [ -f $$sub/Makefile ]; then \ | |
$(MAKE) -C $$sub clean ; \ | |
fi; \ | |
done | |
.PHONY: distclean | |
distclean: | |
@$(RM) -r config.log config.status \ | |
$(TEMP_INSTALLDIR) temp-src \ | |
stmp-config-* stmp-build-* stmp-install-* && \ | |
for sub in [ * ]; do \ | |
if [ -f $$sub/config.status ]; then \ | |
echo "Deleting " $$sub "..." && $(RM) -r $$sub ; \ | |
fi; \ | |
done | |
@$(RM) Makefile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment