#!/bin/bash
#
# Simple shell script for building SPLAT! and associated utilities.
# Written by John A. Magliacane, KD2BD May 2002
#

build_citydecoder()
{
	echo -n "Compiling citydecoder... "
	cc -Wall -O3 -s -fomit-frame-pointer citydecoder.c -o citydecoder
	echo "Done!"
}

build_usgs2sdf()
{
	echo -n "Compiling usgs2sdf... "
	cc -Wall -O3 -s -fomit-frame-pointer usgs2sdf.c -o usgs2sdf
	echo "Done!"
}

build_fontdata()
{
	echo -n "Compiling fontdata... "
	cc -Wall -O3 -s -lz -fomit-frame-pointer fontdata.c -o fontdata
	echo "Done!"
}

if [ $# == "0" ]; then
	echo "Usage: build  { citydecoder, usgs2sdf, fontdata, all }"
else

	if [ $1 == "citydecoder" ]; then
		build_citydecoder
	fi

	if [ $1 == "usgs2sdf" ]; then
		build_usgs2sdf
	fi

	if [ $1 == "fontdata" ]; then
		build_fontdata
	fi

	if [ $1 == "clean" ]; then
		rm -f citydecoder usgs2sdf fontdata
	fi

	if [ $1 == "all" ]; then
		build_citydecoder
		build_usgs2sdf
		build_fontdata
	fi

	if [ $1 != "citydecoder" ] && [ $1 != "usgs2sdf" ] && [ $1 != "fontdata" ] && [ $1 != "clean" ] && [ $1 != "all" ]; then
		echo "Usage: build { citydecoder, usgs2sdf, fontdata, all }"
	fi
fi
