-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-mingw32.sh
executable file
·164 lines (130 loc) · 3.98 KB
/
build-mingw32.sh
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
#!/bin/bash -e
CURDIR="`pwd`"
MINGW=i386-mingw32msvc
CROSS_DIR=/opt/cross/$MINGW
COPY_DLLS="libgio*.dll libglib*.dll libgmodule*.dll libgthread*.dll libgobject*.dll"
INSTALL_DESTDIR="$CURDIR/mono-win32"
PROFILES="default net_2_0 net_3_5 net_4_0 moonlight"
TEMPORARY_PKG_CONFIG_DIR=/tmp/$RANDOM-pkg-config-$RANDOM
ORIGINAL_PATH="$PATH"
export CPPFLAGS_FOR_EGLIB CFLAGS_FOR_EGLIB CPPFLAGS_FOR_LIBGC CFLAGS_FOR_LIBGC
function cleanup ()
{
if [ -d "$TEMPORARY_PKG_CONFIG_DIR" ]; then
rm -rf "$TEMPORARY_PKG_CONFIG_DIR"
fi
}
function setup ()
{
local pcname
CROSS_BIN_DIR="$CROSS_DIR/bin"
CROSS_DLL_DIR="$CROSS_DIR/bin"
CROSS_PKG_CONFIG_DIR=$CROSS_DIR/lib/pkgconfig
PATH=$CROSS_BIN_DIR:$PATH
export PATH
if [ -d ./.git/svn ]; then
SVN_INFO='git svn info'
elif [ -d ./.svn ]; then
SVN_INFO='svn info'
else
SVN_INFO=""
fi
if [ -n "$SVN_INFO" ]; then
MONO_SVN_REVISION=`$SVN_INFO | grep Revision | sed 's/.*: //'`
MONO_BRANCH=`$SVN_INFO | grep URL | sed -e 's;.*source/;;g' -e 's;/mono;;g'`
else
MONO_SVN_REVISION="rUNKNOWN"
MONO_BRANCH="tarball"
fi
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
MONO_RELEASE="$MONO_VERSION-$MONO_BRANCH-r$MONO_SVN_REVISION"
MONO_PREFIX="/mono-$MONO_RELEASE"
NOCONFIGURE=yes
export NOCONFIGURE
if [ -d "$CROSS_PKG_CONFIG_DIR" ]; then
install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
for pc in "$CROSS_PKG_CONFIG_DIR"/*.pc; do
pcname="`basename $pc`"
sed -e "s;^prefix=.*;prefix=$CROSS_DIR;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
done
CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
fi
echo Mono Win32 installation prefix: $MONO_PREFIX
}
function build ()
{
./autogen.sh
BUILD="`./config.guess`"
if [ -f ./Makefile ]; then
make distclean
rm -rf autom4te.cache
fi
if [ ! -d "$CURDIR/build-cross-windows" ]; then
mkdir "$CURDIR/build-cross-windows"
fi
cd "$CURDIR/build-cross-windows"
rm -rf *
../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
make
cd "$CURDIR"
if [ ! -d "$CURDIR/build-cross-windows-mcs" ]; then
mkdir "$CURDIR/build-cross-windows-mcs"
fi
rm -rf autom4te.cache
unset PATH
PATH="$ORIGINAL_PATH"
export PATH
cd "$CURDIR/build-cross-windows-mcs"
rm -rf *
../configure --prefix=$MONO_PREFIX --enable-parallel-mark
make
}
function doinstall ()
{
if [ -d "$INSTALL_DIR" ]; then
rm -rf "$INSTALL_DIR"
fi
cd "$CURDIR/build-cross-windows"
make DESTDIR="$INSTALL_DESTDIR" USE_BATCH_FILES=yes install
cd "$CURDIR/../mcs/mcs"
for p in $PROFILES; do
make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "mcs profile $p installation failed"
done
cd "$CURDIR/../mcs/class"
for p in $PROFILES; do
make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "class library profile $p installation failed"
done
cd "$CURDIR/../mcs/tools"
for p in $PROFILES; do
make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "tools profile $p installation failed"
done
cd "$CURDIR/mono-win32"
for dll in $COPY_DLLS; do
cp -ap "$CROSS_DLL_DIR"/$dll "$INSTALL_DESTDIR/$MONO_PREFIX/bin"
done
rm -f "$CURDIR/mono-win32-$MONO_RELEASE".zip
zip -9r "$CURDIR/mono-win32-$MONO_RELEASE".zip .
}
function usage ()
{
cat <<EOF
Usage: build-mingw32.sh [OPTIONS]
where OPTIONS are:
-d DIR Sets the location of directory where MINGW is installed [$CROSS_DIR]
-m MINGW Sets the MINGW target name to be passed to configure [$MINGW]
EOF
exit 1
}
trap cleanup 0
pushd . > /dev/null
while getopts "d:m:h" opt; do
case "$opt" in
d) CROSS_DIR="$OPTARG" ;;
m) MINGW="$OPTARG" ;;
*) usage ;;
esac
done
setup
build
doinstall
popd > /dev/null