#*********************************************************************#
#                                                                     #
#                           Htmlc                                     #
#                                                                     #
#            Pierre Weis, projet Cristal, INRIA Rocquencourt          #
#                                                                     #
# Copyright 1997-2004,                                                #
# Institut National de Recherche en Informatique et en Automatique.   #
# Distributed only by permission.                                     #
#                                                                     #
#*********************************************************************#

#(* $Id: Makefile,v 1.67 2012-06-14 14:15:33 fclement Exp $ *)

MAKEFILESDIR = ./config

include $(MAKEFILESDIR)/Makefile

.PHONY: doc documentation
.PHONY: install installbyt installbin
.PHONY: install-no-documentation install-documentation installman
.PHONY: uninstall uninstallbyt uninstallbin
.PHONY: uninstall-no-documentation uninstall-documentation uninstallman

.PHONY: version tarball distribute install-tarball

all:: default

# Normal build targets
byt: version
	@cd compiler && $(MAKE) $@

bin: version
	@cd compiler && $(MAKE) $@

# To clean the whole thing.
distclean::
	$(MAKE) -f Makefile.distrib $@

install: install-no-documentation install-documentation
install-no-documentation: installbyt installbin
install-documentation: installman

installbyt:
	@cd compiler && $(MAKE) installbyt
installbin:
	@cd compiler && $(MAKE) installbin
installman:
	@cd doc && $(MAKE) install

uninstall: uninstall-documentation uninstall-no-documentation
uninstall-documentation: uninstallman
uninstall-no-documentation: uninstallbin uninstallbyt

uninstallbyt:
	@cd compiler && $(MAKE) uninstallbyt
uninstallbin:
	@cd compiler && $(MAKE) uninstallbin
uninstallman:
	@cd doc && $(MAKE) uninstall

clean::
	@cd compiler && $(MAKE) $@

# For developers and maintainers only.
documentation:
	(cd doc_src && $(MAKE) all) && \
	(cd doc && $(MAKE) all)

doc: documentation

clean_all::
	(cd doc && $(MAKE) clean) && \
	(cd doc_src && $(MAKE) clean) && \
	$(MAKE) -f Makefile.distrib clean && \
	cd compiler && $(MAKE) $@

depend:
	@cd compiler && $(MAKE) $@

test:
	cd compiler && $(MAKE) $@

# Automatic handling of versionning
version: config/Makefile
config/Makefile: config/Makefile.in config/env
	MSG1="# Automatically generated by Htmlc." && \
	MSG2="#" && \
	MSG3="# DO NOT edit this file," && \
	MSG4="# edit its source: \"./Makefile.in\"." && \
	($(ECHO) "$$MSG1"; $(ECHO) "$$MSG2"; \
	 $(ECHO) "$$MSG3"; $(ECHO) "$$MSG4") | \
	$(CAT) - config/Makefile.in | \
	$(HTMLC) -f - -t config/Makefile

tarball distribute install-tarball: all
	$(MAKE) -f Makefile.distrib $@
