#
# New Makefile for ALL source (Osamu Aoki)
#
#  Build multi file html, single file html, and single file text formats.
#  makefile for developer-reference was used as my reference.
#
# ------------------------------------------------------------------- #
#                          WARNING                                    #
#         Use with caution, aimed at Lenny system                     #
# ------------------------------------------------------------------- #

# do not use default suffix rules such as .tex.dvi: (uses tex, not latex!)
.SUFFIXES:
# =================================================================== #
#                 Default configuration part                          #
# =================================================================== #

WIKI_ROOT	:= wiki
HTML_ROOT	:= html
LANG_ALL	:= en fr it es de pt-br pl zh-tw zh-cn ja
LANG_XML	:= en
LANG_SGML	:= fr it es de pt-br pl zh-tw zh-cn ja

.PHONY: all allxml allsgml
all: allxml allsgml
	$(MAKE) clean
allxml:
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  targetclean
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  all
	$(MAKE) index
allsgml:
	$(MAKE) -f Makefile-sgml "LANG_ALL=$(LANG_SGML)" all
	$(MAKE) index
.PHONY: renewxml
renewxml:
	$(MAKE) -C $(WIKI_ROOT) wikiclean
	$(MAKE) -C $(WIKI_ROOT) renew
	$(MAKE) update
	$(MAKE) allxml
	$(MAKE) clean
	$(MAKE) rsync
.PHONY: renew
renew:
	$(MAKE) distclean
	$(MAKE) -C $(WIKI_ROOT) renew
	$(MAKE) update
	$(MAKE) allxml
	$(MAKE) allsgml
	$(MAKE) clean
	$(MAKE) rsync
.PHONY: index
index:
	export HTML_ROOT=$(HTML_ROOT) ; bin/mkindexhtml

# Replicate
REMOTE	:= people.debian.org:public_html/pub/getwiki/
.PHONY: rsync
rsync:
	rsync --delete-after -rlpt . $(REMOTE)

.PHONY: nmu
nmu:
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  nmu

.PHONY: update
update:
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  update

.PHONY: resethtml
resethtml:
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)" resethtml

.PHONY: clean cleanxml cleansgml wikiclean distcleanxml distclean
clean: cleanxml cleansgml

cleanxml:
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  clean

cleansgml:
	$(MAKE) -f Makefile-sgml "LANG_ALL=$(LANG_SGML)" clean

wikiclean: cleanxml
	$(MAKE) -C $(WIKI_ROOT) wikiclean

distcleanxml: cleanxml
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  distclean

distclean: clean resethtml
	$(MAKE) -f Makefile-xml  "LANG_ALL=$(LANG_XML)"  distclean
	$(MAKE) -f Makefile-sgml "LANG_ALL=$(LANG_SGML)" distclean

# if rule bomb out, delete the target
.DELETE_ON_ERROR:
