Don't pass multiple copies of identical type name to scintilla for colorization
[geany-mirror.git] / scripts / cross-build-mingw.sh
blobf3cf9b543d3cf865357b0ee28e8dad060104a1d5
1 #!/bin/sh
2 # A script to automate setup and build for Windows cross-compilation
4 # What it does:
5 # 1) prepare a build directory
6 # 2) download and unpacked the dependencies
7 # (see http://www.gtk.org/download/win32.php)
8 # 2.1) fixup the unpacked pkg-config file paths
9 # 3) setup the few required paths
10 # 4) configure with sensible options for this
11 # 5) build
12 # 6) install in a local directory
13 # 7) pack the installation in a ZIP file, ready to be used
14 # (but does not pack the dependencies)
16 # You may change those
17 HOST=i686-w64-mingw32
18 GTK2_BUNDLE_ZIP="http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip"
19 GTK3_BUNDLE_ZIP="http://win32builder.gnome.org/gtk+-bundle_3.8.2-20131001_win32.zip"
20 BUILDDIR=_build-cross-mingw
21 GTK3=no
22 CONFIGUREFLAGS="--enable-nls"
23 MAKEFLAGS="${MAKEFLAGS:--j2}"
25 while getopts '32h' o; do
26 case "$o" in
27 3) GTK3=yes;;
28 2) GTK3=no;;
30 cat <<EOF
31 USAGE: $0 [-2|-3] [-h]
33 -2 Build against GTK2
34 -3 Build against GTK3
35 -h Show this help and exit
36 EOF
37 exit 0;;
38 *) echo "Invalid option $o (see -h)">&2; exit 1;;
39 esac
40 done
41 shift $((OPTIND - 1))
43 CONFIGUREFLAGS="$CONFIGUREFLAGS --enable-gtk3=$GTK3"
44 if [ "$GTK3" = yes ]; then
45 BUNDLE_ZIP="$GTK3_BUNDLE_ZIP"
46 else
47 BUNDLE_ZIP="$GTK2_BUNDLE_ZIP"
50 # USAGE: fetch_and_unzip URL DEST_PREFIX
51 fetch_and_unzip()
53 local basename=${1##*/}
54 curl -L -# "$1" > "$basename"
55 unzip -q "$basename" -d "$2"
56 rm -f "$basename"
59 if test -d "$BUILDDIR"; then
60 cat >&2 <<EOF
61 ** Directory "$BUILDDIR/" already exists.
62 If it was created by this tool and just want to build, simply run make:
63 $ make -C "$BUILDDIR/_build/"
65 If however you want to recreate it, please remove it first:
66 $ rm -rf "$BUILDDIR/"
67 EOF
68 exit 1
71 set -e
72 set -x
75 test -f configure
76 # check if the host tools are available, because configure falls back
77 # on default non-prefixed tools if they are missing, and it can spit
78 # quite a lot of subtle errors. also avoids going further if something
79 # is obviously missing.
80 type "$HOST-gcc"
82 SRCDIR="$PWD"
84 mkdir "$BUILDDIR"
85 cd "$BUILDDIR"
87 mkdir _deps
88 fetch_and_unzip "$BUNDLE_ZIP" _deps
89 # fixup the prefix= in the pkg-config files
90 sed -i "s%^\(prefix=\).*$%\1$PWD/_deps%" _deps/lib/pkgconfig/*.pc
92 export PKG_CONFIG_PATH="$PWD/_deps/lib/pkgconfig/"
93 export CPPFLAGS="-I$PWD/_deps/include"
94 export LDFLAGS="-L$PWD/_deps/lib"
96 mkdir _build
97 cd _build
98 "$SRCDIR/configure" \
99 --host=$HOST \
100 --disable-silent-rules \
101 --prefix="$PWD/../_install" \
102 $CONFIGUREFLAGS
103 make $MAKEFLAGS
104 make $MAKEFLAGS install