Makefile.am 22.9 KB
Newer Older
1
# Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
2
# Laboratory (LRDE).
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# This file is part of Olena.
#
# Olena is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, version 2 of the License.
#
# Olena is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Olena.  If not, see <http://www.gnu.org/licenses/>.

18

19
# Look for Milena headers in srcdir and for (generated) test headers
20
# (like data.hh) in builddir.
21
AM_CPPFLAGS = -I$(top_srcdir)/milena -I$(top_builddir)/milena
22

Guillaume Lazzara's avatar
Guillaume Lazzara committed
23
DOXYGEN = doxygen
24

25
26
DOXYFILE = Doxyfile

27

28
29
30
31
32
33
34
## --------------------- ##
## LaTeX configuration.  ##
## --------------------- ##

include $(top_srcdir)/build-aux/tex.mk

TEXI2DVI_FLAGS +=							\
Roland Levillain's avatar
Roland Levillain committed
35
36
  -I $(srcdir) -I $(srcdir)/outputs -I $(srcdir)/outputs/split		\
  -I $(srcdir)/img -I $(srcdir)/examples/split
37

Roland Levillain's avatar
Roland Levillain committed
38
39
# Additional files for LaTeX compilations.
DOC_PACKAGES = doxyfuns.sty milena.sty
40
41


42
43
44
45
## --------- ##
## Figures.  ##
## --------- ##

46
# Generate a Makefile helper containing the list of generated figures.
47
EXTRA_DIST = gen-figures-mk
48
49
50
51
52
$(srcdir)/figures.mk: $(srcdir)/gen-figures-mk
	rm -f $@.tmp
	cd $(srcdir) && ./gen-figures-mk >figures.mk.tmp
	mv -f $@.tmp $@
	chmod -w $@
53
include $(srcdir)/figures.mk
54
EXTRA_DIST += $(FIGURES)
55
56
MAINTAINERCLEANFILES = $(FIGURES)

57
58
59
60
61
62
63
.PHONY: regen-figures-mk
regen-figures-mk:
	rm -f $(srcdir)/figures.mk.tmp
	cd $(srcdir) && ./gen-figures-mk >figures.mk.tmp
	mv -f $(srcdir)/figures.mk.tmp $(srcdir)/figures.mk
	chmod -w $(srcdir)/figures.mk

64
65
66
# ------------- #
# PNG figures.  #
# ------------- #
67

68
# PNG figures are generated from PBM, PGM and PPM figures.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

convert_to_png = convert -scale 250 -bordercolor black -border 2x2

SUFFIXES += .pbm .pgm .ppm .png

.pbm.png:
	$(convert_to_png) $< $@

.pgm.png:
	$(convert_to_png) $< $@

.ppm.png:
	$(convert_to_png) $< $@

PNG_FIGURES =					\
  $(PBM_FIGURES:.pbm=.png)			\
  $(PGM_FIGURES:.pgm=.png)			\
  $(PPM_FIGURES:.ppm=.png)
EXTRA_DIST += $(PNG_FIGURES)
88
MAINTAINERCLEANFILES += $(PNG_FIGURES)
89

90
91
92
93
# --------------- #
# Other figures.  #
# --------------- #

94
95
96
97
98
99
100
101
102
103
104
105
TECHNICAL_FIGURES =				\
  figures/technical/file_layout.pdf		\
  figures/technical/file_layout.png
MORE_FIGURES = $(TECHNICAL_FIGURES)

WHITE_PAPER_FIGURES =				\
  $(srcdir)/figures/house.png			\
  $(srcdir)/figures/house_rag.png		\
  $(srcdir)/figures/house_wshed.png		\
  $(srcdir)/figures/house_wshed_mean_colors.png
MORE_FIGURES += $(WHITE_PAPER_FIGURES)

106
# This image seems to be used nowhere.
107
108
MORE_FIGURES += figures/accu_image_morpher_big_picture.pdf

109
110
EXTRA_DIST += $(MORE_FIGURES)

111

112
113
114
115
## ---------- ##
## Examples.  ##
## ---------- ##

116
117
118
# Generate a Makefile helper containing a variable assignment.
EXTRA_DIST += gen-make-variable

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
$(srcdir)/examples.mk: $(srcdir)/gen-make-variable
	rm -f $@.tmp
	$(srcdir)/gen-make-variable EXAMPLES	\
	  `find $(srcdir)/examples -name '*.cc'	\
	     | sed 's,^$(srcdir),\$$(srcdir),'`	\
	  >$@.tmp
	mv -f $@.tmp $@
	chmod -w $@
include $(srcdir)/examples.mk
EXTRA_DIST += $(EXAMPLES)

