169 lines
6.1 KiB
Bash
Executable File
169 lines
6.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
#
|
|
# mignw-configure - configure for cross-compiling with mingw
|
|
# by Yevgen Muntyan <muntyan@math.tamu.edu>
|
|
# Ditributed under the terms of WTFPL license
|
|
#
|
|
|
|
#
|
|
# If you are not using this script, do not forget to use --build.
|
|
# If you think --build is not needed because blah blah blah, then
|
|
# read docs. Or just use --build. Or just use this script damn it.
|
|
#
|
|
|
|
get_config_guess()
|
|
{
|
|
if [ ! -x "$1" ]; then
|
|
for cg in /usr/share/automake-1.10/config.guess \
|
|
/usr/share/automake-1.9/config.guess \
|
|
/usr/share/automake/config.guess;
|
|
do
|
|
if [ -x $cg ]; then
|
|
cp $cg "$1"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ ! -x "$1" ]; then
|
|
echo "config.guess script missing, copy it from some autoconf project"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
write_pkg_config()
|
|
{
|
|
rm -f $1
|
|
cat > $1 << ENDSRIPT
|
|
#!/bin/sh
|
|
|
|
export PKG_CONFIG_LIBDIR="$GTK_PREFIX/lib/pkgconfig":"$WIN32_PYTHON_PREFIX/Lib/pkgconfig"
|
|
export PKG_CONFIG_PATH=\$PKG_CONFIG_LIBDIR
|
|
|
|
# pkg-config doesn't like --define-variable with these
|
|
if [ "x\`echo "\$*" | grep -- --atleast-pkgconfig-version\`" != x -o \\
|
|
"x\`echo "\$*" | grep -- --atleast-version\`" != x ]; then
|
|
exec "$PKG_CONFIG_PROGRAM" \$*
|
|
else
|
|
# pygtk pulls gtk and friends, so if they sit in different prefixes then
|
|
# we're screwed anyway, so pygtk and friends must be relocated to the
|
|
# same prefix as gtk after install, if installed with win32 installer
|
|
exec "$PKG_CONFIG_PROGRAM" --define-variable=prefix="$GTK_PREFIX" \$*
|
|
fi
|
|
ENDSRIPT
|
|
chmod +x $1
|
|
}
|
|
|
|
# Path to the host pkg-config
|
|
PKG_CONFIG_PROGRAM=${PKG_CONFIG_PROGRAM:-`which pkg-config`}
|
|
|
|
# Where gtk libraries are installed
|
|
export GTK_PREFIX=${GTK_PREFIX:-/usr/local/win/gtk}
|
|
|
|
# Prefix of mingw tools. prefix + tool should make up full path
|
|
# to the tool, e.g. prefix is '/usr/bin/i586-mingw32msvc-' on Debian
|
|
# or '/usr/local/mingw32/bin/' on FreeBSD.
|
|
if [ -z "$MINGW_TOOL_PREFIX" ]; then
|
|
case `uname` in
|
|
Darwin)
|
|
MINGW_TOOL_PREFIX="i386-mingw32-"
|
|
;;
|
|
FreeBSD)
|
|
MINGW_TOOL_PREFIX="/usr/local/mingw32/bin/"
|
|
;;
|
|
*)
|
|
MINGW_TOOL_PREFIX="/usr/bin/i586-mingw32msvc-"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if [ "x$1" = "x--with-python=2.4" -o "x$2" = "x--with-python=2.4" ]; then
|
|
export WIN32_PYTHON_PREFIX=${WIN32_PYTHON_PREFIX:-/usr/local/win/Python24}
|
|
else
|
|
export WIN32_PYTHON_PREFIX=${WIN32_PYTHON_PREFIX:-/usr/local/win/Python25}
|
|
fi
|
|
export WIN32_PYTHON_HOME=$WIN32_PYTHON_PREFIX
|
|
export PYTHON=${PYTHON:-python}
|
|
|
|
# Find configure script to run
|
|
if [ x$CONFIGURE = x ]; then
|
|
CONFIGURE="configure"
|
|
if [ ! -e $CONFIGURE ]; then
|
|
CONFIGURE=`dirname $0`/configure
|
|
fi
|
|
if [ ! -e $CONFIGURE ]; then
|
|
echo "Can't find configure script"
|
|
exit 1
|
|
fi
|
|
configure_dir=`dirname "$CONFIGURE"`
|
|
configure_dir=`cd "$configure_dir" && pwd`
|
|
CONFIGURE="$configure_dir"/configure
|
|
CONFIG_GUESS="$configure_dir"/config.guess
|
|
get_config_guess $CONFIG_GUESS
|
|
fi
|
|
|
|
# autoconf is not intelligent enough to guess that
|
|
# i586-pc-mingw32msvc target has anything to do with
|
|
# debian /usr/bin/i586-mingw32msvc-gcc or freebsd
|
|
# /usr/local/mingw32/bin/gcc, hence these variables
|
|
export ADDR2LINE="${MINGW_TOOL_PREFIX}addr2line"
|
|
export AS="${MINGW_TOOL_PREFIX}as"
|
|
export CC="${MINGW_TOOL_PREFIX}gcc"
|
|
export OBJC="${MINGW_TOOL_PREFIX}gcc"
|
|
export CPP="${MINGW_TOOL_PREFIX}cpp"
|
|
export CPPFILT="${MINGW_TOOL_PREFIX}c++filt"
|
|
export CXX="${MINGW_TOOL_PREFIX}g++"
|
|
export DLLTOOL="${MINGW_TOOL_PREFIX}dlltool"
|
|
export DLLWRAP="${MINGW_TOOL_PREFIX}dllwrap"
|
|
export GCOV="${MINGW_TOOL_PREFIX}gcov"
|
|
export LD="${MINGW_TOOL_PREFIX}ld"
|
|
export NM="${MINGW_TOOL_PREFIX}nm"
|
|
export OBJCOPY="${MINGW_TOOL_PREFIX}objcopy"
|
|
export OBJDUMP="${MINGW_TOOL_PREFIX}objdump"
|
|
export READELF="${MINGW_TOOL_PREFIX}readelf"
|
|
export SIZE="${MINGW_TOOL_PREFIX}size"
|
|
export STRINGS="${MINGW_TOOL_PREFIX}strings"
|
|
export WINDRES="${MINGW_TOOL_PREFIX}windres"
|
|
export AR="${MINGW_TOOL_PREFIX}ar"
|
|
export RANLIB="${MINGW_TOOL_PREFIX}ranlib"
|
|
export STRIP="${MINGW_TOOL_PREFIX}strip"
|
|
|
|
export LDFLAGS="-L$GTK_PREFIX/lib $LDFLAGS"
|
|
export CPPFLAGS="-I$GTK_PREFIX/include $CPPFLAGS"
|
|
export CFLAGS="-I$GTK_PREFIX/include -mms-bitfields -march=i686 ${CFLAGS:-"-O2"}"
|
|
export CXXFLAGS="-I$GTK_PREFIX/include -mms-bitfields -march=i686 ${CXXFLAGS:-"-O2"}"
|
|
export OBJCFLAGS="-I$GTK_PREFIX/include -mms-bitfields -march=i686 ${OBJCFLAGS:-"-O2"}"
|
|
|
|
# Set up pkg-config invocation. Some broken packages do not use PKG_CONFIG macros
|
|
# to find pkg-config, so the script must be named 'pkg-config'. Hence it's put
|
|
# into a separate directory and the directory is pushed in front of PATH
|
|
mkdir -p fake-bin
|
|
write_pkg_config fake-bin/pkg-config
|
|
export PKG_CONFIG="`pwd`/fake-bin/pkg-config"
|
|
# Some stupid packages try to run stuff like 'gcc' and 'ld' even when cross-compiling, so
|
|
# cross-tools bin directory should better be in PATH. /usr/i586-mingw32msvc/bin and
|
|
# /usr/local/mingw32/bin are Debian's and FreeBSD's, add yours if needed.
|
|
export PATH=`pwd`/fake-bin:$MINGW_BIN:/usr/i586-mingw32msvc/bin:/usr/local/mingw32/bin:$PATH
|
|
|
|
TARGET=i586-pc-mingw32msvc
|
|
libs_flags="--enable-shared --disable-static"
|
|
|
|
# Now actually run configure. FOO=foo arguments *must* be there if you
|
|
# want automatic re-configuring (which happens if you modify configure.ac and
|
|
# run make) work.
|
|
# NOTE: --build *must* be here, it's autoconf bug (aka 'feature'), confirmed and
|
|
# *documented*.
|
|
echo sh $CONFIGURE --prefix=$GTK_PREFIX --build=`$CONFIG_GUESS` --host=$TARGET --target=$TARGET \
|
|
--enable-all-warnings --enable-maintainer-mode $libs_flags \
|
|
PKG_CONFIG="$PKG_CONFIG" GTK_PREFIX="$GTK_PREFIX" \
|
|
WIN32_PYTHON_PREFIX="$WIN32_PYTHON_PREFIX" WIN32_PYTHON_HOME="$WIN32_PYTHON_HOME" \
|
|
AR="$AR" RANLIB="$RANLIB" STRIP="$STRIP" AS="$AS" DLLTOOL="$DLLTOOL" \
|
|
OBJDUMP="$OBJDUMP" NM="$NM" WINDRES="$WINDRES" $@
|
|
exec sh $CONFIGURE --prefix=$GTK_PREFIX --build=`$CONFIG_GUESS` --host=$TARGET --target=$TARGET \
|
|
--enable-all-warnings --enable-maintainer-mode $libs_flags \
|
|
PKG_CONFIG="$PKG_CONFIG" GTK_PREFIX="$GTK_PREFIX" \
|
|
WIN32_PYTHON_PREFIX="$WIN32_PYTHON_PREFIX" WIN32_PYTHON_HOME="$WIN32_PYTHON_HOME" \
|
|
AR="$AR" RANLIB="$RANLIB" STRIP="$STRIP" AS="$AS" DLLTOOL="$DLLTOOL" \
|
|
OBJDUMP="$OBJDUMP" NM="$NM" WINDRES="$WINDRES" $@
|