Created
December 4, 2013 03:18
-
-
Save pefoley2/7781810 to your computer and use it in GitHub Desktop.
cross!
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
set -e | |
set -o pipefail | |
TOPDIR=`pwd` | |
BUILD=`/usr/share/gnuconfig/config.guess` | |
TARGET=$1 | |
DIR=$TOPDIR/$TARGET | |
export ARCH=`echo $TARGET | sed 's/-.*//'` | |
if test -z $TARGET; then | |
echo "Error: must specify target" | |
echo "Usage: ./cross.sh alpha-linux" | |
exit 1 | |
fi | |
GCC=`wget -q http://ftp.gnu.org/pub/gnu/gcc -O - | sed -e '/folder/!d' -e 's/.*="gcc-//' -e 's/\/".*//' | tail -1` | |
BINUTILS=`wget -q http://ftp.gnu.org/pub/gnu/binutils -O - | sed -e '/tar.bz2</!d' -e 's/.*binutils-//' -e 's/\.tar.*//' | tail -1` | |
GLIBC=`wget -q http://ftp.gnu.org/pub/gnu/glibc/?C=M -O - | sed -e '/xz"/!d' -e 's/.*glibc-//' -e 's/\.tar.*//' -e '/ports/d' | tail -1` | |
LINUX=`wget -q http://kernel.org/pub/linux/kernel/v3.x -O - | sed -e '/tar.xz"/!d' -e 's/.*linux-//' -e 's/\.tar.*//' | sort | tail -1` | |
wget -qN -P tarballs http://ftp.gnu.org/pub/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 \ | |
http://ftp.gnu.org/pub/gnu/binutils/binutils-$BINUTILS.tar.bz2 \ | |
http://ftp.gnu.org/pub/gnu/glibc/glibc-$GLIBC.tar.xz \ | |
http://kernel.org/pub/linux/kernel/v3.x/linux-$LINUX.tar.xz | |
OLDTAR=`find tarballs/* -not \( -name gcc-$GCC.tar.bz2 -o -name \ | |
binutils-$BINUTILS.tar.bz2 -o -name glibc-$GLIBC.tar.xz \ | |
-o -name linux-$LINUX.tar.xz \)` | |
[ -z "$OLDTAR" ] || rm -rf src $OLDTAR | |
unpack() | |
{ | |
mkdir -p src/{gcc,binutils,glibc,linux} | |
tar xf tarballs/gcc-$GCC.tar.bz2 --strip-component=1 -C src/gcc | |
tar xf tarballs/binutils-$BINUTILS.tar.bz2 --strip-component=1 -C src/binutils | |
tar xf tarballs/glibc-$GLIBC.tar.xz --strip-component=1 -C src/glibc | |
tar xf tarballs/linux-$LINUX.tar.xz --strip-component=1 -C src/linux | |
#for p in fortify libgcc; do | |
#patch -p0 <patches/$p.patch | |
#done | |
} | |
conf() | |
{ | |
src=$1 | |
shift | |
work=$1 | |
shift | |
mkdir -p $DIR/{work,logs}/$work | |
cd $DIR/work/$work | |
test -e Makefile || $TOPDIR/src/$src/configure --build=$BUILD $@ \ | |
|& tee $DIR/logs/$work/config.log | |
} | |
build() | |
{ | |
work=$1 | |
shift | |
make -j4 -C $DIR/work/$work $@ |& tee $DIR/logs/$work/build.log | |
} | |
install() | |
{ | |
work=$1 | |
shift | |
make -j4 -C $DIR/work/$work $@ |& tee $DIR/logs/$work/install.log | |
} | |
test -d src || unpack | |
conf binutils binutils --target=$TARGET --prefix=$DIR/install --disable-nls | |
build binutils | |
install binutils install | |
conf gcc gcc --target=$TARGET --prefix=$DIR/install --disable-nls \ | |
--disable-shared --enable-languages=c | |
build gcc all-gcc | |
install gcc install-gcc | |
mkdir -p $DIR/{work,logs}/linux | |
make -j4 -C $TOPDIR/src/linux O=$DIR/work/linux headers_install \ | |
INSTALL_HDR_PATH=$DIR/install/$TARGET |& tee $DIR/logs/linux/build.log | |
conf glibc glibc --host=$TARGET --prefix=$DIR/install/$TARGET \ | |
--with-headers=$DIR/install/$TARGET/include \ | |
CC=$DIR/install/bin/$TARGET-gcc \ | |
libc_cv_forced_unwind=yes libc_cv_ssp=no #HACK | |
install glibc install-headers | |
touch $DIR/install/$TARGET/include/gnu/stubs.h #HACK | |
build gcc all-target-libgcc | |
install gcc install-target-libgcc | |
build glibc | |
install glibc install | |
conf gcc gcc2 --target=$TARGET --prefix=$DIR/install --disable-nls | |
build gcc2 | |
install gcc2 install | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment