Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[cross-compilation] Added some flexibility regarding the location of …

…development packages

The script now supports an extra cross-compilation directory in which you can unpack the
library and development packages necessary for the build to succeed (glib, zlib etc). Also
supported now is specifying the location at which Mono will be installed on Windows.
Replaced SVN and GIT-SVN version checks with git checks.
  • Loading branch information...
commit a8362f1a1469ae47ff9b21116f8272f145c115f1 1 parent 90f74ba
Marek Habersack authored February 08, 2011

Showing 1 changed file with 94 additions and 32 deletions. Show diff stats Hide diff stats

  1. 126  build-mingw32.sh
126  build-mingw32.sh
@@ -2,6 +2,7 @@
2 2
 CURDIR="`pwd`"
3 3
 MINGW=i386-mingw32msvc
4 4
 CROSS_DIR=/opt/cross/$MINGW
  5
+EXTRA_CROSS_DIR=
5 6
 INSTALL_DESTDIR="$CURDIR/mono-win32"
6 7
 PROFILES="default net_2_0 net_3_5 net_4_0 moonlight"
7 8
 TEMPORARY_PKG_CONFIG_DIR=/tmp/$RANDOM-pkg-config-$RANDOM
@@ -16,63 +17,119 @@ function cleanup ()
16 17
     fi
17 18
 }
18 19
 
  20
+function check_pkg_config_dir ()
  21
