2009-11-10 Zoltan Varga <vargaz@gmail.com>
[mono-project.git] / build-mingw32.sh
blob200c5fa71881a68495dc6f40f7a7427701ff7c18
1 #!/bin/bash -e
2 CURDIR="`pwd`"
3 CROSS_DIR=${1:-/opt/cross/}
4 MINGW=${1:-i386-mingw32msvc}
5 CROSS_BIN_DIR="$CROSS_DIR/bin"
6 CROSS_DLL_DIR="$CROSS_DIR/$MINGW/bin"
7 CROSS_PKG_CONFIG_DIR=$CROSS_DIR/$MINGW/lib/pkgconfig
8 COPY_DLLS="libgio*.dll libglib*.dll libgmodule*.dll libgthread*.dll libgobject*.dll"
9 PATH=$CROSS_BIN_DIR:$PATH
10 INSTALL_DESTDIR="$CURDIR/mono-win32"
11 PROFILES="default net_2_0 net_2_1 net_3_5"
13 export PATH
15 function setup ()
17 if [ -d ./.git/svn ]; then
18 SVN_INFO='git svn info'
19 elif [ -d ./.svn ]; then
20 SVN_INFO='svn info'
21 else
22 SVN_INFO=""
25 if [ -n "$SVN_INFO" ]; then
26 MONO_SVN_REVISION=`$SVN_INFO | grep Revision | sed 's/.*: //'`
27 MONO_BRANCH=`$SVN_INFO | grep URL | sed -e 's;.*source/;;g' -e 's;/mono;;g'`
28 else
29 MONO_SVN_REVISION="rUNKNOWN"
30 MONO_BRANCH="tarball"
33 MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
34 MONO_RELEASE="$MONO_VERSION-$MONO_BRANCH-r$MONO_SVN_REVISION"
35 MONO_PREFIX="/mono-$MONO_RELEASE"
37 NOCONFIGURE=yes
38 export NOCONFIGURE
40 echo Mono Win32 installation prefix: $MONO_PREFIX
43 function build ()
45 ./autogen.sh
47 if [ -f ./Makefile ]; then
48 make distclean
51 if [ ! -d "$CURDIR/build-cross-windows" ]; then
52 mkdir "$CURDIR/build-cross-windows"
55 cd "$CURDIR/build-cross-windows"
56 rm -rf *
57 ../configure --prefix=$MONO_PREFIX --with-crosspkgdir=$CROSS_PKG_CONFIG_DIR --target=$MINGW --host=$MINGW --enable-parallel-mark --program-transform-name=""
58 make
59 cd "$CURDIR"
61 if [ ! -d "$CURDIR/build-cross-windows-mcs" ]; then
62 mkdir "$CURDIR/build-cross-windows-mcs"
64 cd "$CURDIR/build-cross-windows-mcs"
65 rm -rf *
66 ../configure --prefix=$MONO_PREFIX --enable-parallel-mark
67 make
70 function doinstall ()
72 if [ -d "$INSTALL_DIR" ]; then
73 rm -rf "$INSTALL_DIR"
75 cd "$CURDIR/build-cross-windows"
76 make DESTDIR="$INSTALL_DESTDIR" USE_BATCH_FILES=yes install
78 cd "$CURDIR/../mcs/mcs"
80 for p in $PROFILES; do
81 make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "mcs profile $p installation failed"
82 done
84 cd "$CURDIR/../mcs/class"
85 for p in $PROFILES; do
86 make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "class library profile $p installation failed"
87 done
89 cd "$CURDIR/../mcs/tools"
90 for p in $PROFILES; do
91 make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "tools profile $p installation failed"
92 done
94 cd "$CURDIR/mono-win32"
95 for dll in $COPY_DLLS; do
96 cp -ap "$CROSS_DLL_DIR"/$dll "$INSTALL_DESTDIR/$MONO_PREFIX/bin"
97 done
99 rm -f "$CURDIR/mono-win32-$MONO_RELEASE".zip
100 zip -9r "$CURDIR/mono-win32-$MONO_RELEASE".zip .
104 pushd . > /dev/null
106 setup
107 build
108 doinstall
110 popd > /dev/null