* XplatUI.cs:
[mono-project.git] / web / mono-build-w32.sh
blobfe9d061fe51311684dbe497f30c7d60d2415b790
1 #!/bin/bash
3 # Script to automate the building of mono and its dependencies on
4 # cygwin. Relies on wget being installed (could make it fall back to
5 # using lynx, links, w3, curl etc), assumes that gcc, make, tar,
6 # automake, etc are already installed too (may be worth testing for
7 # all that right at the top and bailing out if missing/too old/too new
8 # etc).
11 # See where we are. This will become the top level directory for the
12 # installation, unless we are given an alternative location
13 here=$1
14 test -z "$here" && here=`pwd`
16 echo "Building Mono and dependencies in $here, installing to $here/install"
18 PATH=$here/install/bin:$here/install/lib:$PATH
19 export C_INCLUDE_PATH=$here/install/include
21 # Make sure cygwin's libiconv is installed, or libtool blows its tiny mind
22 if [ ! -f /usr/lib/libiconv.la ]; then
23 echo "You need to install the cygwin \"libiconv\" package!"
24 exit -1
27 # Check mono out first, so we can run aclocal from inside the mono dir (it
28 # needs to see which version of the real aclocal to run)
29 test -z "$CVSROOT" && CVSROOT=:pserver:anonymous@anoncvs.go-mono.com:/mono
30 export CVSROOT
32 echo "Updating mono"
34 # cvs checkout does the same as cvs update, except that it copes with
35 # new modules being added
37 # Older versions of cvs insist on a cvs login for :pserver: methods
38 # Make sure cvs is using ssh for :ext: methods
40 if [ ${CVSROOT:0:5} = ":ext:" ]; then
41 CVS_RSH=ssh
42 export CVS_RSH
43 elif [ ${CVSROOT:0:9} = ":pserver:" ]; then
44 if ! grep $CVSROOT ~/.cvspass > /dev/null 2>&1 ; then
45 echo "Logging into CVS server. Anonymous CVS password is probably empty"
46 cvs login || exit -1
50 cvs checkout mono || exit -1
52 echo "Checking automake version"
53 automake_required="1.6.2"
54 automake_version=`automake --version | head -1 | awk '{print $4}' | tr -d '[a-zA-Z]' | sed 's/-.*$//g'`
55 echo "Found automake version $automake_version"
56 if expr $automake_version \< $automake_required > /dev/null; then
57 echo "Your automake is too old! You need version $automake_required or newer."
58 exit -1
59 else
60 echo "Automake version new enough."
63 # This causes libgc-not-found problem
65 ## Select the stable version anyway...
66 #if [ ! -z "${AUTO_STABLE}" -o -e /usr/autotool/stable ]; then
67 # export AUTO_STABLE=${AUTO_STABLE:-/usr/autotool/stable}
68 # export AUTO_DEVEL=${AUTO_STABLE}
69 #fi
71 # Need to install pkgconfig and set ACLOCAL_FLAGS if there is not a
72 # pkgconfig installed already. Otherwise set PKG_CONFIG_PATH to the
73 # glib we're about to install in $here/install.
76 # --print-ac-dir was added in 1.2h according to the ChangeLog. This
77 # should mean that any automake new enough for us has it.
79 # This sets ACLOCAL_FLAGS to point to the freshly installed pkgconfig
80 # if it doesnt already exist on the system (otherwise auto* breaks if
81 # it finds two copies of the m4 macros). The GIMP for Windows
82 # pkgconfig sets its prefix based on the location of its binary, so we
83 # dont need PKG_CONFIG_PATH (the internal pkgconfig config file
84 # $prefix is handled similarly). For the cygwin pkgconfig we do need to
85 # set it, and we need to edit the mingw pc files too.
87 function aclocal_scan () {
88 # Quietly ignore the rogue '-I' and other aclocal flags that
89 # aren't actually directories...
91 # cd into mono/ so that the aclocal wrapper can work out which version
92 # of aclocal to run, and add /usr/share/aclocal too cos aclocal looks there
93 # too.
94 for i in `(cd mono && aclocal --print-ac-dir)` /usr/share/aclocal $ACLOCAL_FLAGS
96 if [ -f $i/$1 ]; then
97 return 0
99 done
101 return 1
104 function install_icuconfig() {
105 if [ ! -f $here/install/bin/icu-config ]; then
106 wget http://www.go-mono.com/archive/icu-config
107 mv icu-config $here/install/bin
108 chmod 755 $here/install/bin/icu-config
113 function install_package() {
114 zipfile=$1
115 markerfile=$2
116 name=$3
118 echo "Installing $name..."
119 if [ ! -f $here/$zipfile ]; then
120 wget http://www.go-mono.com/archive/$zipfile
123 # Assume that the package is installed correctly if the marker
124 # file is there
125 if [ ! -f $here/install/$markerfile ]; then
126 (cd $here/install || exit -1; unzip -o $here/$zipfile || exit -1) || exit -1
130 # pkgconfig is only used during the build, so we can use the cygwin version
131 # if it exists
132 if aclocal_scan pkg.m4 ; then
133 install_pkgconfig=no
134 else
135 install_pkgconfig=yes
138 # This causes libgc-not-found problem
140 ## But we still need to use the mingw libs for glib & co
141 #ACLOCAL_FLAGS="-I $here/install/share/aclocal $ACLOCAL_FLAGS"
143 #export PATH
144 #export ACLOCAL_FLAGS
146 # Grab pkg-config, glib etc
147 if [ ! -d $here/install ]; then
148 mkdir $here/install || exit -1
151 # Fetch and install pkg-config, glib, iconv, intl
153 if [ $install_pkgconfig = "yes" ]; then
154 install_package pkgconfig-0.11-20020310.zip bin/pkg-config.exe pkgconfig
155 else
156 echo "Not installing pkgconfig, you already seem to have it installed"
158 install_package glib-2.0.4-20020703.zip lib/libglib-2.0-0.dll glib
159 install_package glib-dev-2.0.4-20020703.zip lib/glib-2.0.lib glib-dev
160 install_package libiconv-1.7.zip lib/iconv.dll iconv
161 install_package libintl-0.10.40-20020101.zip lib/libintl-1.dll intl
162 install_package libgc-dev.zip lib/gc.dll gc-dev
163 install_package icu-2.6.1-Win32_msvc7.zip icu/bin/icuuc26.dll icu
165 install_icuconfig
167 if [ $install_pkgconfig = "no" ]; then
168 echo "Fixing up the pkgconfig paths"
169 for i in $here/install/lib/pkgconfig/*.pc
171 mv $i $i.orig
172 sed -e "s@^prefix=/target\$@prefix=$here/install@" < $i.orig > $i
173 done
174 export PKG_CONFIG_PATH=$here/install/lib/pkgconfig
177 # Needed to find the libgc bits
178 export CFLAGS="-I $here/install/include -I $here/install/icu/include"
179 export LDFLAGS="-L$here/install/lib -L$here/install/icu/lib"
180 export PATH="$here/install/icu/bin:$PATH"
182 # Make sure we build native w32, not cygwin
183 #CC="gcc -mno-cygwin"
184 #export CC
186 # --prefix is used to set the class library dir in mono, and it needs
187 # to be in windows-native form. It also needs to have '\' turned into
188 # '/' to avoid quoting issues during the build.
189 prefix=`cygpath -w $here/install | sed -e 's@\\\\@/@g'`
191 # Build and install mono
192 echo "Building and installing mono"
194 (cd $here/mono; ./autogen.sh --prefix=$prefix || exit -1; make || exit -1; make install || exit -1) || exit -1
197 echo ""
198 echo ""
199 echo "All done."
200 echo "Add $here/install/bin and $here/install/lib to \$PATH"
201 echo "Don't forget to copy the class libraries to $here/install/lib"