.PHONY: regen-examples-mk
regen-examples-mk:
	rm -f $(srcdir)/examples.mk.tmp
	$(srcdir)/gen-make-variable EXAMPLES	\
	  `find $(srcdir)/examples -name '*.cc'	\
	     | sed 's,^$(srcdir),\$$(srcdir),'`	\
	  >$(srcdir)/examples.mk.tmp
	mv -f $(srcdir)/examples.mk.tmp $(srcdir)/examples.mk
	chmod -w $(srcdir)/examples.mk

140
141
142
143
144
145
146
147
148
# Examples used in the technical documentation. 
TECHNICAL_EXAMPLES =				\
  examples/devel/dispatch.cc.raw		\
  examples/devel/facade.cc.raw			\
  examples/devel/impl.cc.raw
EXTRA_DIST += $(TECHNICAL_EXAMPLES)

# Non generated examples.
MORE_EXAMPLES =					\
Roland Levillain's avatar
Roland Levillain committed
149
  examples/accu-wrong-instantiation.cc.raw	\
150
151
152
153
154
155
156
  examples/fill-proto.cc.raw			\
  examples/ima2d-restricted-1.cc.raw		\
  examples/ima2d-restricted-2.cc.raw		\
  examples/ima2d-restricted-3.cc.raw		\
  examples/tuto3/fill_non_generic.cc.raw
EXTRA_DIST += $(MORE_EXAMPLES)

157
158
159
160
## ---------------- ##
## Split examples.  ##
## ---------------- ##

161
162
# Generate a Makefile helper handling the generation of split examples.
EXTRA_DIST += gen-split-examples-mk
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
$(srcdir)/split-examples.mk: $(srcdir)/gen-split-examples-mk
	rm -f $@.tmp
	cd $(srcdir) && ./gen-split-examples-mk >split-examples.mk.tmp
	mv -f $@.tmp $@
	chmod -w $@
include $(srcdir)/split-examples.mk
EXTRA_DIST += $(SPLIT_EXAMPLES)
MAINTAINERCLEANFILES += $(SPLIT_EXAMPLES)

.PHONY: regen-split-examples-mk
regen-split-examples-mk:
	rm -f $(srcdir)/split-examples.mk.tmp
	cd $(srcdir) && ./gen-split-examples-mk >split-examples.mk.tmp
	mv -f $(srcdir)/split-examples.mk.tmp $(srcdir)/split-examples.mk
	chmod -w $(srcdir)/split-examples.mk


180
181
182
183
## ----------------------- ##
## Doxygen documentation.  ##
## ----------------------- ##

184
REFMAN_deps =				\
185
  $(PNG_FIGURES)				\
186
187
  $(srcdir)/tutorial.hh				\
  $(srcdir)/ref-guide.hh
188

189
# ----------------------- #
190
# User Reference Manual.  #
191
# ----------------------- #
192

193
all-local: $(srcdir)/$(USER_REFMAN)
194

195
196
197
# Run "make regen-doc" to forcefully rebuild the Doxygen documentation.
.PHONY: regen-doc
regen-doc:
198
	rm -f $(srcdir)/user-refman.stamp
199
	$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/user-refman.stamp
200

201
DOXYFILE_USER = Doxyfile_user
202

Roland Levillain's avatar
Roland Levillain committed
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Sed is used to generate Doxyfile from Doxyfile.in instead of
# configure, because the former is way faster than the latter.
#
## FIXME: This is because, as in TC, we depend on $Id$ from the
## ChangeLog.  Maybe we should depend from something less prone to
## change.  See Bison's build system.
edit = sed -e "s|@ID@|$$Id|"					\
	   -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g'		\
	   -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g'	\
	   -e 's,@top_srcdir\@,$(top_srcdir),g'			\
	   -e 's,@top_builddir\@,$(top_builddir),g'		\
	   -e 's,@srcdir\@,$(srcdir),g'				\
	   -e 's,@builddir\@,$(builddir),g'

$(DOXYFILE_USER): $(srcdir)/$(DOXYFILE).in
	Id=`grep '^\$$Id' $(top_srcdir)/milena/ChangeLog	\
	      | sed -e 's/\\\$$//g'`;				\
	  $(edit) $< >$@
221
MAINTAINERCLEANFILES += $(DOXYFILE_USER)
Roland Levillain's avatar
Roland Levillain committed
222

223
USER_REFMAN = user-refman
224

225
226
227
228
# PDF.
USER_REFMAN_PDF = user-refman.pdf
dist_pdf_DATA = $(srcdir)/$(USER_REFMAN_PDF)

229
230
231
$(srcdir)/$(USER_REFMAN_PDF): $(srcdir)/$(USER_REFMAN)
	cd $(srcdir)/$(USER_REFMAN)/latex && $(MAKE) $(AM_MAKEFLAGS) pdf
	cp -f $(srcdir)/$(USER_REFMAN)/latex/refman.pdf $@
