File: Makefile

package info (click to toggle)
ale 0.9.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,260 kB
  • sloc: cpp: 21,826; sh: 10,106; xml: 4,129; ansic: 2,343; makefile: 565; perl: 454; exp: 319
file content (829 lines) | stat: -rw-r--r-- 29,377 bytes parent folder | download | duplicates (5)
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
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
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
#
# Makefile modified by David Hilvert to generate ALE documentation.
# 24-Sep-2006
#

# $Source$
# $Author: xmldoc $
# $Date: 2006-09-01 15:47:16 +0900 (Fri, 01 Sep 2006) $
# $Revision: 6235 $
# vim: number
#
# -----------------------------------------------------------------
#  ** Makefile.DocBook -- generate output from DocBook sources **
# -----------------------------------------------------------------
#
#   This file is part of the DocBook Project XSL Stylesheet
#   distribution.
#
#   See http://docbook.sourceforge.net/release/xsl/current/
#   for copyright and other information.

# DOCBOOK_OUTPUT_FORMATS is the default set of targets (output
# formats) that get built when you type "make" without any targets
# explicitly specified. To generate a different set of output
# formats, change the value of DOCBOOK_OUTPUT_FORMATS here or set
# it in your environment; for example:
#
#   set DOCBOOK_OUTPUT_FORMATS="html pdf"; export DOCBOOK_OUTPUT_FORMATS
#
# Of course by explicitly specifying particular targets when you
# invoke "make", you can always override generation of the default
# set of targets; for example:
#
#   make html txt
#
# That would generate just HTML (unchunked) and plain-text output.
#
DOCBOOK_OUTPUT_FORMATS ?= man chunk txt pdf info

# If you want XHTML output instead of HTML, set HTML_OR_XHTML to
# 'xhtml' or just specify 'xhtml" in DOCBOOK_OUTPUT_FORMATS.
ifeq ($(findstring xhtml,$(DOCBOOK_OUTPUT_FORMATS)),)
HTML_OR_XHTML ?= html
else
HTML_OR_XHTML ?= xhtml
endif

# -----------------------------------------------------------------
#                *** TOOLS and other DEPENDENCIES ***
# -----------------------------------------------------------------
# we use rmdir(1) to remove dirs we create for chunked HTML output
RMDIR = rmdir
# "-p" causes empty parent dirs to be deleted as well
RMDIR_FLAGS = --ignore-fail-on-non-empty -p

# possible values for PDF_MAKER are:
#   dblatex|fop|xep|xmlroff|passivetex
PDF_MAKER = fop

# possible values for TXT_MAKER are:
#   links|lynx|w3m|w3mmee
TXT_MAKER = links
TXT_MAKER_FLAGS = -dump

# xsl
XSLT = xsltproc
XSLT_FLAGS = --xinclude

# http://dblatex.sourceforge.net/
DBLATEX = dblatex
DBLATEX_FLAGS = -b pdftex -P page.margin.inner=0.8 -P page.margin.outer=0.5 -P double.sided=1 -T db2latex

FOP = fop
FOP_FLAGS =

XEP = xep
XEP_FLAGS =

# http://xmlroff.sourceforge.net/
XMLROFF = xmlroff
XMLROFF_FLAGS =

PDFTEX = pdftex
PDFTEX_FLAGS =

# used by PassiveTeX
PDFXMLTEX = pdfxmltex

# http://docbook2x.sourceforge.net/
DB2X_XSLTPROC = db2x_xsltproc
DB2X_XSLTPROC_FLAGS = --xinclude
DB2X_TEXIXML = db2x_texixml --list-files
DB2X_TEXIXML_FLAGS = 

# we call the man(1) command to generate "foo.N.pdf" and
# "foo.N.txt" output (see "man-pdf" & "man-txt" targets)
MAN = man
MAN_FLAGS =

# The "ps2pdf" command is part of GhostSript (gs) distro.
# It is just a wrapper script around gs that does this:
#
#   gs -dCompatibilityLevel=1.2 -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
#     "-sOutputFile=$outfile" -dCompatibilityLevel=1.2 -c .setpdfwrite -f "$infile"
#
# Where, for example: $outfile = foo.pdf and $infile = foo.1
PS2PDF = ps2pdf
PS2PDF_FLAGS =

# The "col" command is needed for stripping backspaces and
# underscores from man(1) output to get pure plain-text
COL = col
COL_FLAGS =

