toolchain-mipsel/Makefile

232 lines
7.3 KiB
Makefile
Raw Permalink Normal View History

2007-06-15 15:10:02 +02:00
# used kernel:
_KERNEL_DIR := /home/development/asus-stuff/broadcom/src/linux/linux
# output dir:
_TOOLCHAIN=/opt/mipsel-toolchain
# #####################################################################
_SRCBASE=$(shell /bin/pwd)
_CONFIGS=$(_SRCBASE)/configs
_DOWNLOAD_DIR=$(_SRCBASE)/download
_PATCHES=$(_SRCBASE)/patches
_SOURCE=$(_SRCBASE)/source
_TOOLS=$(_SRCBASE)/tools
WGET := /usr/bin/wget --passive-ftp -nd
# #####################################################################
# MAIN TARGETS
# #####################################################################
toolchain: $(_TOOLCHAIN)/.all-done
toolchain-fetch: binutils-fetch gcc-fetch uclibc-fetch
# binutils (+ extracted patches from broadcom hnd-tools + uclibc buildroot patches)
$(_TOOLCHAIN)/.step1: binutils-install
touch $(_TOOLCHAIN)/.step1
# static gcc (+ extracted patches from broadcom hnd-tools + uclibc buildroot patches)
$(_TOOLCHAIN)/.step2: $(_TOOLCHAIN)/.step1 gcc-initial-install
touch $(_TOOLCHAIN)/.step2
# kernel header (NOT USED !)
$(_TOOLCHAIN)/.step3: $(_TOOLCHAIN)/.step2
touch $(_TOOLCHAIN)/.step3
# uclibc
$(_TOOLCHAIN)/.step4: $(_TOOLCHAIN)/.step3 uclibc-install
touch $(_TOOLCHAIN)/.step4
# shared gcc (+ extracted patches from broadcom hnd-tools + uclibc buildroot patches)
$(_TOOLCHAIN)/.step5: $(_TOOLCHAIN)/.step4 gcc-final-install
touch $(_TOOLCHAIN)/.step5
# final
$(_TOOLCHAIN)/.all-done: $(_TOOLCHAIN)/.step5
touch $(_TOOLCHAIN)/.all-done
# #####################################################################
# BUILD HOST TOOLCHAIN
# #####################################################################
_PACKAGE_BINUTILS=$(_DOWNLOAD_DIR)/binutils-2.13.2.1.tar.bz2
_DOWNLOAD_BINUTILS=ftp://ftp.fu-berlin.de/unix/gnu/binutils/binutils-2.13.2.1.tar.bz2
_BUILD_BINUTILS_SRC=$(_SOURCE)/binutils-2.13.2.1
_BUILD_BINUTILS=$(_SOURCE)/binutils-2.13.2.1-host
binutils: binutils-clean $(_BUILD_BINUTILS)/.all-done
binutils-fetch: $(_PACKAGE_BINUTILS)
$(_PACKAGE_BINUTILS):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_BINUTILS)
$(_BUILD_BINUTILS_SRC)/.unpacked: $(_PACKAGE_BINUTILS)
tar -C $(_SOURCE) -xjf $(_PACKAGE_BINUTILS)
touch $(_BUILD_BINUTILS_SRC)/.unpacked
$(_BUILD_BINUTILS_SRC)/.patched: $(_BUILD_BINUTILS_SRC)/.unpacked
(cd $(_BUILD_BINUTILS_SRC); cat $(_PATCHES)/???_binutils-*.patch | patch -p1 );
touch $(_BUILD_BINUTILS_SRC)/.patched
$(_BUILD_BINUTILS)/.configured: $(_BUILD_BINUTILS_SRC)/.patched
mkdir -p $(_BUILD_BINUTILS)
(cd $(_BUILD_BINUTILS); $(_BUILD_BINUTILS_SRC)/configure \
--build=i386-pc-linux-gnu \
--host=i386-pc-linux-gnu \
--target=mipsel-linux-uclibc \
--prefix=$(_TOOLCHAIN) \
--disable-nls \
--with-bcm4710a0 );
touch $(_BUILD_BINUTILS)/.configured
$(_BUILD_BINUTILS)/.all-done: $(_BUILD_BINUTILS)/.configured
make -C $(_BUILD_BINUTILS) all
touch $(_BUILD_BINUTILS)/.all-done
binutils-install: $(_BUILD_BINUTILS)/.all-done
mkdir -p $(_TOOLCHAIN)/lib $(_TOOLCHAIN)/mipsel-linux-uclibc
(cd $(_TOOLCHAIN)/mipsel-linux-uclibc; ln -s ../lib lib);
make -C $(_BUILD_BINUTILS) install
binutils-clean:
rm -f $(_BUILD_BINUTILS)/.configured $(_BUILD_BINUTILS)/.compiled $(_BUILD_BINUTILS)/.all-done
binutils-distclean:
rm -rf $(_BUILD_BINUTILS)
# #####################################################################
_PACKAGE_GCC=$(_DOWNLOAD_DIR)/gcc-3.2.3.tar.gz
_DOWNLOAD_GCC=ftp://ftp.fu-berlin.de/unix/gnu/gcc/gcc-3.2.3.tar.gz
_BUILD_GCC_SRC=$(_SOURCE)/gcc-3.2.3
_BUILD_GCC1=$(_BUILD_GCC_SRC)-initial
gcc-initial: $(_BUILD_GCC1)/.all-done
gcc-fetch: $(_PACKAGE_GCC)
gcc-initial-fetch: $(_PACKAGE_GCC)
$(_PACKAGE_GCC):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_GCC)
$(_BUILD_GCC_SRC)/.unpacked: $(_PACKAGE_GCC)
tar -C $(_SOURCE) -xzf $(_PACKAGE_GCC)
touch $(_BUILD_GCC_SRC)/.unpacked
$(_BUILD_GCC_SRC)/.patched: $(_BUILD_GCC_SRC)/.unpacked
(cd $(_BUILD_GCC_SRC); cat $(_PATCHES)/???_gcc-*.patch | patch -p1 );
touch $(_BUILD_GCC_SRC)/.patched
$(_BUILD_GCC1)/.configured: $(_BUILD_GCC_SRC)/.patched
mkdir -p $(_BUILD_GCC1)
(cd $(_BUILD_GCC1); $(_BUILD_GCC_SRC)/configure \
--build=i386-pc-linux-gnu \
--host=i386-pc-linux-gnu \
--target=mipsel-linux-uclibc \
--prefix=$(_TOOLCHAIN) \
--enable-languages=c \
--disable-shared \
--disable-threads \
--disable-nls \
--with-gnu-ld \
--with-gnu-as \
--with-bcm4710a0 );
touch $(_BUILD_GCC1)/.configured
$(_BUILD_GCC1)/.all-done: $(_BUILD_GCC1)/.configured
make -C $(_BUILD_GCC1) all-gcc
touch $(_BUILD_GCC1)/.all-done
gcc-initial-install: $(_BUILD_GCC1)/.all-done
make -C $(_BUILD_GCC1) install-gcc
gcc-initial-clean:
rm -f $(_BUILD_GCC1)/.configured $(_BUILD_GCC1)/.compiled $(_BUILD_GCC1)/.all-done
gcc-initial-distclean:
rm -rf $(_BUILD_GCC1)
# #####################################################################
_PACKAGE_UCLIBC=$(_DOWNLOAD_DIR)/uClibc-0.9.27.tar.bz2
_DOWNLOAD_UCLIBC=http://www.uclibc.org/downloads/uClibc-0.9.27.tar.bz2
_BUILD_UCLIBC=$(_SOURCE)/uClibc-0.9.27
uclibc: $(_BUILD_UCLIBC)/.all-done
uclibc-fetch: $(_PACKAGE_UCLIBC)
$(_PACKAGE_UCLIBC):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_UCLIBC)
$(_BUILD_UCLIBC)/.unpacked: $(_PACKAGE_UCLIBC)
tar -C $(_SOURCE) -xjf $(_PACKAGE_UCLIBC)
touch $(_BUILD_UCLIBC)/.unpacked
$(_BUILD_UCLIBC)/.configured: $(_BUILD_UCLIBC)/.unpacked
cp $(_CONFIGS)/uclibc.conf $(_BUILD_UCLIBC)/.config
sed -i -e 's:KERNEL_SOURCE=.*:KERNEL_SOURCE=\"$(_KERNEL_DIR)\":g' $(_BUILD_UCLIBC)/.config
sed -i -e 's:RUNTIME_PREFIX=.*:RUNTIME_PREFIX=\"$(_TOOLCHAIN)\":g' $(_BUILD_UCLIBC)/.config
sed -i -e 's:DEVEL_PREFIX=.*:DEVEL_PREFIX=\"$(_TOOLCHAIN)\":g' $(_BUILD_UCLIBC)/.config
make -C $(_BUILD_UCLIBC) oldconfig
touch $(_BUILD_UCLIBC)/.configured
$(_BUILD_UCLIBC)/.all-done: $(_BUILD_UCLIBC)/.configured
make -C $(_BUILD_UCLIBC) CROSS=mipsel-linux-uclibc- DEVEL_PREFIX=$(_TOOLCHAIN) all
make -C $(_BUILD_UCLIBC)/utils RUNTIME_PREFIX=$(_TOOLCHAIN) hostutils
touch $(_BUILD_UCLIBC)/.all-done
uclibc-install: $(_BUILD_UCLIBC)/.all-done
make -C $(_BUILD_UCLIBC) install
cp $(_BUILD_UCLIBC)/utils/ldd.host $(_TOOLCHAIN)/bin/mipsel-linux-uclibc-ldd
uclibc-clean:
rm -f $(_BUILD_UCLIBC)/.configured $$(_BUILD_UCLIBC)/.compiled $(_BUILD_UCLIBC)/.all-done
uclibc-distclean:
rm -rf $(_BUILD_UCLIBC)
# #####################################################################
_BUILD_GCC2=$(_BUILD_GCC_SRC)-final
gcc-final: $(_BUILD_GCC2)/.all-done
$(_BUILD_GCC2)/.configured: $(_BUILD_GCC_SRC)/.patched
mkdir -p $(_BUILD_GCC2)
(cd $(_TOOLCHAIN)/mipsel-linux-uclibc; ln -s ../include sys-include);
(cd $(_BUILD_GCC2); $(_BUILD_GCC_SRC)/configure \
--build=i386-pc-linux-gnu \
--host=i386-pc-linux-gnu \
--target=mipsel-linux-uclibc \
--prefix=$(_TOOLCHAIN) \
--enable-languages=c,c++ \
--enable-shared \
--disable-nls \
--with-gnu-ld \
--with-gnu-as \
--with-bcm4710a0 );
touch $(_BUILD_GCC2)/.configured
$(_BUILD_GCC2)/.all-done: $(_BUILD_GCC2)/.configured
make -C $(_BUILD_GCC2) all
touch $(_BUILD_GCC2)/.all-done
gcc-final-install: $(_BUILD_GCC2)/.all-done
make -C $(_BUILD_GCC2) install
set -e; (cd $(_TOOLCHAIN); \
ln -sf mipsel-linux-uclibc mipsel-linux; \
ln -sf mipsel-linux-uclibc mipsel-uclibc; \
cd bin; \
for app in mipsel-linux-uclibc-* ; do \
ln -sf $${app} mipsel-linux$${app##mipsel-linux-uclibc}; \
ln -sf $${app} mipsel-uclibc$${app##mipsel-linux-uclibc}; \
done; \
);
gcc-final-clean:
rm -f $(_BUILD_GCC2)/.configured $(_BUILD_GCC2)/.compiled $(_BUILD_GCC2)/.all-done
gcc-final-distclean:
rm -rf $(_BUILD_GCC2)