232

233
# HTML.
234
235
EXTRA_DIST += $(srcdir)/user-refman.stamp
MAINTAINERCLEANFILES += $(srcdir)/user-refman.stamp
236
$(srcdir)/user-refman.stamp: $(srcdir)/$(DOXYFILE).in $(REFMAN_deps)
237
238
	@rm -f $@.tmp
	@touch $@.tmp
239
	rm -rf $(USER_REFMAN).tmp
240
241
	$(MAKE) $(AM_MAKE_FLAGS) $(DOXYFILE_USER)
	$(DOXYGEN) $(DOXYFILE_USER)
242
243
## Doxygen may generate an incomplete output and exit with success!
## Check some files before deeming the output as acceptable.
244
	test -f $(USER_REFMAN).tmp/latex/refman.tex
245
	rm -rf $(srcdir)/$(USER_REFMAN)
246
## FIXME: Moving directories between file systems is not portable.
247
	mv $(USER_REFMAN).tmp $(srcdir)/$(USER_REFMAN)
248
249
	@mv -f $@.tmp $@

250
$(srcdir)/$(USER_REFMAN): $(srcdir)/user-refman.stamp
251
## Recover from the removal of $@.
252
253
254
255
256
	@if test -d $@; then :; else \
	  rm -f $<; \
	  $(MAKE) $(AM_MAKEFLAGS) $<; \
	fi

257
258
259
260
261
262
263
264
# Installing a directory located in the source dir is not supported by
# Automake by default, so we cannot simply add `$(USER_REFMAN)/html'
# to `dist_doc_DATA'.  The rule `install-data-local' (see below) used
# to work around this limitation is borrowed from the Vaucanson
# project.
EXTRA_DIST += $(USER_REFMAN)


265
# ---------------------------- #
266
# Developer Reference Manual.  #
267
# ---------------------------- #
268

269
270
271
272
# Run "make regen-devel-doc" to forcefully rebuild the Doxygen
# developer documentation.
.PHONY: regen-devel-doc
regen-devel-doc:
273
	rm -f $(srcdir)/devel-refman.stamp
274
	$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/devel-refman.stamp
275

276
DOXYFILE_DEVEL = Doxyfile_devel
277

Roland Levillain's avatar
Roland Levillain committed
278
edit_devel = sed							      \
279
  -e 's,OUTPUT_DIRECTORY       = @builddir@/user-refman.tmp/,OUTPUT_DIRECTORY       = @builddir@/devel-refman.tmp/,' \
Roland Levillain's avatar
Roland Levillain committed
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
  -e 's,EXTRACT_ALL            = NO,EXTRACT_ALL            = YES,'	      \
  -e 's,EXTRACT_PRIVATE        = NO,EXTRACT_PRIVATE        = YES,'	      \
  -e 's,EXTRACT_STATIC         = NO,EXTRACT_STATIC         = YES,'	      \
  -e 's,EXTRACT_LOCAL_CLASSES  = NO,EXTRACT_LOCAL_CLASSES  = YES,'	      \
  -e 's,HIDE_UNDOC_MEMBERS     = YES,HIDE_UNDOC_MEMBERS     = NO,'	      \
  -e 's,HIDE_UNDOC_CLASSES     = YES,HIDE_UNDOC_CLASSES     = NO,'	      \
  -e 's,HIDE_FRIEND_COMPOUNDS  = YES,HIDE_FRIEND_COMPOUNDS  = NO,'	      \
  -e 's,HIDE_IN_BODY_DOCS      = YES,HIDE_IN_BODY_DOCS      = NO,'	      \
  -e 's,INTERNAL_DOCS          = NO,INTERNAL_DOCS          = YES,'	      \
  -e 's,GENERATE_TODOLIST      = NO,GENERATE_TODOLIST      = YES,'	      \
  -e 's,PROJECT_NUMBER         = \"User documentation ,PROJECT_NUMBER         = \",'	 \
  -e 's,EXCLUDE_SYMBOLS	       = \*::internal\* \*_ mln::trait::\*,EXCLUDE_SYMBOLS	       =,'

$(DOXYFILE_DEVEL): $(srcdir)/$(DOXYFILE).in
	rm -f $@.tmp
	Id=`grep '^\$$Id' $(top_srcdir)/milena/ChangeLog	\
	      | sed -e 's/\\\$$//g'`;				\
	  $(edit) $< >$@.tmp
	$(edit_devel) $@.tmp >$@
	rm -f $@.tmp
300
MAINTAINERCLEANFILES += $(DOXYFILE_DEVEL)
Roland Levillain's avatar
Roland Levillain committed
301

