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

# $Id: Makefile,v 1.2 2002/12/27 14:31:18 weis Exp $

PACKAGE=ledit
VERSION=1.6
TARGET=ledit.out

include Makefile.config

SOURCES = cursor.ml ledit.ml go.ml
SOURCES1 = $(SOURCES:.mly=.ml)
SOURCES2 = $(SOURCES1:.mll=.ml)
OBJS = $(SOURCES2:.ml=.zo)

CAMLC = camlc
CAMLDEP = camldep
CAMLLEX = camllex
CAMLYACC = camlyacc

all: default
	cd test; ${MAKE} all
	cd doc; ${MAKE} all

default: depend
	${MAKE} $(TARGET)

$(TARGET): $(OBJS)
	$(CAMLC) -custom unix.zo $(OBJS) -lunix -o $(TARGET)

install:
	mkdirhier $(BINDIR) $(MANDIR)
	-cp -p $(TARGET) $(BINDIR)/ledit
	-cp -p doc/ledit.l $(MANDIR)/ledit.l

# 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)
WEBSITEDIR=/net/pauillac/infosystems/www/bazar-cl/$(PACKAGE)
FTPDIR=/net/pauillac/infosystems/ftp/cristal/caml-light/bazar-cl/$(PACKAGE)

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

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

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

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

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

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

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

.mll.ml:
	$(CAMLLEX) $<

.mly.ml:
	$(CAMLYACC) $<

clean:
	/bin/rm -f *.z[xio] *.o *~ .*~ *.a $(TARGET)
	/bin/rm -f .depend; touch .depend
	cd doc; ${MAKE} clean
	cd test; ${MAKE} clean

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

include .depend
