#!/bin/bash

#set -x
PRODUCTS="CAN2 CANTx CANRx diotoggle spi8200 ts8160ctl DIOTest"

run0() {
	ARCH="$1"
	shift
	while [ "$1" != "" ]; do
		ARCH="$ARCH-$1"
		shift
	done
	echo "Arch $ARCH"
}
run() {
	local I
	run0 $@
	rm libtsctl.h
	while [ "$1" != "" ]; do
		echo "#include \"ts/$1.c\"" >> libtsctl.h
		shift
	done
	echo "#include \"ts/tsinit.c\"" >> libtsctl.h
	make clean > /dev/null
	make > /dev/null
	mkdir -p /u/x/home/michael/tsctl/product_$ARCH
	for I in $PRODUCTS; do
	    mv -f $I  /u/x/home/michael/tsctl/product_$ARCH/
	done
	#echo Hit Enter
	#read A
}

DIR=~/release_test/config
for I in ts4200 ts4500 ts4700 ts4800; do
	run $I
	for J in ts81x0 ts8900; do
	    	run $I $J
	    	run $I $J tsdio24
	    	run $I $J tsrelay8
	    	run $I $J tsdio24 tsrelay8
	done
done

for I in ts7552 ts7553 ts7558; do
	run $I
done