302
DEVEL_REFMAN = devel-refman
303

304
305
# PDF.
DEVEL_REFMAN_PDF = devel-refman.pdf
306
307
308
309
310
311
# Be warned, most LaTeX installations will not be able to compile the
# PDF development documentation as-is, as TeX's default memory
# capacities are usually too small to handle such a large document.
$(srcdir)/$(DEVEL_REFMAN_PDF): $(srcdir)/$(DEVEL_REFMAN)
	cd $(srcdir)/$(DEVEL_REFMAN)/latex && $(MAKE) $(AM_MAKEFLAGS) pdf
	cp -f $(srcdir)/$(DEVEL_REFMAN)/latex/refman.pdf $@
312

313
# HTML.
314
MAINTAINERCLEANFILES += $(srcdir)/devel-refman.stamp
315
$(srcdir)/devel-refman.stamp: $(srcdir)/$(DOXYFILE).in $(REFMAN_deps)
316
317
	@rm -f $@.tmp
	@touch $@.tmp
318
	rm -rf $(DEVEL_REFMAN).tmp
319
320
	$(MAKE) $(AM_MAKE_FLAGS) $(DOXYFILE_DEVEL)
	$(DOXYGEN) $(DOXYFILE_DEVEL)
321
322
## Doxygen may generate an incomplete output and exit with success!
## Check some files before deeming the output as acceptable.
323
	test -f $(DEVEL_REFMAN).tmp/latex/refman.tex
324
	rm -rf $(srcdir)/$(DEVEL_REFMAN)
325
## FIXME: Moving directories between file systems is not portable.
326
	mv $(DEVEL_REFMAN).tmp $(srcdir)/$(DEVEL_REFMAN)
327
328
	@mv -f $@.tmp $@

329
$(srcdir)/$(DEVEL_REFMAN): $(srcdir)/devel-refman.stamp
330
## Recover from the removal of $@.
331
332
333
334
335
336
	@if test -d $@; then :; else \
	  rm -f $<; \
	  $(MAKE) $(AM_MAKEFLAGS) $<; \
	fi


337
## ------------------------- ##
338
## Technical documentation.  ##
339
340
## ------------------------- ##

341
EXTRA_DIST += technical.tex
342

343
344
TECHNICAL_deps =				\
  $(TECHNICAL_FIGURES)				\
Roland Levillain's avatar
Roland Levillain committed
345
346
347
  $(TECHNICAL_EXAMPLES)				\
  $(PNG_FIGURES)				\
  $(DOC_PACKAGES)
348

349
350
351
352
# PDF.
TECHNICAL_PDF = $(srcdir)/technical.pdf
dist_pdf_DATA += $(TECHNICAL_PDF)
$(TECHNICAL_PDF): $(TECHNICAL_deps)
353

354
355
356
357
358
359
360
361
# HTML.
TECHNICAL = technical
all-local: $(srcdir)/$(TECHNICAL).stamp
# The HTML output contains several files (the HTML file itself, its
# CSS style sheet, possibly some images).  Therefore, we cannot rely
# on a simple suffix rule to produce them.  Instead, put the products
# in a directory and use a time stamp.
$(srcdir)/$(TECHNICAL).stamp: $(srcdir)/technical.tex $(TECHNICAL_deps)
362
363
	@rm -f $@.tmp
	@touch $@.tmp
364
365
366
367
368
369
370
	rm -rf $(TECHNICAL).tmp
	mkdir $(TECHNICAL).tmp
	$(TEXI2HTML) $(TEXI2HTML_FLAGS) \
	  -o $(TECHNICAL).tmp/$(TECHNICAL).html $<
	rm -rf $(srcdir)/$(TECHNICAL)
## FIXME: moving directories between file systems is not portable.
	mv $(TECHNICAL).tmp $(srcdir)/$(TECHNICAL)
371
	@mv -f $@.tmp $@
372
373
EXTRA_DIST += $(srcdir)/$(TECHNICAL).stamp
MAINTAINERCLEANFILES += $(srcdir)/$(TECHNICAL).stamp
374

375
376
377
$(srcdir)/$(TECHNICAL): $(srcdir)/$(TECHNICAL).stamp
## Recover from the removal of $@.
	@if test -d $@; then :; else \
378
379
380
	  rm -f $<; \
	  $(MAKE) $(AM_MAKEFLAGS) $<; \
	fi
381
DATA_html_dirs = $(TECHNICAL)
382

383

384
385
386
387
## ---------- ##
## Tutorial.  ##
## ---------- ##

388
EXTRA_DIST += tutorial.tex
389