+{
  22
+    local DIR="$1"
  23
+    local DIR_PREFIX="$2"
  24
+
  25
+    if [ ! -d "$DIR" ]; then
  26
+	return
  27
+    fi
  28
+
  29
+    install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
  30
+    for pc in "$DIR"/*.pc; do
  31
+	if [ -f $pc ]; then
  32
+	    pcname="`basename $pc`"
  33
+	    sed -e "s;^prefix=.*;prefix=$DIR_PREFIX;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
  34
+	fi;
  35
+    done
  36
+
  37
+    if [ -z "$CROSS_PKG_CONFIG_DIR" ]; then
  38
+	CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
  39
+    fi
  40
+}
  41
+
  42
+function show_build_info ()
  43
+{
  44
+    cat <<EOF
  45
+Installation prefix: $MONO_PREFIX
  46
+           CPPFLAGS: ${CPPFLAGS:=not set}
  47
+            LDFLAGS: ${LDFLAGS:=not set}
  48
+          MONO_PATH: ${MONO_PATH:=not set}
  49
+EOF
  50
+}
  51
+
19 52
 function setup ()
20 53
 {
21 54
     local pcname
22 55
 
23 56
     CROSS_BIN_DIR="$CROSS_DIR/bin"
24 57
     CROSS_DLL_DIR="$CROSS_DIR/bin"
25  
-    CROSS_PKG_CONFIG_DIR=$CROSS_DIR/lib/pkgconfig
26 58
     PATH=$CROSS_BIN_DIR:$PATH
27 59
 
28 60
     MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
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=""
36  
-    fi
37  
-
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  
-	MONO_RELEASE="$MONO_VERSION-$MONO_BRANCH-r$MONO_SVN_REVISION"
  61
+    
  62
+    if [ -d ./.git ]; then
  63
+	MONO_GIT_COMMIT="`git log -1 --format=format:%t`"
  64
+	MONO_GIT_BRANCH="`git branch|grep '\*'|cut -d ' ' -f 2`"
  65
+	MONO_RELEASE="$MONO_VERSION-$MONO_GIT_BRANCH-$MONO_GIT_COMMIT"
42 66
     else
43 67
 	MONO_RELEASE="$MONO_VERSION"
44 68
     fi
45 69
 
46  
-    MONO_PREFIX="/mono-$MONO_RELEASE"
  70
+    MONO_PREFIX="$MONO_PREFIX/mono-$MONO_RELEASE"
47 71
 
48 72
     NOCONFIGURE=yes
49 73
     export NOCONFIGURE
50 74
 
51  
-    if [ -d "$CROSS_PKG_CONFIG_DIR" ]; then
52  
-	install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
53  
-	for pc in "$CROSS_PKG_CONFIG_DIR"/*.pc; do
54  
-	    if [ -f $pc ]; then
55  
-	        pcname="`basename $pc`"
56  
-	        sed -e "s;^prefix=.*;prefix=$CROSS_DIR;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
57  
-	    fi;
58  
-	done
59  
-	CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
  75
+    check_pkg_config_dir "$CROSS_DIR/lib/pkgconfig" "$CROSS_DIR"
  76
+
  77
+    if [ -n "$EXTRA_CROSS_DIR" -a -d "$EXTRA_CROSS_DIR" ]; then
  78
+	if [ -d "$EXTRA_CROSS_DIR/bin" ]; then
  79
+		PATH="$EXTRA_CROSS_DIR/bin":$PATH
  80
+	fi
  81
+	
  82
+	check_pkg_config_dir "$EXTRA_CROSS_DIR/lib/pkgconfig" "$EXTRA_CROSS_DIR"
  83
+
  84
+	if [ -d "$EXTRA_CROSS_DIR/include" ]; then
  85
+	    if [ -z "$CPPFLAGS" ]; then
  86
+		CPPFLAGS="-I \"$EXTRA_CROSS_DIR/include\""
  87
+	    else
  88
+		CPPFLAGS="-I \"$EXTRA_CROSS_DIR/include\" $CFLAGS"
  89
+	    fi
  90
+	fi
  91
+
  92
+	if [ -d "$EXTRA_CROSS_DIR/lib" ]; then
  93
+	    if [ -z "$LDFLAGS" ]; then
  94
+		LDFLAGS="-I \"$EXTRA_CROSS_DIR/lib\""
  95
+	    else
  96
+		LDFLAGS="-I \"$EXTRA_CROSS_DIR/lib\" $LDFLAGS"
  97
+	    fi
  98
+	fi
  99
+
  100
+	if [ -d "$EXTRA_CROSS_DIR/share/aclocal" ]; then
  101
+	    if [ -z "$MONO_PATH" ]; then
  102
+		MONO_PATH="\"$EXTRA_CROSS_DIR\""
  103
+	    else
  104
+		MONO_PATH="\"$EXTRA_CROSS_DIR\":$MONO_PATH"
  105
+	    fi
  106
+	fi
60 107
     fi
61  
-
62  
-    echo Mono Win32 installation prefix: $MONO_PREFIX
  108
+    
  109
+    export PATH MONO_PATH CPPFLAGS
  110
+    show_build_info
63 111
 }
64 112
 
65 113
 function build ()
66 114
 {
67  
-    ./autogen.sh 
68  
-
69  
-    BUILD="`./config.guess`"
70  
-
71 115
     if [ -f ./Makefile ]; then
72 116
 	make distclean
73  
-	rm -rf autom4te.cache
74 117
     fi
75 118
 
  119
+    if [ -d ./autom4te.cache ]; then
  120
+	rm -rf ./autom4te.cache
  121
+    fi
  122
+
  123
+    if [ -f ./config.status ]; then
  124
+	for f in `find -name config.status -type f`; do
  125
+	    rm $f
  126
+	done
  127
+    fi
  128
+
  129
+    ./autogen.sh 
  130
+
  131
+    BUILD="`./config.guess`"
  132
+
76 133
     if [ ! -d "$CURDIR/build-cross-windows" ]; then
77 134
 	mkdir "$CURDIR/build-cross-windows"
78 135
     fi
@@ -140,7 +197,9 @@ Usage: build-mingw32.sh [OPTIONS]
140 197
 where OPTIONS are:
141 198
 
142 199
  -d DIR     Sets the location of directory where MINGW is installed [$CROSS_DIR]
  200
+ -e DIR     Sets the location of directory where additional cross develoment packages are installed [${EXTRA_CROSS_DIR:=none}]
143 201
  -m MINGW   Sets the MINGW target name to be passed to configure [$MINGW]
  202
+ -p PREFIX  Prefix at which Mono is to be installed. Build will append the 'mono-X.Y' string to that path
144 203
 EOF
145 204
 
146 205
     exit 1
@@ -150,10 +209,12 @@ trap cleanup 0
150 209
 
151 210
 pushd . > /dev/null
152 211
 
153  
-while getopts "d:m:h" opt; do
  212
+while getopts "d:m:e:p:" opt; do
154 213
     case "$opt" in
155 214
 	d) CROSS_DIR="$OPTARG" ;;
156 215
 	m) MINGW="$OPTARG" ;;
  216
+	e) EXTRA_CROSS_DIR="$OPTARG" ;;
  217
+	p) MONO_PREFIX="$OPTARG" ;;
157 218
 	*) usage ;;
158 219
     esac
159 220
 done
@@ -161,5 +222,6 @@ done
161 222
 setup
162 223
 build
163 224
 doinstall
  225
+show_build_info
164 226
 
165 227
 popd > /dev/null

0 notes on commit a8362f1

Please sign in to comment.
Something went wrong with that request. Please try again.