129 lines
3.2 KiB
Bash
Executable File
129 lines
3.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Terminate when a command is unsuccesful
|
|
set -e
|
|
|
|
echo "This script doesn't work anymore. See
|
|
http://developer.wz2100.net/wiki/CompileGuideWindows/MingwCrossEnv for the
|
|
needed commands until someone changes this script to do that."
|
|
|
|
exit
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
##
|
|
# Function that provides make-like behaviour for executed commands. It prints
|
|
# the commandline used to execute them before execution.
|
|
##
|
|
execute()
|
|
{
|
|
local r
|
|
|
|
echo "$@"
|
|
"$@"
|
|
}
|
|
|
|
# Some default configuration settings
|
|
HOST_TRIPLET=i586-mingw32msvc
|
|
DOWNLOADS="$(pwd)/downloads"
|
|
INSTALLER_VERSION="2.2.0.999"
|
|
DEBUGFLAG="--disable-debug"
|
|
CC_FOR_BUILD="gcc"
|
|
CXX_FOR_BUILD="g++"
|
|
CFLAGS="-gstabs -g3"
|
|
CXXFLAGS="-gstabs -g3"
|
|
CFLAGS_FOR_BUILD=" "
|
|
CXXFLAGS_FOR_BUILD=" "
|
|
CPPFLAGS_FOR_BUILD=" "
|
|
|
|
if [ -f __BUILD_CONFIG.USER ]; then
|
|
. ./__BUILD_CONFIG.USER
|
|
fi
|
|
|
|
which $HOST_TRIPLET-gcc || (echo "You need to install a cross-compiler ($HOST_TRIPLET-gcc) to cross-compile."; exit 1)
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
*=*) val=`expr "X$arg" : '[^=]*=\(.*\)'` ;;
|
|
*) val=yes ;;
|
|
esac
|
|
|
|
case "$arg" in
|
|
--enable-debug* | --disable-debug)
|
|
unset DEBUGFLAG
|
|
;;
|
|
--enable-installer | --enable-installer=yes)
|
|
INSTALLERFLAG="--enable-data --enable-installer --with-installer-extdir=\"$PWD/build/libs\"
|
|
${INSTALLER_VERSION:+--with-installer-version=$INSTALLER_VERSION}"
|
|
;;
|
|
-with-* | --with-* | -enable-* | --enable-*)
|
|
;;
|
|
*=*)
|
|
var=`expr "x$arg" : 'x\([^=]*\)='`
|
|
# Reject names that are not valid shell variable names.
|
|
expr "x$var" : ".*[^_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]" >/dev/null && {
|
|
echo "$0: error: invalid variable name: $var" >&2
|
|
exit 1
|
|
}
|
|
eval $var=\$val
|
|
export $var
|
|
;;
|
|
clean | very-clean | preclean | very-preclean)
|
|
execute rm -rf build
|
|
execute make -C libs clean
|
|
expr "$arg" : 'very-' >/dev/null && execute rm -rf downloads
|
|
expr "$arg" : '.*pre' || exit 0
|
|
;;
|
|
*)
|
|
echo "$0: error: unknown command line option: $arg" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
__BOTHFLAGS="-pipe -m32 -march=i686 -O2 -g"
|
|
CFLAGS="$__BOTHFLAGS $CFLAGS"
|
|
CXXFLAGS="$__BOTHFLAGS $CXXFLAGS"
|
|
CPPFLAGS="-I$PWD/build/libs/include $CPPFLAGS"
|
|
LDFLAGS="-L$PWD/build/libs/lib $LDFLAGS"
|
|
unset __BOTHFLAGS
|
|
|
|
if [ -z "$PKG_CONFIG_PATH" ] ; then
|
|
PKG_CONFIG_PATH="$PWD/build/libs/lib/pkgconfig"
|
|
fi
|
|
export PKG_CONFIG_PATH
|
|
|
|
if [ -f "/proc/cpuinfo" ] ; then
|
|
MAKE_FLAGS=-j$((`grep '^processor' /proc/cpuinfo | wc -l` + 1))
|
|
fi
|
|
|
|
# Make sure we've got a build directory
|
|
if [ ! -d build/libs ] ; then
|
|
mkdir -p build/libs
|
|
fi
|
|
|
|
# Echo commands as we execute them
|
|
set -x
|
|
|
|
# Make sure that the dependencies have been built
|
|
make $MAKE_FLAGS -C libs "HOST_TRIPLET=$HOST_TRIPLET" "DOWNLOADS=$DOWNLOADS"
|
|
|
|
cd build
|
|
|
|
[ -x ../../configure ] || ../../autogen.sh
|
|
../../configure "$@" \
|
|
"--host=$HOST_TRIPLET" --enable-static --disable-shared ${DEBUGFLAG:+$DEBUGFLAG} \
|
|
${INSTALLERFLAG:+$INSTALLERFLAG} \
|
|
CFLAGS="$CFLAGS" \
|
|
CXXFLAGS="$CXXFLAGS -fno-exceptions" \
|
|
CPPFLAGS="$CPPFLAGS" \
|
|
LDFLAGS="$LDFLAGS" \
|
|
CC_FOR_BUILD="$CC_FOR_BUILD" \
|
|
CXX_FOR_BUILD="$CXX_FOR_BUILD" \
|
|
CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD" \
|
|
CXXFLAGS_FOR_BUILD="$CXXFLAGS_FOR_BUILD" \
|
|
CPPFLAGS_FOR_BUILD="$CPPFLAGS_FOR_BUILD" \
|
|
PKGCONFIG_DEFAULT_PREFIX=${PKGCONFIG_DEFAULT_PREFIX:-$PWD/build/libs} \
|
|
${PKG_CONFIG_PATH:+PKG_CONFIG_PATH=$PKG_CONFIG_PATH}
|
|
make $MAKE_FLAGS
|