* scripts/Makefile.am:
[mono.git] / doc / mono-build-w32.sh
index 06d15f7fa71849b469ef2fa0ed21fe15fc790b85..d9e1f963c7958adcc6f41cb9880a356ba7f03145 100755 (executable)
@@ -17,6 +17,12 @@ echo "Building Mono and dependencies in $here, installing to $here/install"
 
 PATH=$here/install/bin:$here/install/lib:$PATH
 
+# Make sure cygwin's libiconv is installed, or libtool blows its tiny mind
+if [ ! -f /usr/lib/libiconv.la ]; then
+    echo "You need to install the cygwin \"libiconv\" package!"
+    exit -1
+fi
+
 # Check mono out first, so we can run aclocal from inside the mono dir (it
 # needs to see which version of the real aclocal to run)
 test -z "$CVSROOT" && CVSROOT=:pserver:anonymous@anoncvs.go-mono.com:/mono
@@ -42,10 +48,26 @@ fi
 
 cvs checkout mono || exit -1
 
+echo "Checking automake version"
+automake_required="1.6.2"
+automake_version=`automake --version | head -1 | awk '{print $4}' | tr -d '[a-zA-Z]' | sed 's/-.*$//g'`
+echo "Found automake version $automake_version"
+if expr $automake_version \< $automake_required > /dev/null; then
+       echo "Your automake is too old!  You need version $automake_required or newer."
+       exit -1
+else
+       echo "Automake version new enough."
+fi
+
+# Select the stable version anyway...
+if [ ! -z "${AUTO_STABLE}" -o -e /usr/autotool/stable ]; then
+    export AUTO_STABLE=${AUTO_STABLE:-/usr/autotool/stable}
+    export AUTO_DEVEL=${AUTO_STABLE}
+fi
+
 # Need to install pkgconfig and set ACLOCAL_FLAGS if there is not a
 # pkgconfig installed already.  Otherwise set PKG_CONFIG_PATH to the
-# glib we're about to install in $here/install.  This script could
-# attempt to be clever and see if glib 2 is already installed, too.
+# glib we're about to install in $here/install.
 
 
 # --print-ac-dir was added in 1.2h according to the ChangeLog.  This
@@ -56,15 +78,17 @@ cvs checkout mono || exit -1
 # it finds two copies of the m4 macros).  The GIMP for Windows
 # pkgconfig sets its prefix based on the location of its binary, so we
 # dont need PKG_CONFIG_PATH (the internal pkgconfig config file
-# $prefix is handled similarly).
+# $prefix is handled similarly). For the cygwin pkgconfig we do need to
+# set it, and we need to edit the mingw pc files too.
 
 function aclocal_scan () {
     # Quietly ignore the rogue '-I' and other aclocal flags that
     # aren't actually directories...
     #
     # cd into mono/ so that the aclocal wrapper can work out which version
-    # of aclocal to run
-    for i in `(cd mono && aclocal --print-ac-dir)` $ACLOCAL_FLAGS
+    # of aclocal to run, and add /usr/share/aclocal too cos aclocal looks there
+    # too.
+    for i in `(cd mono && aclocal --print-ac-dir)` /usr/share/aclocal $ACLOCAL_FLAGS
     do
        if [ -f $i/$1 ]; then
            return 0
@@ -91,10 +115,17 @@ function install_package() {
     fi
 }
 
-if ! aclocal_scan pkg.m4 ; then
-    ACLOCAL_FLAGS="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
+# pkgconfig is only used during the build, so we can use the cygwin version
+# if it exists
+if aclocal_scan pkg.m4 ; then
+    install_pkgconfig=no
+else
+    install_pkgconfig=yes
 fi
 
+# But we still need to use the mingw libs for glib & co
+ACLOCAL_FLAGS="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
+
 export PATH
 export ACLOCAL_FLAGS
 
@@ -105,23 +136,36 @@ fi
 
 # Fetch and install pkg-config, glib, iconv, intl
 
-install_package pkgconfig-0.80-tml-20020101.zip bin/pkg-config.exe pkgconfig
-install_package glib-1.3.12-20020101.zip lib/libglib-1.3-12.dll glib
-install_package glib-dev-1.3.12-20020101.zip lib/glib-1.3.lib glib-dev
+if [ $install_pkgconfig = "yes" ]; then
+    install_package pkgconfig-0.11-20020310.zip bin/pkg-config.exe pkgconfig
+else
+    echo "Not installing pkgconfig, you already seem to have it installed"
+fi
+install_package glib-2.0.4-20020703.zip lib/libglib-2.0-0.dll glib
+install_package glib-dev-2.0.4-20020703.zip lib/glib-2.0.lib glib-dev
 install_package libiconv-1.7.zip lib/iconv.dll iconv
-install_package libiconv-dev-1.7.zip lib/iconv.lib iconv-dev
 install_package libintl-0.10.40-20020101.zip lib/libintl-1.dll intl
 install_package libgc-dev.zip lib/gc.dll gc-dev
 
-# Needed to find the libiconv bits
+if [ $install_pkgconfig = "no" ]; then
+    echo "Fixing up the pkgconfig paths"
+    for i in $here/install/lib/pkgconfig/*.pc
+    do
+       mv $i $i.orig
+       sed -e "s@^prefix=/target\$@prefix=$here/install@" < $i.orig > $i
+    done
+    export PKG_CONFIG_PATH=$here/install/lib/pkgconfig
+fi
+
+# Needed to find the libgc bits
 CPPFLAGS="$CPPFLAGS -I$here/install/include"
 LDFLAGS="$LDFLAGS -L$here/install/lib"
 export CPPFLAGS
 export LDFLAGS
 
 # Make sure we build native w32, not cygwin
-CC="gcc -mno-cygwin"
-export CC
+#CC="gcc -mno-cygwin"
+#export CC
 
 # --prefix is used to set the class library dir in mono, and it needs
 # to be in windows-native form.  It also needs to have '\' turned into