File: Makefile.generic

package info (click to toggle)
logidee-tools 1.2.18
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 656 kB
  • sloc: xml: 1,433; sh: 81; perl: 61; makefile: 42
file content (216 lines) | stat: -rw-r--r-- 5,941 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

# Include Makefile.local  if any
#include Makefile.local

# The main directory of logidee-tools
DIR = ..

# The default language (fallback)
DEFAULT_LANG = en

# Other default values
ifndef SELECTION
SELECTION = none
endif
ifndef TRAINER
TRAINER = false
endif
ifndef CHARTE
CHARTE = default
endif
ifndef CYCLE
CYCLE = false
endif
ifndef LANG
LANG = $(DEFAULT_LANG)
endif
ifndef SLIDE
SLIDE = true
endif
ifndef DESC
DESC = true
endif

# Try to use a supported language
ifeq (en,$(findstring en,$(LANG)))
override LANG = en
else
ifeq (fr,$(findstring fr,$(LANG)))
override LANG = fr
else
ifeq (de,$(findstring de,$(LANG)))
override LANG = de
else
# the language may not be supported
# switch to the language by default
override LANG = $(DEFAULT_LANG)
endif
endif
endif

export TEXINPUTS=$(shell kpsepath tex):./charte/$(CHARTE)//:../charte/$(CHARTE)//:../../charte/$(CHARTE)//

# Values for libxslt/xsltproc
XMLVALID = xmllint --xinclude --noout --valid
XMLOUT = 
XSLTPROC  = xsltproc --xinclude
XSLTPARAM = --stringparam
XSLTXSL =
XSLTIN =
XSLTOUT = >

# Values for xerces-c/xalan-c
# XMLVALID = DOMPrint -v=always
# XMLOUT = > /dev/null
# XSLTPROC="testXSLT"
# XSLTPARAM="-param"
# XSLTXSL="-xsl"
# XSLTIN = "-in"
# XSLTOUT="-out"

XSLT = $(XSLTPROC) $(XSLTPARAM) selection "$(SELECTION)" $(XSLTPARAM) cycle "$(CYCLE)" $(XSLTPARAM) charte "$(CHARTE)" $(XSLTPARAM) trainer "$(TRAINER)" $(XSLTPARAM) lang "$(LANG)" $(XSLTPARAM) slide "$(SLIDE)" $(XSLTPARAM) description "$(DESC)"

NAMES=$(shell find . -name "*.xml" -exec basename {} .xml \;)
CEXTS=.bak .toc .log .aux .dvi .tex
RCEXTS=.ps .pdf .html .txt

help:
	@printf "Usage: \n"
	@printf "make formations:\tbuilds PDF (a4) for all formations \n\t\t\t(formation*.xml) in the directory ;\n"
	@printf "make formations_2pp:\tbuilds PS (a4) with 2 pages per \n\t\t\tsheet for all formations (formation*.xml) ;\n"
	@printf "make formations_show:\tbuilds all slide shows (PDF) for all formations ;\n"
	@printf "\n"
	@printf "The rules available for « formations » are also available for « themes ».\n"
	@printf "\n"
	@printf "make tex:\t builds all TeX document ;\n"
	@printf "make toto:\t builds toto.ps using toto.xml as input ;\n"
	@printf "make check:\t check the validity of all XML documents.\n"


# Generic rules
tex: $(patsubst %.xml,%.tex,$(wildcard *.xml))
html: $(patsubst %.xml,%.html,$(wildcard *.xml))
ps: $(patsubst %.xml,%.ps,$(wildcard *.xml))
2pp: $(patsubst %.xml,%_2pp.ps,$(wildcard *.xml))
pdf: $(patsubst %.xml,%.pdf,$(wildcard *.xml)) $(patsubst %.xml,%_slideshow.pdf,$(wildcard *.xml))
show: slideshow
slide: slideshow
slideshow: $(patsubst %.xml,%_slideshow.pdf,$(wildcard *.xml))
txt: $(patsubst %.xml,%.txt,$(wildcard *.xml))

define mktex
	@echo "include Makefile" >makefile.tmp
	@echo $@: $(shell $(DIR)/verif_dep.sh $(@:%$(2)=%.xml)) >>makefile.tmp
	@echo "	$(XSLT) $(XSLTXSL) $(DIR)/xsl/$(1) $(XSLTIN) $(@:%$(2)=%.xml) $(XSLTOUT) $@" >>makefile.tmp
	make -f makefile.tmp $@
	rm makefile.tmp