390
TUTORIAL_deps =					\
Roland Levillain's avatar
Roland Levillain committed
391
  $(EXAMPLES)					\
392
  $(SPLIT_EXAMPLES)				\
Roland Levillain's avatar
Roland Levillain committed
393
  $(OUTPUTS)					\
394
  $(SPLIT_OUTPUTS)				\
Roland Levillain's avatar
Roland Levillain committed
395
396
  $(PNG_FIGURES)				\
  $(DOC_PACKAGES)
397

398
399
400
401
# PDF.
TUTORIAL_PDF = $(srcdir)/tutorial.pdf
dist_pdf_DATA += $(TUTORIAL_PDF)
$(TUTORIAL_PDF): $(TUTORIAL_deps)
402

403
404
405
406
407
408
409
410
411
# HTML.
TUTORIAL = tutorial
all-local: $(srcdir)/$(TUTORIAL).stamp

# The HTML output contains several files (the HTML file itself, its
# CSS style sheet, possibly some images).  Therefore, we cannot rely
# on a simple suffix rule to produce them.  Instead, put the products
# in a directory and use a time stamp.
$(srcdir)/$(TUTORIAL).stamp: $(srcdir)/tutorial.tex $(TUTORIAL_deps)
412
413
	@rm -f $@.tmp
	@touch $@.tmp
414
415
416
417
418
419
420
	rm -rf $(TUTORIAL).tmp
	mkdir $(TUTORIAL).tmp
	$(TEXI2HTML) $(TEXI2HTML_FLAGS)			\
	  -o $(TUTORIAL).tmp/$(TUTORIAL).html $<
	rm -rf $(srcdir)/$(TUTORIAL)
## FIXME: moving directories between file systems is not portable.
	mv $(TUTORIAL).tmp $(srcdir)/$(TUTORIAL)
421
	@mv -f $@.tmp $@
422
423
EXTRA_DIST += $(srcdir)/$(TUTORIAL).stamp
MAINTAINERCLEANFILES += $(srcdir)/$(TUTORIAL).stamp
424

425
426
427
$(srcdir)/$(TUTORIAL): $(srcdir)/$(TUTORIAL).stamp
## Recover from the removal of $@.
	@if test -d $@; then :; else \
428
429
430
	  rm -f $<; \
	  $(MAKE) $(AM_MAKEFLAGS) $<; \
	fi
431
DATA_html_dirs += $(TUTORIAL)
432

433
# Intermediate product for the (Doxygen) User Reference Manual.
434
435
436
437
#
# This is not a bug: TUTORIAL_HH is meant to have a `.hh' extension,
# since it is later parsed by Doxygen, which complains about `.html'
# files.
438
439
TUTORIAL_HH = $(srcdir)/tutorial.hh
$(TUTORIAL_HH): $(srcdir)/$(TUTORIAL).stamp $(srcdir)/tools/todoxygen.sh
440
441
442
443
444
# The script `todoxygen.sh' may fail and still create a (partial and
# invalid) file, thus preventing Make from trying to generate it
# again.  The solution is to use a temporary file as output and rename
# it if the script succeeds.
	rm -f $@.tmp
445
446
	$(srcdir)/tools/todoxygen.sh					\
	  $(srcdir)/$(TUTORIAL)/$(TUTORIAL).html $@.tmp $(srcdir)
447
	mv -f $@.tmp $@
448
EXTRA_DIST += $(TUTORIAL_HH)
449
MAINTAINERCLEANFILES += $(TUTORIAL_HH)
450

451

452
453
454
455
## ------------- ##
## White Paper.  ##
## ------------- ##

456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
EXTRA_DIST += white-paper.tex graphicx.hva

WHITE_PAPER_deps =				\
  $(WHITE_PAPER_FIGURES)			\
  graphicx.hva

# PDF.
WHITE_PAPER_PDF = $(srcdir)/white-paper.pdf
dist_pdf_DATA += $(WHITE_PAPER_PDF)
$(WHITE_PAPER_PDF): $(WHITE_PAPER_deps)

# HTML.
WHITE_PAPER = white-paper
all-local: $(srcdir)/$(WHITE_PAPER).stamp

# The HTML output contains several files (the HTML file itself, its
# CSS style sheet, possibly some images).  Therefore, we cannot rely
# on a simple suffix rule to produce them.  Instead, put the products
# in a directory and use a time stamp.
$(srcdir)/$(WHITE_PAPER).stamp: $(srcdir)/white-paper.tex $(WHITE_PAPER_deps)
476
477
	@rm -f $@.tmp
	@touch $@.tmp
478
479
480
481
482
483
484
485
486
487
	rm -rf $(WHITE_PAPER).tmp
	mkdir $(WHITE_PAPER).tmp
