# Makefile pour la documentation de lettre.cls # # This file is part of the "lettre" package. # # This work may be distributed and/or modified under the # conditions of the LaTeX Project Public License, either version 1.3 # of this license or (at your option) any later version. # The latest version of this license is in # http://www.latex-project.org/lppl.txt # and version 1.3 or later is part of all distributions of LaTeX # version 2005/12/01 or later. # # This work has the LPPL maintenance status `maintained'. # # The Current Maintainer of this work is Vincent Belaïche. # # This work consists of all files listed in README # DOCDIR ?= . include $(DOCDIR)/lettre-makedefinitions.mak .DEFAULT_GOAL:=$(firstword $(DOC)) SUBSRC_TRIMMED := $(patsubst %.tex,%.trimmed,$(SUBSRC)) SUBSRC_PDF := $(patsubst %.tex,%.pdf,$(SUBSRC)) ROOT:=../../.. LETTRETEX:=$(ROOT)/tex/latex/lettre DOWNLOADDIR:=$(ROOT)/../download_area MAKELEVELBASE ?= 0 NEEDS_RELOCATION?= $(shell if [ "$$(kpsewhich lettre.cls)" -ef $(LETTRETEX)/lettre.cls \ -a "$$(kpsewhich lettre.tex)" -ef ./lettre.tex ]; then echo "1"; else echo "0"; fi) #NEEDS_RELOCATION:=0 TEXSRC:=$(TEMPLATES) $(STYFILES) ifeq ($(strip $(NEEDS_RELOCATION)),1) RELOCATION:=relocation MKDIRTMP:=mkdirtmp TMPDIR := /tmp/lettre else RELOCATION:=$(TEXSRC) MKDIRTMP:= TMPDIR:=. endif DISTFORGE:=$(ROOT)/dist_forge LATEX := latex TEX2PDF := latexmk TEX2PDFOPT := -r latexmkrc.pl DVIPS= dvips DVIPSOPT= -o PS2PDF= ps2pdf COMMA:=,# # Attention: le script monoligne AWK doit être robuste à un release-note avec CRLF traité par un awk # *nixien s'attendant à des fins de ligne en LF. define VERSION_AWK BEGIN { BINMODE=3; RS="\r?\n|\r"}; \ /^v[0-9]+(\.[0-9]+)?w? *:/ { match($$0,/^v([0-9]+(\.[0-9]+)?w?)/,a); print a[1]; exit(0)} endef define LISTIFY $(addsuffix $(COMMA),$(filter-out $(lastword $(1)),$(1))) $(lastword $(1)) endef $(DOCDIR)/version.m4 : $(DOCDIR)/release-notes $(DOCDIR)/makefile $(SET_OUTFILE); \ version=$$(awk '$(VERSION_AWK)' $<); \ curdate=$$(date "+%s"); \ printf "\ divert(-1)changequote({[>,<]})\\n\ define({[>lt_setquote<]},{[>changequote({[>,<]})<]})\\n\ define({[>ProvidesClass<]},{[>lt_setquote()Provides{[><]}Class{lettre}[<]}lt_date vlt_version{[>]%%\\nchangequote(,)dnl<]})\\n\ define({[>lt_version<]},{[>$${version}<]})\\n\ define({[>vlt_version<]},{[>v<]}lt_version)\\n\ define({[>ctanlt_version<]},{[>ctan<]}lt_version)\\n\ define({[>lt_date<]},{[>"$$(date -jf '%s' "$$curdate" '+%Y/%m/%d')"<]})\\n\ define({[>lt_date_iso<]},{[>"$$(date -jf '%s' "$$curdate" '+%Y-%m-%d')"<]})\\n\ define({[>lt_annee<]},{[>"$$(date -jf '%s' "$$curdate" '+%Y')"<]})\\n\ ifdef({[>lt_disttype<]},,{[>define({[>lt_disttype<]},{[>$(DISTTYPE)<]})<]})\\n\ define({[>lt_liste_des_fichiers<]},{[>\ ifelse(lt_disttype,plain,$(subst $(SPACE),\\n,$(addprefix lettre.zip/,$(DOCSRC) $(STYFILES)))\\n,\ lt_disttype,dtx,lettre.zip/lettre.dtx\\n)\ $(subst $(SPACE),\\n,$(addprefix lettre.zip/,$(DOC) $(README) $${version}-release-notes.txt))\\n\ lt_liste_tds_des_fichiers<]})\\n\ define({[>lt_racine_tds<]},{[>lettre.zip/<]})\\n\ define({[>lt_liste_tds_des_fichiers<]},\\n\ $(subst $(SPACE),\\n,$(patsubst %,{[>lt_racine_tds()lettre.tds.zip/doc/latex/lettre/%<]},$(DOC) $(README)))\\n\ ifelse(lt_disttype,plain,$(subst $(SPACE),\\n,$(patsubst %,{[>lt_racine_tds()lettre.tds.zip/doc/latex/lettre/%<]},$(DOCSRC)))\\n)\ $(subst $(SPACE),\\n,$(patsubst %,{[>lt_racine_tds()lettre.tds.zip/tex/latex/lettre/%<]},$(STYFILES)))\\n\ {[>lt_racine_tds(){[>lettre.tds.zip/doc/latex/lettre/$${version}-release-notes.txt<]}<]})\\n\ define({[>lt_examples<]},{[>$(call LISTIFY,$(EXAMPLES))<]})\\n\ define({[>lt_langs<]},{[>$(call LISTIFY,$(LANGS))<]})\\n\ define({[>lt_instituts<]},{[>$(call LISTIFY,$(INSTITUTS))<]})\\n\ define({[>lt_autos<]},{[>$(call LISTIFY,$(patsubst %.tex,%,$(AUTO_SRC)))<]})\\n\ define({[>lt_templates<]},{[>$(call LISTIFY,$(patsubst %.tpl,%,$(TEMPLATES)))<]})\\n\ define({[>lt_foreach<]},{[>ifelse("'$$'"#,0,,"'$$'"#,1,{[>ifelse({[>"'$$'"1<]},,,{[>lt_foreach_mappee({[>"'$$'"1<]})<]})<]},{[>lt_foreach_mappee({[>"'$$'"1<]}){[><]}lt_foreach_comma()lt_foreach(shift("'$$'"@))<]})<]})\\n\ define({[>lt_gobble_endinput<]},{[><]})\\n\ changequote(,)divert(0)dnl\\n" > $(OUTFILE) latexmkrc.pl: $(DOCDIR)/version.m4 $(DOCDIR)/latexmkrc.m4 m4 $^ > $@ ifeq ($(MAKELEVEL),$(MAKELEVELBASE)) INPUTSDIR := ../../../tex/latex/lettre STYDIR := ../../../tex/latex/lettre .PHONY: doc doc: $(RELOCATION) $(DOCSRC) $(addprefix $(STYDIR)/,$(STYFILES_INDOC)) ifeq ($(strip $(NEEDS_RELOCATION)),1) $(MAKE) -f $(abspath makefile) -C $(TMPDIR) doc "DOCDIR=$(abspath $(DOCDIR))" for w in $(DOCPDF); do cp -u $(TMPDIR)/$$w -t . ; done endif ifeq ($(strip $(NEEDS_RELOCATION)),1) $(DOCPDF):%: relocation $(DOCSRC) $(MAKE) -f $(abspath makefile) -C $(TMPDIR) $@ "DOCDIR=$(abspath $(DOCDIR))" cp -u $(TMPDIR)/$@ -t . endif # Il est nécessaire de relocaliser le code source de la documentation dans un répertoire temporaire pour # compiler, parce que latex n'est en général pas capable de compiler un fichier qui se trouve sous le TEXMF de # plus, de sorte que ce qui est sous l'archive TDS soit autonome, on re-utilise le même makefile de façon # re-entrante .PHONY: relocation relocation: $(TMPDIR)/release-notes.txt $(addprefix $(TMPDIR)/,$(AUTO_SRC) \ $(DOCSRC) $(TEXSRC) letdoc.ist) $(MKDIRTMP) ifeq ($(strip $(NEEDS_RELOCATION)),1) $(addprefix $(TMPDIR)/,$(DOCSRC) letdoc.ist):$(TMPDIR)/%: % cp $< $@ endif $(addprefix $(TMPDIR)/,$(TEXSRC)):$(TMPDIR)/%: $(LETTRETEX)/% $(DOCDIR)/version.m4 m4 $(DOCDIR)/version.m4 $< > $@ define UNTABIFY BEGIN {print_enb = 0}; \ !/^ *$$/ && !/^ *%/ {print_enb = 1}; \ print_enb == 1 { \ k = split($$0,a,"\t"); \ for(i=1; i<=k; ++i){ \ w = a[i]; \ if(i == 1) \ printf("%s",w); \ else \ printf("%s%s",substr(" ",c+1),w);\ l = length(w); \ c = l-int(l/8)*8; \ } \ print "" \ } endef $(TMPDIR)/release-notes.txt: release-notes $(MKDIRTMP) awk '$(UNTABIFY)' $< > $@ define LETTRE_PATH '\newcommand*\inputsdir{$(INPUTSDIR)/}\ \newcommand*\versnum{lt_version}\ \newcommand*\inputreleasenotes{\verbatiminput{release-notes.txt}}\ \newcommand*\documentationducode{\DocInput{lettre.cls}\subsection{Définition des langues}$(patsubst %,\DocInput{lettre-%.ldf},$(LANGS))}\ \newcommand*\listeexemples{lt_examples()}\ \newcommand*\listegabarits{lt_templates()}' endef $(TMPDIR)/lettre-path.tex: $(DOCDIR)/version.m4 $(MKDIRTMP) $(SET_OUTFILE); \ echo $(LETTRE_PATH) | m4 $< - > $(OUTFILE) $(addprefix $(TMPDIR)/, $(SCRIPTOUT_SRC)): $(DOCDIR)/lettre-script.tex cd $(TMPDIR); latex $<; $(call DOS2UNIX,$@) .PHONY: mkdirtmp mkdirtmp: mkdir -p $(TMPDIR) endif ifeq ($(MAKELEVEL),$(shell expr $(MAKELEVELBASE) + $(NEEDS_RELOCATION))) ifeq ($(strip $(NEEDS_RELOCATION)),1) INPUTSDIR:= . STYDIR := . endif .SUFFIXES: .ps .tex .dvi .idx TPL:=$(addprefix $(INPUTSDIR)/,$(TEMPLATES)) # on fournit une version Postscript et deux fichiers .dvi (polices CM et EC) .PHONY: doc doc: $(patsubst %.tex,%.pdf,$(TOPSRC)) $(patsubst %.tex,%.pdf,$(TOPSRC)): %.pdf: %.tex $(MAINSRC) $(AUTO_SRC) \ release-notes.txt $(TPL) $(STYFILES_INDOC) \ $(SUBSRC_TRIMMED) $(SUBSRC_PDF) $(LOGOSPDF) latexmkrc.pl @$(TEX2PDF) $(TEX2PDFOPT) $< $(SUBSRC_TRIMMED): %.trimmed: %.tex awk '$(TEX_TRIMMER_AWK)' $< > $@ $(SUBSRC_PDF): %.pdf: %.tex $(LOGOS) latexmkrc.pl $(STYFILES) @$(TEX2PDF) $(TEX2PDFOPT) $< endif ifeq ($(strip $(NEEDS_RELOCATION)),0) LATEXMKRC_MAYBE:=latexmkrc.pl else LATEXMKRC_MAYBE:=# endif .PHONY: clean mostlyclean clean mostlyclean: $(LATEXMKRC_MAYBE) ifeq ($(strip $(NEEDS_RELOCATION)),1) rm -fr $(TMPDIR) else $(TEX2PDF) $(TEX2PDFOPT) -c $(TOPSRC) $(SUBSRC) $(LOGOS) rm -f release-notes.txt $(STYFILES_INDOC) $(AUTO_SRC) endif rm -f $(DOCDIR)/version.m4 rm -f $(addprefix $(DOCDIR)/lettre-script.,aux tns log) .PHONY: realclean squeaky realclean squeaky: clean rm -f $(DOCPDF) ifeq ($(strip $(NEEDS_RELOCATION)),0) $(TEX2PDF) $(TEX2PDFOPT) -C $(TOPSRC) $(SUBSRC) rm -f $(SUBSRC_PDF) $(SUBSRC_TRIMMED) $(TEXSRC) latexmkrc.pl endif # on précise le codage (pour EMACS) pour le bon affichage des commentaires. # Local Variables: # coding: latin-1 # End: