#!/bin/sh

CBSRC=`dirname "$0"`

CBROOT="$CBSRC/.."

CODE=cb.c
A_OUT=a.out

while [ $# -ne 0 ]
do
    case $1 in
	-o)	if [ "$2" = "" ] ; then
		    echo 2>& "-o requires output filename"
		    exit 1
		fi

		A_OUT="$2"
		shift
		;;

	-o*)	A_OUT=`echo $1|sed -e s/-o//`
		;;

	-s)	CODE=cb.s
		;;

	*)	ARGS="$ARGS $1"
    esac

    shift
done

"$CBSRC/cbf" -I. -I$CBROOT/include $ARGS && \
    gcc -g -ansi -pedantic -Wall -Wno-unused "-I$CBSRC" "-L$CBSRC" \
	$CODE -lcb -o $A_OUT
