#--------------------------------------------------------------- # Project : Mandrake Linux # Module : Borges # File : Makefile.module # 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 module specific # tasks, specifically creating the reports for revision checking include /home/stew/rpm-rebuilder/RPM/BUILD/Borges-0.7.12/doc/Makefile.include XSL_EXTRACT_ID=$(DISTDIR)/XSL/extract_ids.xsl XSL_EXTRACT_REVISIONS=$(DISTDIR)/XSL/extract_revisions.xsl XSLFILTER=$(DISTDIR)/XSL/filter.xsl xml_head='<?xml version="1.0" encoding="ISO-8859-1" ?><revisions>' xml_foot='</revisions>' deps:= $(foreach ext,.ids.xml .xmla .id.xml .src-ids.xml,$(addsuffix $(ext),$(basename $(wildcard *.xml)))) # Wich lang is this modules repository LOC_LANG=$(shell pwd | sed -e "s,.*/,,") allmodules=$(strip $(shell find $(ROOTDIR)/$(MODULESDIR)/$(LANG)/ -name '*.xml' ! \( -name '*.html.xml' -o -name '*changes.xml' -o -name '*.db.xml' -o -name '*id.xml' -o -name '*ids.xml' \) ) $(foreach import,$(IMPORTS),$(wildcard $(ROOTDIR)/$(MODULESDIR)/$(import)/$(LANG)/*.db.xml))) # modules in current language modules=$(strip $(shell find $(ROOTDIR)/$(MODULESDIR)/$(LOC_LANG)/ -name '*.xml' ! \( -name '*.html.xml' -o -name '*changes.xml' -o -name '*.db.xml' -o -name '*id.xml' -o -name '*ids.xml' \) ) $(foreach import,$(IMPORTS),$(wildcard $(ROOTDIR)/$(MODULESDIR)/$(import)/$(LOC_LANG)/*.db.xml))) # the modules.ent file also holds information on modules # namely whether they are valid XML and in synch with original # <!ENTITY security-chapter SYSTEM "security-chapter.xml"> <!-- Valid --> <!-- NotSynch --> # This function maintains this # a function that switches a module $(1) variable $(2) to another value $(3) in modules.ent SWITCH=$(shell [ -e $(1).xml ] && perl -pi -e "/ $(1) / && s,<\!-- [^-]*$(2) -->,<\!-- $(3)$(2) -->," modules.ent) .PRECIOUS: $(deps) test: echo $(modules) modules.ent: $(modules) rm -f $@ ifeq ($(strip $(modules)),) touch $@ else @for f in $^; do i=`basename $$f | sed -e "s/\.db\./\./"`; \ echo -n "<!ENTITY ">> $@; \ echo -n $${i%.xml} >> $@; \ echo -n " SYSTEM \"">> $@; \ echo -n $$f >> $@; \ echo "\"> <!-- Valid --> <!-- Synch -->" >> $@; \ done endif %.status: @echo changing $(*F) $(VAR) to $(VAL) $(call SWITCH,$(*F),$(VAR),$(VAL)) # Check module's validity %.validate: %.xmla modules.ent @echo @echo " ************* Validating $<....." @if xsltproc -o $@ $(XSLFILTER) $<; then \ echo "******* Validation OK ********"; \ make $(*F).status VAR=Valid VAL=; \ else \ echo "******* NOT Valid !!!!!! ********"; \ make $(*F).status VAR=Valid VAL=Not; \ fi @rm -f $@ %.release: %.xmla # increment Module's current release number by adding a new revisions cycle @echo "******* Adding release $(REL) in $*.xml" ifeq ($(REL),) @echo "******* I need a release Number!" else @current=$$($(DISTDIR)/bin/confparse.pl /*/*/revhistory/revision[1]/revnumber $<); \ if [ "$(REL)" != "$$current" ]; then \ for t in $(call GET,/configuration/repository/revisions/type/name,$(rootconf)); do \ $(ADD) --xpath=/*/*/revhistory/revision --value=" " $<; \ $(ADD) --xpath=/*/*/revhistory/revision[1]/revremark --value="$$t" $<; \ a=$$($(DISTDIR)/bin/confparse.pl "/configuration/repository/revisions/type[name[text()='$$t']]/author" $(rootconf)); \ $(ADD) --xpath=/*/*/revhistory/revision[1]/authorinitials --value="$$a" $<; \ $(ADD) --xpath=/*/*/revhistory/revision[1]/date --value="YYYY-MM-DD" $<; \ $(ADD) --xpath=/*/*/revhistory/revision[1]/revnumber --value="$$REL" $<; \ done; fi @perl -p -e "s/&/&/g" $< > $*.xml endif # Removes possible automatic Ids and assign them. %.id %.xmlab: %.xmla perl -pi -e "s/\sid=\"[\w\d-\.]*-\w\w\d+\"//g" $< scatter_ids.pl $< $* > $<b perl -p -e "s/&/&/g" $<b > $*.xml # extract the ID/revision information from a module # and its original module in case we deal with a translation %.ids.xml %.src-ids.xml: %.xmla -make $(*F).validate # if master-revisions.xml do not exists, make it @if [ ! -e $(ROOTDIR)/$(MANUALSDIR)/$(manual)/master-revisions.xml ]; then \ make -C $(ROOTDIR)/$(MANUALSDIR)/$(manual)/ master-revisions.xml; fi $(XSLT) -o $*.ids.xml --param manual '"$(manual)"' --param module '"$(*F)"' --param manualpath '"$(ROOTDIR)/$(MANUALSDIR)"' --param modulepath '"$(ROOTDIR)/$(MODULESDIR)"' --param lang '"$(LANG)"' $(XSL_EXTRACT_ID) $< # if it is a translation, process the original @if [ -e .lang.master ]; then \ mv $*.ids.xml $*.src-ids.xml; \ MLANG=`cat .lang.master`; \ export path=$(ROOTDIR)/$(MODULESDIR)/$$MLANG; \ cd $$path; \ echo "*************************************"; \ pwd; echo $(LANG); echo $$MLANG; echo $$path; \ echo "*************************************"; \ $(XSLT) -o $*.ids.xml --param manual '"$(manual)"' --param module '"$(*F)"' --param manualpath '"$(ROOTDIR)/$(MANUALSDIR)"' --param modulepath '"$(ROOTDIR)/$(MODULESDIR)"' --stringparam lang $$MLANG $(XSL_EXTRACT_ID) $(*F).xmla; \ cd $(ROOTDIR)/$(MODULESDIR)/$(LANG); \ mv $$path/$(*F).ids.xml .; \ else \ cp $*.ids.xml $*.src-ids.xml; \ fi # this "else" was to avoid unnecessary recompilation next time? rm -f .lang.master # creates the HTML report of ID/revision changes # between a translation and the original # quite ugly... %.ids.html: %.ids.xml %.src-ids.xml # if modules.ent do not exists, make it @[ ! -e modules.ent ] && make modules.ent -diff2html --only-changes $*.ids.xml $*.src-ids.xml > $@ @if ( grep 'id="' $@ > /dev/null ); then \ echo "******** Changes"; \ make $(*F).status VAR=Synch VAL=Not; \ else \ rm -f $@; touch $@; \ echo "******** No changes"; \ make $(*F).status VAR=Synch VAL=; \ fi # creates the XML report of changes # between a translation and the original %.changes.xml %.src-changes.xml %.ids.html.xml: %.ids.html for l in $(LANGS); do make -rC $(ROOTDIR)/$(MODULESDIR)/$$l/ $*.xmla; done echo $(xml_head) > $<.xml grep 'class="modified"' $< | grep "revision" |\ perl -p -e "s,&(nbsp|lt|gt);,,g" >> $<.xml echo $(xml_foot) >> $<.xml $(XSLT) --param file1 '"$(ROOTDIR)/$(MODULESDIR)/$(LANG)/$*.changes.xml"' --param file2 '"$(ROOTDIR)/$(MODULESDIR)/$(LANG)/$*.src-changes.xml"' --param path '"$(ROOTDIR)"' $(XSL_EXTRACT_REVISIONS) $<.xml # creates the XML report of changes from above files %.changes.html: %.changes.xml %.src-changes.xml diff2html $^ > $@ perl -pi -e "s/&/&/g" $@ # add a revision entry/date into a module info header # experimental: need independance from revision types defined %.revision: %.xmla force #ensure first that there is a revhistory @grep revhistory $< > /dev/null || \ (echo "**** There is no revision history in $*; Generate the module templates first! ****"; \ exit 1) ifndef TYPE @echo @echo "********* ERROR: What is the type of revision you want to publish?" @echo "Usage: make <LCA1-1.1.1>.revision TYPE=[write|translate|tproof|pproof|lproof|ispell] [AUTHOR=<your_initials>]" else ifndef AUTHOR @echo @echo "********* ERROR: What are your initials?" @echo "Usage: make <LCA1-1.1.1>.revision TYPE=[write|translate|tproof|pproof|lproof|ispell] AUTHOR=[your_initials]" else ifeq ($(TYPE),pproof) @make -r $*.id endif ifeq ($(TYPE),translate) @make -r $*.id endif @rm -f $*.xmla @make -r $*.xmla @echo "********* Changing \"$*\" module \"$(TYPE)\" task to \"$(AUTHOR)\"" @current=$$($(DISTDIR)/bin/confparse.pl /*/*/revhistory/revision[1]/revnumber $<); \ change_revision.pl $< $(TYPE) $(AUTHOR) $$current # tidy messes up everything and is discarded until we get something # tidy -xml -m -latin1 $*.xmla @perl -p -e "s/&/&/g" $< > $*.xml endif endif # remote check module validity before allowing to commit it on CVS server # experimental %.commit: %.xml echo $(servername); echo $(shell echo $(servername) | perl -pe s/[^\.]*\./\./ - ) serverip=$(serverip); domain=$(shell echo $(servername) | perl -pe s/[^\.]*\./\./ - ); \ uname -n | grep $$domain &>/dev/null && serverip=$(localserverip); \ uname -n | grep $(servername) &>/dev/null && serverip="localhost"; \ scp $*.xml $(serverlogin)@$$serverip:/tmp/$(*F)-$(USER).xml; \ ssh $(serverlogin)@$$serverip "chmod a+r /tmp/$(*F)-$(USER).xml"; \ ssh $(serverlogin)@$$serverip "ROOTDIR=/home/$(robot)/l/learning sudo -u $(robot) /home/$(robot)/l/learning/backend/check.sh $(LANG) /tmp/$(*F)-$(USER).xml; rm -f /tmp/$(*F)-$(USER).xml" > check.log @if grep "Checking /tmp/$(*F)-$(USER).xml validity: \[ OK \]" check.log; then \ cvs -z2 commit $*.xml; \ else \ cat check.log; \ echo "Found errors in $(*F).xml: see above"; \ fi @rm -f check.log