#*********************************************************************#
#                                                                     #
#                           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.71 2013-04-24 10:19:44 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::
	if test -r Makefile.distrib; then \
	  $(MAKE) -f Makefile.distrib $@; \
	fi

install: install-no-documentation install-documentation

install-no-documentation: installbyt installbin

install-documentation: installman

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

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

installman:
	@(cd doc && $(MAKE) install)

uninstall: uninstall-documentation uninstall-no-documentation

uninstall-documentation: uninstallman

uninstall-no-documentation: uninstallbin uninstallbyt

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

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

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) && \
	if test -d doc_src; then (cd doc_src && $(MAKE) clean); fi && \
	if test -r Makefile.distrib; then \
	  $(MAKE) -f Makefile.distrib clean; \
	fi && \
	(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 $@
