2010-05-11 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / build-mingw32.sh
blob16b91cefe6d4cea4eb05cd682b534a9dd132dd07
1 #!/bin/bash -e
2 CURDIR="`pwd`"
3 MINGW=i386-mingw32msvc
4 CROSS_DIR=/opt/cross/$MINGW
5 COPY_DLLS="libgio*.dll libglib*.dll libgmodule*.dll libgthread*.dll libgobject*.dll"
6 INSTALL_DESTDIR="$CURDIR/mono-win32"
7 PROFILES="default net_2_0 net_3_5 net_4_0 moonlight"
8 TEMPORARY_PKG_CONFIG_DIR=/tmp/$RANDOM-pkg-config-$RANDOM
9 ORIGINAL_PATH="$PATH"
11 export CPPFLAGS_FOR_EGLIB CFLAGS_FOR_EGLIB CPPFLAGS_FOR_LIBGC CFLAGS_FOR_LIBGC
13 function cleanup ()
15 if [ -d "$TEMPORARY_PKG_CONFIG_DIR" ]; then
16 rm -rf "$TEMPORARY_PKG_CONFIG_DIR"
20 function setup ()
22 local pcname
24 CROSS_BIN_DIR="$CROSS_DIR/bin"
25 CROSS_DLL_DIR="$CROSS_DIR/bin"
26 CROSS_PKG_CONFIG_DIR=$CROSS_DIR/lib/pkgconfig
27 PATH=$CROSS_BIN_DIR:$PATH
29 export PATH
30 if [ -d ./.git/svn ]; then
31 SVN_INFO='git svn info'
32 elif [ -d ./.svn ]; then
33 SVN_INFO='svn info'
34 else
35 SVN_INFO=""
38 if [ -n "$SVN_INFO" ]; then
39 MONO_SVN_REVISION=`$SVN_INFO | grep Revision | sed 's/.*: //'`
40 MONO_BRANCH=`$SVN_INFO | grep URL | sed -e 's;.*source/;;g' -e 's;/mono;;g'`
41 else
42 MONO_SVN_REVISION="rUNKNOWN"
43 MONO_BRANCH="tarball"
46 MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
47 MONO_RELEASE="$MONO_VERSION-$MONO_BRANCH-r$MONO_SVN_REVISION"
48 MONO_PREFIX="/mono-$MONO_RELEASE"
50 NOCONFIGURE=yes
51 export NOCONFIGURE
53 if [ -d "$CROSS_PKG_CONFIG_DIR" ]; then
54 install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
55 for pc in "$CROSS_PKG_CONFIG_DIR"/*.pc; do
56 pcname="`basename $pc`"
57 sed -e "s;^prefix=.*;prefix=$CROSS_DIR;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
58 done
59 CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
62 echo Mono Win32 installation prefix: $MONO_PREFIX
65 function build ()
67 ./autogen.sh
69 BUILD="`./config.guess`"
71 if [ -f ./Makefile ]; then
72 make distclean
73 rm -rf autom4te.cache
76 if [ ! -d "$CURDIR/build-cross-windows" ]; then
77 mkdir "$CURDIR/build-cross-windows"
80 cd "$CURDIR/build-cross-windows"
81 rm -rf *
82 ../configure --prefix=$MONO_PREFIX --with-crosspkgdir=$CROSS_PKG_CONFIG_DIR --build=$BUILD --target=$MINGW --host=$MINGW --enable-parallel-mark --program-transform-name="" --with-tls=none --disable-mcs-build --disable-embed-check --enable-win32-dllmain=yes --with-libgc-threads=win32 --with-profile4=yes
83 make
84 cd "$CURDIR"
86 if [ ! -d "$CURDIR/build-cross-windows-mcs" ]; then
87 mkdir "$CURDIR/build-cross-windows-mcs"
90 rm -rf autom4te.cache
91 unset PATH
92 PATH="$ORIGINAL_PATH"
93 export PATH
94 cd "$CURDIR/build-cross-windows-mcs"
95 rm -rf *
96 ../configure --prefix=$MONO_PREFIX --enable-parallel-mark
97 make
100 function doinstall ()
102 if [ -d "$INSTALL_DIR" ]; then
103 rm -rf "$INSTALL_DIR"
105 cd "$CURDIR/build-cross-windows"
106 make DESTDIR="$INSTALL_DESTDIR" USE_BATCH_FILES=yes install
108 cd "$CURDIR/../mcs/mcs"
110 for p in $PROFILES; do
111 make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "mcs profile $p installation failed"
112 done
114 cd "$CURDIR/../mcs/class"
115 for p in $PROFILES; do
116 make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "class library profile $p installation failed"
117 done
119 cd "$CURDIR/../mcs/tools"
120 for p in $PROFILES; do
121 make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "tools profile $p installation failed"
122 done
124 cd "$CURDIR/mono-win32"
125 for dll in $COPY_DLLS; do
126 cp -ap "$CROSS_DLL_DIR"/$dll "$INSTALL_DESTDIR/$MONO_PREFIX/bin"
127 done
129 rm -f "$CURDIR/mono-win32-$MONO_RELEASE".zip
130 zip -9r "$CURDIR/mono-win32-$MONO_RELEASE".zip .
134 function usage ()
136 cat <<EOF
137 Usage: build-mingw32.sh [OPTIONS]
139 where OPTIONS are:
141 -d DIR Sets the location of directory where MINGW is installed [$CROSS_DIR]
142 -m MINGW Sets the MINGW target name to be passed to configure [$MINGW]
145 exit 1
148 trap cleanup 0
150 pushd . > /dev/null
152 while getopts "d:m:h" opt; do
153 case "$opt" in
154 d) CROSS_DIR="$OPTARG" ;;
155 m) MINGW="$OPTARG" ;;
156 *) usage ;;
157 esac
158 done
160 setup
161 build
162 doinstall
164 popd > /dev/null