go to newer mingw setup

This commit is contained in:
Bill Currie 2002-12-13 17:58:51 +00:00
parent 9fd59ac09a
commit 7c86ec2396

View file

@ -1,10 +1,12 @@
#!/bin/sh #!/bin/sh
# This is my script for building a complete cross-compiler # This is my script for building a complete cross-compiler toolchain.
# toolchain. It is based partly on Mo Dejong's script for doing # It is based partly on Ray Kelm's script, which in turn was built on
# the same, but with some added fixes. # Mo Dejong's script for doing the same, but with some added fixes.
# The intent with this script is to build a cross-compiled version
# of the current MinGW environment.
# #
# Written by Ray Kelm <rhk@newimage.com> # Updated by Sam Lantinga <slouken@libsdl.org>
# what flavor are we building? # what flavor are we building?
@ -17,28 +19,26 @@ PREFIX=/usr/local/cross-tools
# you probably don't need to change anything from here down # you probably don't need to change anything from here down
TOPDIR=`pwd` TOPDIR=`pwd`
SRCDIR=$TOPDIR/source SRCDIR="$TOPDIR/source"
# these files are available from Mumit Khan's archive # These are the files from the MinGW 1.1 release
BINUTILS=binutils-19990818 MINGW_URL=http://unc.dl.sourceforge.net/sourceforge/mingw
BINUTILS_TAR=$BINUTILS-1-src.tar.gz GCC=gcc-3.2-20020817-1
GCC=gcc-2.95.2 GCC_ARCHIVE=$GCC.src.tar.gz
GCC_TAR=$GCC-1-src.tar.gz GCC_PATCH=""
MSVCRT_ZIP=bin-msvcrt-2000-03-27.zip BINUTILS=binutils-2.13.90-20021006-2
MUMIT_URL=ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1 BINUTILS_ARCHIVE=$BINUTILS-src.tar.gz
MUMIT_URL2=ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/runtime MINGW=mingw-runtime-2.2
MINGW_ARCHIVE=$MINGW.tar.gz
W32API=w32api-2.0
W32API_ARCHIVE=$W32API.tar.gz
# taniwha's binutils patch # These are the files from the SDL website
BINUTILS_PATCH=binutils-19990818-bison-patch
TAN_URL=http://quakeforge.net/~taniwha/
# this is from my archive SDL_URL=http://www.libsdl.org/extras/win32/common
OPENGL_ARCHIVE=opengl-devel.tar.gz
GCC_PATCH=gcc-2.95.2-libio-patch DIRECTX_ARCHIVE=directx-devel.tar.gz
RHK_URL=http://www.newimage.com/~rhk/crossgcc/
OPENGL_TAR=opengl.tar.gz
DIRECTX_TAR=directx.tar.gz
# need install directory first on the path so gcc can find binutils # need install directory first on the path so gcc can find binutils
@ -50,10 +50,10 @@ PATH="$PREFIX/bin:$PATH"
download_file() download_file()
{ {
cd $SRCDIR cd "$SRCDIR"
if test ! -f $1 ; then if test ! -f $1 ; then
echo "Downloading $1" echo "Downloading $1"
wget $2/$1 wget "$2/$1"
if test ! -f $1 ; then if test ! -f $1 ; then
echo "Could not download $1" echo "Could not download $1"
exit 1 exit 1
@ -61,142 +61,166 @@ download_file()
else else
echo "Found $1 in the srcdir $SRCDIR" echo "Found $1 in the srcdir $SRCDIR"
fi fi
cd $TOPDIR cd "$TOPDIR"
} }
download_files() download_files()
{ {
mkdir -p $SRCDIR mkdir -p "$SRCDIR"
# Make sure wget is installed # Make sure wget is installed
if test "x`which wget`" = "x" ; then if test "x`which wget`" = "x" ; then
echo "You need to install wget." echo "You need to install wget."
exit 1 exit 1
fi fi
download_file $BINUTILS_TAR $MUMIT_URL download_file "$GCC_ARCHIVE" "$MINGW_URL"
download_file $BINUTILS_PATCH $TAN_URL download_file "$BINUTILS_ARCHIVE" "$MINGW_URL"
download_file $GCC_TAR $MUMIT_URL download_file "$MINGW_ARCHIVE" "$MINGW_URL"
download_file $MSVCRT_ZIP $MUMIT_URL2 download_file "$W32API_ARCHIVE" "$MINGW_URL"
download_file $GCC_PATCH $RHK_URL download_file "$OPENGL_ARCHIVE" "$SDL_URL"
download_file $OPENGL_TAR $RHK_URL download_file "$DIRECTX_ARCHIVE" "$SDL_URL"
download_file $DIRECTX_TAR $RHK_URL
} }
install_libs() install_libs()
{ {
echo "Installing binary cross libs and includes" echo "Installing cross libs and includes"
mkdir -p $PREFIX/$TARGET mkdir -p "$PREFIX/$TARGET"
cd $PREFIX cd "$PREFIX/$TARGET"
unzip -q -o $SRCDIR/$MSVCRT_ZIP gzip -dc "$SRCDIR/$MINGW_ARCHIVE" | tar xf -
cd $PREFIX/$TARGET gzip -dc "$SRCDIR/$W32API_ARCHIVE" | tar xf -
gzip -dc $SRCDIR/opengl.tar.gz | tar xf - gzip -dc "$SRCDIR/$OPENGL_ARCHIVE" | tar xf -
gzip -dc $SRCDIR/directx.tar.gz | tar xf - gzip -dc "$SRCDIR/$DIRECTX_ARCHIVE" | tar xf -
cd $TOPDIR cd "$TOPDIR"
} }
extract_binutils() extract_binutils()
{ {
cd $SRCDIR cd "$SRCDIR"
rm -rf $BINUTILS rm -rf "$BINUTILS"
echo "Extracting binutils" echo "Extracting binutils"
gzip -dc $SRCDIR/$BINUTILS_TAR | tar xf - gzip -dc "$SRCDIR/$BINUTILS_ARCHIVE" | tar xf -
cd $TOPDIR mv binutills-2.13.90-20021006-2 binutils-2.13.90-20021006-2
} cd "$TOPDIR"
patch_binutils()
{
echo "Patching binutils"
cd $SRCDIR/$BINUTILS
patch -p1 < $SRCDIR/$BINUTILS_PATCH
cd $TOPDIR
} }
configure_binutils() configure_binutils()
{ {
cd $TOPDIR cd "$TOPDIR"
rm -rf binutils-$TARGET rm -rf "binutils-$TARGET"
mkdir binutils-$TARGET mkdir "binutils-$TARGET"
cd binutils-$TARGET cd "binutils-$TARGET"
echo "Configuring binutils" echo "Configuring binutils"
$SRCDIR/$BINUTILS/configure --prefix=$PREFIX --target=$TARGET &> configure.log "$SRCDIR/$BINUTILS/configure" --prefix="$PREFIX" --target=$TARGET &> configure.log
cd $TOPDIR cd "$TOPDIR"
} }
build_binutils() build_binutils()
{ {
cd $TOPDIR/binutils-$TARGET cd "$TOPDIR/binutils-$TARGET"
echo "Building binutils" echo "Building binutils"
make &> make.log make &> make.log
if test $? -ne 0; then if test $? -ne 0; then
echo "make failed" echo "make failed - log available: binutils-$TARGET/make.log"
exit 1 exit 1
fi fi
cd $TOPDIR cd "$TOPDIR"
} }
install_binutils() install_binutils()
{ {
cd $TOPDIR/binutils-$TARGET cd "$TOPDIR/binutils-$TARGET"
echo "Installing binutils" echo "Installing binutils"
make install &> make-install.log make install &> make-install.log
if test $? -ne 0; then if test $? -ne 0; then
echo "install failed" echo "install failed - log available: binutils-$TARGET/make-install.log"
exit 1 exit 1
fi fi
cd $TOPDIR cd "$TOPDIR"
} }
extract_gcc() extract_gcc()
{ {
cd $SRCDIR cd "$SRCDIR"
rm -rf $GCC rm -rf "$GCC"
echo "Extracting gcc" echo "Extracting gcc"
gzip -dc $SRCDIR/$GCC_TAR | tar xf - gzip -dc "$SRCDIR/$GCC_ARCHIVE" | tar xf -
cd $TOPDIR cd "$TOPDIR"
} }
patch_gcc() patch_gcc()
{ {
if [ "$GCC_PATCH" != "" ]; then
echo "Patching gcc" echo "Patching gcc"
cd $SRCDIR/$GCC cd "$SRCDIR/$GCC"
patch -p1 < $SRCDIR/$GCC_PATCH patch -p1 < "$SRCDIR/$GCC_PATCH"
cd $TOPDIR cd "$TOPDIR"
fi
} }
configure_gcc() configure_gcc()
{ {
cd $TOPDIR cd "$TOPDIR"
rm -rf gcc-$TARGET rm -rf "gcc-$TARGET"
mkdir gcc-$TARGET mkdir "gcc-$TARGET"
cd gcc-$TARGET cd "gcc-$TARGET"
echo "Configuring gcc" echo "Configuring gcc"
$SRCDIR/$GCC/configure -v --prefix=$PREFIX --target=$TARGET \ "$SRCDIR/$GCC/configure" -v \
--with-gnu-as --with-gnu-ld --disable-multilib &> configure.log --prefix="$PREFIX" --target=$TARGET \
cd $TOPDIR --with-headers="$PREFIX/$TARGET/include" \
--with-gnu-as --with-gnu-ld \
--without-newlib --disable-multilib &> configure.log
cd "$TOPDIR"
} }
build_gcc() build_gcc()
{ {
cd $TOPDIR/gcc-$TARGET cd "$TOPDIR/gcc-$TARGET"
echo "Building gcc" echo "Building gcc"
make LANGUAGES="c c++" &> make.log make LANGUAGES="c c++" &> make.log
if test $? -ne 0; then if test $? -ne 0; then
echo "make failed" echo "make failed - log available: gcc-$TARGET/make.log"
exit 1 exit 1
fi fi
cd $TOPDIR cd "$TOPDIR"
} }
install_gcc() install_gcc()
{ {
cd $TOPDIR/gcc-$TARGET cd "$TOPDIR/gcc-$TARGET"
echo "Installing gcc" echo "Installing gcc"
make LANGUAGES="c c++" install &> make-install.log make LANGUAGES="c c++" install &> make-install.log
if test $? -ne 0; then if test $? -ne 0; then
echo "install failed" echo "install failed - log available: gcc-$TARGET/make-install.log"
exit 1 exit 1
fi fi
cd $TOPDIR cd "$TOPDIR"
}
final_tweaks()
{
echo "Finalizing installation"
# remove gcc build headers
rm -rf "$PREFIX/$TARGET/sys-include"
# make cc and c++ symlinks to gcc and g++
if [ ! -f "$PREFIX/$TARGET/bin/g++" ]; then
ln "$PREFIX/bin/$TARGET-g++" "$PREFIX/$TARGET/bin/g++"
fi
if [ ! -f "$PREFIX/$TARGET/bin/cc" ]; then
ln -s "gcc" "$PREFIX/$TARGET/bin/cc"
fi
if [ ! -f "$PREFIX/$TARGET/bin/c++" ]; then
ln -s "g++" "$PREFIX/$TARGET/bin/c++"
fi
# strip all the binaries
ls "$PREFIX"/bin/* "$PREFIX/$TARGET"/bin/* | egrep -v '.dll$' |
while read file; do
strip "$file"
done
echo "Installation complete!"
} }
download_files download_files
@ -204,7 +228,6 @@ download_files
install_libs install_libs
extract_binutils extract_binutils
patch_binutils
configure_binutils configure_binutils
build_binutils build_binutils
install_binutils install_binutils
@ -215,3 +238,4 @@ configure_gcc
build_gcc build_gcc
install_gcc install_gcc
final_tweaks