doc: Avoid using stdout in Makefile rule to generate .spv files.
[pspp] / doc / automake.mk
1 ## PSPP - a program for statistical analysis.
2 ## Copyright (C) 2019, 2020 Free Software Foundation, Inc.
3 ##
4 ## This program is free software: you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation, either version 3 of the License, or
7 ## (at your option) any later version.
8 ##
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
13 ##
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 ## Process this file with automake to produce Makefile.in  -*- makefile -*-
18
19 info_TEXINFOS = doc/pspp.texi doc/pspp-dev.texi
20
21 doc_pspp_TEXINFOS = doc/version.texi \
22         doc/bugs.texi \
23         doc/command-index.texi \
24         doc/concept-index.texi \
25         doc/data-io.texi \
26         doc/data-selection.texi \
27         doc/expressions.texi \
28         doc/files.texi \
29         doc/combining.texi \
30         doc/flow-control.texi \
31         doc/function-index.texi \
32         doc/installing.texi \
33         doc/introduction.texi \
34         doc/invoking.texi \
35         doc/language.texi \
36         doc/license.texi \
37         doc/pspp-convert.texi \
38         doc/pspp-output.texi \
39         doc/pspp-dump-sav.texi \
40         doc/ni.texi \
41         doc/not-implemented.texi \
42         doc/statistics.texi \
43         doc/transformation.texi \
44         doc/tutorial.texi \
45         doc/tut.texi \
46         doc/regression.texi \
47         doc/utilities.texi \
48         doc/variables.texi \
49         doc/matrices.texi \
50         doc/fdl.texi
51
52 doc_pspp_dev_TEXINFOS = doc/version-dev.texi \
53         doc/dev/system-file-format.texi \
54         doc/dev/pc+-file-format.texi \
55         doc/dev/portable-file-format.texi \
56         doc/dev/spv-file-format.texi \
57         doc/dev/tlo-file-format.texi \
58         doc/dev/encrypted-file-wrappers.texi
59
60 dist_man_MANS += doc/pspp.1 \
61                  doc/psppire.1
62
63 EXTRA_DIST += doc/get-commands.py \
64               doc/help-pages-list \
65               doc/prepdoc.sh
66
67 $(srcdir)/doc/ni.texi: $(top_srcdir)/src/language/command.def doc/get-commands.py
68         $(AM_V_GEN)$(PYTHON3) $(top_srcdir)/doc/get-commands.py $(top_srcdir)/src/language/command.def > $@
69
70 $(srcdir)/doc/tut.texi:
71         $(AM_V_GEN)echo "@set example-dir $(examplesdir)" > $@
72
73
74 doc/pspp.xml: doc/pspp.texi $(doc_pspp_TEXINFOS) doc/help-pages-list
75 if BROKEN_DOCBOOK_XML
76         touch $@
77 else
78         $(AM_V_GEN)$(MAKEINFO) --docbook $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) \
79                 -I doc -I $(srcdir)/doc $< -o $@
80 endif
81
82 docbookdir = $(docdir)
83 dist_docbook_DATA = doc/pspp.xml
84
85
86 CLEANFILES += pspp-dev.dvi $(docbook_DATA) doc/pspp.info* doc/pspp.xml
87
88
89 doc: $(INFO_DEPS) $(DVIS) $(PDFS) $(PNGS) $(HTMLS) $(dist_docbook_DATA)
90 PHONY += doc
91
92 doc/help-pages-list: $(UI_FILES)
93          $(AM_V_GEN)cat $^ | grep '"help[-_]page"' | \
94    $(SED) -e 's% *<property name="help[-_]page">\([^<]*\)</property>%//*[@id='"'"'\1'"'"']%' \
95         -e 's%#%'"'"']/*[@id='"'"'%g' > $@,tmp
96         test -s $@,tmp
97         mv $@,tmp $@
98
99 EXTRA_DIST += \
100         doc/help-pages-list \
101         doc/pspp-manual.css
102
103 am__TEXINFO_TEX_DIR=:$(top_srcdir)/doc:$(top_builddir)/doc
104
105 ################# Example programs ##############################
106
107 FIGURE_SYNTAX = \
108  doc/pspp-figures/aggregate.sps \
109  doc/pspp-figures/autorecode.sps \
110  doc/pspp-figures/chisquare.sps \
111  doc/pspp-figures/compute.sps \
112  doc/pspp-figures/count.sps \
113  doc/pspp-figures/ctables1.sps \
114  doc/pspp-figures/ctables2.sps \
115  doc/pspp-figures/ctables3.sps \
116  doc/pspp-figures/ctables4.sps \
117  doc/pspp-figures/ctables5.sps \
118  doc/pspp-figures/ctables6.sps \
119  doc/pspp-figures/ctables7.sps \
120  doc/pspp-figures/ctables8.sps \
121  doc/pspp-figures/ctables9.sps \
122  doc/pspp-figures/ctables10.sps \
123  doc/pspp-figures/ctables11.sps \
124  doc/pspp-figures/ctables12.sps \
125  doc/pspp-figures/ctables13.sps \
126  doc/pspp-figures/ctables14.sps \
127  doc/pspp-figures/ctables15.sps \
128  doc/pspp-figures/ctables16.sps \
129  doc/pspp-figures/ctables17.sps \
130  doc/pspp-figures/ctables18.sps \
131  doc/pspp-figures/ctables19.sps \
132  doc/pspp-figures/ctables20.sps \
133  doc/pspp-figures/ctables21.sps \
134  doc/pspp-figures/ctables22.sps \
135  doc/pspp-figures/ctables23.sps \
136  doc/pspp-figures/ctables24.sps \
137  doc/pspp-figures/ctables25.sps \
138  doc/pspp-figures/ctables26.sps \
139  doc/pspp-figures/ctables27.sps \
140  doc/pspp-figures/ctables28.sps \
141  doc/pspp-figures/ctables29.sps \
142  doc/pspp-figures/ctables30.sps \
143  doc/pspp-figures/ctables31.sps \
144  doc/pspp-figures/ctables32.sps \
145  doc/pspp-figures/ctables33.sps \
146  doc/pspp-figures/ctables34.sps \
147  doc/pspp-figures/ctables35.sps \
148  doc/pspp-figures/ctables36.sps \
149  doc/pspp-figures/crosstabs.sps \
150  doc/pspp-figures/descriptives.sps \
151  doc/pspp-figures/flip.sps \
152  doc/pspp-figures/frequencies.sps \
153  doc/pspp-figures/matrix-print.sps \
154  doc/pspp-figures/means.sps \
155  doc/pspp-figures/one-sample-t.sps \
156  doc/pspp-figures/independent-samples-t.sps \
157  doc/pspp-figures/reliability.sps \
158  doc/pspp-figures/select-if.sps \
159  doc/pspp-figures/show-system.sps \
160  doc/pspp-figures/sort-cases.sps \
161  doc/pspp-figures/split.sps \
162  doc/pspp-figures/temporary.sps \
163  doc/pspp-figures/tutorial1.sps \
164  doc/pspp-figures/tutorial2.sps \
165  doc/pspp-figures/tutorial3.sps \
166  doc/pspp-figures/tutorial4.sps \
167  doc/pspp-figures/tutorial5.sps \
168  doc/pspp-figures/tutorial6.sps \
169  doc/pspp-figures/tutorial7.sps \
170  doc/pspp-figures/weight.sps
171
172
173 EXTRA_DIST += $(FIGURE_SYNTAX)
174
175 FIGURE_SPVS = $(FIGURE_SYNTAX:.sps=.spv) \
176         doc/pspp-figures/tutorial2a.spv \
177         doc/pspp-figures/tutorial2b.spv \
178         doc/pspp-figures/tutorial5a.spv \
179         doc/pspp-figures/tutorial5b.spv \
180         doc/pspp-figures/tutorial7a.spv \
181         doc/pspp-figures/tutorial7b.spv
182 FIGURE_TXTS = $(FIGURE_SPVS:.spv=.txt)
183 FIGURE_TEXIS = $(FIGURE_TXTS:.txt=.texi)
184 FIGURE_HTMLS = $(FIGURE_SPVS:.spv=.html)
185 FIGURE_PDFS = $(FIGURE_SPVS:.spv=.pdf)
186 FIGURE_PNGS = $(FIGURE_SPVS:.spv=.png)
187
188 figure-spvs: $(FIGURE_SPVS)
189 figure-txts: $(FIGURE_TXTS)
190 figure-texis: $(FIGURE_TEXIS)
191 figure-htmls: $(FIGURE_HTMLS)
192 figure-pdfs: $(FIGURE_PDFS)
193 figure-pngs: $(FIGURE_PNGS)
194 PHONY += \
195         figure-spv \
196         figure-txts \
197         figure-texis \
198         figure-htmls \
199         figure-pdfs \
200         figure-pngs
201
202 $(top_builddir)/doc/pspp.info:  $(FIGURE_PNGS)
203 $(top_builddir)/doc/pspp.ps:    $(FIGURE_TEXIS)
204 $(top_builddir)/doc/pspp.dvi:   $(FIGURE_TEXIS)
205 $(top_builddir)/doc/pspp.html:  $(FIGURE_HTMLS)
206 $(top_builddir)/doc/pspp.pdf:   $(FIGURE_TEXIS)
207 $(top_builddir)/doc/pspp.xml:   $(FIGURE_TEXIS)
208
209 CLEANFILES += \
210         $(FIGURE_TXTS) \
211         $(FIGURE_SPVS) \
212         $(FIGURE_TEXIS) \
213         $(FIGURE_HTMLS) \
214         $(FIGURE_PNGS)
215 SUFFIXES += .sps .spv .txt .html .texi .pdf .png
216
217 # Use pspp to process a syntax file into an output file.
218 if cross_compiling
219 pspp = native/src/ui/terminal/pspp
220 pspp_output = native/utilities/pspp-output
221
222 native/Makefile:
223         $(MKDIR_P) native
224         (cd native && $(abs_top_srcdir)/configure --host=$(build) --without-gui)
225
226 # The gnulib header files are required for the object files of the native pspp
227 # They are defined in BUILT_SOURCES but that is only defined as a first dependency
228 # for the make all target. src/ui/terminal/pspp as a target will try to compile the
229 # objects first but that fails without the header files. Therefore I build the native
230 # executables via the default make target
231 $(pspp) $(pspp_output) &: native/Makefile
232         (cd native && flock --verbose $(top_builddir)/native-lock $(MAKE) )
233
234 else
235 pspp = src/ui/terminal/pspp$(EXEEXT)
236 pspp_output = utilities/pspp-output$(EXEEXT)
237 endif
238
239 $(FIGURE_SPVS): $(pspp)
240 .sps.spv:
241         $(AM_V_GEN)of=`pwd`/$@.tmp; (cd "$(top_srcdir)/examples" \
242          && "$(abs_top_builddir)/$(pspp)" ../doc/pspp-figures/$(<F) -o $$of -O format=spv)
243         $(AM_V_at)mv $@.tmp $@
244
245 # In some cases, the tutorial only wants some parts of the output.
246 convert = $(AM_V_GEN)LSAN_OPTIONS="suppressions=$(abs_top_srcdir)/tests/lsan.supp:print_suppressions=0:$$LSAN_OPTIONS" $(pspp_output) convert $< $@
247 doc/pspp-figures/tutorial2a.spv: doc/pspp-figures/tutorial2.spv $(pspp_output)
248         $(convert) --command='Descriptives'
249 doc/pspp-figures/tutorial2b.spv: doc/pspp-figures/tutorial2.spv $(pspp_output)
250         $(convert) --label='Extreme Values'
251 doc/pspp-figures/tutorial5a.spv: doc/pspp-figures/tutorial5.spv $(pspp_output)
252         $(convert) --commands=examine --nth-command=1 --labels=descriptives
253 doc/pspp-figures/tutorial5b.spv: doc/pspp-figures/tutorial5.spv $(pspp_output)
254         $(convert) --commands=examine --nth-command=2 --labels=descriptives
255 doc/pspp-figures/tutorial7a.spv: doc/pspp-figures/tutorial7.spv $(pspp_output)
256         $(convert) --commands=regression --nth-command=1 --subtypes=coefficients
257 doc/pspp-figures/tutorial7b.spv: doc/pspp-figures/tutorial7.spv $(pspp_output)
258         $(convert) --commands=regression --nth-command=2 --subtypes=coefficients
259
260
261 $(FIGURE_PNGS): $(pspp_output)
262 $(FIGURE_TXTS): $(pspp_output)
263 $(FIGURE_HTMLS): $(pspp_output)
264 $(FIGURE_PDFS): $(pspp_output)
265
266 # Convert an output file into a text file or HTML file.
267 $(FIGURE_TXTS) $(FIGURE_HTMLS): $(pspp_output)
268 .spv.txt:
269         $(convert)
270 .spv.pdf:
271         $(convert) -O trim=true -O left-margin=0in -O right-margin=0in -O top-margin=0in -O bottom-margin=0in -O paper-size=7.5x99in --table-look=$(srcdir)/doc/tutorial.stt
272 .spv.png:
273         $(convert) -O trim=true -O left-margin=0in -O right-margin=0in -O top-margin=0in -O bottom-margin=0in -O paper-size=7.5x99in --table-look=$(srcdir)/doc/tutorial.stt
274 EXTRA_DIST += doc/tutorial.stt
275 .spv.html:
276         $(convert) -O format=html -O bare=true
277
278 # Make sure that tutorial.stt outputs all layers, because a few of the
279 # examples in the manual rely on that and it would be easy to replace
280 # it with a style that didn't.
281 ALL_LOCAL += tutorial-stt-must-print-all-layers
282 tutorial-stt-must-print-all-layers:
283         $(AM_V_GEN)grep 'printAllLayers="true"' $(srcdir)/doc/tutorial.stt >/dev/null 2>&1 && touch $@
284
285 # Convert a text file into a Texinfo file.
286 .txt.texi:
287         $(AM_V_GEN)$(SED) -e 's/@/@@/g' $< > $@
288
289 AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) --css-ref=pspp-manual.css
290 # Adjust the path for screenshot images.
291 # But make sure these operations are idempotent.
292 html-local: doc/pspp.html
293         test -d doc/pspp.html
294         for h in doc/pspp.html/*.html; do \
295                 if grep -Fq '<img src="screenshots/' $$h; then continue; fi ; \
296                 $(SED) -i -e 's|<img src="\([^"]*\)"|<img src="screenshots/\1"|' $$h; \
297         done
298
299 install-html-local: html-local $(HTML_SCREENSHOTS)
300         $(MKDIR_P) $(DESTDIR)$(prefix)/share/doc/pspp/pspp.html
301         $(INSTALL) -d $(DESTDIR)$(prefix)/share/doc/pspp/pspp.html/screenshots
302         for p in $(HTML_SCREENSHOTS); do \
303                 $(INSTALL_DATA) $$p $(DESTDIR)$(prefix)/share/doc/pspp/pspp.html/screenshots ;\
304         done
305         $(INSTALL_DATA) ${top_srcdir}/doc/pspp-manual.css $(DESTDIR)$(prefix)/share/doc/pspp/pspp.html
306
307 \f
308
309 desktopdir = $(datadir)/applications
310
311 doc/org.gnu.pspp.metainfo.xml: doc/org.gnu.pspp.metainfo.xml.in $(POFILES)
312         $(AM_V_GEN)$(MSGFMT) --xml --template $< -o $@ -d $(top_srcdir)/po || \
313           $(MSGFMT) -L appdata --xml --template $< -o $@ -d $(top_srcdir)/po
314
315 doc/org.gnu.pspp.desktop: doc/org.gnu.pspp.desktop.in $(POFILES)
316         $(AM_V_GEN)$(MSGFMT) --desktop --template $< -o $@ -d $(top_srcdir)/po
317
318 CLEANFILES+=doc/org.gnu.pspp.desktop \
319             doc/org.gnu.pspp.metainfo.xml
320
321 desktop_DATA = doc/org.gnu.pspp.desktop
322
323 appdatadir = $(datadir)/metainfo
324 dist_appdata_DATA = doc/org.gnu.pspp.metainfo.xml
325
326 EXTRA_DIST += doc/org.gnu.pspp.metainfo.xml.in \
327         doc/org.gnu.pspp.desktop.in
328
329 \f
330
331 SCREENSHOTS = \
332 $(top_srcdir)/doc/screenshots/autorecode.grab \
333 $(top_srcdir)/doc/screenshots/chisquare.grab \
334 $(top_srcdir)/doc/screenshots/count.grab \
335 $(top_srcdir)/doc/screenshots/count-define.grab \
336 $(top_srcdir)/doc/screenshots/compute.grab \
337 $(top_srcdir)/doc/screenshots/crosstabs.grab \
338 $(top_srcdir)/doc/screenshots/descriptives.grab \
339 $(top_srcdir)/doc/screenshots/one-sample-t.grab \
340 $(top_srcdir)/doc/screenshots/independent-samples-t.grab \
341 $(top_srcdir)/doc/screenshots/define-groups-t.grab \
342 $(top_srcdir)/doc/screenshots/frequencies.grab \
343 $(top_srcdir)/doc/screenshots/reliability.grab \
344 $(top_srcdir)/doc/screenshots/split-status-bar.grab \
345 $(top_srcdir)/doc/screenshots/sort-simple.grab \
346 $(top_srcdir)/doc/screenshots/sort.grab
347
348
349 PDF_SCREENSHOTS =  $(SCREENSHOTS:.grab=-hc.png)
350 EPS_SCREENSHOTS =  $(SCREENSHOTS:.grab=-hc.eps)
351 HTML_SCREENSHOTS = $(SCREENSHOTS:.grab=-ad.png)
352 INFO_SCREENSHOTS = $(SCREENSHOTS:.grab=-ad.png)
353
354 doc-make: doc/doc-make.in Makefile
355         $(SED) -e 's|%top_srcdir%|@top_srcdir@|g' \
356         -e 's|%abs_builddir%|@abs_builddir@|g' \
357         -e 's|%MKDIR_P%|@MKDIR_P@|g' \
358         -e 's|%src_ui_gui_psppiredir%|$(src_ui_gui_psppiredir)|g' \
359         -e 's|%UI_FILES%|$(UI_FILES)|g' \
360         -e 's|%IMAGES%|$(INFO_SCREENSHOTS) $(HTML_SCREENSHOTS) $(EPS_SCREENSHOTS) $(PDF_SCREENSHOTS)|g' \
361         $< > $@
362
363
364 # Install all the PNG files so that info readers can recognise them
365 install-info-local: $(FIGURE_PNGS)
366         $(MKDIR_P) $(DESTDIR)$(infodir)/screenshots
367         for p in $(INFO_SCREENSHOTS); do \
368                 $(INSTALL_DATA) $$p $(DESTDIR)$(infodir)/screenshots ;\
369         done
370         $(INSTALL) -d $(DESTDIR)$(infodir)/pspp-figures
371         for p in $(FIGURE_PNGS); do \
372                 $(INSTALL_DATA) $$p $(DESTDIR)$(infodir)/pspp-figures ;\
373         done
374
375 uninstall-local:
376         for p in $(INFO_SCREENSHOTS); do \
377                 f=`basename $$p ` ; \
378                 rm -f $(DESTDIR)$(infodir)/screenshots/$$f ; \
379         done
380         for p in $(FIGURE_PNGS); do \
381                 f=`basename $$p ` ; \
382                 rm -f $(DESTDIR)$(infodir)/pspp-figures/$$f ; \
383         done
384
385 EXTRA_DIST+= $(SCREENSHOTS) doc/doc-make.in doc/screengrab
386
387 EXTRA_DIST+= $(EPS_SCREENSHOTS) $(PDF_SCREENSHOTS) $(INFO_SCREENSHOTS)