#--------------------------------------------------------------- # Project : Mandrake Linux # Module : Borges # File : Makefile.manual # Author : Camille Bégnis # Created On : Mon May 1 16:25:21 2001 # Copyright : Camille Bégnis camille@mandrakesoft.com, # MandrakeSoft under the GPL license #--------------------------------------------------------------- # This Makefile is responsible for performing all manual specific # tasks, specifically creating the master document (master.xml) # from the specifications (master.top.xml); and creating the reports include /home/stew/rpm-rebuilder/RPM/BUILD/Borges-0.7.12/doc/Makefile.include include $(shell ls $(OUTPUTS)) XSLTEMPLATE=$(DISTDIR)/XSL/master2templates.xsl XSLREPORT=$(DISTDIR)/XSL/bigbrother.xsl XSLREVISIONS=$(DISTDIR)/XSL/templates2revisions.xsl XSLFILTER=$(DISTDIR)/XSL/filter.xsl XSLOMF=$(DISTDIR)/XSL/db2omf.xsl IS_V58=$(shell perl -v | grep v5.8) document=$(shell basename `pwd` ) conf=conf.xml # now get parameters from conf files # formats for compiling all outputs MANUALS=$(call GET,//manual/@id,$(conf)) # Compute needed local langs in the order given by conf/repository.xml ALLLOCALLANGS=$(call GET,//manual/lang,$(conf)) LOCALLANGS=$(foreach l,$(LANGS),$(findstring $(l),$(sort $(ALLLOCALLANGS)))) # Get module filenames for that manual modules=$(addsuffix .xml,$(call GET,//para[@role=\"module\"],master.top.xml)) # the meta entities file pointing to other entities files # plus the ⟨ entity entities="<!ENTITY % src SYSTEM '$(ROOTDIR)/$(MODULESDIR)/$(LANG)/modules.ent'> <!ENTITY % local SYSTEM '$(LANG)/local.ents'> <!ENTITY % global-entities SYSTEM '$(ROOTDIR)/entities/$(LANG)/catalog'> %src; %local; %global-entities; <!ENTITY lang '$(LANG)'> <!ENTITY index SYSTEM 'index.xml'>" # Possible targets to be cleaned toclean=$(foreach man,$(MANUALS),$(wildcard $(man)*) ) .PHONY: all release # make all available manuals according to conf.xml, plus OMF files all: $(foreach man,$(MANUALS),make $(man).all; ) # make all available manuals for a single subdoc, according to conf.xml, plus OMF files %.all: $(foreach lang,$(call GET,//manual[@id=\"$*\"]/lang,$(conf)), mkdir -p $(OUTPUTSDIR)/$(lang); $(foreach ext,$(call GET,//manual[@id=\"$*\"]/format,$(conf)),make $*.$(ext) LANG=$(lang); mv $*.$(ext) $(if $(findstring flat,$(ext)),images) $(OUTPUTSDIR)/$(lang); )) make $*.omf; mv $*.omf $(OUTPUTSDIR); # scan entities files entities: i18n $(wildcard $(ROOTDIR)/entities/$(LANG)/*.ent) $(wildcard $(foreach mod,$(modules),$(ROOTDIR)/$(MODULESDIR)/$(LANG)/$(mod))) $(if $(IMPORTS),$(wildcard $(ROOTDIR)/$(MODULESDIR)/$(IMPORTS)/$(LANG)/*)) $(wildcard $(LANG)/*.ent) ifneq ($(IMPORTS),) @cd $(ROOTDIR)/$(MODULESDIR); \ for i in $(IMPORTS); do \ if [ -e $$i/$(LANG) ]; then make -rC $$i all LANGS=$(LANG); fi; \ done; endif @make -rC $(ROOTDIR)/$(MODULESDIR)/$(LANG) modules.ent @make -rC $(ROOTDIR)/entities/$(LANG) catalog @make -rC $(LANG) local.ents @echo $(entities) > entities # this is a trick to keep track of the lang used for last compilation i18n: i18n.$(LANG) @touch $@ i18n.%: @rm -f i18n.* @touch $@ # keep master.xml because useful for Emacs editing of modules .PRECIOUS:master.xml # creates the master from specifications master.xml master.filtered.xml: $(TOP) i18n entities # perl version 5.8 has better utf-8 support ifneq ($(IS_V58),) master2master.pl $< >$@ else master2master.pl $< | iconv -f UTF-8 -t ISO-8859-1> $@ endif ifdef exclude # the < & entities must not be transformed! perl -pi -e "s/&(nbsp|lt|amp);/&$$1;/" $@ @xsltproc -o master.filtered.xml --stringparam exclude $(exclude) $(XSLFILTER) $@ @DOCTYPE='$(shell $(DISTDIR)/bin/extract_doctype.pl $(TOP))'; \ perl -p -e "s#(<\?xml.*)#\1\n$$DOCTYPE#" master.filtered.xml > $@ endif # master guidelines master.top.flat.xml: $(conf) i18n entities $(TOP) cp -f master.top.xml $@ # Catch *.xml targets and make a specialized manual out of it # following conf.xml excludes # also we must verify all depending modules exists with DTD specific %.mod.deps target %.flat.xml: $(conf) i18n entities %.index.deps %.mod.deps $(TOP) $(if $(IMPORTS),$(wildcard $(ROOTDIR)/$(MODULESDIR)/$(IMPORTS)/$(LANG)/*)) make master.xml exclude="\"$(call GET,//manual[@id=\"$*\"]/exclude,$<)\"" cp -f master.xml $@ # the same but without index for making the index... %.noindex.xml: $(conf) i18n entities %.mod.deps $(TOP) $(if $(IMPORTS),$(wildcard $(ROOTDIR)/$(MODULESDIR)/$(IMPORTS)/$(LANG)/*)) touch index.xml make master.xml exclude="\"$(call GET,//manual[@id=\"$*\"]/exclude,$<)\"" mv master.xml $@ %.validate: %.xml @echo @echo " ************* Validating document....." @xsltproc -o $@ $(XSLFILTER) $< && \ echo "******* Validation OK ********" @rm -f $@ # Create module templates according to master document # put revision histories where needed alltemplates: for l in $(LANGS); do make templates LANG=$$l; done templates: .templates.$(LANG) @touch $@ .templates.$(LANG): $(TOP) i18n entities cd $(ROOTDIR)/$(MODULESDIR)/$(LANG); \ BORGES_MODULES="$(modules)" gen-templates.sh $(TOP) ../../$(MANUALSDIR)/$(document) \ $(ROOTDIR)/conf/repository.xml $(XSLTEMPLATE) $(ENCODING) $(CURRREL) touch $@ # create an intermediate file containing all revision related info # of all modules used in this manual master-revisions.xml: $(TOP) $(addprefix $(ROOTDIR)/$(MODULESDIR)/$(LANG)/,$(modules)) i18n entities $(XSLREVISIONS) for l in $(LOCALLANGS); do \ rm -f .templates.$$l; \ make -r templates LANG=$$l; \ done # get back to initial language make i18n @for l in $(LANGS); do make -C $(ROOTDIR)/$(MODULESDIR)/$$l $(addsuffix a,$(modules)); done $(XSLT) -o $@ --param conf-file "'$(ROOTDIR)/conf/repository.xml'" \ --param modules-path "'$(ROOTDIR)/$(MODULESDIR)'" \ --param release "'$(CURRREL)'" $(XSLREVISIONS) $< # insert LOCALLANGS in result (ugly?) for l in $(LOCALLANGS); do \ $(PUT) --xpath=/*[1]/*[1]/foreignphrase --value="$$l" $@; \ done # creates the global report for that manual master-report.html: master-revisions.xml $(XSLREPORT) i18n entities # make master-revisions.xml # look for unsynched modules and incorporate that information @for l in $(LOCALLANGS); do \ make -rC $(ROOTDIR)/$(MODULESDIR)/$$l modules.ent; \ mkdir -p reports/$$l; \ for s in $(modules); do \ m=`basename $$s .xml`; \ echo "********************************* $$m ***************************************"; \ make -rC $(ROOTDIR)/$(MODULESDIR)/$$l $$m.ids.html LANG=$$l manual=$(document); \ if grep $$m $(ROOTDIR)/$(MODULESDIR)/$$l/modules.ent | grep "NotSynch"; then \ make -rC $(ROOTDIR)/$(MODULESDIR)/$$l $$m.changes.html LANG=$$l manual=$(document); \ perl -pi -e "s/(lang=\"$$l\" module=\"$$m\")/\1 synch=\"no\"/" master-revisions.xml; \ cp $(ROOTDIR)/$(MODULESDIR)/$$l/{$$m.ids.html,$$m.changes.html} reports/$$l; \ fi; \ if grep $$m $(ROOTDIR)/$(MODULESDIR)/$$l/modules.ent | grep "NotValid"; then \ perl -pi -e "s/(lang=\"$$l\" module=\"$$m\")>/\1 valid=\"no\">/" master-revisions.xml; \ fi; \ done; \ done $(XSLT) -o $@ --param reports-path "'reports'" $(XSLREPORT) master-revisions.xml # Creates the costs summary for each authors of this module costs.html: master-revisions.xml @echo "Computing costs in $@..." @accounting.pl $(ROOTDIR)/conf/repository.xml $< > $@ # add a new revision to revision history CURRREL=$(strip $(call GET,/*/*/revhistory/revision[1]/revnumber,$(TOP))) ifeq ($(REL),) ifeq ($(CURRREL),) REL=1.0 endif endif # if entities are not available XML::LibXML suppresses them from file... release: $(TOP) entities ifeq ($(REL),$(CURRREL)) @echo "***** Current release is already $(REL) !" else # increment current release number @if [ ! "$(REL)" == "" ]; then REL=$(REL); \ else REL=$(shell a=$(CURRREL); b=$${a##*.}; c=$${a%%$$b}; echo $$c$$[$$b+1]); fi; \ echo changing release from $(CURRREL) to $$REL; \ cp -f $< $<.tmp; \ $(ADD) --xpath=/*/*/revhistory/revision --value=" " $<.tmp; \ $(ADD) --xpath=/*/*/revhistory/revision[1]/authorinitials --value="$(AUTHOR)" $<.tmp \ $(ADD) --xpath=/*/*/revhistory/revision[1]/revremark --value="Starting new revision $$REL" $<.tmp; \ $(ADD) --xpath=/*/*/revhistory/revision[1]/date --value="$(shell date +%Y-%m-%d)" $<.tmp; \ $(ADD) --xpath=/*/*/revhistory/revision[1]/revnumber --value="$$REL" $<.tmp; \ $(foreach lang,$(LANGS),make -C $(ROOTDIR)/$(MODULESDIR)/$(lang) \ $(foreach mod,$(modules),$(patsubst %.xml,%.release,$(mod)) )REL=$$REL; ) # Above: Add new revision cycle in depending modules # because XML::LibXML fucks up entities definitions @$(DISTDIR)/bin/extract_doctype.pl $< $<.tmp > $<.tmp1 @mv -f $<.tmp1 $<; endif # assign tasks for all modules of that document revisions: $(TOP) make -C $(ROOTDIR)/$(MODULESDIR)/$(LANG) $(patsubst %.xml,%.revision,$(modules)) # Build the OMF file for scrollkeeper %.omf: conf.xml $(TOP) @echo "Generating OMF data for $* ..." @xsltproc -o $@ --stringparam doc $* $(XSLOMF) $< # custom rules come in here: include Makefile.include