# The "expand" command is needed for expanding tabs from files
# generated from "man foo.1 | col -b" output
# output to get pure plain-text
EXPAND = expand
EXPAND_FLAGS =

# value of DOCBOOK_XSL should either be the canonical
# (docbook.sourceforge.net) URL for the DocBook Project XSL
# stylesheets OR it can be a local system path
DOCBOOK_XSL = http://docbook.sourceforge.net/release/xsl/current

# -----------------------------------------------------------------
#       names of some DIRECTORIES and FILES we need
# -----------------------------------------------------------------
# We create a tmp directory once per make invocation; it's needed
# for holding a temporary copy of the custom DBLaTeX stylesheet
# (because dblatex currently can't read a stylesheet from stdin)
TMP ?= /tmp
TMPNUM := $(shell echo $$$$)
DOCBOOK_TMP := $(TMP)/docbook-make-$(TMPNUM)

# MAN_MANIFEST_EXT is file extension added to individual manifest
# files
MAN_MANIFEST_EXT = manifest_man

# HTML_MANIFEST_EXT is file extension added to HTML manifest files
HTML_MANIFEST_EXT = manifest_html

# BASEDIR_SUFFIX is a what you need to set if you want a suffix
# added to the end of each "base.dir" we create while generating
# chunked HTML output
#BASEDIR_SUFFIX = -html
#BASEDIR_SUFFIX = _html
BASEDIR_SUFFIX = 

#
# Workaround the fact that we don't calculate dependencies.
#

BROKEN_DEPENDENCIES = package/changelog/index.in $(shell find . -name "*.xml") package/changelog/index.xml make-changelog Makefile


# -----------------------------------------------------------------
#                        assorted OPTIONS
# -----------------------------------------------------------------
# HTML_STYLESHEET -> $html.stylesheet stylesheet param
# http://docbook.sourceforge.net/snapshots/xsl/doc/html/html.stylesheet.html
HTML_STYLESHEET = style.css
# HTML_IMAGES -> $admon.graphics.path
# http://docbook.sourceforge.net/snapshots/xsl/doc/html/admon.graphics.path.html
HTML_IMAGES = images/
# HTML_IMAGES_EXT -> $admon.graphics.extension
# http://docbook.sourceforge.net/snapshots/xsl/doc/html/admon.graphics.extension.html
HTML_IMAGES_EXT = .png

# use these to set params on the command-line
# format is, e.g., HTML_PARAMS="--stringparam variablelist.as.table 1..."
FO_PARAMS =
HTML_PARAMS =
MAN_PARAMS =

# DBX_PARAMS is for dblatex(1); format uses "-p":
# DBX_PARAMS="-p doc.publisher.show 1 -p term.breakline 1...
DBX_PARAMS=

# What file extension do you use for DocBook source files?
DOCBOOK_FILE_EXTENSION = .docbook
SOURCE_FILE_EXTENSION = .xml

# -----------------------------------------------------------------
#       make(1) functions for building file lists
# -----------------------------------------------------------------
#
#    the values of the following are used for determing what needs
#    to be built and/or cleaned up

SOURCE_FILES_DBK = $(wildcard *$(SOURCE_FILE_EXTENSION))

FILES_FO   = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).fo)
FILES_TXT  = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).txt)
FILES_PDF  = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).pdf)
FILES_LOG  = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).log)
FILES_OUT  = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).out)
FILES_AUX  = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).aux)
FILES_HTML = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).html)
FILES_INFO = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).info)
DIRS_CHUNK = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base)$(BASEDIR_SUFFIX))
LISTS_HTML = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).$(HTML_MANIFEST_EXT))
LISTS_MAN  = $(foreach base,$(basename $(SOURCE_FILES_DBK)),$(base).$(MAN_MANIFEST_EXT))
FILES_CHNK = $(shell for manifest in $(LISTS_HTML); do if [ -f "$$manifest" ]; then cat $$manifest; fi done)
FILES_MAN  = $(shell for manifest in $(LISTS_MAN);  do if [ -f "$$manifest" ]; then cat $$manifest; fi done)
FILES_MANP = $(foreach base,$(FILES_MAN),$(base).pdf)
FILES_MANT = $(foreach base,$(FILES_MAN),$(base).txt)
DIRS_MAN   = $(shell for file in $(FILES_MAN); do dirname $$file; done | uniq)

