Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mono-build.sh « web - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 10878bf2780c6dae03965d308056af7c08d1f6a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash

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

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
	wget http://www.go-mono.org/archive/$tarfile
    fi

    # Assume that the package built correctly if the dir is there
    if [ ! -d $here/$dirname ]; then
	# Build and install package
	tar xzf $here/$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
    install_pkgconfig=no
else
    install_pkgconfig=yes
fi

if aclocal_scan glib-2.0.m4 ; then
    install_glib=no
    if [ $install_pkgconfig = "yes" ]; then
	# We have to tell the newly-installed pkgconfig about the
	# system-installed glib
	PKG_CONFIG_PATH=`pkgconfig_scan glib-2.0`:$PKG_CONFIG_PATH
    fi
else
    install_glib=yes
    PKG_CONFIG_PATH="$here/install/lib/pkgconfig:$PKG_CONFIG_PATH"
fi

if [ -f /usr/include/gc/gc.h ]; then
    install_libgc=no
else
    install_libgc=yes
fi

if [ $install_pkgconfig = "yes" -o $install_glib = "yes" ]; then
    ACLOCAL_FLAGS="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
fi

export PATH
export LD_LIBRARY_PATH
export ACLOCAL_FLAGS
export PKG_CONFIG_PATH

CPPFLAGS="$CPPFLAGS -I$here/install/include"
LDFLAGS="$LDFLAGS -L$here/install/lib"
export CPPFLAGS
export LDFLAGS

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

if [ $install_pkgconfig = "yes" ]; then
    install_package pkgconfig-0.8.0.tar.gz pkgconfig-0.8.0 pkgconfig ""
else
    echo "Not installing pkgconfig, you already seem to have it installed"
fi

if [ $install_glib = "yes" ]; then
    install_package glib-1.3.13.tar.gz glib-1.3.13 glib ""
else
    echo "Not installing glib, you already seem to have it installed"
fi

if [ $install_libgc = "yes" ]; then
    LIBS="-ldl" install_package gc6.0.tar.gz gc6.0 libgc "--enable-threads=pthreads"
    # make install didnt do the headers!
    mkdir -p $here/install/include/gc
    cp -r $here/gc6.0/include/* $here/install/include/gc
else
    echo "Not installing libgc, you already seem to have it installed"
fi

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

test -z "$CVSROOT" && CVSROOT=:pserver:anonymous@anoncvs.go-mono.com:/mono
export CVSROOT

echo "Updating mono"

# cvs checkout does the same as cvs update, except that it copes with
# new modules being added

# Older versions of cvs insist on a cvs login for :pserver: methods
# Make sure cvs is using ssh for :ext: methods

if [ ${CVSROOT:0:5} = ":ext:" ]; then
    CVS_RSH=ssh
    export CVS_RSH
elif [ ${CVSROOT:0:9} = ":pserver:" ]; then
    # Chop off the trailing /mono because cvs 1.11 adds the port number
    # into the .cvspass line
    if ! grep ${CVSROOT%:/mono} ~/.cvspass > /dev/null 2>&1 ; then
	echo "Logging into CVS server.  Anonymous CVS password is probably empty"
	cvs login
    fi
fi

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."
echo "Add $here/install/bin to \$PATH"
echo "Add $here/install/lib to \$LD_LIBRARY_PATH"
echo "Don't forget to copy the class libraries to $here/install/lib"