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 # Find a tool to fetch files. It must take an HTTP URL on the command line and
21 # save the file in the current directory. (It must also talk HTTP/1.1, which
22 # rules out BSD's ftp(1), at least on FreeBSD 4.4.)
23 viable_downloaders
="wget fetch"
24 for i
in $viable_downloaders
26 if which $i > /dev
/null
; then
32 if [ -z "$downloader" ]; then
33 echo "Can't find a commandline download tool (tried: $viable_downloaders)"
36 echo "Using $downloader to fetch files"
39 # We need to prefer GNU make if there's a choice. BSD make falls over in
40 # the glib build if gtk-doc is disabled.
41 viable_makers
="gmake make"
42 for i
in $viable_makers
44 if which $i > /dev
/null
; then
50 if [ -z "$MAKE" ]; then
51 echo "Can't find a make tool (tried: $viable_makers)"
58 # Need to install pkgconfig and set ACLOCAL_FLAGS if there is not a
59 # pkgconfig installed already. Otherwise set PKG_CONFIG_PATH to the
60 # glib we're about to install in $here/install. This script could
61 # attempt to be clever and see if glib 2 is already installed, too.
64 # --print-ac-dir was added in 1.2h according to the ChangeLog. This
65 # should mean that any automake new enough for us has it.
67 function aclocal_scan
() {
68 # Quietly ignore the rogue '-I' and other aclocal flags that
69 # aren't actually directories...
70 for i
in `aclocal --print-ac-dir` $ACLOCAL_FLAGS
80 function pkgconfig_scan
() {
83 echo "Finding pkgconfig files for $module..."
85 # Should we use locate? or just a list of well-known directories?
86 # locate has the problem of false positives in src dirs
87 for i
in /usr
/lib
/pkgconfig
/usr
/local
/lib
/pkgconfig
89 echo "Looking in $i..."
90 if [ -f $i/${module}.pc
]; then
97 function install_package
() {
103 echo "Installing $name..."
104 if [ ! -f $here/$tarfile ]; then
105 (cd $here && $downloader http
://www.go-mono.com
/archive
/$tarfile)
108 # Assume that the package built correctly if the dir is there
109 if [ ! -d $here/$dirname ]; then
110 # Build and install package
111 (cd $here && tar xzf
$tarfile) ||
exit -1
112 (cd $here/$dirname; .
/configure
--prefix=$here/install $configure_options ||
exit -1; $MAKE ||
exit -1; $MAKE install ||
exit -1)
114 if [ $success -ne 0 ]; then
115 echo "***** $name build failure. Run rm -rf $here/$dirname to have this script attempt to build $name again next time"
121 if aclocal_scan pkg.
m4 ; then
124 install_pkgconfig
=yes
127 if aclocal_scan glib-2.0.
m4 ; then
129 if [ $install_pkgconfig = "yes" ]; then
130 # We have to tell the newly-installed pkgconfig about the
131 # system-installed glib
132 PKG_CONFIG_PATH
=`pkgconfig_scan glib-2.0`:$PKG_CONFIG_PATH
136 PKG_CONFIG_PATH
="$here/install/lib/pkgconfig:$PKG_CONFIG_PATH"
139 if [ -f /usr
/include
/gc
/gc.h
]; then
145 if [ $install_pkgconfig = "yes" -o $install_glib = "yes" ]; then
146 ACLOCAL_FLAGS
="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
150 export LD_LIBRARY_PATH
152 export PKG_CONFIG_PATH
154 # Freebsd puts iconv in /usr/local, so see if we need to add
155 # /usr/local/include and /usr/local/lib to CPPFLAGS and LDFLAGS. We could
156 # skip this if it would add /usr/include and /usr/lib, but leaving it
157 # shouldnt break anything.
159 # Actually, it does break stuff :-( gcc 3.2 prints gratuitous warnings
160 # and configure fails to find header files because of this cpp output.
162 if [ ! -f /usr
/include
/iconv.h
]; then
163 iconvdirs
="/usr/local/include"
166 if [ -f $i/iconv.h
]; then
172 if [ -z "$iconvh_dir" ]; then
173 echo "Can't find iconv headers (looked in $iconvdirs)"
177 iconvlib_dir
=`echo $iconvh_dir | sed -e 's/include/lib/'`
179 echo "Adding $iconvh_dir to CPPFLAGS"
180 echo "Adding $iconvlib_dir to LDFLAGS"
182 CPPFLAGS
="$CPPFLAGS -I$here/install/include -I$iconvh_dir"
183 LDFLAGS
="$LDFLAGS -L$here/install/lib -L$iconvlib_dir"
185 CPPFLAGS
="$CPPFLAGS -I$here/install/include"
186 LDFLAGS
="$LDFLAGS -L$here/install/lib"
192 # Grab pkg-config, glib and libgc if necessary
194 if [ $install_pkgconfig = "yes" ]; then
195 install_package pkgconfig-0.8
.0.
tar.gz pkgconfig-0.8
.0 pkgconfig
""
197 echo "Not installing pkgconfig, you already seem to have it installed"
200 if [ $install_glib = "yes" ]; then
201 install_package glib-2.0
.6.
tar.gz glib-2.0
.6 glib
""
203 echo "Not installing glib, you already seem to have it installed"
206 if [ $install_libgc = "yes" ]; then
207 install_package gc6.1alpha5.
tar.gz gc6.1alpha5 libgc
"--enable-threads=pthreads"
208 # make install didnt do the headers!
209 mkdir
-p $here/install
/include
/gc
210 cp -r $here/gc6.1alpha
5/include
/* $here/install
/include
/gc
212 echo "Not installing libgc, you already seem to have it installed"
215 # End of build dependencies, now get the latest mono checkout and build that
217 test -z "$CVSROOT" && CVSROOT
=:pserver
:anonymous@anoncvs.go-mono.com
:/mono
222 # cvs checkout does the same as cvs update, except that it copes with
223 # new modules being added
225 # Older versions of cvs insist on a cvs login for :pserver: methods
226 # Make sure cvs is using ssh for :ext: methods
228 if [ ${CVSROOT:0:5} = ":ext:" ]; then
231 elif [ ${CVSROOT:0:9} = ":pserver:" ]; then
232 # Chop off the trailing /mono because cvs 1.11 adds the port number
233 # into the .cvspass line
234 if ! grep ${CVSROOT%:/mono} ~
/.cvspass
> /dev
/null
2>&1 ; then
235 echo "Logging into CVS server. Anonymous CVS password is probably empty"
240 (cd $here && cvs checkout mono
) ||
exit -1
242 # Build and install mono
243 echo "Building and installing mono"
245 (cd $here/mono
; .
/autogen.sh
--prefix=$here/install ||
exit -1; $MAKE ||
exit -1; $MAKE install ||
exit -1) ||
exit -1
251 echo "Add $here/install/bin to \$PATH"
252 echo "Add $here/install/lib to \$LD_LIBRARY_PATH"
253 echo "Don't forget to copy the class libraries to $here/install/lib"