+
+function aclocal_scan () {
+ # Quietly ignore the rogue '-I' and other aclocal flags that
+ # aren't actually directories...
+ for i in `aclocal --print-ac-dir` $ACLOCAL_FLAGS
+ do
+ if [ -f $i/$1 ]; then
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+function pkgconfig_scan () {
+ module=$1
+
+ echo "Finding pkgconfig files for $module..."
+
+ # Should we use locate? or just a list of well-known directories?
+ # locate has the problem of false positives in src dirs
+ for i in /usr/lib/pkgconfig /usr/local/lib/pkgconfig
+ do
+ echo "Looking in $i..."
+ if [ -f $i/${module}.pc ]; then
+ echo $i
+ return
+ fi
+ done
+}
+
+function install_package() {
+ tarfile=$1
+ dirname=$2
+ name=$3
+ configure_options=$4
+
+ echo "Installing $name..."
+ if [ ! -f $here/$tarfile ]; then
+ (cd $here && $downloader http://www.go-mono.com/archive/$tarfile)
+ fi
+
+ # Assume that the package built correctly if the dir is there
+ if [ ! -d $here/$dirname ]; then
+ # Build and install package
+ (cd $here && tar xzf $tarfile) || exit -1
+ (cd $here/$dirname; ./configure --prefix=$here/install $configure_options || exit -1; $MAKE || exit -1; $MAKE install || exit -1)
+ success=$?
+ if [ $success -ne 0 ]; then
+ echo "***** $name build failure. Run rm -rf $here/$dirname to have this script attempt to build $name again next time"
+ exit -1
+ fi
+ fi
+}
+
+if aclocal_scan pkg.m4 ; then