2010-03-06 18:08:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-10-23 21:14:24 +00:00
|
|
|
set -e
|
|
|
|
|
2010-03-06 18:08:22 +00:00
|
|
|
# Creates a tree with all the required libraries for use with the
|
|
|
|
# mingw cross compiler. The libraries are compiled appropriately.
|
|
|
|
# Read the file "README.Windows.txt" for instructions.
|
|
|
|
|
|
|
|
#
|
2011-10-23 21:14:24 +00:00
|
|
|
# SETUP -- adjust these variables if neccessary.
|
|
|
|
# You can also override them from the command line:
|
|
|
|
# INSTALL_DIR=/opt/mingw ./setup_cross_compilation_env.sh
|
2010-03-06 18:08:22 +00:00
|
|
|
#
|
|
|
|
|
2011-10-23 21:14:24 +00:00
|
|
|
TARGET=${TARGET:-i686-pc-mingw32}
|
|
|
|
INSTALL_DIR=${INSTALL_DIR:-$HOME/mingw-cross-env}
|
|
|
|
# Leave this empty if you want the script to use all of your CPU
|
|
|
|
# cores.
|
|
|
|
PARALLEL=${PARALLEL:-$(( $(awk '/^core id/ { print $4 }' /proc/cpuinfo | sort | tail -n 1) + 2 ))}
|
2010-03-06 18:08:22 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# END OF SETUP -- usually no need to change anything else
|
|
|
|
#
|
|
|
|
|
2011-10-23 21:14:24 +00:00
|
|
|
SRCDIR=$(pwd)
|
|
|
|
LOGFILE=$(mktemp)
|
2010-03-07 13:44:42 +00:00
|
|
|
|
2011-10-23 21:14:24 +00:00
|
|
|
function update_mingw_cross_env {
|
|
|
|
if [[ ! -d $INSTALL_DIR ]]; then
|
|
|
|
echo Retrieving the mingw-cross-env build scripts >> $LOGFILE
|
2012-05-31 11:39:43 +00:00
|
|
|
git clone https://github.com/mbunkus/mxe $INSTALL_DIR >> $LOGFILE 2>&1
|
2011-10-23 21:14:24 +00:00
|
|
|
else
|
|
|
|
echo Updating the mingw-cross-env build scripts >> $LOGFILE
|
|
|
|
cd $INSTALL_DIR
|
2012-05-21 15:58:26 +00:00
|
|
|
git pull >> $LOGFILE 2>&1
|
2011-10-23 21:14:24 +00:00
|
|
|
fi
|
2010-03-06 18:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function create_run_configure_script {
|
2011-10-23 21:14:24 +00:00
|
|
|
cd $SRCDIR
|
|
|
|
|
2010-03-06 18:34:51 +00:00
|
|
|
echo Creating \'run_configure.sh\' script
|
|
|
|
cat > run_configure.sh <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
|
2012-05-31 11:39:43 +00:00
|
|
|
export PATH=$PATH:${INSTALL_DIR}/usr/bin
|
2011-10-23 21:14:24 +00:00
|
|
|
hash -r
|
|
|
|
|
2010-03-06 18:34:51 +00:00
|
|
|
./configure \\
|
2011-10-23 21:14:24 +00:00
|
|
|
--host=${TARGET} \\
|
|
|
|
--with-boost="${INSTALL_DIR}/usr/${TARGET}" \\
|
2012-05-31 11:39:43 +00:00
|
|
|
--with-wx-config="${INSTALL_DIR}/usr/bin/${TARGET}-wx-config" \\
|
2011-10-23 21:14:24 +00:00
|
|
|
"\$@"
|
2010-03-06 18:34:51 +00:00
|
|
|
|
|
|
|
exit \$?
|
|
|
|
EOF
|
|
|
|
chmod 755 run_configure.sh
|
2012-05-31 11:39:43 +00:00
|
|
|
|
|
|
|
if [[ ! -f configure ]]; then
|
|
|
|
echo Creating \'configure\'
|
|
|
|
./autogen.sh
|
|
|
|
fi
|
2010-03-06 18:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function configure_mkvtoolnix {
|
2011-10-23 21:14:24 +00:00
|
|
|
cd $SRCDIR
|
|
|
|
|
|
|
|
echo Running configure.
|
|
|
|
./run_configure.sh >> $LOGFILE 2>&1
|
2010-03-06 18:34:51 +00:00
|
|
|
local result=$?
|
|
|
|
|
|
|
|
echo
|
|
|
|
if [ $result -eq 0 ]; then
|
2011-10-23 21:14:24 +00:00
|
|
|
echo 'Configuration went well. Congratulations. You can now run "drake"'
|
|
|
|
echo 'after adding the mingw cross compiler installation directory to your PATH:'
|
2012-05-31 11:39:43 +00:00
|
|
|
echo ' export PATH=$PATH:'${INSTALL_DIR}'/usr/bin'
|
2011-10-23 21:14:24 +00:00
|
|
|
echo ' hash -r'
|
|
|
|
echo ' ./drake'
|
2010-03-06 18:34:51 +00:00
|
|
|
else
|
2011-10-23 21:14:24 +00:00
|
|
|
echo "Configuration failed. Look at ${LOGFILE} as well as"
|
|
|
|
echo "at ./config.log for hints as to why."
|
2010-03-06 18:34:51 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo 'If you need to re-configure mkvtoolnix then you can do that with'
|
|
|
|
echo 'the script ./run_configure.sh. Any parameter you pass to run_configure.sh'
|
|
|
|
echo 'will be passed to ./configure as well.'
|
2010-03-06 18:08:22 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 21:14:24 +00:00
|
|
|
function build_base {
|
|
|
|
echo Building the cross-compiler itself
|
|
|
|
cd ${INSTALL_DIR}
|
|
|
|
make TARGET=${TARGET} JOBS=${PARALLEL} gcc w32api mingwrt >> $LOGFILE 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
function build_libraries {
|
|
|
|
echo Building the required libraries
|
|
|
|
cd ${INSTALL_DIR}
|
2012-05-21 15:58:26 +00:00
|
|
|
make TARGET=${TARGET} JOBS=${PARALLEL} gettext boost bzip2 curl file flac libiconv lzo ogg pthreads vorbis wxwidgets zlib >> $LOGFILE 2>&1
|
2011-10-23 21:14:24 +00:00
|
|
|
}
|
|
|
|
|
2010-03-06 18:08:22 +00:00
|
|
|
# main
|
|
|
|
|
2011-10-23 21:14:24 +00:00
|
|
|
echo "Cross-compiling mkvtoolnix. Log output can be found in ${LOGFILE}"
|
|
|
|
update_mingw_cross_env
|
|
|
|
build_base
|
|
|
|
build_libraries
|
2010-03-06 18:34:51 +00:00
|
|
|
create_run_configure_script
|
|
|
|
configure_mkvtoolnix
|