# -----------------------------------------------------------------
#   ** stylesheet for testing whether a file has a refentry
# -----------------------------------------------------------------
REFENTRY_CHECK := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
                version="1.0" \
                xmlns:db="http://docbook.org/ns/docbook" \
                > \
  <xsl:output method="text"/> \
  <xsl:template match="/"> \
    <xsl:if test="//refentry|//db:refentry"> \
      <xsl:text>true</xsl:text> \
    </xsl:if> \
  </xsl:template> \
</xsl:stylesheet>

# -----------------------------------------------------------------
#             ** Stylesheet Customization Layers ** 
# -----------------------------------------------------------------
#
# for DBLaTeX
DBX_CUSTOM := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
                 version="1.0"> \
  <xsl:param name="co.linkends.show">0</xsl:param> \
  <xsl:param name="callout.markup.circled">1</xsl:param> \
  <xsl:param name="callout.linkends.hot">0</xsl:param> \
  <xsl:param name="doc.publisher.show">1</xsl:param> \
  <xsl:param name="term.breakline">1</xsl:param> \
  <xsl:param name="doc.alignment">left</xsl:param> \
  <xsl:param name="newtbl.use">1</xsl:param> \
  <xsl:param name="latex.hyperparam"/> \
  <xsl:param name="latex.style">docbook</xsl:param> \
  <xsl:param name="latex.biblio.output">all</xsl:param> \
  <xsl:param name="latex.bibfiles">""</xsl:param> \
  <xsl:param name="latex.bibwidelabel">WIDELABEL</xsl:param> \
  <xsl:param name="latex.output.revhistory">0</xsl:param> \
  <xsl:param name="latex.figure.position">[htbp]</xsl:param> \
  <xsl:param name="latex.figure.boxed">0</xsl:param> \
  <xsl:param name="latex.babel.use">1</xsl:param> \
  <xsl:param name="latex.babel.language"></xsl:param> \
  <xsl:param name="latex.class.options">twoside</xsl:param> \
  <xsl:param name="biblioentry.item.separator">, </xsl:param> \
  <xsl:param name="refentry.xref.manvolnum">1</xsl:param> \
  <xsl:param name="refsynopsis.title">Synopsis</xsl:param> \
  <xsl:param name="refnamediv.title"></xsl:param> \
  <xsl:param name="funcsynopsis.style">ansi</xsl:param> \
  <xsl:param name="funcsynopsis.decoration">1</xsl:param> \
  <xsl:param name="function.parens">0</xsl:param> \
  <xsl:param name="classsynopsis.default.language">java</xsl:param> \
  <xsl:param name="show.comments">0</xsl:param> \
</xsl:stylesheet>

# for FO output

