[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Another try for a Makefile building all translated docs in ddp


I've revised my Makefile to build all translated doc in the ddp, and to
build not only html, but also several formats.

** Features
- has a conf part and an 'active' part. The first could become the makefile
  of each dir, and the second be the base of a Makefile.standard
- can build the following format (configurable): ps pdf txt tov info

- build the version.ent if possible (ie, if dir 'debian' exists)

- publish anything properlly (I think), symlinking what should be symlinked

- have a conf variable ORIG_LANG to say what is the cannonical language, and
  handle it properlly
- contains a bad trick to fix what debiandoc2* does.
  It does pt_BR -> pt-br, and I revert it (not only of pt_BR, but for .._..).
  This trick is bad because debiandoc2* should be fixed.

** The tests I've done

it works with no change in the following dirs with no change:
- maint-guide
- developers-reference
- project-history

It fails in the following dirs :
- faq: there is more than on manual in there. I will need to rework the
  Makefile a bit

- tutorial: the manual is named 'debian-tutorial'. So, we can't find it from
  the pwd (but could be done in conf part).
I did not try the others dir.

** What is needed now ?

- a way to build an index.html containing links to all available materials
  (for now, it is the index.en.html, and users won't see the result other

So, I think it should be ok this time. Can someone review (should be quick),
and commit it ?

Bye, Mt.
# Makefile for the Debian New Maintainers' Guide
# Should work both for a manual in the Debian Documentation Project
# manuals.sgml tree, and for maint-guide package build.

##### CONF PART 
# this can and will be overriden by a higher level makefile
PUBLISHDIR := ../../../public_html/manuals.html
MANUAL = $(notdir $(shell pwd))

# The cannonical language, in which the original document is
# list of langs (above the canonical one)
LANGS=fr #to test
#LANGS=$(shell ls $(MANUAL).*.sgml|sed 's/.*$(MANUAL)\.\([^.]*\)\.sgml/\1/')

EXTS=ps pdf txt tov info

# what will be built
HTMLDIRS=$(MANUAL).html $(foreach lang,$(LANGS),$(MANUAL).$(lang).html)
ALLFILES=$(foreach ext,$(EXTS),\
	    $(foreach lang,$(LANGS),$(MANUAL).$(lang).$(ext))\

#====[ build rules ]===========================================================
# generate anything some dirs want version.ent to be builded, some not

DEBIAN=$(wildcard debian)
ifeq ($(DEBIAN),"debian")
all: version.ent $(HTMLDIRS) $(ALLFILES)

version.ent: debian/changelog
	./debian/rules $@

#----[ generating HTML ]-------------------------------------------------------
# for orig_lang
$(MANUAL).html: $(MANUAL).sgml
	debiandoc2html -l $(ORIG_LANG) -c $<

# for translated languages
# FIXME: there is a trick because debiandoc2html does a sed 'y/.../...' 
#        which should be reverted to have the content negociation working.
#   This trick is bad. debiandoc2html should be corrected.
$(MANUAL).%.html: $(MANUAL).%.sgml
	debiandoc2html -l $* -c $<
	@echo "cleaning up file extensions";\
	for file in `ls $(MANUAL).$*.html/*` ; do\
	 newfile=`echo $$file|\
	          sed 's/$(shell echo $*|\
	      sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz-/'\
	 if [ $$file != $$newfile ] ; then\
	   mv $$file $$newfile;\

#----[ generating plain text ]-------------------------------------------------
# for orig_lang
$(MANUAL).$(ORIG_LANG).txt: $(MANUAL).sgml
	debiandoc2text -l $(ORIG_LANG) -c $<

# for translated languages
$(MANUAL).%.txt: $(MANUAL).%.sgml
	debiandoc2text -l $* $<

#----[ generating tov ]--------------------------------------------------------
# for orig_lang
$(MANUAL).$(ORIG_LANG).tov: $(MANUAL).sgml
	debiandoc2textov -l $(ORIG_LANG) -c $<

# for translated languages
$(MANUAL).%.tov: $(MANUAL).%.sgml
	debiandoc2textov -l $* $<

#----[ generating info ]-------------------------------------------------------
# for orig_lang
$(MANUAL).$(ORIG_LANG).info: $(MANUAL).sgml
	debiandoc2info -l $(ORIG_LANG) -c $<

# for translated languages
$(MANUAL).%.info: $(MANUAL).%.sgml
	debiandoc2info -l $* $<

#----[ generating PostScript ]-------------------------------------------------
# for orig_lang
$(MANUAL).$(ORIG_LANG).ps: $(MANUAL).sgml
	debiandoc2latexps -l $(ORIG_LANG) -c $<

# for translated languages
$(MANUAL).%.ps: $(MANUAL).%.sgml
	debiandoc2latexps -l $* $<

#----[ generating PDF ]--------------------------------------------------------
# for orig_lang
$(MANUAL).$(ORIG_LANG).pdf: $(MANUAL).sgml
	debiandoc2latexpdf -l $(ORIG_LANG) -c $<

# for translated languages
$(MANUAL).%.pdf: $(MANUAL).%.sgml
	debiandoc2latexpdf -l $* $<

#====[ publishing to the DDP web pages ]=======================================
publish: publish-html publish-files

#----[ publish html ]----------------------------------------------------------
publish-html: $(HTMLDIRS)
	test -d $(PUBLISHDIR)/$(MANUAL) \
	   || install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
	rm -f $(PUBLISHDIR)/$(MANUAL)/*.html
	 # install any translated html
	$(foreach lang,$(LANGS),\
	  install -p -m 644 $(MANUAL).$(lang).html/*.html $(PUBLISHDIR)/$(MANUAL)/;)
	 # install original html
	 install -p -m 644 $(MANUAL).html/*.html \
	 # make the simlinks for html files
	 @$(foreach file,$(wildcard  $(MANUAL).html/*.html),\
	  name=`echo $(file) | sed 's/$(MANUAL).html\///'`; \
	  link=`echo $$name|sed 's/.$(ORIG_LANG).html$$/.html/'`;\
	  rm -f $$link; \
	  echo "$$link -> $$name";\
	  ln -s $(PUBLISHDIR)/$(MANUAL)/$$name\

#----[ publish the files ]-----------------------------------------------------
publish-files: $(ALLFILES)
	test -d $(PUBLISHDIR)/$(MANUAL) \
	   || install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
	$(foreach ext,$(EXTS),\
	 rm -f $(PUBLISHDIR)/$(MANUAL)/*.$(ext);\
	 $(foreach lang,$(LANGS),\
	  install -p -m 644 $(MANUAL).$(lang).$(ext)\
	 install -p -m 644 $(MANUAL).$(ORIG_LANG).$(ext)\
	 rm -f $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).$(ext);\
	 ln -s $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).$(ORIG_LANG).$(ext)\

#----[ publish the ps ]--------------------------------------------------------
publish-ps: ps
	test -d $(PUBLISHDIR)/$(MANUAL) \
	   || install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
	rm -f $(PUBLISHDIR)/$(MANUAL)/*.ps
	 # install any translated ps
	$(foreach lang,$(LANGS),\
	  install -p -m 644 $(MANUAL).$(lang).ps \
	                    $(PUBLISHDIR)/$(MANUAL)/ ;)
	 # install original ps
	 install -p -m 644 $(MANUAL).$(ORIG_LANG).ps\
	 # make the simlinks for ps
	 rm -f $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).ps;

#====[ validating SGML ]=======================================================
	set -x; for i in $(wildcard *.sgml); do nsgmls -ges -wall $$i; done

#====[ cleaning up ]===========================================================
clean distclean:
	rm -f maint-guide*.{txt,ps,dvi,pdf,info*,log,tex,aux,toc,sasp*} *~
	rm -rf maint-guide*.html

.PHONY: all html txt ps\
	publish publish-html publish-txt publish-ps\
	clean distclean validate

Reply to: