CC=gcc
CFLAGS = -Wall -Werror -O3

all: ent ent.1

ent: ent.o iso8859.o randtest.o
	$(CC) $(CFLAGS) ent.o iso8859.o randtest.o -o ent -lm

ent.c: iso8859.h randtest.h

clean:
	rm -f *.o ent ent.1 test/actual

.PHONY: test
test: ent
	./ent entitle.gif >test/actual
	./ent -c entitle.gif >test/actual
	./ent -fc entitle.gif >>test/actual
	./ent -b entitle.gif >>test/actual
	./ent -bc entitle.gif >>test/actual
	./ent -t entitle.gif >>test/actual
	./ent -ct entitle.gif >>test/actual
	./ent -ft entitle.gif >>test/actual
	./ent -bt entitle.gif >>test/actual
	./ent -bct entitle.gif >>test/actual
	diff -s test/expected test/actual

%.1: %.1.txt
	asciidoc -b docbook -d manpage $<
	docbook2x-man $*.1.xml
	rm -f $*.1.xml
