HEADER_FILES=openFile.h getCharacter.h
OBJS=main.c getCharacter.c openFile.c
CFLAGS=-pedantic -Wall -Werror -std=c99

#
# 
PROG=swc

%.o:%.c
	gcc -c $(CFLAGS) $< -o $@

$(PROG): $(OBJS)
	gcc $(OBJS) -o $@ -lm

$(OBJS): $(HEADER_FILES)

bb:
	@echo Performing black box tests
# stdin
	@echo " -- stdin ---"
	@echo -n "$(PROG) -l: ";    export COUNT=$$(seq 1 10 | $(PROG) -l); if [ $$COUNT -ne 10 ] ; then echo " failure" ; exit 1 ; else echo "ok" ; fi
	@echo -n "$(PROG) -c: ";    export COUNT=$$(seq 1 10 | $(PROG) -c); if [ $$COUNT -ne 21 ] ; then echo " failure" ; exit 1 ; else echo "ok" ; fi
	@echo -n "$(PROG) -l -: ";    export COUNT=$$(seq 1 10 | $(PROG) -l - | awk '{ print $$1}'); if [ $$COUNT -ne 10 ] ; then echo " failure" ; exit 1 ; else echo "ok" ; fi
	@echo -n "$(PROG) -c - : ";    export COUNT=$$(seq 1 10 | $(PROG) -c - | awk '{ print $$1}'); if [ $$COUNT -ne 21 ] ; then echo " failure" ; exit 1 ; else echo "ok" ; fi
	@echo -n "$(PROG) -c: ";    export COUNT=$$(cat test-data/words.txt | $(PROG) -c | awk '{ print $$1}'); if [ $$COUNT -ne 56 ] ; then echo "Count $$COUNT != 56" ; exit 1 ; else echo "ok"; fi
	@echo -n "$(PROG) -l: ";   export COUNT=$$(cat test-data/words.txt | $(PROG) -l - | awk '{ print $$1}'); if [ $$COUNT -ne 3 ] ; then echo "Count $$COUNT != 56" ; exit 1 ; else echo "ok"; fi
# file
	@echo " -- file ---"
	@echo -n "$(PROG) -c: "; export COUNT=$$( $(PROG) -c test-data/words.txt | awk '{ print $$1}'); if [ $$COUNT -ne 56 ] ; then echo "Count $$COUNT != 56" ; exit 1 ; else echo "ok"; fi
	@echo -n "$(PROG) -c: "; export COUNT=$$( $(PROG) -l test-data/words.txt | awk '{ print $$1}'); if [ $$COUNT -ne 3 ] ; then echo "Count $$COUNT != 56" ; exit 1 ; else echo "ok"; fi


