#*********************************************************************#
#                                                                     #
#                             Active-DVI                              #
#                                                                     #
#                   Projet Cristal, INRIA Rocquencourt                #
#                                                                     #
#  Copyright 2002-2004,                                               #
#  Institut National de Recherche en Informatique et en Automatique.  #
#  All rights reserved. This file is distributed under the terms of   #
#  the GNU Lesser General Public License.                             #
#                                                                     #
#  Jun Furuse, Didier Rémy and Pierre Weis.                           #
#  Contributions by Roberto Di Cosmo, Didier Le Botlan,               #
#  Xavier Leroy, and Alan Schmitt.                                    #
#                                                                     #
#  Based on Mldvi by Alexandre Miquel.                                #
#*********************************************************************#

# $Id: Makefile.distrib,v 1.3 2004/10/02 21:35:09 weis Exp $

include Makefile

# Just for $(PACKAGE) maintainers, distribution of the software.
# Usage:
# make -f Makefile.distrib distribute

# Need an INSTALL and README 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 directory of the package, as mentioned in
# $(WEBSITEDIR). Presumably the doc directory contains 2 files named
# eng.htm and fra.htm that respectively contain the English and French
# documentation.

# A tar ball file with the source files is also constructed and moved
# into the $(FTPDIR) directory.

WEBSITEDIR=/net/pauillac/infosystems/www/$(PACKAGE)
FTPSITEDIR=/net/pauillac/infosystems/ftp/cristal/caml-light/bazar-ocaml/$(PACKAGE)

fake:
	echo '\n\nThis Makefile is used to distribute the software,\n\
Read it to understand how to use it!'

distribute: advi adk

advi:
	# Make documentation and test before release
	$(MAKE) -f Makefile documentation
	(cd doc; $(MAKE) distribute)
	(cd test; $(MAKE) all)# jpdemo.dvi)
	# Then clean the old stuff
	$(RM) release
	mkdir release
	$(RM) $(WEBSITEDIR)/*
	- mkdirhier $(WEBSITEDIR)
	# And check out a brand new version,
	# clean it
	# copy the documentation in it
	# then copy the images
	cd release; cvs co bazar-ocaml/$(PACKAGE); \
	$(CP) ../doc bazar-ocaml/$(PACKAGE)/; \
	$(RM) Makefile.distrib; \
	find . -name '.cvsignore' -print | xargs $(RM); \
	find . -name 'CVS' -print | xargs $(RM); \
	find . -name 'advi-development-kit' -print | xargs rm -rf; \
	$(CP) bazar-ocaml/$(PACKAGE)/README bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) bazar-ocaml/$(PACKAGE)/LICENSE bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) bazar-ocaml/$(PACKAGE)/INSTALL bazar-ocaml/$(PACKAGE)/doc/; \
		$(CP) ../test/*.dvi bazar-ocaml/$(PACKAGE)/test/; \
	$(CP) ../doc/*.dvi bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/*.ps bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/*.pdf bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/*.html bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/*.htm bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/*.gif bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/*.jpg bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/style.css bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) ../doc/pngs bazar-ocaml/$(PACKAGE)/doc/; \
	$(CP) bazar-ocaml/$(PACKAGE)/doc/* $(WEBSITEDIR)/;
	# Build the Web site
	ln -s $(WEBSITEDIR)/index.htm $(WEBSITEDIR)/index.html
	# Copy legalease to $(FTPSITEDIR)
	$(CP) release/bazar-ocaml/advi/LGPL \
		release/bazar-ocaml/advi/README \
		release/bazar-ocaml/advi/INDEX $(FTPSITEDIR)
	# Give the release its versioning name
	cd release; mv bazar-ocaml/$(PACKAGE) $(PACKAGEFULLNAME); \
	(cd bazar-ocaml/$(PACKAGE)/doc/; \
	ln -sf eng.html index.html; cd ..); \
	$(CP) bazar-ocaml/$(PACKAGE)/doc/* $(WEBSITEDIR)
	- chgrp -R caml $(WEBSITEDIR)
	- chmod -R g+w $(WEBSITEDIR)
	# Build the archive and move it in the proper ftp site
	tar zcvf $(PACKAGEFULLNAME).tgz $(PACKAGEFULLNAME); \
	$(MV) $(PACKAGEFULLNAME).tgz $(FTPSITEDIR)
	$(RM) release

adk :
	cd advi-development-kit; \
	$(MAKE) distribute
