-#!/bin/bash
-
-# Download and cross-compile dependencies for Yoink. This script requires
-# bash, wget, md5sum, unzip, tar, patch, make and install. Have fun!
-
-HOST="i686-mingw32"
-PREFIX="/usr/$HOST/usr"
+#!/bin/sh
+
+#
+# Yoink
+# Run this script to download and cross-compile dependencies for win32.
+#
+# A directory named deps will be created and/or populated in the current
+# directory. Upon successful completion (be patient), the compiled
+# dependencies will be packaged into an archive named deps.tar.bz2 in the
+# current directory. To install the dependencies, execute this command:
+#
+# tar xf deps.tar.bz2 -C $PREFIX
+#
+# where $PREFIX is the path to your mingw32 toolchain. If problems occur,
+# check stdout and stderr for clues. You may be able to easily determine
+# the problem and make the necessary corrections. These packages will be
+# downloaded and built:
+#
+# SDL 1.2.14
+# boost 1.42.0 (headers only)
+# libogg 1.1.4
+# libpng 1.4.1
+# libvorbis 1.2.3
+# lua 5.1.4
+# openal-soft 1.11.753
+# zlib 1.2.3
+#
+# This script requires a working mingw32 toolchain and other basic tools.
+# Have fun!
+#
+# Example usage:
+# ./makedeps.sh -H i486-mingw32 -p /usr/i486-mingw32 -m "-j8"
+#
+# Bugs: Each time the script is run, all of the dependencies will be
+# rebuilt, even the ones which were already built successfully.
+#
+
+function showhelp()
+{
+ echo "Download and cross-compile dependencies for win32."
+ echo "Usage: $0 [-h] [-m makeopts] -H host -p prefix"
+ echo ""
+ echo " -H Specify the name of your toolchain, like i486-mingw32."
+ echo " -h Show this help an exit."
+ echo " -m Specify options to be passed to make."
+ echo " -p Specify the path to your toolchain installation."
+}
-MAKEOPTS="-j8"
+while getopts ":H:hm:p:" opt
+do
+ case $opt in
+ H)
+ HOST="$OPTARG"
+ ;;
+ h)
+ showhelp
+ exit 0
+ ;;
+ m)
+ MAKEOPTS="$OPTARG"
+ ;;
+ p)
+ PREFIX="$OPTARG"
+ ;;
+ \?)
+ echo "Invalid option: -$OPTARG" >&2
+ showhelp
+ exit 1
+ ;;
+ esac
+done
+
+if test x$HOST = x || test x$PREFIX = x
+then
+ showhelp
+ exit 1
+fi
-#####
function die()
{
PACKAGE="boost_1_42_0"
VERSION="1.42.0"
cd $DESTDIR
-[[ ! -f $PACKAGE.tar.bz2 ]] && (wget "http://sourceforge.net/projects/boost/files/boost/$VERSION/$PACKAGE.tar.bz2/download" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.tar.bz2 && (wget "http://sourceforge.net/projects/boost/files/boost/$VERSION/$PACKAGE.tar.bz2/download" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
7bf3b4eb841b62ffb0ade2b82218ebe6 boost_1_42_0.tar.bz2
EOL
PACKAGE="SDL-1.2.14"
cd $DESTDIR
-[[ ! -f $PACKAGE.tar.gz ]] && (wget "http://www.libsdl.org/release/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.tar.gz && (wget "http://www.libsdl.org/release/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
e52086d1b508fa0b76c52ee30b55bec4 SDL-1.2.14.tar.gz
EOL
PACKAGE="libogg-1.1.4"
cd $DESTDIR
-[[ ! -f $PACKAGE.tar.gz ]] && (wget "http://downloads.xiph.org/releases/ogg/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.tar.gz && (wget "http://downloads.xiph.org/releases/ogg/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
10200ec22543841d9d1c23e0aed4e5e9 libogg-1.1.4.tar.gz
EOL
PACKAGE="libvorbis-1.2.3"
cd $DESTDIR
-[[ ! -f $PACKAGE.tar.gz ]] && (wget "http://downloads.xiph.org/releases/vorbis/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.tar.gz && (wget "http://downloads.xiph.org/releases/vorbis/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
5aa77f55c0e0aab8eb8ed982335daac8 libvorbis-1.2.3.tar.gz
EOL
PACKAGE="openal-soft-1.11.753-bin"
cd $DESTDIR
-[[ ! -f $PACKAGE.zip ]] && (wget "http://kcat.strangesoft.net/$PACKAGE.zip" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.zip && (wget "http://kcat.strangesoft.net/$PACKAGE.zip" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
20747ce5ca0f902ae082fef15d7b41a5 openal-soft-1.11.753-bin.zip
EOL
PACKAGE="zlib123-dll"
cd $DESTDIR
-[[ ! -f $PACKAGE.zip ]] && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.zip && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
cc7fa97f9c19386bb701acc79d0abbca zlib123-dll.zip
EOL
PACKAGE="libpng-1.4.1"
cd $DESTDIR
-[[ ! -f $PACKAGE.tar.gz ]] && (wget "http://prdownloads.sourceforge.net/libpng/$PACKAGE.tar.gz?download" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.tar.gz && (wget "http://prdownloads.sourceforge.net/libpng/$PACKAGE.tar.gz?download" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
fa0b2a84733463f90d3ac9f43ccafabc libpng-1.4.1.tar.gz
EOL
PACKAGE="lua-5.1.4"
cd $DESTDIR
-[[ ! -f $PACKAGE.tar.gz ]] && (wget "http://www.lua.org/ftp/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
+test ! -f $PACKAGE.tar.gz && (wget "http://www.lua.org/ftp/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
(md5sum -c <<"EOL"
d0870f2de55d59c1c8419f36e8fac150 lua-5.1.4.tar.gz
EOL
# What to install.
-TO_BIN= lua luac
-+TO_BIN= lua.exe luac.exe
++TO_BIN= lua.exe luac.exe lua51.dll
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.a liblua.dll.a