#
# NOTE: The following changes may be required to the stock docbook stylesheets
# for double-sided output:
#
# In /usr/share/xml/docbook/stylesheet/nwalsh/fo:
#
# 	o Add '<xsl:attribute name="margin-left">0pc</xsl:attribute>'
#	  to the template 'footer.table'.  This fixes number positioning in
#	  double-sided output.
#	o In the test for generating 'section.head.marker', change
#	  the test '$double-sided != 0' to read '$double-sided > 1'.
#	  This disables section-name headings in favor of chapter-name
#	  headings.
#
#	--dhilvert@auricle.dyndns.org, 12-Oct-2006
#
FO_CUSTOM := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
                xmlns:fo="http://www.w3.org/1999/XSL/Format" \
                version="1.0"> \
  <xsl:import href="$(DOCBOOK_XSL)/fo/docbook.xsl"/> \
  <xsl:param name="$(PDF_MAKER).extensions">1</xsl:param> \
  <xsl:param name="paper.type">Custom</xsl:param> \
  <xsl:param name="commented.page.height">9.25in</xsl:param> \
  <xsl:param name="commented.page.width">7.5in</xsl:param> \
  <xsl:param name="page.height">PAPER_HEIGHT</xsl:param> \
  <xsl:param name="page.width">PAPER_WIDTH</xsl:param> \
  <xsl:param name="commented.page.margin.inner">3in</xsl:param> \
  <xsl:param name="commented.page.margin.outer">3in</xsl:param> \
  <xsl:param name="chapter.autolabel">1</xsl:param> \
  <xsl:param name="section.autolabel">1</xsl:param> \
  <xsl:param name="toc.section.depth">2</xsl:param> \
  <xsl:param name="commented.toc.max.depth">2</xsl:param> \
  <xsl:param name="double.sided">DOUBLE_SIDED</xsl:param> \
  <xsl:param name="draft.watermark.image"></xsl:param> \
  <xsl:param name="hyphenation">false</xsl:param> \
  <xsl:param name="hyphenate.verbatim">1</xsl:param> \
  <xsl:param name="alignment">left</xsl:param> \
  <xsl:param name="refentry.generate.name">1</xsl:param> \
  <xsl:param name="refentry.generate.title">0</xsl:param> \
  <xsl:param name="refentry.pagebreak">1</xsl:param> \
  <xsl:param name="shade.verbatim">1</xsl:param> \
  <xsl:param name="variablelist.as.blocks">1</xsl:param> \
  <xsl:param name="ulink.show">1</xsl:param> \
  <xsl:param name="ulink.footnotes">1</xsl:param> \
  <xsl:param name="index.on.type">1</xsl:param> \
  <xsl:attribute-set name="xref.properties"> \
    <xsl:attribute name="color">XREF_COLOR</xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:template match="section[@tocexclude = 1]"  mode="toc" /> \
  <xsl:template name="commented.page.number.format"> \
  <xsl:param name="element" select="local-name(.)"/> \
  <xsl:choose> \
    <xsl:when test="$element = 'toc'">i</xsl:when> \
    <xsl:when test="$element = 'preface'">i</xsl:when> \
    <xsl:when test="$element = 'dedication'">i</xsl:when> \
    <xsl:when test="$element = 'book'">i</xsl:when> \
    <xsl:when test="$element = 'set'">i</xsl:when> \
    <xsl:otherwise>1</xsl:otherwise> \
  </xsl:choose> \
  </xsl:template> \
  <xsl:template match="*" mode="toc.for.set"> \
    <xsl:call-template name="set.toc"/> \
  </xsl:template> \
  <xsl:attribute-set name="shade.verbatim.style"> \
    <xsl:attribute name="background-color">\#E0E0E0</xsl:attribute> \
    <xsl:attribute name="padding-left">4pt</xsl:attribute> \
    <xsl:attribute name="padding-right">4pt</xsl:attribute> \
    <xsl:attribute name="padding-top">4pt</xsl:attribute> \
    <xsl:attribute name="padding-bottom">4pt</xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:attribute-set name="section.title.level1.properties"> \
    <xsl:attribute name="font-size"> \
      <xsl:value-of select="$$body.font.master * 1.5"></xsl:value-of> \
      <xsl:text>pt</xsl:text> \
    </xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:attribute-set name="section.title.level2.properties"> \
    <xsl:attribute name="font-size"> \
      <xsl:value-of select="$$body.font.master * 1.3"></xsl:value-of> \
      <xsl:text>pt</xsl:text> \
    </xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:attribute-set name="section.title.level3.properties"> \
    <xsl:attribute name="font-size"> \
      <xsl:value-of select="$$body.font.master * 1.1"></xsl:value-of> \
      <xsl:text>pt</xsl:text> \
    </xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:attribute-set name="section.title.level4.properties"> \
    <xsl:attribute name="font-size"> \
      <xsl:value-of select="$$body.font.master"></xsl:value-of> \
      <xsl:text>pt</xsl:text> \
    </xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:attribute-set name="component.title.properties"> \
    <xsl:attribute name="font-size"> \
      <xsl:value-of select="$$body.font.master * 1.5"></xsl:value-of> \
      <xsl:text>pt</xsl:text> \
    </xsl:attribute> \
  </xsl:attribute-set> \
  <xsl:attribute-set name="monospace.verbatim.properties"> \
    <xsl:attribute name="wrap-option">wrap</xsl:attribute> \
    <xsl:attribute name="hyphenation-character">\</xsl:attribute> \
    <xsl:attribute name="font-size"> \
      <xsl:value-of select="$$body.font.master * 0.8"></xsl:value-of> \
      <xsl:text>pt</xsl:text> \
    </xsl:attribute> \
  </xsl:attribute-set> \
</xsl:stylesheet>

FO_LETTER_COLOR := $(subst PAPER_WIDTH, 8.5in, \
                   $(subst PAPER_HEIGHT, 11in, \
		   $(subst XREF_COLOR,blue, \
		   $(subst DOUBLE_SIDED, 0,  \
		   	$(FO_CUSTOM)))))

FO_LETTER_MONO  := $(subst PAPER_WIDTH, 8.5in, \
                   $(subst PAPER_HEIGHT, 11in, \
		   $(subst XREF_COLOR,black, \
		   $(subst DOUBLE_SIDED, 0,  \
		   	$(FO_CUSTOM)))))

