#*********************************************************************#
#                                                                     #
#                                Htmlc                                #
#                                                                     #
#            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.28 2012-03-16 12:51:46 fclement Exp $

MAKEFILESDIR=../config

include $(MAKEFILESDIR)/Makefile

# Makefile to generate the HTML files of a WEB site from their sources
# in another directory.

# Usage:
#
# Initialization:
#  create an empty file named .Makefile.auto in the same directory,
#  fill in the SRC, PACKAGE, and FILES variables below,
#  type make auto to initialize the Makefile included rules.

# Site maintenance (or creation):
#  make (or make all) will rebuild the whole thing
#  make clean will remove all the generated files

# Sources files directory
SRC=../doc_src

# Prefix before regular names
PACKAGE=htmlc

# The list of files for this part of the Web site
FILES=index.htm fra.htm eng.htm
MANFILES=$(PACKAGE).$(MANEXT)
COPYRIGHTFILES=copyright-fra.htm copyright-eng.htm

ALLFILES=$(FILES) $(MANFILES) $(COPYRIGHTFILES)

######## This part of the Makefile should automatically handle the
######## generation of object files for the list $(FILES)

# Automatic generation of rules to handle $(FILES)
# Rules are written into auxiliary file $(AUTO) that is included at
# the end of this Makefile.
AUTO=.Makefile.auto

PHONY: $AUTO

byt bin all:: $(AUTO) $(ALLFILES)

clean:: $(AUTO)
	@$(RM) $(ALLFILES)

install:
	@$(MKDIR) $(MANDIR) && \
	$(INSTALL_READ_ONLY) $(MANFILES) $(MANDIR)

uninstall:
	@for MANFILE in $(MANFILES); do \
	  $(RM) $(MANDIR)/$$MANFILE; \
	done &&\
	$(RMDIR) $(MANDIR) 2> /dev/null || true

#  Note: make auto regenerates the rules into file .Makefile.auto
# (handled automatically). .Makefile.auto depends upon this Makefile,
# since any addition to the Makefile may leads to the recompilation of
# the rules. Hence,
#   make clean all
# will recompute rules and the set of files again.

$(AUTO): Makefile
	rm -f $(AUTO)
	for i in $(FILES); do \
	  j=`basename $$i .htm`; \
	  echo $$i: $(SRC)/$(PACKAGE)-$$j.htm >> $(AUTO) && \
	  echo "	cp $(SRC)/$(PACKAGE)-$$j.htm $$j.htm && \\" >> $(AUTO) && \
	  echo "	chmod ug+w $$j.htm" >> $(AUTO) && \
	  echo >> $(AUTO) && \
	  echo $(SRC)/$(PACKAGE)-$$j.htm: $(SRC)/$(PACKAGE)-$$j.html>> $(AUTO) && \
	  echo "	(cd $(SRC) && \\" >> $(AUTO) && \
	  echo "	 $$""(MAKE) $(PACKAGE)-$$j.htm)" >> $(AUTO) && \
	  echo >> $(AUTO); \
	done
	for i in $(MANFILES); do \
	  j=`basename $$i .$(MANEXT)`; \
	  echo $$i: $(SRC)/$$j.$(MANEXT) >> $(AUTO) && \
	  echo "	cp $(SRC)/$$j.$(MANEXT) $$j.$(MANEXT) && \\" >> $(AUTO) && \
	  echo "	chmod ug+w $$j.$(MANEXT)" >> $(AUTO) && \
	  echo >> $(AUTO) && \
	  echo $(SRC)/$$j.$(MANEXT): $(SRC)/$$j.man >> $(AUTO) && \
	  echo "	(cd $(SRC) && \\" >> $(AUTO) && \
	  echo "	 $$""(MAKE) $$j.$(MANEXT))" >> $(AUTO) && \
	  echo >> $(AUTO); \
	done
	for i in $(COPYRIGHTFILES); do \
	  j=`basename $$i .htm` && \
	  echo $$i: $(SRC)/$$j.htm >> $(AUTO) && \
	  echo "	cp $(SRC)/$$j.htm $$j.htm && \\" >> $(AUTO) && \
	  echo "	chmod ug+w $$j.htm" >> $(AUTO) && \
	  echo >> $(AUTO) && \
	  echo $(SRC)/$$j.htm: $(SRC)/Includes/$$j.html >> $(AUTO) && \
	  echo "	(cd $(SRC) && \\" >> $(AUTO) && \
	  echo "	 $$""(MAKE) $$j.htm)" >> $(AUTO) && \
	  echo >> $(AUTO); \
	done

include $(AUTO)