## Copy images.
	mkdir $(WHITE_PAPER).tmp/figures
	cp $(WHITE_PAPER_FIGURES) $(WHITE_PAPER).tmp/figures
	$(TEXI2HTML) $(TEXI2HTML_FLAGS)			\
	  -o $(WHITE_PAPER).tmp/$(WHITE_PAPER).html $<
	rm -rf $(srcdir)/$(WHITE_PAPER)
## FIXME: moving directories between file systems is not portable.
	mv $(WHITE_PAPER).tmp $(srcdir)/$(WHITE_PAPER)
488
	@mv -f $@.tmp $@
489
490
EXTRA_DIST += $(srcdir)/$(WHITE_PAPER).stamp
MAINTAINERCLEANFILES += $(srcdir)/$(WHITE_PAPER).stamp
491

492
493
494
$(srcdir)/$(WHITE_PAPER): $(srcdir)/$(WHITE_PAPER).stamp
## Recover from the removal of $@.
	@if test -d $@; then :; else \
495
496
497
	  rm -f $<; \
	  $(MAKE) $(AM_MAKEFLAGS) $<; \
	fi
498
DATA_html_dirs += $(WHITE_PAPER)
499

500

501
502
503
504
## ----------------- ##
## Reference Guide.  ##
## ----------------- ##

505
EXTRA_DIST += ref-guide.tex
506

507
REF_GUIDE_deps =				\
Roland Levillain's avatar
Roland Levillain committed
508
  $(EXAMPLES)					\
509
  $(SPLIT_EXAMPLES)				\
Roland Levillain's avatar
Roland Levillain committed
510
  $(OUTPUTS)					\
511
  $(SPLIT_OUTPUTS)				\
Roland Levillain's avatar
Roland Levillain committed
512
513
  $(PNG_FIGURES)				\
  $(DOC_PACKAGES)
514

515
516
517
518
519
520
521
522
523
524
525
526
527
528
# PDF.
REF_GUIDE_PDF = $(srcdir)/ref-guide.pdf
dist_pdf_DATA += $(REF_GUIDE_PDF)
$(REF_GUIDE_PDF): $(REF_GUIDE_deps)

# HTML.
REF_GUIDE = ref-guide
all-local: $(srcdir)/$(REF_GUIDE).stamp

# The HTML output contains several files (the HTML file itself, its
# CSS style sheet, possibly some images).  Therefore, we cannot rely
# on a simple suffix rule to produce them.  Instead, put the products
# in a directory and use a time stamp.
$(srcdir)/$(REF_GUIDE).stamp: $(srcdir)/ref-guide.tex $(REF_GUIDE_deps)
529
530
	@rm -f $@.tmp
	@touch $@.tmp
531
532
533
534
535
536
537
	rm -rf $(REF_GUIDE).tmp
	mkdir $(REF_GUIDE).tmp
	$(TEXI2HTML) $(TEXI2HTML_FLAGS)			\
	  -o $(REF_GUIDE).tmp/$(REF_GUIDE).html $<
	rm -rf $(srcdir)/$(REF_GUIDE)
## FIXME: moving directories between file systems is not portable.
	mv $(REF_GUIDE).tmp $(srcdir)/$(REF_GUIDE)
538
	@mv -f $@.tmp $@
539
540
EXTRA_DIST += $(srcdir)/$(REF_GUIDE).stamp
MAINTAINERCLEANFILES += $(srcdir)/$(REF_GUIDE).stamp
541

542
543
544
$(srcdir)/$(REF_GUIDE): $(srcdir)/$(REF_GUIDE).stamp
## Recover from the removal of $@.
	@if test -d $@; then :; else \
545
546
547
	  rm -f $<; \
	  $(MAKE) $(AM_MAKEFLAGS) $<; \
	fi
548
DATA_html_dirs += $(REF_GUIDE)
549

550
# Intermediate product for the (Doxygen) User Reference Manual.
551
552
553
554
#
# This is not a bug: REF_GUIDE_HH is meant to have a `.hh' extension,
# since it is later parsed by Doxygen, which complains about `.html'
# files.
555
556
REF_GUIDE_HH = $(srcdir)/ref-guide.hh
$(REF_GUIDE_HH): $(srcdir)/$(REF_GUIDE).stamp $(srcdir)/tools/todoxygen.sh
557
558
559
560
561
# The script `todoxygen.sh' may fail and still create a (partial and
# invalid) file, thus preventing Make from trying to generate it
# again.  The solution is to use a temporary file as output and rename
# it if the script succeeds.
	rm -f $@.tmp
562
563
	$(srcdir)/tools/todoxygen.sh \
	  $(srcdir)/$(REF_GUIDE)/$(REF_GUIDE).html $@.tmp $(srcdir)