FO_SMALL_COLOR  := $(subst PAPER_WIDTH, 7.5in, \
                   $(subst PAPER_HEIGHT, 9.25in, \
		   $(subst XREF_COLOR,blue, \
		   $(subst DOUBLE_SIDED, 1,  \
		   	$(FO_CUSTOM)))))

FO_SMALL_MONO   := $(subst PAPER_WIDTH, 7.5in, \
                   $(subst PAPER_HEIGHT, 9.25in, \
		   $(subst XREF_COLOR,black, \
		   $(subst DOUBLE_SIDED, 1,  \
		   	$(FO_CUSTOM)))))

# for single-file (X)HTML outpout
HTML_CUSTOM := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
                version="1.0"> \
  <xsl:import href="$(DOCBOOK_XSL)/$(HTML_OR_XHTML)/docbook.xsl"/> \
  <xsl:param name="gentext.custom">local.l10n.xml</xsl:param> \
  <xsl:param name="local.l10n.xml" select="document($$gentext.custom)"/> \
  <xsl:param name="refentry.generate.name">1</xsl:param> \
  <xsl:param name="refentry.generate.title">0</xsl:param> \
  <xsl:param name="root.filename"></xsl:param> \
  <xsl:param name="variablelist.as.table">0</xsl:param> \
  <xsl:param name="html.stylesheet">$(HTML_STYLESHEET)</xsl:param> \
  <xsl:param name="admon.graphics">0</xsl:param> \
  <xsl:param name="index.on.type">1</xsl:param> \
  <xsl:param name="chapter.autolabel">1</xsl:param> \
  <xsl:param name="section.autolabel">1</xsl:param> \
  <xsl:param name="toc.section.depth">2</xsl:param> \
  <xsl:param name="commented.toc.max.depth">2</xsl:param> \
  <xsl:template match="section[@tocexclude = 1]"  mode="toc" /> \
  <xsl:param name="generate.toc"> \
appendix  toc,title \
article/appendix  nop \
article   toc, title \
book      toc,title,figure,table,example,equation \
chapter   toc,title \
part      toc,title \
preface   toc,title \
qandadiv  toc \
qandaset  toc \
reference toc,title \
sect1     toc \
sect2     toc \
sect3     toc \
sect4     toc \
sect5     toc \
section   toc \
set       toc,title \
</xsl:param> \
</xsl:stylesheet>

# for chunked (X)HTML output
CHNK_CUSTOM := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
                version="1.0"> \
  <xsl:import href="$(DOCBOOK_XSL)/$(HTML_OR_XHTML)/chunk.xsl"/> \
  <xsl:param name="refentry.generate.name">0</xsl:param> \
  <xsl:param name="refentry.generate.title">1</xsl:param> \
  <xsl:param name="variablelist.as.table">0</xsl:param> \
  <xsl:param name="html.stylesheet">$(HTML_STYLESHEET)</xsl:param> \
  <xsl:param name="admon.graphics">1</xsl:param> \
  <xsl:param name="admon.graphics.path">$(HTML_IMAGES)</xsl:param> \
  <xsl:param name="admon.graphics.extension">$(HTML_IMAGES_EXT)</xsl:param> \
  <xsl:param name="root.filename"></xsl:param> \
  <xsl:param name="generate.manifest">1</xsl:param> \
  <xsl:param name="use.id.as.filename">1</xsl:param> \
  <xsl:param name="chunker.output.indent">yes</xsl:param> \
  <xsl:param name="index.on.type">1</xsl:param> \
  <xsl:param name="chapter.autolabel">1</xsl:param> \
  <xsl:param name="section.autolabel">1</xsl:param> \
  <xsl:param name="toc.section.depth">2</xsl:param> \
  <xsl:param name="commented.toc.max.depth">2</xsl:param> \
  <xsl:template match="section[@tocexclude = 1]"  mode="toc" /> \
  <xsl:param name="generate.toc"> \
appendix  toc,title \
article/appendix  nop \
article   toc,title \
book      toc,title,figure,table,example,equation \
chapter   toc,title \
part      toc,title \
preface   toc,title \
qandadiv  toc \
qandaset  toc \
reference toc,title \
sect1     toc \
sect2     toc \
sect3     toc \
sect4     toc \
sect5     toc \
section   toc \
set       toc,title \
</xsl:param> \
</xsl:stylesheet>

