#!/bin/sh
# --------------------------------------------------------------------
# This nifty batch script will compile one tool which is specified
# on the commandline
#
# for example if we want to build ttpack we will call this tool:
# buildone.bat ttpack
#
# if upx is found in the path it will pack the executables otherwise
# they stay in their original form
#
# at the end of the batch script the final executable is moved into
# the calctools bin directory
# --------------------------------------------------------------------
echo compiling $1 ...
gcc -Os -o $1 $1.c
if [ $? -ne 0 ] ; then
exit 1
fi

if [ -n `which upx` ] ; then
upx --best $1 &>/dev/null
else
echo compression skipped
fi

echo moving executable ...
if [ -f "$1.exe" ]
then
cp $1.exe ../../bin &>/dev/null
rm -f $1.exe
elif [ -f "$1" ]
then
cp $1 ../../bin &>/dev/null
rm -f $1
fi
