#*********************************************************************#
#                                                                     #
#                           Caml Light                                #
#                                                                     #
#            Pierre Weis, projet Cristal, INRIA Rocquencourt          #
#                                                                     #
#  Copyright 2000 Institut National de Recherche en Informatique et   #
#  en Automatique.  Distributed only by permission.                   #
#                                                                     #
#*********************************************************************#

LIBDIR=/usr/local/lib/caml-light/
SOURCES= test_ppm1.ml test_ppm2.ml test_ppm3.ml test_ppm4.ml test_bmp5.ml 

OBJS=$(SOURCES:.ml=.zo)
EXES=test1 test2 test3 test4 test5

CAMLDEP=camldep
CAMLC=camlc -I ..

WITHGRAPHICS=-custom unix.zo graphics.zo -ccopt -L/usr/X11R6/lib -lgraph -lunix -lX11

WITHGRIMAGE=libgrimage.zo

all: $(OBJS) exe
	echo '********************************************************'
	echo; echo; \
	echo 'To run tests, enter'; \
	echo; \
	echo '  make tests'; \
	echo

exe: $(OBJS) $(EXES)

test1:
	for i in 1 2 3 4; do \
	 $(CAMLC) -o test$$i $(WITHGRAPHICS) $(WITHGRIMAGE) test_ppm$$i.zo; \
	done
	for i in 5; do \
	 $(CAMLC) -o test$$i $(WITHGRAPHICS) $(WITHGRIMAGE) test_bmp$$i.zo; \
	done

tests: $(OBJS) exe
	for i in 1 2 3 4 5; do \
	echo; echo "***** TEST $$i *****"; echo; \
	./test$$i; \
	done

.SUFFIXES:
.SUFFIXES: .ml .mli .zo .mll .mly

.ml.zo:
	$(CAMLC) -c $<

.mll.zo:
	$(CAMLLEX) $<
	$(CAMLC) -c $*.ml

.mly.zo:
	$(CAMLYACC) $<
	$(CAMLC) -c $*.mli
	$(CAMLC) -c $*.ml

.mly.cmi:
	$(CAMLYACC) $<
	$(CAMLC) -c $*.mli

.mll.ml:
	$(CAMLLEX) $<

.mly.ml:
	$(CAMLYACC) $<

clean:
	/bin/rm -f a.out *.z[xio] *~ *.o
	/bin/rm -f test? bmps/test*.bmp ppms/test*.ppm