564
	mv -f $@.tmp $@
565
EXTRA_DIST += $(REF_GUIDE_HH)
566
MAINTAINERCLEANFILES += $(REF_GUIDE_HH)
Guillaume Lazzara's avatar
Guillaume Lazzara committed
567
568


569
## ---------- ##
570
## Programs.  ##
571
572
## ---------- ##

573
include $(srcdir)/programs-examples.mk
574
EXTRA_PROGRAMS = $(PROGRAMS_examples)
575
CLEANFILES = $(PROGRAMS_examples)
576

577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
## --------- ##
## Outputs.  ##
## --------- ##

$(srcdir)/outputs.mk: $(srcdir)/gen-make-variable
	rm -f $@.tmp
# Ignore sources in examples/trash/.
	$(srcdir)/gen-make-variable OUTPUTS				\
	  `find $(srcdir)/examples					\
               -name \*.cc -a \! -path $(srcdir)/examples/trash/\*	\
	     | sed -e 's,$(srcdir)/examples/,,'				\
	           -e 'y,/,_,'						\
	           -e 's,\(.*\)\.cc$$,$$(srcdir)/outputs/\1.txt,'`	\
	  >$@.tmp
	mv -f $@.tmp $@
	chmod -w $@
include $(srcdir)/outputs.mk
EXTRA_DIST += $(OUTPUTS)
MAINTAINERCLEANFILES += $(OUTPUTS)

.PHONY: regen-outputs-mk
regen-outputs-mk:
	rm -f $(srcdir)/outputs.mk.tmp
# Ignore sources in examples/trash/.
	$(srcdir)/gen-make-variable OUTPUTS				\
	  `find $(srcdir)/examples					\
               -name \*.cc -a \! -path $(srcdir)/examples/trash/\*	\
	     | sed -e 's,$(srcdir)/examples/,,'				\
	           -e 'y,/,_,'						\
	           -e 's,\(.*\)\.cc$$,$$(srcdir)/outputs/\1.txt,'`	\
	  >$(srcdir)/outputs.mk.tmp
	mv -f $(srcdir)/outputs.mk.tmp $(srcdir)/outputs.mk
	chmod -w $(srcdir)/outputs.mk
610

611
612
613
## These outputs are also required by the (LaTeX) documentation.
## However, they have no corresponding program in examples/, hence
## they cannot be regenerated.
614
615
616
617
618
619
620
621
MORE_OUTPUTS =					\
  $(srcdir)/outputs/graph-output-1.txt		\
  $(srcdir)/outputs/ima2d-display-1.txt		\
  $(srcdir)/outputs/ima2d-display-2.txt		\
  $(srcdir)/outputs/ima2d-display-output-1.txt	\
  $(srcdir)/outputs/ima2d-display-output-2.txt	\
  $(srcdir)/outputs/parray-display-1.txt	\
  $(srcdir)/outputs/win-create-1-display.txt
Roland Levillain's avatar
Roland Levillain committed
622
EXTRA_DIST += $(MORE_OUTPUTS)
623

624
# Generate a Makefile helper containing outputs rules and timestamps.
625
626
EXTRA_DIST += gen-examples-outputs-mk

627
628
629
630
631
632
633
634
$(srcdir)/examples-outputs.mk: $(srcdir)/gen-examples-outputs-mk
	rm -f $@.tmp
# Ignore sources in examples/trash/.
	cd $(srcdir) &&							\
	  ./gen-examples-outputs-mk					\
	    `find examples -name \*.cc -a \! -path examples/trash/\*	\
	       | env LC_ALL=C sort`					\
	    >examples-outputs.mk.tmp
635
636
	mv -f $@.tmp $@
	chmod -w $@
637
include $(srcdir)/examples-outputs.mk
638

639
640
.PHONY: regen-examples-outputs-mk
regen-examples-outputs-mk:
641
642
643
644
645
646
647
648
	rm -f $(srcdir)/examples-outputs.mk.tmp
	cd $(srcdir) &&							\
	  ./gen-examples-outputs-mk					\
	    `find examples -name \*.cc -a \! -path examples/trash/\*	\
	       | env LC_ALL=C sort`					\
	    >examples-outputs.mk.tmp
	mv -f $(srcdir)/examples-outputs.mk.tmp $(srcdir)/examples-outputs.mk
	chmod -w $(srcdir)/examples-outputs.mk
649

650
651
652
## --------------- ##
## Split outputs.  ##
## --------------- ##
653

654
655
# Generate a Makefile helper handling the generation of split outputs.
EXTRA_DIST += gen-split-outputs-mk
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
$(srcdir)/split-outputs.mk: $(srcdir)/gen-split-outputs-mk
	rm -f $@.tmp
	cd $(srcdir) && ./gen-split-outputs-mk >split-outputs.mk.tmp
	mv -f $@.tmp $@
	chmod -w $@