endef

FORCE:

# Rules to generate various files
formation%_slideshow.tex: FORCE
	$(call mktex,formation-ptex.xsl,_slideshow.tex)

formation%.tex: FORCE
	$(call mktex,formation-tex.xsl,.tex)

theme%_slideshow.tex: FORCE
	$(call mktex,theme-ptex.xsl,_slideshow.tex)

theme%.tex:  FORCE
	$(call mktex,theme-tex.xsl,.tex)

formations: $(patsubst %.xml,%.pdf,$(wildcard formation*.xml))
formations_show: $(patsubst %.xml,%_slideshow.pdf,$(wildcard formation*.xml))
formations_2pp: $(patsubst %.xml,%_2pp.ps,$(wildcard formation*.xml))

themes: $(patsubst %.xml,%.pdf,$(wildcard theme*.xml))
themes_show: $(patsubst %.xml,%_slideshow.pdf,$(wildcard theme*.xml))
themes_2pp: $(patsubst %.xml,%_2pp.ps,$(wildcard theme*.xml))

%_slideshow.tex: FORCE
	$(call mktex,module-ptex.xsl,_slideshow.tex)

%.tex: FORCE 
	$(call mktex,module-tex.xsl,.tex)

%.txt: %.xml
	$(XSLT) $(XSLTXSL) $(DIR)/xsl/module-txt.xsl $(XSLTIN) $< $(XSLTOUT) $@

formation%.html: formation%.xml 
	@echo "Formations and themes cannot be converted to HTML."
theme%.html: theme%.xml
	@echo "Formations and themes cannot be converted to HTML."

%.html: %.xml
	test -d $@ || mkdir $@
	cp $(DIR)/charte/$(CHARTE)/default.css $@/default.css
	cp $(DIR)/charte/$(CHARTE)/icones/*.png $@/
	cp $(DIR)/charte/$(CHARTE)/html/$(LANG)/*.html $@/
	$(XSLT) $(XSLTPARAM) dir "$(CURDIR)/$@" $(XSLTXSL) $(DIR)/xsl/module-html.xsl $(XSLTIN) $< $(XSLTOUT) $@/index.html
	for i in `cat $@/images`; do \
	    convert $$i $@/`basename $${i%%.eps}.png`; \
	done
	rm $@/images
	touch $@

%_slideshow.dvi: %_slideshow.tex $(wildcard *.eps) $(DIR)/charte/$(CHARTE)/tex/logidoc.cls
	latex $<

%.dvi: %.tex $(wildcard *.eps) $(DIR)/charte/$(CHARTE)/tex/logidoc.cls
	# Three times to get cross-references right (argh)
	latex $< && latex $< && latex $<

%_slideshow.ps: %_slideshow.dvi
	dvips -t a4 -t landscape -f $< > $@
	#dvips -T 31.0cm,21.1cm -f $< > $@

%_slideshow.pdf: %_slideshow.ps
	ps2pdf $< $@

%.pdf: %.ps
	ps2pdf $< $@

%.ps: %.dvi
	dvips -f $< > $@

%_2pp.ps: %.ps
	ps2ps $< tmp.ps
	psnup -2 tmp.ps > $@
	rm tmp.ps

%_slideshow: %_slideshow.pdf

%: %.xml
	make $@.pdf $@_slideshow.pdf

# Rules for checking the validity of XML files
check: $(patsubst %.xml, %.xml-check, $(wildcard *.xml))

%.xml-check: %.xml $(DIR)/dtd/module.dtd
	@echo "*** Validation of $<"
	$(XMLVALID) $< $(XMLOUT)

# Rules for cleaning the directories
define files
`for EXT in $(1); do \
     for FILEBASE in $(NAMES); do \
         echo $$FILEBASE*$$EXT; \
     done; \
done`
endef

clean::
	rm -rf $(call files, $(CEXTS))

realclean::
	rm -rf $(call files, $(CEXTS) $(RCEXTS))
	rm -rf .log texput.log images/.gscache*

rclean: realclean

# Meta information about target & rules for make
.PHONY: formations formations_show formations_2pp themes themes_show themes_2pp clean help tex txt ps pdf 2pp slide show slideshow check %.xml-check 
.PRECIOUS: %.ps %.pdf %_slideshow.pdf %_slideshow.ps
#.SECONDARY: %.dvi %_slideshow.dvi %.tex %_slideshow.tex