From 130135a09f3102a839a97f358a66a41b631fbea5 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 15 Mar 2011 21:58:15 +0000 Subject: [PATCH] win32: support building json-glib in mingw script Since Tor does not currently provide win32 binaries for json-glib we need to cross compile it before we can build clutter. This extends mingw-fetch-dependencies.sh so it can fetch, unpack and cross-compile json-glib into the same prefix as the binary dependencies. --- build/mingw/mingw-fetch-dependencies.sh | 73 ++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/build/mingw/mingw-fetch-dependencies.sh b/build/mingw/mingw-fetch-dependencies.sh index f3d5481..6129db4 100755 --- a/build/mingw/mingw-fetch-dependencies.sh +++ b/build/mingw/mingw-fetch-dependencies.sh @@ -24,6 +24,10 @@ TOR_DEPS=( \ libpng{-dev,}_1.4.0-1_win32.zip \ zlib{-dev,}_1.2.4-2_win32.zip ); +GNOME_SOURCES_URL="http://ftp.gnome.org/pub/GNOME/sources/" +SOURCES_DEPS=(\ + json-glib/0.12/json-glib-0.12.2.tar.gz ); + GL_HEADER_URLS=( \ http://cgit.freedesktop.org/mesa/mesa/plain/include/GL/gl.h \ http://cgit.freedesktop.org/mesa/mesa/plain/include/GL/mesa_wgl.h \ @@ -111,6 +115,24 @@ function do_unzip_d () fi; } +function do_untar_source () +{ + do_untar_source_d "$BUILD_DIR" "$@"; +} + +function do_untar_source_d () +{ + local exdir="$1"; shift; + local tarfile="$1"; shift; + + tar -C "$exdir" -zxvf "$tarfile" "$@"; + + if [ "$?" -ne 0 ]; then + echo "Failed to extract $tarfile"; + exit 1; + fi; +} + function add_env () { echo "export $1=\"$2\"" >> $env_file; @@ -156,6 +178,28 @@ function find_compiler () echo "Using compiler ${MINGW_TOOL_PREFIX}gcc and target $TARGET"; } +function do_cross_compile () +{ + local dep="$1"; shift; + local builddir="$BUILD_DIR/$dep"; + + cd "$builddir" + . $ROOT_DIR/share/env.sh + ./configure --prefix="$ROOT_DIR" --host="$TARGET" --target="$TARGET" --build="`./config.guess`" + + if [ "$?" -ne 0 ]; then + echo "Failed to configure $dep"; + exit 1; + fi; + + make all install + + if [ "$?" -ne 0 ]; then + echo "Failed to build $dep"; + exit 1; + fi; +} + # If a download directory hasn't been specified then try to guess one # but ask for confirmation first guess_dir DOWNLOAD_DIR "downloads" \ @@ -187,6 +231,11 @@ guess_dir ROOT_DIR "clutter-cross" \ SLASH_SCRIPT='s/\//\\\//g'; quoted_root_dir=`echo "$ROOT_DIR" | sed "$SLASH_SCRIPT" `; +# If a build directory hasn't been specified then try to guess one +# but ask for confirmation first +guess_dir BUILD_DIR "build" \ + "the directory to build source dependencies in" "Build directory"; + ## # Download files ## @@ -210,6 +259,11 @@ for dep in "${GL_HEADER_URLS[@]}"; do download_file "$dep" "$bn"; done; +for dep in "${SOURCES_DEPS[@]}"; do + src="${dep##*/}"; + download_file "$GNOME_SOURCES_URL/$dep" "$src"; +done; + ## # Extract files ## @@ -225,6 +279,12 @@ for dep in "${TOR_DEPS[@]}"; do do_unzip "$DOWNLOAD_DIR/$dep"; done; +for src in "${SOURCES_DEPS[@]}"; do + echo "Extracting $src..."; + src="${src##*/}"; + do_untar_source "$DOWNLOAD_DIR/$src"; +done; + echo "Fixing pkgconfig files..."; for x in "$ROOT_DIR/lib/pkgconfig/"*.pc; do sed "s/^prefix=.*\$/prefix=${quoted_root_dir}/" \ @@ -254,7 +314,7 @@ for header in "${GL_HEADERS[@]}"; do done; ## -# Build +# Build environment ## env_file="$ROOT_DIR/share/env.sh"; @@ -290,3 +350,14 @@ fi; EOF chmod a+x "$env_file"; + +## +# Build source dependencies +## + +for dep in "${SOURCES_DEPS[@]}"; do + echo "Building $dep..."; + src="${dep##*/}"; + src="${src%%.tar.gz}"; + do_cross_compile "$src" +done; -- 2.7.4