1 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
2 | $(error "variable MORPHEO_TOPLEVEL is undefined"); |
---|
3 | else |
---|
4 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
5 | endif |
---|
6 | |
---|
7 | #-------------------------------------------------------------------------------- |
---|
8 | #-----[ Variable ]--------------------------------------------------------------- |
---|
9 | #-------------------------------------------------------------------------------- |
---|
10 | |
---|
11 | ENV_LATEX = export TEXINPUTS=$(DIR_INCLUDE):$$TEXINPUTS |
---|
12 | LATEX_WITH_ENV = $(ENV_LATEX); $(LATEX) |
---|
13 | |
---|
14 | #-------------------------------------------------------------------------------- |
---|
15 | #-----[ Directory ]-------------------------------------------------------------- |
---|
16 | #-------------------------------------------------------------------------------- |
---|
17 | |
---|
18 | # DIR_DOCUMENTATION must be set previously |
---|
19 | |
---|
20 | DIR_TOPLEVEL = $(DIR_DOCUMENTATION) |
---|
21 | DIR_TOPLEVEL_SCHEMA = $(DIR_TOPLEVEL)/fig |
---|
22 | DIR_TOPLEVEL_GRAPH = $(DIR_TOPLEVEL)/dot |
---|
23 | DIR_TOPLEVEL_PDF = $(DIR_TOPLEVEL)/pdf |
---|
24 | DIR_DOC = . |
---|
25 | DIR_TEX = ./tex |
---|
26 | DIR_SCHEMA = ./fig |
---|
27 | DIR_GRAPH = ./dot |
---|
28 | DIR_SCHEMA_EPS = ./eps |
---|
29 | |
---|
30 | #-------------------------------------------------------------------------------- |
---|
31 | #-----[ Files ]------------------------------------------------------------------ |
---|
32 | #-------------------------------------------------------------------------------- |
---|
33 | |
---|
34 | TEX_FILES = $(wildcard $(DIR_DOC)/*.tex) |
---|
35 | DVI_FILES = $(patsubst $(DIR_DOC)/%.tex,%.dvi,$(TEX_FILES)) |
---|
36 | PS_FILES = $(patsubst $(DIR_DOC)/%.tex,%.ps ,$(TEX_FILES)) |
---|
37 | PDF_FILES = $(patsubst $(DIR_DOC)/%.tex,%.pdf,$(TEX_FILES)) |
---|
38 | EPS_FILES = $(patsubst $(DIR_GRAPH)/%.dot,$(DIR_SCHEMA_EPS)/%.eps,$(wildcard $(DIR_GRAPH)/*.dot)) \ |
---|
39 | $(patsubst $(DIR_SCHEMA)/%.fig,$(DIR_SCHEMA_EPS)/%.eps,$(wildcard $(DIR_SCHEMA)/*.fig)) \ |
---|
40 | $(patsubst $(DIR_SCHEMA)/%.eps,$(DIR_SCHEMA_EPS)/%.eps,$(wildcard $(DIR_SCHEMA)/*.eps)) \ |
---|
41 | $(patsubst $(DIR_TOPLEVEL_GRAPH)/%.dot,$(DIR_SCHEMA_EPS)/%.eps,$(wildcard $(DIR_TOPLEVEL_GRAPH)/*.dot)) \ |
---|
42 | $(patsubst $(DIR_TOPLEVEL_SCHEMA)/%.fig,$(DIR_SCHEMA_EPS)/%.eps,$(wildcard $(DIR_TOPLEVEL_SCHEMA)/*.fig)) \ |
---|
43 | $(patsubst $(DIR_TOPLEVEL_SCHEMA)/%.eps,$(DIR_SCHEMA_EPS)/%.eps,$(wildcard $(DIR_TOPLEVEL_SCHEMA)/*.eps)) |
---|
44 | |
---|
45 | #-------------------------------------------------------------------------------- |
---|
46 | #-----[ Rules ]------------------------------------------------------------------ |
---|
47 | #-------------------------------------------------------------------------------- |
---|
48 | |
---|
49 | #-------------------------------------------------------------------------------- |
---|
50 | # The reset of this file shall not be editted |
---|
51 | #-------------------------------------------------------------------------------- |
---|
52 | |
---|
53 | vpath %.tex $(DIR_TEX) |
---|
54 | vpath %.dot $(DIR_GRAPH):$(DIR_TOPLEVEL_GRAPH) |
---|
55 | vpath %.fig $(DIR_SCHEMA):$(DIR_TOPLEVEL_SCHEMA) |
---|
56 | vpath %.eps $(DIR_SCHEMA):$(DIR_TOPLEVEL_SCHEMA) |
---|
57 | |
---|
58 | |
---|
59 | .PHONY : all view view_global view_local clean help |
---|
60 | .SECONDARY : $(DVI_FILES) $(PS_FILES) $(PDF_FILES) $(EPS_FILES) $(DIR_SCHEMA_EPS) |
---|
61 | |
---|
62 | all_documentation : $(EPS_FILES) |
---|
63 | @\ |
---|
64 | $(MAKE) $(PDF_FILES) |
---|
65 | |
---|
66 | #-------------------------------------------------------------------------------- |
---|
67 | # Generation of the formatted text: |
---|
68 | # regular flow tex -> dvi -> ps -> pdf. |
---|
69 | #-------------------------------------------------------------------------------- |
---|
70 | |
---|
71 | %.pdf : %.ps $(DIR_TOPLEVEL_PDF) |
---|
72 | @\ |
---|
73 | $(ECHO) "Generate files : $*.pdf"; \ |
---|
74 | $(PS2PDF) $< $@; \ |
---|
75 | $(CP) $@ $(DIR_TOPLEVEL_PDF); |
---|
76 | |
---|
77 | %.ps : %.dvi |
---|
78 | @\ |
---|
79 | $(ECHO) "Generate files : $*.ps"; \ |
---|
80 | $(DVIPS) -o $@ $<; |
---|
81 | |
---|
82 | %.dvi : %.tex $(DIR_TEX)/* |
---|
83 | @\ |
---|
84 | $(ECHO) "Generate files : $*.dvi"; \ |
---|
85 | $(LATEX_WITH_ENV) $<; \ |
---|
86 | if $(TEST) $$? -eq 0; then \ |
---|
87 | $(LATEX_WITH_ENV) $< > /dev/null; \ |
---|
88 | citation=`$(GREP) "citation" $*.aux`; \ |
---|
89 | if $(TEST) -n "$$citation" ; then \ |
---|
90 | $(BIBTEX) $* ; \ |
---|
91 | fi; \ |
---|
92 | $(LATEX_WITH_ENV) $< > /dev/null; \ |
---|
93 | $(LATEX_WITH_ENV) $< > /dev/null; \ |
---|
94 | fi; |
---|
95 | |
---|
96 | #-------------------------------------------------------------------------------- |
---|
97 | # The figures directory |
---|
98 | #-------------------------------------------------------------------------------- |
---|
99 | $(DIR_SCHEMA_EPS) : |
---|
100 | @\ |
---|
101 | $(ECHO) "Make directory : $@"; \ |
---|
102 | $(MKDIR) $@; |
---|
103 | |
---|
104 | $(DIR_TOPLEVEL_PDF) : |
---|
105 | @\ |
---|
106 | $(ECHO) "Make directory : $@"; \ |
---|
107 | $(MKDIR) $@; |
---|
108 | |
---|
109 | $(DIR_SCHEMA_EPS)/%.eps : %.eps $(DIR_SCHEMA_EPS) |
---|
110 | @\ |
---|
111 | $(ECHO) "Generate files : $*.eps"; \ |
---|
112 | $(CP) $< $(DIR_SCHEMA_EPS); |
---|
113 | |
---|
114 | $(DIR_SCHEMA_EPS)/%.eps : %.fig $(DIR_SCHEMA_EPS) |
---|
115 | @\ |
---|
116 | $(ECHO) "Generate files : $*.eps"; \ |
---|
117 | $(FIG2EPS) $< $@; |
---|
118 | |
---|
119 | $(DIR_SCHEMA_EPS)/%.eps : %.dot $(DIR_SCHEMA_EPS) |
---|
120 | @\ |
---|
121 | $(ECHO) "Generate files : $*.eps"; \ |
---|
122 | $(DOT) -Tfig -o $(DIR_SCHEMA_EPS)/${*}.fig $<; \ |
---|
123 | $(FIG2EPS) $(DIR_SCHEMA_EPS)/${*}.fig $@; \ |
---|
124 | $(RM) $(DIR_SCHEMA_EPS)/${*}.fig; |
---|
125 | |
---|
126 | #-------------------------------------------------------------------------------- |
---|
127 | # View |
---|
128 | #-------------------------------------------------------------------------------- |
---|
129 | view_local : all |
---|
130 | @\ |
---|
131 | declare SELECT_FILE; \ |
---|
132 | declare SELECT_FORMAT; \ |
---|
133 | declare SELECT_VIEWER; \ |
---|
134 | \ |
---|
135 | \ |
---|
136 | $(ECHO) ""; \ |
---|
137 | $(ECHO) "Choose a document : (0 by default)"; \ |
---|
138 | \ |
---|
139 | declare -i CPT; \ |
---|
140 | declare -i NUM_FILE; \ |
---|
141 | declare -a FILES; \ |
---|
142 | \ |
---|
143 | CPT=0; \ |
---|
144 | for files in $(PDF_FILES); do \ |
---|
145 | files=`$(BASENAME) $$files .pdf`; \ |
---|
146 | $(ECHO) "$$CPT) $$files"; \ |
---|
147 | FILES[$$CPT]=$$files; \ |
---|
148 | CPT=$$(($$CPT+1)); \ |
---|
149 | done; \ |
---|
150 | \ |
---|
151 | if $(TEST) "$$CPT" -eq "0"; then \ |
---|
152 | $(ECHO) "None document found"; \ |
---|
153 | exit; \ |
---|
154 | fi; \ |
---|
155 | \ |
---|
156 | read NUM_FILE; \ |
---|
157 | \ |
---|
158 | if $(TEST) "$$NUM_FILE" -ge "$$CPT"; then \ |
---|
159 | NUM_FILE=0; \ |
---|
160 | fi; \ |
---|
161 | \ |
---|
162 | SELECT_FILE=$${FILES[$$NUM_FILE]}; \ |
---|
163 | \ |
---|
164 | \ |
---|
165 | $(ECHO) "Document selected : $$SELECT_FILE"; \ |
---|
166 | $(ECHO) ""; \ |
---|
167 | $(ECHO) "Choose a format : (0 by default)"; \ |
---|
168 | \ |
---|
169 | declare -i NUM_FORMAT; \ |
---|
170 | declare -a FORMAT; \ |
---|
171 | declare -a VIEWER; \ |
---|
172 | \ |
---|
173 | PRINT=( "pdf (fullscreen)" "pdf" "ps" "dvi"); \ |
---|
174 | FORMAT=("pdf" "pdf" "ps" "dvi"); \ |
---|
175 | VIEWER=("$(VIEWPDF_FS)" "$(VIEWPDF)" "$(VIEWPS)" "$(VIEWDVI)"); \ |
---|
176 | \ |
---|
177 | CPT=0; \ |
---|
178 | while [ $$CPT -lt $${#FORMAT[*]} ]; do \ |
---|
179 | $(ECHO) "$$CPT) $${PRINT[$$CPT]}"; \ |
---|
180 | CPT=$$(($$CPT+1)); \ |
---|
181 | done; \ |
---|
182 | read NUM_FORMAT; \ |
---|
183 | \ |
---|
184 | if $(TEST) "$$NUM_FORMAT" -ge "$$CPT"; then \ |
---|
185 | NUM_FORMAT=0; \ |
---|
186 | fi; \ |
---|
187 | \ |
---|
188 | SELECT_FORMAT=$${FORMAT[$$NUM_FORMAT]}; \ |
---|
189 | SELECT_VIEWER=$${VIEWER[$$NUM_FORMAT]}; \ |
---|
190 | $(ECHO) "Format selected : $$SELECT_FORMAT"; \ |
---|
191 | $(ECHO) ""; \ |
---|
192 | \ |
---|
193 | $$SELECT_VIEWER "$$SELECT_FILE.$$SELECT_FORMAT" & \ |
---|
194 | \ |
---|
195 | $(ECHO) ""; |
---|
196 | |
---|
197 | view_global : all |
---|
198 | @\ |
---|
199 | declare SELECT_FILE; \ |
---|
200 | declare SELECT_FORMAT; \ |
---|
201 | declare SELECT_VIEWER; \ |
---|
202 | \ |
---|
203 | \ |
---|
204 | $(ECHO) ""; \ |
---|
205 | $(ECHO) "Choose a document : (0 by default)"; \ |
---|
206 | \ |
---|
207 | declare -i CPT; \ |
---|
208 | declare -i NUM_FILE; \ |
---|
209 | declare -a FILES; \ |
---|
210 | \ |
---|
211 | CPT=0; \ |
---|
212 | for files in $(wildcard $(DIR_TOPLEVEL_PDF)/*.pdf); do \ |
---|
213 | files=`$(BASENAME) $$files .pdf`; \ |
---|
214 | $(ECHO) "$$CPT) $$files"; \ |
---|
215 | FILES[$$CPT]=$(DIR_TOPLEVEL_PDF)/$$files; \ |
---|
216 | CPT=$$(($$CPT+1)); \ |
---|
217 | done; \ |
---|
218 | \ |
---|
219 | if $(TEST) "$$CPT" -eq "0"; then \ |
---|
220 | $(ECHO) "None document found"; \ |
---|
221 | exit; \ |
---|
222 | fi; \ |
---|
223 | \ |
---|
224 | read NUM_FILE; \ |
---|
225 | \ |
---|
226 | if $(TEST) "$$NUM_FILE" -ge "$$CPT"; then \ |
---|
227 | NUM_FILE=0; \ |
---|
228 | fi; \ |
---|
229 | \ |
---|
230 | SELECT_FILE=$${FILES[$$NUM_FILE]}; \ |
---|
231 | \ |
---|
232 | \ |
---|
233 | $(ECHO) "Document selected : $$SELECT_FILE"; \ |
---|
234 | $(ECHO) ""; \ |
---|
235 | $(ECHO) "Choose a format : (0 by default)"; \ |
---|
236 | \ |
---|
237 | declare -i NUM_FORMAT; \ |
---|
238 | declare -a FORMAT; \ |
---|
239 | declare -a VIEWER; \ |
---|
240 | \ |
---|
241 | PRINT=( "pdf (fullscreen)" "pdf" ); \ |
---|
242 | FORMAT=("pdf" "pdf" ); \ |
---|
243 | VIEWER=("$(VIEWPDF_FS)" "$(VIEWPDF)"); \ |
---|
244 | \ |
---|
245 | CPT=0; \ |
---|
246 | while [ $$CPT -lt $${#FORMAT[*]} ]; do \ |
---|
247 | $(ECHO) "$$CPT) $${PRINT[$$CPT]}"; \ |
---|
248 | CPT=$$(($$CPT+1)); \ |
---|
249 | done; \ |
---|
250 | read NUM_FORMAT; \ |
---|
251 | \ |
---|
252 | if $(TEST) "$$NUM_FORMAT" -ge "$$CPT"; then \ |
---|
253 | NUM_FORMAT=0; \ |
---|
254 | fi; \ |
---|
255 | \ |
---|
256 | SELECT_FORMAT=$${FORMAT[$$NUM_FORMAT]}; \ |
---|
257 | SELECT_VIEWER=$${VIEWER[$$NUM_FORMAT]}; \ |
---|
258 | $(ECHO) "Format selected : $$SELECT_FORMAT"; \ |
---|
259 | $(ECHO) ""; \ |
---|
260 | \ |
---|
261 | $$SELECT_VIEWER "$$SELECT_FILE.$$SELECT_FORMAT" & \ |
---|
262 | \ |
---|
263 | $(ECHO) ""; |
---|
264 | |
---|
265 | |
---|
266 | #-------------------------------------------------------------------------------- |
---|
267 | # Cleaning |
---|
268 | #-------------------------------------------------------------------------------- |
---|
269 | |
---|
270 | clean : local_clean |
---|
271 | @\ |
---|
272 | $(ECHO) "Delete temporary files "$(PWD); \ |
---|
273 | $(RM) $(DIR_SCHEMA_EPS); \ |
---|
274 | $(RM) $(DVI_FILES) $(PS_FILES) $(PDF_FILES); \ |
---|
275 | $(MAKE) clean_rec DIR_CLEAN=$(PWD); |
---|
276 | |
---|
277 | clean_all : clean |
---|
278 | |
---|
279 | #Clean recursive |
---|
280 | clean_rec : |
---|
281 | @\ |
---|
282 | $(ECHO) "Delete temporary files in directory $(DIR_CLEAN)"; \ |
---|
283 | $(RM) $(DIR_CLEAN)/*~ \ |
---|
284 | $(DIR_CLEAN)/*.bak \ |
---|
285 | $(DIR_CLEAN)/*.aux \ |
---|
286 | $(DIR_CLEAN)/*.bbl \ |
---|
287 | $(DIR_CLEAN)/*.blg \ |
---|
288 | $(DIR_CLEAN)/*.bmt \ |
---|
289 | $(DIR_CLEAN)/*.log \ |
---|
290 | $(DIR_CLEAN)/*.mtc* \ |
---|
291 | $(DIR_CLEAN)/*.toc \ |
---|
292 | $(DIR_CLEAN)/*.idx \ |
---|
293 | $(DIR_CLEAN)/*.ilg \ |
---|
294 | $(DIR_CLEAN)/*.ind \ |
---|
295 | $(DIR_CLEAN)/*.out \ |
---|
296 | $(DIR_CLEAN)/*.nav \ |
---|
297 | $(DIR_CLEAN)/*.maf \ |
---|
298 | $(DIR_CLEAN)/*.snm \ |
---|
299 | $(DIR_CLEAN)/missfont.log; \ |
---|
300 | for files in `$(LS) $(DIR_CLEAN)`; do \ |
---|
301 | if $(TEST) -d $(DIR_CLEAN)/$$files; \ |
---|
302 | then \ |
---|
303 | $(MAKE) clean_rec DIR_CLEAN=$(DIR_CLEAN)/$$files; \ |
---|
304 | fi; \ |
---|
305 | done; |
---|
306 | |
---|
307 | #-------------------------------------------------------------------------------- |
---|
308 | # Help |
---|
309 | #-------------------------------------------------------------------------------- |
---|
310 | |
---|
311 | help : |
---|
312 | @\ |
---|
313 | $(ECHO) " -----[ Documentation ]------------------------------";\ |
---|
314 | $(ECHO) ""; \ |
---|
315 | $(ECHO) " * all_documentation : Generate all documents"; \ |
---|
316 | $(ECHO) " * clean : Erase all generated files"; \ |
---|
317 | $(ECHO) " * clean_all : cf clean"; \ |
---|
318 | $(ECHO) " * help : Print this message"; \ |
---|
319 | $(ECHO) " * view : View local documents"; \ |
---|
320 | $(ECHO) " * view_view : View all documents"; \ |
---|
321 | $(ECHO) ""; |
---|