From ae066e93a7918f32cbfb4ec2f8bc50fe8d47caef Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 16 Oct 2001 16:18:59 +0000 Subject: [PATCH] make people's lives easier --- tools/cross/.gitignore | 4 + tools/cross/cross-configure.sh | 9 ++ tools/cross/cross-make.sh | 7 ++ tools/cross/cross.sh | 203 +++++++++++++++++++++++++++++++++ 4 files changed, 223 insertions(+) create mode 100644 tools/cross/.gitignore create mode 100755 tools/cross/cross-configure.sh create mode 100755 tools/cross/cross-make.sh create mode 100755 tools/cross/cross.sh diff --git a/tools/cross/.gitignore b/tools/cross/.gitignore new file mode 100644 index 0000000..11f720f --- /dev/null +++ b/tools/cross/.gitignore @@ -0,0 +1,4 @@ +binutils-i386-mingw32msvc +gcc-i386-mingw32msvc +source + diff --git a/tools/cross/cross-configure.sh b/tools/cross/cross-configure.sh new file mode 100755 index 0000000..b528a3b --- /dev/null +++ b/tools/cross/cross-configure.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +PATH=/usr/local/cross-tools/bin:/usr/local/cross-tools/i386-mingw32msvc/bin:$PATH \ + ./configure \ + --host=i386-mingw32msvc \ + --target=i386-mingw32msvc \ + --build=i386-linux \ + $* + diff --git a/tools/cross/cross-make.sh b/tools/cross/cross-make.sh new file mode 100755 index 0000000..3aa9766 --- /dev/null +++ b/tools/cross/cross-make.sh @@ -0,0 +1,7 @@ +#!/bin/sh +HOST_CC=gcc +PATH=$PATH:/usr/local/cross-tools/bin:/usr/local/cross-tools/i386-mingw32msvc/bin +export HOST_CC +export PATH +make $* + diff --git a/tools/cross/cross.sh b/tools/cross/cross.sh new file mode 100755 index 0000000..c3baa08 --- /dev/null +++ b/tools/cross/cross.sh @@ -0,0 +1,203 @@ +#!/bin/sh + +# This is my script for building a complete cross-compiler +# toolchain. It is based partly on Mo Dejong's script for doing +# the same, but with some added fixes. +# +# Written by Ray Kelm + +# what flavor are we building? + +TARGET=i386-mingw32msvc + +# where does it go? + +PREFIX=/usr/local/cross-tools + +# you probably don't need to change anything from here down + +TOPDIR=`pwd` +SRCDIR=$TOPDIR/source + +# these files are available from Mumit Khan's archive + +BINUTILS=binutils-19990818 +BINUTILS_TAR=$BINUTILS-1-src.tar.gz +GCC=gcc-2.95.2 +GCC_TAR=$GCC-1-src.tar.gz +MSVCRT_ZIP=bin-msvcrt-2000-03-27.zip +MUMIT_URL=ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1 +MUMIT_URL2=ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/runtime + +# this is from my archive + +GCC_PATCH=gcc-2.95.2-libio-patch +RHK_URL=http://www.libsdl.org/Xmingw32/crossgcc +OPENGL_TAR=opengl.tar.gz +DIRECTX_TAR=directx.tar.gz + +# need install directory first on the path so gcc can find binutils + +PATH="$PREFIX/bin:$PATH" + +# +# download a file from a given url, only if it is not present +# + +download_file() +{ + cd $SRCDIR + if test ! -f $1 ; then + echo "Downloading $1" + wget $2/$1 + if test ! -f $1 ; then + echo "Could not download $1" + exit 1 + fi + else + echo "Found $1 in the srcdir $SRCDIR" + fi + cd $TOPDIR +} + +download_files() +{ + mkdir -p $SRCDIR + + # Make sure wget is installed + if test "x`which wget`" = "x" ; then + echo "You need to install wget." + exit 1 + fi + download_file $BINUTILS_TAR $MUMIT_URL + download_file $GCC_TAR $MUMIT_URL + download_file $MSVCRT_ZIP $MUMIT_URL2 + download_file $GCC_PATCH $RHK_URL + download_file $OPENGL_TAR $RHK_URL + download_file $DIRECTX_TAR $RHK_URL +} + +install_libs() +{ + echo "Installing binary cross libs and includes" + mkdir -p $PREFIX/$TARGET + cd $PREFIX + unzip -q -o $SRCDIR/$MSVCRT_ZIP + cd $PREFIX/$TARGET + gzip -dc $SRCDIR/opengl.tar.gz | tar xf - + gzip -dc $SRCDIR/directx.tar.gz | tar xf - + cd $TOPDIR +} + +extract_binutils() +{ + cd $SRCDIR + rm -rf $BINUTILS + echo "Extracting binutils" + gzip -dc $SRCDIR/$BINUTILS_TAR | tar xf - + cd $TOPDIR +} + +configure_binutils() +{ + cd $TOPDIR + rm -rf binutils-$TARGET + mkdir binutils-$TARGET + cd binutils-$TARGET + echo "Configuring binutils" + $SRCDIR/$BINUTILS/configure --prefix=$PREFIX --target=$TARGET &> configure.log + cd $TOPDIR +} + +build_binutils() +{ + cd $TOPDIR/binutils-$TARGET + echo "Building binutils" + make &> make.log + if test $? -ne 0; then + echo "make failed" + exit 1 + fi + cd $TOPDIR +} + +install_binutils() +{ + cd $TOPDIR/binutils-$TARGET + echo "Installing binutils" + make install &> make-install.log + if test $? -ne 0; then + echo "install failed" + exit 1 + fi + cd $TOPDIR +} + +extract_gcc() +{ + cd $SRCDIR + rm -rf $GCC + echo "Extracting gcc" + gzip -dc $SRCDIR/$GCC_TAR | tar xf - + cd $TOPDIR +} + +patch_gcc() +{ + echo "Patching gcc" + cd $SRCDIR/$GCC + patch -p1 < $SRCDIR/$GCC_PATCH + cd $TOPDIR +} + +configure_gcc() +{ + cd $TOPDIR + rm -rf gcc-$TARGET + mkdir gcc-$TARGET + cd gcc-$TARGET + echo "Configuring gcc" + $SRCDIR/$GCC/configure -v --prefix=$PREFIX --target=$TARGET \ + --with-gnu-as --with-gnu-ld --disable-multilib &> configure.log + cd $TOPDIR +} + +build_gcc() +{ + cd $TOPDIR/gcc-$TARGET + echo "Building gcc" + make LANGUAGES="c c++" &> make.log + if test $? -ne 0; then + echo "make failed" + exit 1 + fi + cd $TOPDIR +} + +install_gcc() +{ + cd $TOPDIR/gcc-$TARGET + echo "Installing gcc" + make LANGUAGES="c c++" install &> make-install.log + if test $? -ne 0; then + echo "install failed" + exit 1 + fi + cd $TOPDIR +} + +download_files + +install_libs + +extract_binutils +configure_binutils +build_binutils +install_binutils + +extract_gcc +patch_gcc +configure_gcc +build_gcc +install_gcc +