#--------------------------------------------------------------- # Project : Linux-Mandrake # Module : Borges # File : Makefile # Author : Camille Bégnis, Fabian Mandelbaum # Created On : 2001-05-29 # Last Modif. : 2002-12-21 # Copyright : MandrakeSoft under the GPL license #--------------------------------------------------------------- # dispatch "Makefile"s from "Makefile.in"s to # required places and setup variables according to conf/ # Root directory where is installed the repository ROOTDIR=$(shell pwd) # Place where Borges is installed DISTDIR=/usr/share/Borges/ # Place where backend is available BACKEND=$(DISTDIR)backend # most bins PATH=$(shell echo $$PATH):$(DISTDIR)/bin export PATH DISTDIR # Main configuration file CONF=conf/repository.xml # now get parameters from conf files # a function that looks for param $(1) in file $(2) GET=$(shell [ -e $(2) ] && $(DISTDIR)/bin/confparse.pl $(1) $(2)) # a function that adds element $(1) with value $(2) file $(3) PUT=$(shell [ -e $(3) ] && $(DISTDIR)/bin/confadd.pl --xpath=$(1) --value=$(2) $(3)) #Where are manuals MANUALSDIR=$(call GET,configuration/repository/paths/manuals,$(CONF)) #Where are modules MODULESDIR=$(call GET,configuration/repository/paths/modules,$(CONF)) # manuals defined MANUALS=$(call GET,configuration/repository/manuals/manual,$(CONF)) # external modules imported IMPORTS=$(call GET,configuration/repository/imports/import,$(CONF)) # langs supported LANGS=$(call GET,configuration/repository/languages/lang,$(CONF)) # Default lang DEF_LANG=$(call GET,configuration/repository/languages/lang[1],$(CONF)) # Makefiles for compiling manuals OUTPUTS=$(call GET,configuration/repository/outputs/makefile,$(CONF)) # Dir to store all outputs OUTPUTSDIR=Outputs # default revision types and associated responsibles: TYPES=$(call GET,configuration/repository/revisions/type/name,$(CONF)) AUTHORS=$(call GET,configuration/repository/revisions/type/author,$(CONF)) # Dirs where compilation may occur SUBS=$(foreach man,$(MANUALS),$(MANUALSDIR)/$(man) $(foreach lang,$(LANGS),$(MANUALSDIR)/$(man)/$(lang))) $(patsubst %,$(MODULESDIR)/%,$(LANGS)) $(patsubst %,$(MODULESDIR)/%,$(IMPORTS)) $(patsubst %,$(MANUALSDIR)/images/%,$(LANGS)) $(patsubst %,entities/%,$(LANGS)) reports $(MANUALSDIR)/module # Default author initials AUTHOR=$(call GET,//initials,conf/author.xml) # default language: LANG=$(call GET,//lang,conf/author.xml) # User login on remote compilation server and server info remoteserverlogin=$(call GET,//remoteserverlogin,conf/author.xml) servername=$(call GET,//server/name,$(CONF)) localserverip=$(call GET,//server/localip,$(CONF)) serverip=$(call GET,//server/ip,$(CONF)) robot=$(call GET,//server/robot,$(CONF)) INCLUDE=$(ROOTDIR)/Makefile.include subst="s,\@LANGS\@,$(LANGS),g; s,\@AUTHOR\@,$(AUTHOR),g; s,\@LANG\@,$(LANG),g; \ s,\@TYPES\@,$(TYPES),g;s,\@AUTHORS\@,$(AUTHORS),g;s,\@MANUALS\@,$(MANUALS),g; \ s,\@MODULESDIR\@,$(MODULESDIR),g;s,\@MANUALSDIR\@,$(MANUALSDIR),g; \ s,\@servername\@,$(servername),g; s,\@localserverip\@,$(localserverip),g; \ s,\@ROOTDIR\@,$(ROOTDIR),g;s,\@remoteserverlogin\@,$(remoteserverlogin),g; \ s,\@OUTPUTS\@,$(OUTPUTS),g; s,\@IMPORTS\@,$(IMPORTS),g; \ s,\@robot\@,$(robot),g; s,\@serverip\@,$(serverip),g; s,\@robot\@,$(robot),g" .PHONY: configure # Create all directories according to information in conf/repository # and fill'em with appropriate Makefile and .cvsignore # Also creates appropriate Makefile(s), .cvsignore and params.ent for single # module compilation configure: make -C conf author.xml make Makefile.include @for i in $(LANGS); do \ mkdir -p images/$$i; \ mkdir -p $(MANUALSDIR)/images/$$i; \ mkdir -p $(MANUALSDIR)/module/$$i; \ mkdir -p entities/$$i; \ mkdir -p $(MODULESDIR)/$$i; \ perl -p -e "s,\@INCLUDE\@,$(INCLUDE),g" \ $(BACKEND)/Makefile.images > $(MANUALSDIR)/images/$$i/Makefile; \ cp -f $(BACKEND)/cvsignore.images $(MANUALSDIR)/images/$$i/.cvsignore; \ perl -p -e "s,\@INCLUDE\@,$(INCLUDE),g" \ $(BACKEND)/Makefile.entities > entities/$$i/Makefile; \ cp -f $(BACKEND)/cvsignore.entities entities/$$i/.cvsignore; \ perl -p -e "s,\@INCLUDE\@,$(INCLUDE),g" \ $(BACKEND)/Makefile.module > $(MODULESDIR)/$$i/Makefile; \ cp -f $(BACKEND)/cvsignore.module $(MODULESDIR)/$$i/.cvsignore; \ for j in $(MANUALS); do \ mkdir -p $(MANUALSDIR)/$$j/$$i; \ perl -p -e "s,\@INCLUDE\@,$(INCLUDE),g" \ $(BACKEND)/Makefile.local > $(MANUALSDIR)/$$j/$$i/Makefile; \ cp -f $(BACKEND)/cvsignore.local $(MANUALSDIR)/$$j/$$i/.cvsignore; \ done; \ perl -p -e "s,\@INCLUDE@,$(INCLUDE),g" \ $(BACKEND)/Makefile.local > $(MANUALSDIR)/module/$$i/Makefile; \ cp -f $(BACKEND)/cvsignore.local $(MANUALSDIR)/module/$$i/.cvsignore; \ done @for j in $(MANUALS); do \ perl -p -e "s,\@INCLUDE\@,$(INCLUDE),g" \ $(BACKEND)/Makefile.manual > $(MANUALSDIR)/$$j/Makefile; \ cp -f $(BACKEND)/cvsignore.manual $(MANUALSDIR)/$$j/.cvsignore; \ if [ ! -e $(MANUALSDIR)/$$j/Makefile.include ]; then \ cp -u $(BACKEND)/Makefile.manual.include $(MANUALSDIR)/$$j/Makefile.include; fi; \ export target=$(MANUALSDIR)/$$j/conf.xml; \ if [ ! -e $$target ]; then cp -u $(DISTDIR)/template/conf/manual-default.xml $$target; fi;\ done @cp -f $(BACKEND)/cvsignore.onemodule $(MANUALSDIR)/module/.cvsignore; @perl -p -e "s,\@INCLUDE\@,$(INCLUDE),g" $(BACKEND)/Makefile.manual > $(MANUALSDIR)/module/Makefile @cp -f $(BACKEND)/Makefile.onemodule.include $(MANUALSDIR)/module/Makefile.include; @if [ ! -e $(MANUALSDIR)/module/conf.xml ]; then \ cp -u $(DISTDIR)/template/conf/manual-default.xml $(MANUALSDIR)/module/conf.xml; fi @mkdir -p reports @cp -u $(DISTDIR)/template/reports/Makefile reports/Makefile; @cp -u $(DISTDIR)/template/conf/Makefile conf/Makefile; @cp -u $(DISTDIR)/template/conf/DocBook.xml conf; @export target=conf/author.xml.in; if [ ! -e $$target ]; then \ cp -u $(DISTDIR)/template/conf/author.xml.in $$target; fi # Generate PSGML master document @make -C $(MANUALSDIR)/module/ psgml-top.xml # In case I am curerntly adding a new document (adddoc), get modules used in it ifneq ($(master),) modules=$(addsuffix .xml,$(call GET,//para[@role=\"module\"],$(master))) endif Makefile.include: $(BACKEND)/Makefile.include.in $(wildcard conf/*.xml) @perl -p -e $(subst) $(BACKEND)/Makefile.include.in > $@ test: echo OUTPUTS: $(OUTPUTS) echo initials: $(AUTHOR) echo langs: $(LANGS) echo manualsathlangs: $(MANUALSDIR) echo default lang: $(DEF_LANG) echo manuals: $(MANUALS) $(call ADD,revhistory/revision," ",master.top.xml) Makefile: $(DISTDIR)/template/Makefile cp -f $< $@ XSL_DOCS_INDEX=$(DISTDIR)/XSL/docs_index.xsl # Name of manuals conf file conf=conf.xml # Look for all available sub-docs SUBDOCS=$(foreach man,$(MANUALS),$(foreach sub,$(call GET,//@id,$(ROOTDIR)/$(MANUALSDIR)/$(man)/$(conf)),$(man)/$(sub))) # Compile some available sub-documents $(SUBDOCS) (or all if not specified) # in all available languages and formats as defined in conf.xml all: $(CONF) configure mkdir -p $(OUTPUTSDIR) for s in $(SUBDOCS); do \ doc=$$(echo $$s | sed 's,/.*, ,'); \ make -C $(MANUALSDIR)/$$(echo $$s | sed 's,/, ,').all; \ cp -Ruf $(MANUALSDIR)/$$(echo $$s | sed 's,/.*,,')/$(OUTPUTSDIR)/* $(OUTPUTSDIR); \ done xsltproc --stringparam rootdir $(ROOTDIR) --stringparam subdocs "$(SUBDOCS)" \ $(XSL_DOCS_INDEX) $< > $(OUTPUTSDIR)/index.html # update the CVS repository and imported modules checkout: if [ -e CVS ]; then cvs -z2 update -d -P; fi ifneq ($(IMPORTS),) cd $(MODULESDIR); \ for i in $(IMPORTS); do \ cvs -z2 co $$i; \ done; endif make configure # Add a new language to conf file, create all resulting directories. # Copy all entities files from default lang dir to new lang dir. # Create correponding module templates. # And finally add all that to CVS repository if available. addlang: ifeq ($(findstring $(LANG),$(LANGS)),) $(call PUT,/configuration/repository/languages/lang,$(LANG),$(CONF)) $(call PUT,/configuration/manuals/manual/lang,$(LANG),conf/manual-default.xml) make configure $(foreach man,$(MANUALS),cp $(MANUALSDIR)/$(man)/$(DEF_LANG)/*.ent \ $(MANUALSDIR)/$(man)/$(LANG); ) -cp entities/$(DEF_LANG)/*.ent entities/$(LANG) $(foreach man,$(MANUALS),make -C $(MANUALSDIR)/$(man) templates LANG=$(LANG);) if [ -e CVS ]; then \ cvs -z2 add \ $(foreach dir,entities images modules,$(dir)/$(LANG))\ $(foreach man,$(MANUALS),$(MANUALSDIR)/$(man)/$(LANG)); \ cvs -z2 add \ $(foreach dir,entities $(MODULESDIR),$(dir)/$(LANG)/.cvsignore)\ $(foreach man,$(MANUALS),$(MANUALSDIR)/$(man)/$(LANG)/.cvsignore)\ $(foreach man,$(MANUALS),$(wildcard $(MANUALSDIR)/$(man)/$(LANG)/*.ent))\ $(foreach man,$(MANUALS),$(wildcard entities/$(LANG)/*.ent))\ $(wildcard $(MODULESDIR)/$(LANG)/*.xml);\ fi else @echo "This language ($(LANG)) is already defined..." @echo "Usage: make addlang LANG=xx" endif # Add a new document to conf file, create all resulting directories. # Take as an argument the master.top.xml file for that document # Copy all entities files from Sample doc to new lang dir. # Create correponding module templates. # And finally add all that to CVS repository if available. adddoc: ifeq ($(findstring $(doc),$(MANUALS)),) ifneq ($(wildcard $(master)),) $(call PUT,/configuration/repository/manuals/manual,$(doc),conf/repository.xml) # if there is no revision history, create it ifeq ($(call GET,/*/*/revhistory,$(master)),) $(DISTDIR)/bin/add-revhistory.pl $(master) endif # insert new doc make configure perl -pi -e "s/id=\"\"/id=\"$(doc)\"/" $(MANUALSDIR)/$(doc)/conf.xml # if scrollkeeper is available compute a seriesid for this new document seriesid=$(shell if which scrollkeeper-gen-seriesid > /dev/null 2>&1; then scrollkeeper-gen-seriesid; fi) perl -pi -e "s/omf.seriesid=\"\"/omf.seriesid=\"$$seriesid\"/" $(MANUALSDIR)/$(doc)/conf.xml $(foreach lang,$(LANGS),cp $(DISTDIR)/template/manuals/Sample/en/*.ent \ $(MANUALSDIR)/$(doc)/$(lang); ) mv $(master) $(MANUALSDIR)/$(doc)/master.top.xml # add revision make -C $(MANUALSDIR)/$(doc) release # Make modules templates make -C $(MANUALSDIR)/$(doc) alltemplates perl -pi -e "s/id=\"\"/id=\"$(doc)\"/" $(MANUALSDIR)/$(doc)/conf.xml # add related files to CVS if available if [ -e CVS ]; then \ cvs -z2 add $(MANUALSDIR)/$(doc); \ cvs -z2 add $(foreach lang,$(LANGS),$(MANUALSDIR)/$(doc)/$(lang)); \ cvs -z2 add \ $(foreach lang,$(LANGS),$(MANUALSDIR)/$(doc)/$(lang)/.cvsignore)\ $(foreach lang,$(LANGS),$(MANUALSDIR)/$(doc)/$(lang)/*.ent)\ $(foreach lang,$(LANGS),$(foreach mod,$(modules),$(MODULESDIR)/$(lang)/$(mod)))\ $(MANUALSDIR)/$(doc)/{master.top.xml,.cvsignore,Makefile.include,conf.xml};\ fi else @echo "You must provide a master document..." @echo "Usage: make adddoc doc=My_New_Manual master=path/to/master.top.xml" endif else @echo "This Document ($(doc)) is already defined..." @echo "Usage: make adddoc doc=My_New_Manual master=path/to/master.top.xml" endif # reconfigure author parameters reconfigure: @echo "Backing up conf/author.xml to conf/author.old.xml" @mv conf/author.xml conf/author.old.xml @make -C conf author.xml # create an archive with everything but specific CVS files # WARNING: cleans everything! archive: superclean rm -f archive.tar.bz2 tar jcvf archive.tar.bz2 --exclude CVS --exclude .cvsignore * # make clean in all subdirs clean: configure for i in $(SUBS); do make -C $$i clean; done for i in `cat .cvsignore | grep -v Makefile`; do rm -rf $$i; done # removes also compiled images cleaner: clean rm -rf $(MANUALSDIR)/images make configure # remove all files ignored by CVS and dirs too superclean: configure for i in $(SUBS); do make -C $$i superclean; done for i in `find -name .cvsignore | sed "s,\(.*\)/.*,\1,"`; do \ cd $(ROOTDIR)/$$i; \ rm -rf `cat .cvsignore` *~; \ done # Used for debugging purposes debug: $(run)