# for man-page output
MAN_CUSTOM := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
                version="1.0"> \
  <xsl:import href="$(DOCBOOK_XSL)/manpages/docbook.xsl"/> \
  <xsl:param name="man.output.manifest.enabled" select="1"/> \
  <xsl:param name="man.output.in.separate.dir" select="1"/> \
  <xsl:param name="man.output.base.dir">man/</xsl:param> \
  <xsl:param name="man.output.subdirs.enabled" select="1"/> \
</xsl:stylesheet>

#
# ALE documentation targets
#

ALE_SUBDIRS := user technical
ALE_TYPES := letter.pdf txt info
ALE_PACKAGE := TODO ChangeLog NEWS README REPORTING-BUGS
ALE_MANUALS := $(foreach subdir, $(ALE_SUBDIRS), $(subdir)-manual)
ALE_MANUAL_TARGETS := $(foreach manual, $(ALE_MANUALS), $(foreach type, $(ALE_TYPES), $(manual).$(type)))
ALE_PACKAGE_TARGETS := $(foreach package, $(ALE_PACKAGE), ../$(package))
ALE_TARGETS := $(ALE_MANUAL_TARGETS) $(ALE_PACKAGE_TARGETS)


# -----------------------------------------------------------------
#                  ** TARGETS START HERE ** 
# -----------------------------------------------------------------
#  prevents make from deleting, e.g. foo.1, after making foo.1.pdf
#  and foo.1.txt from it.
.PRECIOUS: %.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9

# docbook: index.docbook $(DOCBOOK_OUTPUT_FORMATS) ../TODO ../ChangeLog ../NEWS ../README ../REPORTING-BUGS
docbook: $(ALE_TARGETS) index.docbook chunk
	rm -rf html
	mv index html
	mkdir -p info; mv *.info info
	rm index.docbook

%-manual.docbook: %/index.xml
	$(XSLT) $(XSLT_FLAGS) ale-doc.xsl $< > $@
	
manual-set.docbook: index.xml
	$(XSLT) $(XSLT_FLAGS) ale-doc.xsl $< > $@

../TODO: package/todo/index.txt
	mv package/todo/index.txt ../TODO
	
../ChangeLog: package/changelog/index.txt
	mv package/changelog/index.txt ../ChangeLog
	
../NEWS: package/news/index.txt
	mv package/news/index.txt ../NEWS
	
../README: package/readme/index.txt
	mv package/readme/index.txt ../README
	
man: $(LISTS_MAN)

# we can generate PDFs from man pages
man-pdf: man
	$(MAKE) $(FILES_MANP)

# we can generate plain text from man pages
man-txt: man
	$(MAKE) $(FILES_MANT)

html: $(FILES_HTML)

chunk: $(LISTS_HTML)

txt: $(FILES_TXT)

pdf: $(FILES_PDF)

info: $(FILES_INFO)

# use the "debug" target to echo variables, etc., to
# test/troubleshoot changes you make to this makefile
debug:
	@echo $(DIRS_MAN)

# -----------------------------------------------------------------
#     preprocess xml to docbook.
# -----------------------------------------------------------------
%$(DOCBOOK_FILE_EXTENSION): %.xml $(BROKEN_DEPENDENCIES) ale-doc.xsl
	$(XSLT) $(XSLT_FLAGS) ale-doc.xsl $< > $@

package/changelog/index.xml: package/changelog/index.in ./make-changelog
	./make-changelog < package/changelog/index.in > package/changelog/index.xml

# -----------------------------------------------------------------
#     pattern rule for making (X)HTML and plain-text output
# -----------------------------------------------------------------
%.html: %$(DOCBOOK_FILE_EXTENSION) $(BROKEN_DEPENDENCIES)
	@echo '$(HTML_CUSTOM)' | $(XSLT) $(XSLT_FLAGS) $(HTML_PARAMS) - $< > $@

%.txt: %.html
	$(TXT_MAKER) $(TXT_MAKER_FLAGS) ./$< \
	  | sed "s/^\(\s\+[0-9]\+\. \)file:\/\/.\+$$/\\1(local)/g" \
	  | egrep -v '^	file:///.+$$' \
	  > $@
# if DOCBOOK_OUTPUT_FORMATS does not contain "html", then we need
# to remove the "intermediate" HTML files we used for generating
# plain-text output
ifeq ($(findstring html,$(DOCBOOK_OUTPUT_FORMATS)),)
	$(RM) $<
endif

