diff --git a/packaging/win32/create_cross_mingw.sh b/packaging/win32/create_cross_mingw.sh index 82dc36c441..2a86afe50a 100755 --- a/packaging/win32/create_cross_mingw.sh +++ b/packaging/win32/create_cross_mingw.sh @@ -1,5 +1,13 @@ #! /bin/bash +function qpushd() { pushd "$@" >/dev/null; } +function qpopd() { popd >/dev/null; } +function unix_path() { echo "$*" | sed 's,^\([A-Za-z]\):,/\1,;s,\\,/,g'; } + +qpushd "$(dirname "$0")" +. functions.sh +. defaults.sh + # # From http://www.mingw.org/MinGWiki/index.php/BuildMingwCross # @@ -54,7 +62,7 @@ TARGET=mingw32 # have write-access to this directory. If you leave it # blank, it defaults to the current directory. -BUILDDIR= +BUILDDIR=`unix_path $TMP_DIR` # Where does the cross-compiler go? # This should be the directory into which your cross-compiler @@ -62,7 +70,7 @@ BUILDDIR= # that only root has write access to, you will need to run this # script as root. -PREFIX= +PREFIX=`unix_path $MINGW_DIR` # Purge anything and everything already in the $PREFIX #(also known as the destination or installation) directory? @@ -443,3 +451,4 @@ final_tweaks # # End # +qpopd diff --git a/packaging/win32/defaults.sh b/packaging/win32/defaults.sh index 07acc8d1e2..590ea7eabf 100644 --- a/packaging/win32/defaults.sh +++ b/packaging/win32/defaults.sh @@ -69,25 +69,20 @@ fi #### # For cross-compiling, change this to "yes" -set_default cross_compile "no" +set_default CROSS_COMPILE "no" -if test "x$cross_compile" != xyes ; then - LIBTOOLIZE=libtoolize - HOST_XCOMPILE="" - TARGET_XCOMPILE="" - LD=ld - CC=gcc - DLLTOOL=dlltool +if [ "$CROSS_COMPILE" != yes ]; then + set_default LIBTOOLIZE libtoolize + set_default LD ld + set_default CC gcc + set_default DLLTOOL dlltool else # Insert your cross-compiler mingw32 bin-directories here - PATH=$GLOBAL_DIR/bin:$GLOBAL_DIR/mingw32/bin:$PATH - LIBTOOLIZE=$GLOBAL_DIR/autotools/bin/libtoolize - PKG_CONFIG_PATH="" # to avoid using the host's installed packages - HOST_XCOMPILE="--host=mingw32" - TARGET_XCOMPILE="--target=mingw32" - LD=mingw32-ld - CC=mingw32-gcc - DLLTOOL=mingw32-dlltool + set_default LIBTOOLIZE $GLOBAL_DIR/autotools/bin/libtoolize + set_default HOST_XCOMPILE "--host=mingw32" + set_default LD mingw32-ld + set_default CC mingw32-gcc + set_default DLLTOOL mingw32-dlltool fi #### @@ -266,20 +261,20 @@ set_default DOCS_DIR $GLOBAL_DIR\\gnucash-docs # There is no reason to ever need to comment these out! # * commented out glade, as it is not needed to run gnucash -if test x$cross_compile != xyes ; then +if [ "$CROSS_COMPILE" != "yes" ]; then add_step inst_wget add_step inst_dtk - add_step inst_mingw add_step inst_unzip fi +add_step inst_mingw add_step inst_regex add_step inst_readline -if test x$cross_compile != xyes ; then +if [ "$CROSS_COMPILE" != "yes" ]; then add_step inst_active_perl fi add_step inst_autotools add_step inst_guile -if test x$cross_compile != xyes ; then +if [ "$CROSS_COMPILE" != "yes" ]; then add_step inst_svn add_step inst_openssl fi @@ -299,11 +294,11 @@ add_step inst_gwenhywfar add_step inst_ktoblzcheck add_step inst_aqbanking ## -if test x$cross_compile != xyes ; then +if [ "$CROSS_COMPILE" != "yes" ]; then add_step inst_inno add_step inst_hh fi -if test x$UPDATE_SOURCES = xyes ; then +if [ "$UPDATE_SOURCES" = "yes" ]; then add_step svn_up fi add_step inst_gnucash diff --git a/packaging/win32/install.sh b/packaging/win32/install.sh index 1f1dfc280a..7599a4ab0e 100755 --- a/packaging/win32/install.sh +++ b/packaging/win32/install.sh @@ -1,5 +1,7 @@ #!/bin/sh +[ ! "$BASH" -a -x /bin/bash ] && exec /bin/bash "$0" "$@" + set -e function qpushd() { pushd "$@" >/dev/null; } @@ -69,6 +71,10 @@ function prepare() { if [ "$DISABLE_OPTIMIZATIONS" = "yes" ]; then export CFLAGS="$CFLAGS -g -O0" fi + + if [ "$CROSS_COMPILE" ]; then + PKG_CONFIG_PATH="" # to avoid using the host's installed packages + fi } function inst_wget() { @@ -109,28 +115,36 @@ function inst_dtk() { } function test_for_mingw() { - ${CC} --version && - g++ --version && - ${LD} --help && - mingw32-make --help + ${CC} --version + ${LD} --help + if [ "$CROSS_COMPILE" != "yes" ]; then + g++ --version + mingw32-make --help + fi } function inst_mingw() { setup MinGW _MINGW_UDIR=`unix_path $MINGW_DIR` _MINGW_WFSDIR=`win_fs_path $MINGW_DIR` + [ "$CROSS_COMPILE" = "yes" ] && add_to_env $_MINGW_UDIR/bin PATH + if quiet test_for_mingw then echo "mingw already installed. skipping." else mkdir -p $_MINGW_UDIR - wget_unpacked $BINUTILS_URL $DOWNLOAD_DIR $MINGW_DIR - wget_unpacked $GCC_CORE_URL $DOWNLOAD_DIR $MINGW_DIR - wget_unpacked $GCC_GPP_URL $DOWNLOAD_DIR $MINGW_DIR - wget_unpacked $MINGW_RT_URL $DOWNLOAD_DIR $MINGW_DIR - wget_unpacked $W32API_URL $DOWNLOAD_DIR $MINGW_DIR - wget_unpacked $MINGW_MAKE_URL $DOWNLOAD_DIR $MINGW_DIR - (echo "y"; echo "y"; echo "$_MINGW_WFSDIR") | sh pi.sh + if [ "$CROSS_COMPILE" != "yes" ]; then + wget_unpacked $BINUTILS_URL $DOWNLOAD_DIR $MINGW_DIR + wget_unpacked $GCC_CORE_URL $DOWNLOAD_DIR $MINGW_DIR + wget_unpacked $GCC_GPP_URL $DOWNLOAD_DIR $MINGW_DIR + wget_unpacked $MINGW_RT_URL $DOWNLOAD_DIR $MINGW_DIR + wget_unpacked $W32API_URL $DOWNLOAD_DIR $MINGW_DIR + wget_unpacked $MINGW_MAKE_URL $DOWNLOAD_DIR $MINGW_DIR + (echo "y"; echo "y"; echo "$_MINGW_WFSDIR") | sh pi.sh + else + ./create_cross_mingw.sh + fi quiet test_for_mingw || die "mingw not installed correctly" fi } @@ -308,7 +322,7 @@ function inst_guile() { guile -c '(use-modules (srfi srfi-39))' && guile -c "(use-modules (ice-9 slib)) (require 'printf)" || die "guile not installed correctly" fi - if test x$cross_compile = xyes ; then + if [ "$CROSS_COMPILE" = "yes" ]; then qpushd $_GUILE_UDIR/bin # The cross-compiling guile expects these program names # for the build-time guile @@ -551,7 +565,7 @@ EOF # ${PKG_CONFIG} --exists gconf-2.0 libgnome-2.0 libgnomeui-2.0 libgnomeprint-2.2 libgtkhtml-3.14 && # not gnomeprint quiet intltoolize --version || die "gnome not installed correctly" fi - if test x$cross_compile = xyes ; then + if [ "$CROSS_COMPILE" = "yes" ]; then qpushd $_GNOME_UDIR/lib/pkgconfig perl -pi.bak -e"s!^prefix=.*\$!prefix=$GNOME_DIR!" *.pc #perl -pi.bak -e's!^Libs: !Libs: -L\${prefix}/bin !' *.pc @@ -945,7 +959,7 @@ function inst_gnucash() { LIBOFX_OPTIONS="--enable-ofx --with-ofx-prefix=${_LIBOFX_UDIR}" qpushd $REPOS_DIR - if test "x$cross_compile" = xyes ; then + if [ "$CROSS_COMPILE" = "yes" ]; then # Set these variables manually because of cross-compiling export GUILE_LIBS="${GUILE_LDFLAGS} -lguile -lguile-ltdl" export GUILE_INCS="${GUILE_CPPFLAGS}" @@ -960,7 +974,7 @@ function inst_gnucash() { qpopd qpushd $BUILD_DIR - $_REL_REPOS_UDIR/configure ${HOST_XCOMPILE} ${TARGET_XCOMPILE} \ + $_REL_REPOS_UDIR/configure ${HOST_XCOMPILE} \ --prefix=$_INSTALL_WFSDIR \ --enable-debug \ --enable-schemas-install=no \ @@ -1101,7 +1115,7 @@ function finish() { echo echo "'${_CHANGE}' >> /etc/profile.d/installer.sh" fi done - if test "x$cross_compile" = "xyes" ; then + if [ "$CROSS_COMPILE" = "yes" ]; then echo "You might want to create a binary tarball now as follows:" qpushd $GLOBAL_DIR echo tar -czf $HOME/gnucash-fullbin.tar.gz --anchored \