Update known-issues and IL size info
[mono.git] / build-mingw32.sh
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 moonlight net_3_5"
8 TEMPORARY_PKG_CONFIG_DIR=/tmp/$RANDOM-pkg-config-$RANDOM
9
10 export CPPFLAGS_FOR_EGLIB CFLAGS_FOR_EGLIB CPPFLAGS_FOR_LIBGC CFLAGS_FOR_LIBGC
11
12 function cleanup ()
13 {
14     if [ -d "$TEMPORARY_PKG_CONFIG_DIR" ]; then
15         rm -rf "$TEMPORARY_PKG_CONFIG_DIR"
16     fi
17 }
18
19 function setup ()
20 {
21     local pcname
22
23     CROSS_BIN_DIR="$CROSS_DIR/bin"
24     CROSS_DLL_DIR="$CROSS_DIR/bin"
25     CROSS_PKG_CONFIG_DIR=$CROSS_DIR/lib/pkgconfig
26     PATH=$CROSS_BIN_DIR:$PATH
27
28     export PATH
29     if [ -d ./.git/svn ]; then
30         SVN_INFO='git svn info'
31     elif [ -d ./.svn ]; then
32         SVN_INFO='svn info'
33     else
34         SVN_INFO=""
35     fi
36
37     if [ -n "$SVN_INFO" ]; then
38         MONO_SVN_REVISION=`$SVN_INFO | grep Revision | sed 's/.*: //'`
39         MONO_BRANCH=`$SVN_INFO | grep URL | sed -e 's;.*source/;;g' -e 's;/mono;;g'`
40     else
41         MONO_SVN_REVISION="rUNKNOWN"
42         MONO_BRANCH="tarball"
43     fi
44
45     MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
46     MONO_RELEASE="$MONO_VERSION-$MONO_BRANCH-r$MONO_SVN_REVISION"
47     MONO_PREFIX="/mono-$MONO_RELEASE"
48
49     NOCONFIGURE=yes
50     export NOCONFIGURE
51
52     if [ -d "$CROSS_PKG_CONFIG_DIR" ]; then
53         install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
54         for pc in "$CROSS_PKG_CONFIG_DIR"/*.pc; do
55             pcname="`basename $pc`"
56             sed -e "s;^prefix=.*;prefix=$CROSS_DIR;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
57         done
58         CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
59     fi
60
61     echo Mono Win32 installation prefix: $MONO_PREFIX
62 }
63
64 function build ()
65 {
66     ./autogen.sh 
67
68     BUILD="`./config.guess`"
69
70     if [ -f ./Makefile ]; then
71         make distclean
72     fi
73
74     if [ ! -d "$CURDIR/build-cross-windows" ]; then
75         mkdir "$CURDIR/build-cross-windows"
76     fi
77
78     cd "$CURDIR/build-cross-windows"
79     rm -rf *
80     ../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
81     make
82     cd "$CURDIR"
83
84     if [ ! -d "$CURDIR/build-cross-windows-mcs" ]; then
85         mkdir "$CURDIR/build-cross-windows-mcs"
86     fi
87     cd "$CURDIR/build-cross-windows-mcs"
88     rm -rf *
89     ../configure --prefix=$MONO_PREFIX --enable-parallel-mark
90     make
91 }
92
93 function doinstall ()
94 {
95     if [ -d "$INSTALL_DIR" ]; then
96         rm -rf "$INSTALL_DIR"
97     fi
98     cd "$CURDIR/build-cross-windows"
99     make DESTDIR="$INSTALL_DESTDIR" USE_BATCH_FILES=yes install
100
101     cd "$CURDIR/../mcs/mcs"
102
103     for p in $PROFILES; do
104         make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "mcs profile $p installation failed"
105     done
106
107     cd "$CURDIR/../mcs/class"
108     for p in $PROFILES; do
109         make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "class library profile $p installation failed"
110     done
111
112     cd "$CURDIR/../mcs/tools"
113     for p in $PROFILES; do
114         make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "tools profile $p installation failed"
115     done
116
117     cd "$CURDIR/mono-win32"
118     for dll in $COPY_DLLS; do
119         cp -ap "$CROSS_DLL_DIR"/$dll "$INSTALL_DESTDIR/$MONO_PREFIX/bin"
120     done
121
122     rm -f "$CURDIR/mono-win32-$MONO_RELEASE".zip
123     zip -9r "$CURDIR/mono-win32-$MONO_RELEASE".zip .
124
125 }
126
127 function usage ()
128 {
129     cat <<EOF
130 Usage: build-mingw32.sh [OPTIONS]
131
132 where OPTIONS are:
133
134  -d DIR     Sets the location of directory where MINGW is installed [$CROSS_DIR]
135  -m MINGW   Sets the MINGW target name to be passed to configure [$MINGW]
136 EOF
137
138     exit 1
139 }
140
141 trap cleanup 0
142
143 pushd . > /dev/null
144
145 while getopts "d:m:h" opt; do
146     case "$opt" in
147         d) CROSS_DIR="$OPTARG" ;;
148         m) MINGW="$OPTARG" ;;
149         *) usage ;;
150     esac
151 done
152
153 setup
154 build
155 doinstall
156
157 popd > /dev/null