# -----------------------------------------------------------------
#     pattern rule for making chunked (X)HTML pages
# -----------------------------------------------------------------
%.$(HTML_MANIFEST_EXT): %$(DOCBOOK_FILE_EXTENSION) $(BROKEN_DEPENDENCIES)
	@echo '$(CHNK_CUSTOM)' | $(XSLT) $(XSLT_FLAGS) $(HTML_PARAMS) \
	--stringparam manifest $@  \
	--stringparam base.dir $(basename $@)$(BASEDIR_SUFFIX)/  \
	- $<

# -----------------------------------------------------------------
#     pattern rules for making FO and PDF stuff
# -----------------------------------------------------------------
%.letter.fo: %$(DOCBOOK_FILE_EXTENSION) $(BROKEN_DEPENDENCIES)
	@echo '$(FO_LETTER_COLOR)' \
	  | $(XSLT) $(XSLT_FLAGS) $(FO_PARAMS) - $< > $@

%.small.fo: %$(DOCBOOK_FILE_EXTENSION) $(BROKEN_DEPENDENCIES)
	@echo '$(FO_SMALL_COLOR)' \
	  | $(XSLT) $(XSLT_FLAGS) $(FO_PARAMS) - $< > $@

%.letter-mono.fo: %$(DOCBOOK_FILE_EXTENSION) $(BROKEN_DEPENDENCIES)
	@echo '$(FO_LETTER_MONO)' \
	  | $(XSLT) $(XSLT_FLAGS) $(FO_PARAMS) - $< > $@

%.small-mono.fo: %$(DOCBOOK_FILE_EXTENSION) $(BROKEN_DEPENDENCIES)
	@echo '$(FO_SMALL_MONO)' \
	  | $(XSLT) $(XSLT_FLAGS) $(FO_PARAMS) - $< > $@

ifeq ($(PDF_MAKER),dblatex)
%.pdf: %$(DOCBOOK_FILE_EXTENSION)
	mkdir -p $(DOCBOOK_TMP)
	echo '$(DBX_CUSTOM)' > $(DOCBOOK_TMP)/dblatex.xsl
	-$(DBLATEX) $(DBLATEX_FLAGS)\
	  -p $(DOCBOOK_TMP)/dblatex.xsl \
	  -o $@ \
	  $<
	$(RM) -r $(DOCBOOK_TMP)
endif

%.pdf: %.fo
ifeq ($(PDF_MAKER),)
	$(error No PDF_MAKER specified. Cannot make pdf)
else
ifeq ($(PDF_MAKER),xep)
	$(XEP) $(XEP_FLAGS) $< $@
else
ifeq ($(PDF_MAKER),fop)
	$(FOP) $(FOP_FLAGS) $< $@
else
ifeq ($(PDF_MAKER),xmlroff)
	$(XMLROFF) $(XMLROFF_FLAGS) $< -o $@
else
ifeq ($(PDF_MAKER),passivetex)
	$(PDFTEX) $(PDFTEX_FLAGS) &$(PDFXMLTEX) $<
	@if [ `egrep Rerun $(basename $@).log | wc -l` -gt 0 ]; then \
		$(PDFTEX) $(PDFTEX_FLAGS) &$(PDFXMLTEX) $< ; \
	fi
	@if [ `egrep Rerun $(basename $@).log | wc -l` -gt 0 ]; then \
		$(PDFTEX) $(PDFTEX_FLAGS) &$(PDFXMLTEX) $< ; \
	fi
	$(RM) $(basename $@).log
	$(RM) $(basename $@).aux
	$(RM) $(basename $@).out
else
	$(error I do not know how to make a PDF using "$(PDF_MAKER)")
endif
endif
endif
endif
endif

# -----------------------------------------------------------------
#     pattern rules for making TeXinfo stuff
# -----------------------------------------------------------------
%.txml: %$(DOCBOOK_FILE_EXTENSION)
	$(DB2X_XSLTPROC) $(DB2X_XSLTPROC_FLAGS) -s texi -o $@ $<

%.texi-list: %.txml
	$(DB2X_TEXIXML) $(DB2X_TEXIXML_FLAGS) $< > $@

# the following is actually a built-in rule, but it's redefined
# here just for the sake of clarity
%.info: %.texi-list
	/usr/bin/perl -w make-infos $(MAKEINFO) < $<
	-@ # This doesn't work in general.
	-@ # $(MAKEINFO) $(MAKEINFO_FLAGS) $< -o $@

