1#!/bin/sh
2
3# Cross-compile from Linux to Win32 using mingw32 cross-compiler as
4# provided by Debian.  For Ogg and MP3 support, you need to compile
5# those libraries separately and put them in libs/.  If the libraries
6# are absent, sbagen is compiled without Ogg/MP3 support.
7#
8# Compiling these libraries is not the easiest thing to do, and doing
9# it the way I did it requires a MinGW and MSYS setup running on
10# Windows (or under emulation), under which you can use the
11# 'mk-libmad-mingw' and 'mk-tremor-mingw' scripts to build the
12# libraries in a rather improvised manner.  You only have to do this
13# once, after which you can copy them to libs/ and rebuild endlessly
14# on Linux without trouble.
15
16COPT="-O6 -s -Wall"
17OPT="$COPT -DT_MINGW -I /usr/i586-mingw32msvc/include -I./libs"
18GCC=i586-mingw32msvc-gcc
19LIBDIR=/usr/i586-mingw32msvc/lib
20LIBS=''
21
22[ -f libs/xmingw-libmad.a ] && {
23    OPT="-DMP3_DECODE $OPT"
24    LIBS="$LIBS libs/xmingw-libmad.a"
25}
26[ -f libs/xmingw-libvorbisidec.a ] && {
27    OPT="-DOGG_DECODE $OPT"
28    LIBS="$LIBS libs/xmingw-libvorbisidec.a"
29}
30
31$GCC $OPT sbagen.c $LIBS -L$LIBDIR -lmingw32 -lwinmm -o sbagen.exe ||
32{ echo "FAILED"; exit 1; }
33
34