#*********************************************************************#
#                                                                     #
#                           Objective Caml                            #
#                                                                     #
#            Pierre Weis, projet Cristal, INRIA Rocquencourt          #
#                                                                     #
#  Copyright 2000 Institut National de Recherche en Informatique et   #
#  en Automatique.  All rights reserved.  This file is distributed    #
#  under the terms of the GNU Library General Public License.         #
#                                                                     #
#*********************************************************************#

SOURCES = graphics.ml

CAMLC = ocamlc
CAMLOPT = ocamlopt
CAMLDEP = ocamldep
CAMLLEX = ocamllex
CAMLYACC = ocamlyacc

WITHPSGRAPHICS =graphics.cmo

all: depend
	${MAKE} $(OBJS)

allopt: opt

opt: depend
	${MAKE} $(OPTOBJS)

SOURCES1 = $(SOURCES:.mly=.ml)
SOURCES2 = $(SOURCES1:.mll=.ml)
OBJS = $(SOURCES2:.ml=.cmo)
OPTOBJS = $(SOURCES2:.ml=.cmx)

install:
	- mkdir $(LIBDIR)/graphps
	cp -p $(SOURCES:.ml=.mli) $(LIBDIR)/graphps/
	cp -p $(OBJS) $(LIBDIR)/graphps/

installopt:
	- mkdir $(LIBDIR)/graphps
	cp -p $(SOURCES:.ml=.mli) $(LIBDIR)/graphps/
	cp -p $(OPTOBJS) $(LIBDIR)/graphps/

# Just for $(PACKAGE) maintainers, distribution of the software.
# Need an INSTALL file in the main directory.
# Need a doc directory where the documentation has been written,
# presumably in HTML with an index.html file. This directory is copied
# onto the WEB site of the package, as mentioned in $(WEBSITEDIR)
PACKAGE=graphps
VERSION=1.0
WEBSITEDIR=/net/pauillac/infosystems/www/$(PACKAGE)
FTPDIR=/net/pauillac/infosystems/ftp/cristal/caml-light/bazar-ocaml

distribute:
	rm -rf release
	rm -rf $(WEBSITEDIR)/*
	mkdir release
	cd release; cvs co bazar-ocaml/$(PACKAGE); \
	find . -name '.cvsignore' -print | xargs rm; \
	find . -name 'CVS' -print | xargs rm -rf; \
	cp -p bazar-ocaml/$(PACKAGE)/README bazar-ocaml/$(PACKAGE)/doc/; \
	cp -p bazar-ocaml/$(PACKAGE)/INSTALL bazar-ocaml/$(PACKAGE)/doc/; \
	cp -pr bazar-ocaml/$(PACKAGE)/doc/* $(WEBSITEDIR)/; \
	ln -s $(WEBSITEDIR)/index.html $(WEBSITEDIR)/eng.htm
	- chgrp -R caml $(WEBSITEDIR)
	- chmod -R g+w $(WEBSITEDIR)
	cd release; mv bazar-ocaml/$(PACKAGE) $(PACKAGE)-$(VERSION); \
	tar zcvf $(PACKAGE)-$(VERSION).tgz $(PACKAGE)-$(VERSION); \
	mv -f $(PACKAGE)-$(VERSION).tgz $(FTPDIR)
	rm -rf release

.SUFFIXES:
.SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly

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

.mli.cmi:
	$(CAMLC) -c $<

.ml.cmx:
	$(CAMLOPT) -c $<

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

.mll.cmx:
	$(CAMLLEX) $<
	$(CAMLOPT) -c $*.ml

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

.mly.cmx:
	$(CAMLYACC) $<
	$(CAMLOPT) -c $*.mli
	$(CAMLOPT) -c $*.ml

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

.mll.ml:
	$(CAMLLEX) $<

.mly.ml:
	$(CAMLYACC) $<

clean:
	rm -f *.cm[iox] *.o *~ .*~ #*#
	rm -f .depend; touch .depend
	cd test; make clean

.depend: $(SOURCES2)
	$(CAMLDEP) *.mli *.ml > .depend

depend: $(SOURCES2)
	$(CAMLDEP) *.mli *.ml > .depend

include .depend
include Makefile.config