# -----------------------------------------------------------------
#     pattern rule for making man pages
# -----------------------------------------------------------------
%.$(MAN_MANIFEST_EXT): %$(DOCBOOK_FILE_EXTENSION)
	@if [ "$(strip $(shell echo '$(REFENTRY_CHECK)' | $(XSLT) $(XSLT_FLAGS) - $<))" != "true" ]; then \
	  touch $@; \
	else \
	  echo '$(MAN_CUSTOM)' \
	  | $(XSLT) $(XSLT_FLAGS) $(MAN_PARAMS) \
	    --stringparam man.output.manifest.filename $@ \
	    - $<; \
	fi

# -----------------------------------------------------------------
#  pattern rule for enabling direct "make foo.1" to work
# -----------------------------------------------------------------

%.1 %.2 %.3 %.4 %.5 %.6 %.7: %.xml
	$(MAKE) $(basename $<).$(MAN_MANIFEST_EXT)

# -----------------------------------------------------------------
#  pattern rules for making Postscript/PDF output from man pages
# -----------------------------------------------------------------
%.1.ps: %.1
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.2.ps: %.2
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.3.ps: %.3
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.4.ps: %.4
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.5.ps: %.5
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.6.ps: %.6
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.7.ps: %.7
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.8.ps: %.8
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

%.9.ps: %.9
	$(MAN) -l $(MAN_FLAGS) -Tps $< > $@

# -----------------------------------------------------------------
#  pattern rule for converting Postscript to PDF
# -----------------------------------------------------------------
%.pdf: %.ps
	$(PS2PDF) $(PS2PDF_FLAGS) $<

# -----------------------------------------------------------------
#  pattern rules for making plain-text output from man pages
# -----------------------------------------------------------------
%.1.txt: %.1
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.2.txt: %.2
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.3.txt: %.3
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.4.txt: %.4
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.5.txt: %.5
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.6.txt: %.6
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.7.txt: %.7
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.8.txt: %.8
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

%.9.txt: %.9
	$(MAN) -l $(MAN_FLAGS) -Tascii $< | $(COL) -b $(COL_FLAGS) | $(EXPAND) $(EXPAND_FLAGS) > $@

# -----------------------------------------------------------------
#   target(s) for cleaning up the mess
# -----------------------------------------------------------------
clean:
	find . -name "*.info" | xargs rm -f
	find . -name "*.texi" | xargs rm -f
	find . -name "*.texi-list" | xargs rm -f
	find . -name "*.pdf" | xargs rm -f
	find . -name "*.fo" | xargs rm -f
	find . -name "*.docbook" | xargs rm -f
	find . -name "*.txt" | xargs rm -f
	rm -f package/changelog/index.xml
	rm -rf index
	rm -rf html
ifneq ($(FILES_TXT),)
	$(RM) $(FILES_TXT)
endif
ifneq ($(FILES_PDF),)
	$(RM) $(FILES_PDF)
endif
ifneq ($(FILES_FO),)
	$(RM) $(FILES_FO)
endif
ifneq ($(FILES_LOG),)
	$(RM) $(FILES_LOG)
endif
ifneq ($(FILES_OUT),)
	$(RM) $(FILES_OUT)
endif
ifneq ($(FILES_AUX),)
	$(RM) $(FILES_AUX)
endif
ifneq ($(FILES_HTML),)
	$(RM) $(FILES_HTML)
endif
ifneq ($(FILES_CHNK),)
	$(RM) $(FILES_CHNK)
endif
ifneq ($(FILES_MAN),)
	$(RM) $(FILES_MAN)
endif
ifneq ($(FILES_MANT),)
	$(RM) $(FILES_MANT)
endif
ifneq ($(FILES_MANP),)
	$(RM) $(FILES_MANP)
endif
ifneq ($(FILES_INFO),)
	$(RM) $(FILES_INFO)
endif
ifneq ($(DIRS_CHUNK),)
	for dir in $(DIRS_CHUNK); do \
	  if [ -d "$$dir" ]; then \
	    $(RMDIR) $(RMDIR_FLAGS) $$dir; \
	  fi \
	done
endif
ifneq ($(DIRS_MAN),)
ifneq ($(DIRS_MAN),.)
	for dir in $(DIRS_MAN); do \
	  if [ -d "$$dir" ]; then \
	    $(RMDIR) $(RMDIR_FLAGS) $$dir; \
	  fi \
	done
endif
endif
ifneq ($(LISTS_MAN),)
	$(RM) $(LISTS_MAN)
endif
ifneq ($(LISTS_HTML),)
	$(RM) $(LISTS_HTML)
endif