1 | ### These are all generic; we set all the variables we need |
---|
2 | |
---|
3 | # intermediary build path |
---|
4 | BUILDDIR = build |
---|
5 | # same for images |
---|
6 | BUILDIMAGESDIR = $(BUILDDIR)/images |
---|
7 | |
---|
8 | # images |
---|
9 | # right now, we only allow .png and .fig as source |
---|
10 | # we might add more later if we feel the need |
---|
11 | |
---|
12 | # PNG's can be source or built from .fig |
---|
13 | PNG = $(strip $(PNG_SRC) $(FIG_SRC:.fig=.png)) |
---|
14 | # EPS .ps files can be built from .png or .fig |
---|
15 | EPS = $(strip $(FIG_SRC:.fig=.ps) $(PNG_SRC:.png=.ps)) |
---|
16 | # PDF .pdf files can be built from .png or .fig |
---|
17 | PDF = $(strip $(FIG_SRC:.fig=.pdf) $(PNG_SRC:.png=.pdf)) |
---|
18 | |
---|
19 | # where we expect to find images during building, whether by copying |
---|
20 | # or by generating them |
---|
21 | PNG_BUILT = $(foreach file, $(PNG), $(BUILDIMAGESDIR)/$(file)) |
---|
22 | EPS_BUILT = $(foreach file, $(EPS), $(BUILDIMAGESDIR)/$(file)) |
---|
23 | PDF_BUILT = $(foreach file, $(PDF), $(BUILDIMAGESDIR)/$(file)) |
---|
24 | |
---|
25 | SRC = $(XML) $(PNG_SRC) $(FIG_SRC) $(CSS) $(EXTRA_SOURCES) |
---|
26 | |
---|
27 | # generate A4 docs |
---|
28 | PAPER_LOCALE = nl_NL |
---|
29 | |
---|
30 | ### generate all documentation by default |
---|
31 | # hook in html generation |
---|
32 | all-local: html |
---|
33 | |
---|
34 | # can we generate HTML ? |
---|
35 | if DOC_HTML |
---|
36 | HTML_DAT = html |
---|
37 | HTML_TARGET = html/index.html |
---|
38 | else #!DOC_HTML |
---|
39 | HTML_DAT = |
---|
40 | HTML_TARGET = |
---|
41 | endif #DOC_HTML |
---|
42 | html: $(HTML_TARGET) |
---|
43 | |
---|
44 | # can we generate PS ? |
---|
45 | if DOC_PS |
---|
46 | PS_DAT = $(DOC).ps |
---|
47 | else #!DOC_PS |
---|
48 | PS_DAT = |
---|
49 | endif #DOC_PS |
---|
50 | ps: $(PS_DAT) |
---|
51 | |
---|
52 | # can we generate PDF ? |
---|
53 | if DOC_PDF |
---|
54 | PDF_DAT = $(DOC).pdf |
---|
55 | else #!DOC_PDF |
---|
56 | PDF_DAT = |
---|
57 | endif #DOC_PDF |
---|
58 | pdf: $(PDF_DAT) |
---|
59 | |
---|
60 | debug: |
---|
61 | @echo "outputting some useful debug information" |
---|
62 | @echo "Source XML:" |
---|
63 | @echo "XML: '$(XML)'" |
---|
64 | @echo "CSS: '$(CSS)'" |
---|
65 | @echo "Source image files:" |
---|
66 | @echo "PNG_SRC: '$(PNG_SRC)'" |
---|
67 | @echo "FIG_SRC: '$(FIG_SRC)'" |
---|
68 | @echo "All used image files:" |
---|
69 | @echo "PNG: '$(PNG)'" |
---|
70 | @echo "EPS: '$(EPS)'" |
---|
71 | @echo "PDF: '$(PDF)'" |
---|
72 | @echo "All used image files in their built path:" |
---|
73 | @echo "PNG_BUILT: '$(PNG_BUILT)'" |
---|
74 | @echo "EPS_BUILT: '$(EPS_BUILT)'" |
---|
75 | @echo "PDF_BUILT: '$(PDF_BUILT)'" |
---|
76 | @echo "End result products:" |
---|
77 | @echo "HTML_DAT: '$(HTML_DAT)'" |
---|
78 | @echo "PS_DAT: '$(PS_DAT)'" |
---|
79 | @echo "PDF_DAT: '$(PDF_DAT)'" |
---|
80 | |
---|
81 | # a rule to copy all of the source for docs into $(builddir)/build |
---|
82 | $(BUILDDIR)/$(MAIN): $(XML) $(CSS) $(EXTRA_SOURCES) |
---|
83 | @-mkdir -p $(BUILDDIR) |
---|
84 | @if test "x$(EXTRA_SOURCES)" != "x"; then for a in $(EXTRA_SOURCES); do cp $(srcdir)/$$a $(BUILDDIR); done; fi |
---|
85 | @for a in $(XML); do cp $(srcdir)/$$a $(BUILDDIR); done |
---|
86 | @for a in $(CSS); do cp $(srcdir)/$$a $(BUILDDIR); done |
---|
87 | @cp ../version.entities $(BUILDDIR) |
---|
88 | @cp $(top_srcdir)/docs/url.entities $(BUILDDIR) |
---|
89 | |
---|
90 | html/index.html: $(BUILDDIR)/$(MAIN) $(PNG_BUILT) $(FIG_SRC) |
---|
91 | @make check-local |
---|
92 | @echo "*** Generating HTML output ***" |
---|
93 | @-mkdir -p html |
---|
94 | @cp -f $(srcdir)/../image-png $(BUILDDIR)/image.entities |
---|
95 | @cd $(BUILDDIR) && docbook2html -o ../html -V '%use-id-as-filename%' $(MAIN) |
---|
96 | @test "x$(CSS)" != "x" && \ |
---|
97 | echo "Copying .css files: $(CSS)" && \ |
---|
98 | cp $(srcdir)/$(CSS) html |
---|
99 | @test "x$(PNG)" != "x" && \ |
---|
100 | echo "Copying .png images: $(PNG_BUILT)" && \ |
---|
101 | mkdir -p html/images && \ |
---|
102 | cp $(PNG_BUILT) html/images || true |
---|
103 | |
---|
104 | $(DOC).ps: $(BUILDDIR)/$(MAIN) $(EPS_BUILT) $(PNG_SRC) $(FIG_SRC) |
---|
105 | @make check-local |
---|
106 | @echo "*** Generating PS output ***" |
---|
107 | @cp -f $(srcdir)/../image-eps $(BUILDDIR)/image.entities |
---|
108 | cd $(BUILDDIR) && docbook2ps -o .. $(MAIN) |
---|
109 | # export LC_PAPER=$(PAPER_LOCALE) && cd $(BUILDDIR) && xmlto ps -o .. $(MAIN) |
---|
110 | |
---|
111 | $(DOC).pdf: $(DOC).ps |
---|
112 | @make check-local |
---|
113 | @echo "*** Generating PDF output ***" |
---|
114 | @ps2pdf $(DOC).ps |
---|
115 | |
---|
116 | #$(DOC).pdf: $(MAIN) $(PDF) $(FIG_SRC) |
---|
117 | # @echo "*** Generating PDF output ***" |
---|
118 | # @cp -f $(srcdir)/../image-pdf image.entities |
---|
119 | # @export LC_PAPER=$(PAPER_LOCALE) && xmlto pdf $(MAIN) |
---|
120 | # @rm image.entities |
---|
121 | |
---|
122 | clean-local: |
---|
123 | -$(RM) -r $(BUILDDIR) |
---|
124 | -$(RM) -r html |
---|
125 | -$(RM) $(DOC).ps |
---|
126 | -$(RM) $(DOC).pdf |
---|
127 | -$(RM) -r www |
---|
128 | |
---|
129 | ### image generation |
---|
130 | |
---|
131 | # copy png from source dir png |
---|
132 | $(BUILDIMAGESDIR)/%.png: $(srcdir)/%.png |
---|
133 | @echo "Copying $< to $@" |
---|
134 | @mkdir -p $(BUILDIMAGESDIR) |
---|
135 | @cp $< $@ |
---|
136 | # make png from fig |
---|
137 | $(BUILDIMAGESDIR)/%.png: %.fig |
---|
138 | @echo "Generating $@ from $<" |
---|
139 | @mkdir -p $(BUILDIMAGESDIR) |
---|
140 | @fig2dev -Lpng $< $@ |
---|
141 | |
---|
142 | # make ps(EPS) from fig |
---|
143 | $(BUILDIMAGESDIR)/%.ps: %.fig |
---|
144 | @echo "Generating $@ from $<" |
---|
145 | @mkdir -p $(BUILDIMAGESDIR) |
---|
146 | @fig2dev -Leps $< $@ |
---|
147 | |
---|
148 | # make pdf from fig |
---|
149 | $(BUILDIMAGESDIR)/%.pdf: %.fig |
---|
150 | @echo "Generating $@ from $<" |
---|
151 | @mkdir -p $(BUILDIMAGESDIR) |
---|
152 | @fig2dev -Lpdf $< $@ |
---|
153 | |
---|
154 | # make pdf from png |
---|
155 | $(BUILDIMAGESDIR)/%.pdf: %.png |
---|
156 | @echo "Generating $@ from $<" |
---|
157 | @mkdir -p $(BUILDIMAGESDIR) |
---|
158 | @cat $< | pngtopnm | pnmtops -noturn 2> /dev/null | epstopdf --filter --outfile $@ 2> /dev/null |
---|
159 | |
---|
160 | # make ps(EPS) from png |
---|
161 | $(BUILDIMAGESDIR)/%.ps: %.png |
---|
162 | @echo "Generating $@ from $<" |
---|
163 | @mkdir -p $(BUILDIMAGESDIR) |
---|
164 | @cat $< | pngtopnm | pnmtops -noturn > $@ 2> /dev/null |
---|
165 | |
---|
166 | # make sure xml validates properly |
---|
167 | check-local: $(BUILDDIR)/$(MAIN) |
---|
168 | @cp -f $(srcdir)/../image-png $(BUILDDIR)/image.entities |
---|
169 | cd $(BUILDDIR) && xmllint -noout -valid $(MAIN) |
---|