# Makefile for Image Interpolation Tools
# 	-- See README file for details
#
CC = g++

LIB = -ltiff -ljpeg -lz

PROGS = bilinear disc extract table

all:	$(PROGS)

timing: bilinear disc table.bin map0.tiff
	time ./bilinear -n map0.tiff tempmap1.tiff 8
	time ./bilinear map0.tiff tempmap2.tiff 8
	time ./disc -n map0.tiff tempmap3.tiff 3
	time ./disc map0.tiff tempmap4.tiff 3

iterate mapb4.tiff map4.tiff: bilinear disc table.bin map0.tiff
	./bilinear -n map0.tiff mapb1.tiff 8
	./bilinear -n mapb1.tiff mapb2.tiff 8
	./bilinear -n mapb2.tiff mapb3.tiff 8
	./bilinear -n mapb3.tiff mapb4.tiff 8
	./bilinear mapb4.tiff mapb5.tiff 8
	./disc -n map0.tiff map1.tiff 3
	./disc -n map1.tiff map2.tiff 3
	./disc -n map2.tiff map3.tiff 3
	./disc -n map3.tiff map4.tiff 3
	./disc map4.tiff map5.tiff 3

iterate2: bilinear disc table.bin map4.tiff mapb4.tiff
	./bilinear -n mapb4.tiff mapb5.tiff 8
	./bilinear -n mapb5.tiff mapb6.tiff 8
	./bilinear -n mapb6.tiff mapb7.tiff 8
	./bilinear -n mapb7.tiff mapb8.tiff 8
	./bilinear -n mapb8.tiff mapb9.tiff 8
	./bilinear mapb9.tiff mapb10.tiff 8
	./disc -n map4.tiff map5.tiff 3
	./disc -n map5.tiff map6.tiff 3
	./disc -n map6.tiff map7.tiff 3
	./disc -n map7.tiff map8.tiff 3
	./disc -n map8.tiff map9.tiff 3
	./disc map9.tiff map10.tiff 3

bilinear:	bilinear.o
	$(CC) -O9 bilinear.o -o bilinear $(LIB)

disc:	disc.o
	$(CC) -O9 disc.o -o disc $(LIB)

extract:	extract.o
	$(CC) -O9 extract.o -o extract

table.bin: table
	./table

table:	table.o
	$(CC) -O9 table.o -o table

.c.o:
	$(CC) -O9 -c $< -o $@

.C.o:
	$(CC) -O9 -c $< -o $@

tar:
	tar -cvf source *.[Cc] README map.tiff map0.tiff Makefile
	gzip source 
	mv source.gz source.tgz

save:
	ci -l Makefile README *.c *.C

clean:
	rm -f tempmap*.tiff *.o

veryclean:
	rm -f mapb*.tiff map[123456789].tiff 
	rm -f tempmap*.tiff *.o table.bin ${PROGS}
