# UNIX compatible Makefile for building and testing wbr_wfr_list application
#
# Instructions:
#
# (1) Copy all files from the EXTRAS/SOFTWARE volume directory to
#     a writable directory.
#
# (2) Edit the entry for CC below for your platform if necessary.
#
# (3) make -f WBR_WFR_MAKEFILE.MAK
#
# (4) make -f WBR_WFR_MAKEFILE.MAK test
#
#   Note that roundoff errors on various platforms may make the final
#   test fail.  Check the corresponding diff files.  If the differences
#   exist only in the last digit of some floating point values, you can
#   consider the executable successfully validated.

CC = gcc

CFLAGS = -O

ORIGFILES = T1999229_21_10KHZD_WBRFR.orig \
	T1999230_2_5KHZ2_WFRFR.orig \
	T1999255_25HZ4_WFRFR.orig

OUTFILES = T1999229_21_10KHZD_WBRFR.out \
	T1999230_2_5KHZ2_WFRFR.out \
	T1999255_25HZ4_WFRFR.out

DIFFFILES = T1999229_21_10KHZD_WBRFR.diff \
	T1999230_2_5KHZ2_WFRFR.diff \
	T1999255_25HZ4_WFRFR.diff

wbr_wfr_list: wbr_wfr_list.c WBR_WFR_LIST.C
	$(CC) $(CFLAGS) -o wbr_wfr_list wbr_wfr_list.c -lm

test: wbr_wfr_list $(ORIGFILES) $(OUTFILES) $(DIFFFILES)
	@test `cat T*.diff | wc -l` -eq 0 \
	&& echo "wbr_wfr_list is CORRECT" \
	|| echo "wbr_wfr_list verification FAILED!  See T*.diff files"

wbr_wfr_list.c: WBR_WFR_LIST.C
	tr -d \\r < WBR_WFR_LIST.C > wbr_wfr_list.c

tidy:
	@rm -f T*.orig T*.out T*.diff

clean: tidy
	@rm -f wbr_wfr_list.c wbr_wfr_list

.SUFFIXES: .orig .TXT .out .DAT .diff

.TXT.orig:
	tr -d \\r < $< > $@

.DAT.out:
	./wbr_wfr_list -aercls $< > $@

.out.diff:
	-diff `basename $< .out`.orig $< > $@