3 # Script to automate the building of mono and its dependencies.
4 # Relies on wget being installed (could make it fall back to using
5 # lynx, links, w3, curl etc), assumes that gcc, make, tar, automake,
6 # etc are already installed too (may be worth testing for all that
7 # right at the top and bailing out if missing/too old/too new etc).
10 # See where we are. This will become the top level directory for the
11 # installation, unless we are given an alternative location
13 test -z "$here" && here=`pwd`
15 echo "Building Mono and dependencies in $here, installing to $here/install"
17 PATH=$here/install/bin:$PATH
18 LD_LIBRARY_PATH=$here/install/lib:$LD_LIBRARY_PATH
20 # Need to install pkgconfig and set ACLOCAL_FLAGS if there is not a
21 # pkgconfig installed already. Otherwise set PKG_CONFIG_PATH to the
22 # glib we're about to install in $here/install. This script could
23 # attempt to be clever and see if glib 2 is already installed, too.
26 # --print-ac-dir was added in 1.2h according to the ChangeLog. This
27 # should mean that any automake new enough for us has it.
29 function aclocal_scan () {
30 # Quietly ignore the rogue '-I' and other aclocal flags that
31 # aren't actually directories...
32 for i in `aclocal --print-ac-dir` $ACLOCAL_FLAGS
42 function pkgconfig_scan () {
45 echo "Finding pkgconfig files for $module..."
47 # Should we use locate? or just a list of well-known directories?
48 # locate has the problem of false positives in src dirs
49 for i in /usr/lib/pkgconfig /usr/local/lib/pkgconfig
51 echo "Looking in $i..."
52 if [ -f $i/${module}.pc ]; then
59 function install_package() {
65 echo "Installing $name..."
66 if [ ! -f $here/$tarfile ]; then
67 wget http://www.go-mono.org/archive/$tarfile
70 # Assume that the package built correctly if the dir is there
71 if [ ! -d $here/$dirname ]; then
72 # Build and install package
73 tar xzf $here/$tarfile || exit -1
74 (cd $here/$dirname; ./configure --prefix=$here/install $configure_options || exit -1; make || exit -1; make install || exit -1)
76 if [ $success -ne 0 ]; then
77 echo "***** $name build failure. Run rm -rf $here/$dirname to have this script attempt to build $name again next time"
83 if aclocal_scan pkg.m4 ; then
89 if aclocal_scan glib-2.0.m4 ; then
91 if [ $install_pkgconfig = "yes" ]; then
92 # We have to tell the newly-installed pkgconfig about the
93 # system-installed glib
94 PKG_CONFIG_PATH=`pkgconfig_scan glib-2.0`:$PKG_CONFIG_PATH
98 PKG_CONFIG_PATH="$here/install/lib/pkgconfig:$PKG_CONFIG_PATH"
101 if [ -f /usr/include/gc/gc.h ]; then
107 if [ $install_pkgconfig = "yes" -o $install_glib = "yes" ]; then
108 ACLOCAL_FLAGS="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
112 export LD_LIBRARY_PATH
114 export PKG_CONFIG_PATH
116 CPPFLAGS="$CPPFLAGS -I$here/install/include"
117 LDFLAGS="$LDFLAGS -L$here/install/lib"
121 # Grab pkg-config-0.8, glib-1.3.12 if necessary
123 if [ $install_pkgconfig = "yes" ]; then
124 install_package pkgconfig-0.8.0.tar.gz pkgconfig-0.8.0 pkgconfig ""
126 echo "Not installing pkgconfig, you already seem to have it installed"
129 if [ $install_glib = "yes" ]; then
130 install_package glib-1.3.13.tar.gz glib-1.3.13 glib ""
132 echo "Not installing glib, you already seem to have it installed"
135 if [ $install_libgc = "yes" ]; then
136 LIBS="-ldl" install_package gc6.0.tar.gz gc6.0 libgc "--enable-threads=pthreads"
137 # make install didnt do the headers!
138 mkdir -p $here/install/include/gc
139 cp -r $here/gc6.0/include/* $here/install/include/gc
141 echo "Not installing libgc, you already seem to have it installed"
144 # End of build dependencies, now get the latest mono checkout and build that
146 test -z "$CVSROOT" && CVSROOT=:pserver:anonymous@anoncvs.go-mono.com:/mono
151 # cvs checkout does the same as cvs update, except that it copes with
152 # new modules being added
154 # Older versions of cvs insist on a cvs login for :pserver: methods
155 # Make sure cvs is using ssh for :ext: methods
157 if [ ${CVSROOT:0:5} = ":ext:" ]; then
160 elif [ ${CVSROOT:0:9} = ":pserver:" ]; then
161 # Chop off the trailing /mono because cvs 1.11 adds the port number
162 # into the .cvspass line
163 if ! grep ${CVSROOT%:/mono} ~/.cvspass > /dev/null 2>&1 ; then
164 echo "Logging into CVS server. Anonymous CVS password is probably empty"
169 cvs checkout mono || exit -1
171 # Build and install mono
172 echo "Building and installing mono"
174 (cd $here/mono; ./autogen.sh --prefix=$here/install || exit -1; make || exit -1; make install || exit -1) || exit -1
180 echo "Add $here/install/bin to \$PATH"
181 echo "Add $here/install/lib to \$LD_LIBRARY_PATH"
182 echo "Don't forget to copy the class libraries to $here/install/lib"