#!/bin/bash

# Cross-compiling to ARM. Note: only compiles in OGG and MP3 support
# if the ARM libraries are already setup within libs/, otherwise omits
# them.  To build the libraries, see the 'mk-libmad-linux-xarm' and
# 'mk-tremor-linux-xarm' scripts.  Good luck!!!

CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc

OPT='-DT_LINUX -Wall -O3 -s -lm -lpthread'
LIBS=''

[ -f libs/linux-arm-libmad.a ] && {
    OPT="-DMP3_DECODE $OPT"
    LIBS="$LIBS libs/linux-arm-libmad.a"
}
[ -f libs/linux-arm-libvorbisidec.a ] && {
    OPT="-DOGG_DECODE $OPT"
    LIBS="$LIBS libs/linux-arm-libvorbisidec.a"
}

echo $CC $OPT sbagen.c $LIBS -o sbagen
$CC $OPT sbagen.c $LIBS -o sbagen || exit 1

