2 # A script to automate setup and build for Windows cross-compilation
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
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
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
22 CONFIGUREFLAGS
="--enable-nls"
23 MAKEFLAGS
="${MAKEFLAGS:--j2}"
25 while getopts '32b:h' o
; do
29 b
) BUILDDIR
="$OPTARG";;
32 USAGE: $0 [-2|-3] [-b DIR] [-h]
36 -b DIR Use DIR as build directory
37 -h Show this help and exit
40 *) echo "Invalid option $o (see -h)">&2; exit 1;;
45 CONFIGUREFLAGS
="$CONFIGUREFLAGS --enable-gtk3=$GTK3"
46 if [ "$GTK3" = yes ]; then
47 BUNDLE_ZIP
="$GTK3_BUNDLE_ZIP"
49 BUNDLE_ZIP
="$GTK2_BUNDLE_ZIP"
52 # USAGE: fetch_and_unzip URL DEST_PREFIX
55 local basename=${1##*/}
56 curl
-L -# "$1" > "$basename"
57 unzip -qn "$basename" -d "$2"
61 if test -d "$BUILDDIR"; then
63 ** Directory "$BUILDDIR/" already exists.
64 If it was created by this tool and just want to build, simply run make:
65 $ make -C "$BUILDDIR/_build/"
67 If however you want to recreate it, please remove it first:
78 # check if the host tools are available, because configure falls back
79 # on default non-prefixed tools if they are missing, and it can spit
80 # quite a lot of subtle errors. also avoids going further if something
81 # is obviously missing.
90 fetch_and_unzip
"$GTK3_BUNDLE_ZIP" _deps
91 [ "$GTK3" = yes ] || fetch_and_unzip
"$BUNDLE_ZIP" _deps
92 # fixup the prefix= in the pkg-config files
93 sed -i "s%^\(prefix=\).*$%\1$PWD/_deps%" _deps
/lib
/pkgconfig
/*.pc
95 export PKG_CONFIG_PATH
="$PWD/_deps/lib/pkgconfig/"
96 export CPPFLAGS
="-I$PWD/_deps/include"
97 export LDFLAGS
="-L$PWD/_deps/lib"
101 "$SRCDIR/configure" \
103 --disable-silent-rules \
104 --prefix="$PWD/../_install" \
107 make $MAKEFLAGS install