[Mono-list] Script to help build mono

Dick Porter dick@ximian.com
Mon, 18 Feb 2002 22:33:05 +0000


--e8/wErwm0bqugfcz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


There seems to be a few more people trying to build Mono now, so I
wrote a script that grabs the dependencies, builds them, and then builds
mono itself.  It manages details like ACLOCAL_FLAGS and PKG_CONFIG_PATH
for you.

To use this, you need wget (other url-grabbing scripts can be added if
needed), and all the build tools like gcc, make, automake, etc.  Put the
script wherever you want (eg /usr/local/bin), make a new directory to hold
all the bits, and run it from that new directory.

To spell it out:

1) save the attachment to /usr/local/bin/mono-build.sh
2) chmod 755 /usr/local/bin/mono-build.sh
3) mkdir ~/mono
4) cd ~/mono
5) /usr/local/bin/mono-build.sh


I've tested it here, and it works for me :)  Please let me know if there are
any problems (or improvements.)

Oh, and it's only going to work on Linux or Linux-like systems - cygwin/w32
support is coming.

- Dick


--e8/wErwm0bqugfcz
Content-Type: text/x-sh; charset=us-ascii
Content-Disposition: attachment; filename="mono-build.sh"

#!/bin/sh

# Script to automate the building of mono and its dependencies.
# Relies on wget being installed (could make it fall back to using
# lynx, links, w3, curl etc), assumes that gcc, make, tar, automake,
# etc are already installed too (may be worth testing for all that
# right at the top and bailing out if missing/too old/too new etc).


# See where we are.  This will become the top level directory for the
# installation, unless we are given an alternative location
here=$1
test -z "$here" && here=`pwd`

echo "Building Mono and dependencies in $here, installing to $here/install"

PATH=$here/install/bin:$PATH
LD_LIBRARY_PATH=$here/install/lib:$LD_LIBRARY_PATH

# 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.


# --print-ac-dir was added in 1.2h according to the ChangeLog.  This
# should mean that any automake new enough for us has it.
if [ -f `aclocal --print-ac-dir`/pkg.m4 ]; then
    install_pkgconfig=no
    PKG_CONFIG_PATH="$here/install/lib/pkgconfig"
else
    install_pkgconfig=yes
    ACLOCAL_FLAGS="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
fi


export PATH
export LD_LIBRARY_PATH
export ACLOCAL_FLAGS
export PKG_CONFIG_PATH

# Grab pkg-config-0.8, glib-1.3.12 if necessary

# If any more dependencies are added, it would be worth encapsulating
# the configure; make; make install part in a shell function

if [ $install_pkgconfig = "yes" ]; then
    echo "Installing pkgconfig..."
    if [ ! -f $here/pkgconfig-0.8.0.tar.gz ]; then
	wget --timestamping http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-0.8.0.tar.gz
    fi

    # Assume that pkgconfig built correctly if the dir is there
    if [ ! -d $here/pkgconfig-0.8.0 ]; then
	# Build and install pkg-config
	tar xzf $here/pkgconfig-0.8.0.tar.gz || exit -1
	(cd $here/pkgconfig-0.8.0; ./configure --prefix=$here/install || exit -1; make || exit -1; make install || exit -1)
	success=$?
	if [ $success -ne 0 ]; then
	    echo "***** pkgconfig build failure. Run rm -rf $here/pkgconfig-0.8.0 to have this script attempt to build pkgconfig again next time"
	    exit -1
	fi
    fi
else
    echo "Not installing pkgconfig, you already seem to have it installed"
fi


echo "Installing glib..."
if [ ! -f $here/glib-1.3.13.tar.gz ]; then
    wget --timestamping --passive-ftp ftp://ftp.gtk.org/pub/gtk/v1.3/glib-1.3.13.tar.gz
fi

# Assume that glib built correctly if the dir is there
if [ ! -d $here/glib-1.3.13 ]; then
    # Build and install glib
    tar xzf $here/glib-1.3.13.tar.gz || exit -1
    (cd $here/glib-1.3.13; ./configure --prefix=$here/install || exit -1; make || exit -1; make install || exit -1)
    success=$?
    if [ $success -ne 0 ]; then
	echo "***** glib build failure. Run rm -rf $here/glib-1.3.13 to have this script attempt to build glib again next time"
	exit -1
    fi
fi

# End of build dependencies, now get the latest mono checkout and build that

test -z "$CVSROOT" && CVSROOT=:pserver:anonymous@reypastor.hispalinux.es:/mono
export CVSROOT

echo "Updating mono"

# cvs checkout does the same as cvs update, except that it copes with
# new modules being added
cvs checkout mono || exit -1

# Build and install mono
echo "Building and installing mono"

(cd $here/mono; ./autogen.sh --prefix=$here/install || exit -1; make || exit -1; make install || exit -1) || exit -1


echo ""
echo ""
echo "All done.  Add $here/install/bin to \$PATH"
echo "Don't forget to copy the class libraries to $here/install/lib"


--e8/wErwm0bqugfcz--