include $(srcdir)/split-outputs.mk
EXTRA_DIST += $(SPLIT_OUTPUTS)
MAINTAINERCLEANFILES += $(SPLIT_OUTPUTS)

.PHONY: regen-split-outputs-mk
regen-split-outputs-mk:
	rm -f $(srcdir)/split-outputs.mk.tmp
	cd $(srcdir) && ./gen-split-outputs-mk >split-outputs.mk.tmp
	mv -f $(srcdir)/split-outputs.mk.tmp $(srcdir)/split-outputs.mk
	chmod -w $(srcdir)/split-outputs.mk
671

672

673
674
675
676
## -------------- ##
## Regeneration.  ##
## -------------- ##

677
# Regen Make helpers.
678
EXTRA_DIST += generate_dist_files.sh
679
680
include $(top_srcdir)/build-aux/regen-recursive.mk
regen-am:
681
	$(MAKE) $(AM_MAKEFLAGS) regen-figures-mk
682
	$(MAKE) $(AM_MAKEFLAGS) regen-examples-mk
683
	$(MAKE) $(AM_MAKEFLAGS) regen-split-examples-mk
684
	$(MAKE) $(AM_MAKEFLAGS) regen-outputs-mk
685
	$(MAKE) $(AM_MAKEFLAGS) regen-examples-outputs-mk
686
	$(MAKE) $(AM_MAKEFLAGS) regen-split-outputs-mk
Guillaume Lazzara's avatar
Guillaume Lazzara committed
687

688

689
## -------------- ##
690
## Distribution.  ##
691
692
## -------------- ##

Roland Levillain's avatar
Roland Levillain committed
693
EXTRA_DIST +=					\
694
  $(DATA_html_dirs)				\
695
  $(DOXYFILE).in				\
696
697
698
699
700
701
702
703
704
705
  groups/accu.hh				\
  groups/graph.hh				\
  groups/images.hh				\
  groups/main.hh				\
  groups/neighb.hh				\
  groups/site_set.hh				\
  groups/util.hh				\
  groups/win.hh					\
  img/small-enlarged.png			\
  img/small.png					\
Roland Levillain's avatar
Roland Levillain committed
706
707
708
709
710
  doxyfuns.sty					\
  milena.sty					\
  tools/clearbanner.sh				\
  tools/sample_utils.hh				\
  tools/split_sample.sh				\
711
  tools/todoxygen.sh
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760


## ---------- ##
## Cleaning.  ##
## ---------- ##

MAINTAINERCLEANFILES += $(dist_pdf_DATA)

maintainer-clean-local:
	-rm -rf $(USER_REFMAN).tmp $(srcdir)/$(USER_REFMAN)
	-rm -rf $(DEVEL_REFMAN).tmp $(srcdir)/$(DEVEL_REFMAN)
	-for d in $(DATA_html_dirs); do		\
	  rm -rf $$d.tmp $(srcdir)/$$d;		\
	done


## -------------- ##
## Installation.  ##
## -------------- ##

# We install by hand, otherwise Automake produces "install .../srcdoc
# .../srcdoc", which installs our dir into the previous one, instead
# of replacing it.
install-data-local:
	$(mkdir_p) $(DESTDIR)$(htmldir)
# The user reference manual is located in a subdirectory, hence this
# special case.
	rm -rf $(DESTDIR)$(htmldir)/$(USER_REFMAN)
	cp -r $(srcdir)/$(USER_REFMAN)/html $(DESTDIR)$(htmldir)/$(USER_REFMAN)
# Other HTML directories can be processed uniformly.
	for d in $(DATA_html_dirs); do			\
	  rm -rf $(DESTDIR)$(htmldir)/$$d;		\
	  cp -r $(srcdir)/$$d $(DESTDIR)$(htmldir);	\
	done
## Try GNU chmod's X mode before resorting to something slower but
## more standard.
	chmod -R a+rX $(DESTDIR)$(htmldir) || \
	find $(DESTDIR)$(htmldir) \( -type d -a -exec chmod a+rx {} \; \) \
             -o -exec chmod a+r {} \;

uninstall-local:
	for d in $(DATA_html_dirs); do			\
	  chmod -R 700 $(DESTDIR)$(htmldir)/$$d;	\
	  rm -rf $(DESTDIR)$(htmldir)/$$d;		\
	done
# Same remark as above regarding the special case of the user
# reference manual.
	chmod -R 700 $(DESTDIR)$(htmldir)/$(USER_REFMAN)
	rm -rf $(DESTDIR)$(htmldir)/$(USER_REFMAN)