[MLton] cvs commit: mingw build-cross-gcc script
sweeks@mlton.org
sweeks@mlton.org
Fri, 7 Nov 2003 11:55:05 -0800
sweeks 03/11/07 11:55:05
Modified: bin build-cross-gcc
Log:
From Anoq.
Revision Changes Path
1.8 +47 -6 mlton/bin/build-cross-gcc
Index: build-cross-gcc
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/build-cross-gcc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- build-cross-gcc 10 Apr 2003 02:03:02 -0000 1.7
+++ build-cross-gcc 7 Nov 2003 19:55:04 -0000 1.8
@@ -2,13 +2,24 @@
# This script builds and installs a gcc cross compiler.
-# It has been used to build cross compilers from Linux to Cygwin and
-# from Linux to SunOS. It is unlikely that this script will work
+# It has been used to build cross compilers from Linux to Cygwin,
+# MinGW, and SunOS. It is unlikely that this script will work
# out-of-the-box. It is only intended as a template. You should read
# through it and understand what it does, and make changes as
# necessary. Feel free to add another targetType if you modify this
# script for another target.
+# Notes from Anoq about the mingw target:
+# I downloaded the following files from www.mingw.org:
+# *) binutils-2.13.90-20030111-1-src.tar.gz which I unpacked to
+# binutils-2.13.90-20030111-1-src.tar
+# This script unpacks the .tar to binutils-2.13.90-20030111-1-src
+# *) gcc-3.2.3-20030504-1-src.tar.gz which I unpacked to
+# gcc-3.2.3-20030504-1-src.tar
+# This script unpacks the .tar to gcc-3.2.3-20030504-1
+# However when running make on gcc it complains about missing files
+# stdlib.h and unistd.h
+
set -e
die () {
@@ -20,13 +31,13 @@
name=`basename $0`
usage () {
- die "usage: $name {cygwin|sun}"
+ die "usage: $name {cygwin|mingw|sun}"
}
case "$#" in
1)
case "$1" in
- cygwin|sun)
+ cygwin|mingw|sun)
targetType="$1"
;;
*)
@@ -54,6 +65,8 @@
case "$targetType" in
cygwin)
target='i386-pc-cygwin'
+ configureGCCFlags=''
+ makeGCCFlags=''
# For Cygwin, we also need the cygwin and w32api packages,
# which contain necessary header files and libraries. I got
# them by installing cygwin in a Windows machine (using #
@@ -65,8 +78,23 @@
cygwin='cygwin-1.3.17-1'
w32api='w32api-2.1-1'
;;
+mingw)
+ target='i386-mingw32msvc'
+ # target='mingw32'
+ # These flags are from build-cross.sh from www.libsdl.org except:
+ # I added --disable-nls because of undefined references to dcgettext__
+ configureGCCFlags='--with-headers=$prefix/$target/include --with-gnu-as --with-gnu-ld --without-newlib --disable-multilib --disable-nls'
+ makeGCCFlags='LANGUAGES=c'
+ # For MinGW, we also need the mingw-runtime and w32api packages,
+ # which contain necessary header files and libraries. I got
+ # them from www.mingw.org.
+ mingw='mingw-runtime-3.2'
+ w32api='w32api-2.4'
+;;
sun)
target='sparc-sun-solaris'
+ configureGCCFlags=''
+ makeGCCFlags=''
# For sun, we assume that you have already copied the includes
# and libraries from a SunOS machine to the host machine.
if ! [ -d "$prefix/$target/include" -a -d "$prefix/$target/lib" ]; then
@@ -102,6 +130,19 @@
die "Cannot create $prefix/$target."
(cd usr && tar c include lib) | (cd $prefix/$target/ && tar x)
;;
+mingw)
+ exists $mingw.tar
+ exists $w32api.tar
+ echo 'Copying include files and libraries needed by cross compiler.'
+ cd $root
+ mkdir -p mingw
+ cd mingw
+ tar x <../$mingw.tar
+ tar x <../$w32api.tar
+ mkdir -p $prefix/$target ||
+ die "Cannot create $prefix/$target."
+ (tar c include lib) | (cd $prefix/$target/ && tar x)
+;;
*)
;;
esac
@@ -124,13 +165,13 @@
tar x <$gccTar
mkdir -p build-gcc
cd build-gcc
-../gcc-$gccVers/configure \
+eval ../gcc-$gccVers/configure -v $configureGCCFlags \
--enable-languages=c \
--prefix=$prefix \
--target=$target \
>$root/configure-gcc-log 2>&1 ||
die "Configure of gcc failed."
-make all install >$root/build-gcc-log 2>&1 ||
+eval make $makeGCCFlags all install >$root/build-gcc-log 2>&1 ||
die "Build of gcc failed."
echo 'Success.'