summaryrefslogtreecommitdiff
path: root/doc/doc.am
blob: cddc51907a4f911d6f7e3fa7c2737eb410f31eb2 (plain)
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
# Copyright (C) 2002-2022 Free Software Foundation, Inc.
# Original Makefile.sub written by Werner Lemberg <wl@gnu.org>.
# Adapted to Automake by Bertrand Garrigues
#   (bertrand.garrigues@laposte.net).
#
# This file is part of groff.
#
# groff 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, either version 3 of the License, or (at your
# option) any later version.
#
# groff 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 this program.  If not, see <http://www.gnu.org/licenses/>.

doc_srcdir = $(abs_top_srcdir)/doc
doc_builddir = $(abs_top_builddir)/doc

# Some document sources are parameterized in configuration options like
# the groff version number and the command prefix.  Use this in target
# rules to prepare formattable versions of them from .in files.
DOC_SED = $(SED) \
  -e "s;[@]VERSION[@];$(VERSION);" \
  -e "s;[@]g[@];$(g);g;"

# Use this in target rules to run the build tree's groff.
#
# It includes flags to locate its tmac and device/font description
# directories and to produce verbose diagnostics in the event of syntax
# or formatting problems.
DOC_GROFF = \
  GROFF_COMMAND_PREFIX= \
  GROFF_BIN_PATH="$(GROFF_BIN_PATH)" \
  $(GROFFBIN) -M $(doc_srcdir) $(MFLAG) $(FFLAG) -ww -b

# This image file is used by several documents in the groff source tree.
DOC_GNU_EPS = doc/gnu.eps

# Other doc, installed in $(docdir)
# Files located in the source tree
DOCFILES_INST = \
  doc/me-revisions \
  doc/ms.ms \
  doc/pic.ms
DOCFILES_NOINST = \
  doc/meintro.me.in \
  doc/meintro_fr.me.in \
  doc/meref.me.in
# Files that undergo a transformation prior to groff processing
GENERATEDDOCFILES = \
  doc/meintro.me \
  doc/meintro_fr.me \
  doc/meref.me
# Files generated in the build tree
if USE_GROHTML
PROCESSEDDOCFILES_HTML = \
  doc/pic.html
endif
if USE_GROPDF
PROCESSEDDOCFILES_PDF = \
  doc/automake.pdf \
  doc/groff-man-pages.pdf
endif
PROCESSEDDOCFILES_PS = \
  doc/meref.ps \
  doc/meintro.ps \
  doc/meintro_fr.ps \
  doc/ms.ps \
  doc/pic.ps
PROCESSEDDOCFILES_TXT = \
  doc/groff-man-pages.utf8.txt
PROCESSEDDOCFILES = \
  $(PROCESSEDDOCFILES_HTML) \
  $(PROCESSEDDOCFILES_PS) \
  $(PROCESSEDDOCFILES_PDF) \
  $(PROCESSEDDOCFILES_TXT)

# Declare minimal dependencies for documents by output driver.
PROCESSEDFILES_DEPS_HTML = pre-grohtml groff troff post-grohtml \
  font/devhtml/stamp font/devps/stamp
PROCESSEDFILES_DEPS_PS = groff troff grops font/devps/stamp
PROCESSEDFILES_DEPS_PDF = groff troff gropdf font/devpdf/stamp
PROCESSEDFILES_DEPS_TXT = groff troff grotty font/devutf8/stamp

if USE_GROHTML
$(PROCESSEDDOCFILES_HTML): $(PROCESSEDFILES_DEPS_HTML)
endif
$(PROCESSEDDOCFILES_PS): $(PROCESSEDFILES_DEPS_PS)
if USE_GROPDF
$(PROCESSEDDOCFILES_PDF): $(PROCESSEDFILES_DEPS_PDF)
endif
$(PROCESSEDDOCFILES_TXT): $(PROCESSEDFILES_DEPS_TXT)

otherdocdir = $(docdir)
dist_otherdoc_DATA = $(DOCFILES_INST)
nodist_otherdoc_DATA = $(PROCESSEDDOCFILES) $(GENERATEDDOCFILES)
MOSTLYCLEANFILES += $(GENERATEDDOCFILES) $(PROCESSEDDOCFILES)
EXTRA_DIST += $(DOCFILES_NOINST)

# pdf doc, written in mom and therefore using contrib/mom/mom.am
# definitions
EXTRA_DIST += doc/automake.mom
if USE_GROPDF
docpdfdocdir = $(pdfdocdir)
nodist_docpdfdoc_DATA = doc/automake.pdf
endif
doc/automake.pdf: doc/automake.mom pdfmom contrib/mom/om.tmac

# GNU PIC html documentation, installed in $(htmldocdir)
# Other pic*.html files are installed by the local rule
if USE_GROHTML
htmlpicdir = $(htmldocdir)
htmlpic_DATA = $(PROCESSEDDOCFILES_HTML)
HTMLDOCFILESALL = pic*.html
HTMLDOCIMAGEFILES = pic*
endif

# Examples files, installed in $(exampledir)

# source tree files
EXAMPLEFILES = \
  doc/webpage.ms \
  doc/groff.css \
  doc/grnexmpl.g \
  doc/grnexmpl.me

# Generated in the build tree
if USE_GROHTML
PROCESSEDEXAMPLEFILES_HTML = doc/webpage.html
else
PROCESSEDEXAMPLEFILES_HTML =
endif
PROCESSEDEXAMPLEFILES_PS = \
  doc/webpage.ps \
  doc/grnexmpl.ps
PROCESSEDEXAMPLEFILES = \
  $(PROCESSEDEXAMPLEFILES_HTML) \
  $(PROCESSEDEXAMPLEFILES_PS)

$(PROCESSEDEXAMPLEFILES_HTML): $(PROCESSEDFILES_DEPS_HTML)
$(PROCESSEDEXAMPLEFILES_PS): $(PROCESSEDFILES_DEPS_PS)

docexamplesdir = $(exampledir)
dist_docexamples_DATA = $(EXAMPLEFILES)
nodist_docexamples_DATA = $(PROCESSEDEXAMPLEFILES)
MOSTLYCLEANFILES += $(PROCESSEDEXAMPLEFILES)

if USE_GROHTML
# webpage.html is generated; webpage*.html files are installed by the
# local rule.
HTMLEXAMPLEFILESALL = webpage*.html
HTMLEXAMPLEIMAGEFILES = webpage*
htmlexamplesdir = $(exampledir)
endif

# Locate image subdirectory for HTML documents relative to an
# installation directory such as `htmldocdir` or `exampledir`.  Do _not_
# use for locating files within the source or build trees.
imagedir = img

EXTRA_DIST += \
  doc/txi-en.tex

# Introduce variables to house the groff man pages.  We break the list
# of page sources into multiple chunks because we have to load Swedish
# localization before formatting groff_mmse.7 and then reload English
# localization afterward.  This also serves as a test of groff locale
# switching; being lazy and shunting groff_mmse.7 off to the end of the
# document would not achieve this goal (and not loading Swedish
# localization at all to format it would be gauche).
GROFF_MAN_PAGES1 = \
  src/utils/addftinfo/addftinfo.1 \
  src/utils/afmtodit/afmtodit.1 \
  contrib/chem/chem.1 \
  src/preproc/eqn/eqn.1 \
  contrib/eqn2graph/eqn2graph.1 \
  contrib/gdiffmk/gdiffmk.1 \
  contrib/glilypond/glilypond.1 \
  contrib/gperl/gperl.1 \
  contrib/gpinyin/gpinyin.1 \
  contrib/grap2graph/grap2graph.1 \
  src/preproc/grn/grn.1 \
  src/devices/grodvi/grodvi.1 \
  src/roff/groff/groff.1 \
  src/utils/grog/grog.1 \
  src/devices/grohtml/grohtml.1 \
  src/devices/grolbp/grolbp.1 \
  src/devices/grolj4/grolj4.1 \
  src/devices/gropdf/gropdf.1 \
  src/devices/grops/grops.1 \
  src/devices/grotty/grotty.1 \
  $(GXDITVIEW_MAN1) \
  src/utils/hpftodit/hpftodit.1 \
  src/utils/indxbib/indxbib.1 \
  src/utils/lkbib/lkbib.1 \
  src/utils/lookbib/lookbib.1 \
  contrib/mm/mmroff.1 \
  src/preproc/eqn/neqn.1 \
  src/roff/nroff/nroff.1 \
  src/devices/gropdf/pdfmom.1 \
  contrib/pdfmark/pdfroff.1 \
  src/utils/pfbtops/pfbtops.1 \
  src/preproc/pic/pic.1 \
  contrib/pic2graph/pic2graph.1 \
  src/preproc/preconv/preconv.1 \
  src/preproc/refer/refer.1 \
  src/preproc/soelim/soelim.1 \
  src/preproc/tbl/tbl.1 \
  src/utils/tfmtodit/tfmtodit.1 \
  src/roff/troff/troff.1 \
  $(XTOTROFF_MAN1) \
  man/groff_font.5 \
  man/groff_out.5 \
  man/groff_tmac.5 \
  man/groff.7 \
  man/groff_char.7 \
  man/groff_diff.7 \
  contrib/hdtbl/groff_hdtbl.7 \
  tmac/groff_man.7 \
  tmac/groff_man_style.7 \
  tmac/groff_mdoc.7 \
  tmac/groff_me.7 \
  contrib/mm/groff_mm.7

GROFF_MAN_PAGES2 = \
  contrib/mm/groff_mmse.7

GROFF_MAN_PAGES3 = \
  contrib/mom/groff_mom.7 \
  tmac/groff_ms.7 \
  contrib/rfc1345/groff_rfc1345.7 \
  tmac/groff_trace.7 \
  tmac/groff_www.7 \
  man/roff.7

GROFF_MAN_PAGES_ALL = $(GROFF_MAN_PAGES1) $(GROFF_MAN_PAGES2) \
  $(GROFF_MAN_PAGES3)

# This is a convenience target for (re-)generating all the man pages.
man-all: $(GROFF_MAN_PAGES_ALL)

# ...and for cleaning them.
man-clean:
	$(RM) $(GROFF_MAN_PAGES_ALL)

# Many pages use tbl, a few use eqn, and soelim(1) uses pic.  We also
# need groff's FreeEuro font so we can embed it.
#
# We embed the fonts (-P-e) to (1) honor the current PDF standard, (2)
# ensure consistent rendering of the document, and (3) exercise this
# feature of gropdf.
doc/groff-man-pages.pdf: $(GROFF_MAN_PAGES_ALL) eqn pic tbl \
  $(TMAC_PACKAGE_MAN) $(TMAC_PACKAGE_MDOC) font/devps/freeeuro.pfa
	$(GROFF_V)$(DOC_GROFF) -pet -mandoc -dHF=HB -rC1 \
	  -rCHECKSTYLE=3 -Tpdf -P-e \
	  $(GROFF_MAN_PAGES1) \
	  $(tmac_srcdir)/sv.tmac $(GROFF_MAN_PAGES2) \
	  $(tmac_srcdir)/en.tmac $(GROFF_MAN_PAGES3) > $@

doc/groff-man-pages.utf8.txt: $(GROFF_MAN_PAGES_ALL) eqn pic tbl \
  $(TMAC_PACKAGE_MAN) $(TMAC_PACKAGE_MDOC)
	$(GROFF_V)$(DOC_GROFF) -pet -Tutf8 -mandoc \
	  -rCHECKSTYLE=3 $(GROFF_MAN_PAGES1) \
	  $(tmac_srcdir)/sv.tmac $(GROFF_MAN_PAGES2) \
	  $(tmac_srcdir)/en.tmac $(GROFF_MAN_PAGES3) > $@

doc/grnexmpl.ps: $(doc_srcdir)/grnexmpl.me $(doc_srcdir)/grnexmpl.g \
  grn eqn
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_GROFF) -Tps -ge -me $(doc_srcdir)/grnexmpl.me >$@

# Generating *.me from *.me.in is, surprisingly, a challenge.
# 1.  A pattern rule ("%.me: %.me.in") is not portable to NetBSD or
#     OpenBSD make.
# 2.  A single-suffix rule works in an isolated Makefile, but _only_
#     with the .SUFFIXES special target, not with the
#     (Automake-specific) SUFFIXES macro.
#       .SUFFIXES: .in
#       .in:
#		$(DOC_SED) $< >$@
#     (One can validly complain that this approach is too general.)
# 3.  GNU Automake insists that we use the SUFFIXES macro and not the
#     special target.
#       error: use variable 'SUFFIXES', not target '.SUFFIXES'
# 4.  What about a target rule?  We'd have to explicitly write the first
#     dependency name in the rule commands because NetBSD make (and
#     reportedly OpenBSD) refuses to honor the $< variable in target
#     rules.
#
# So what is left?  A double-suffix rule--but you have to use it in a
# special way that is explicitly not countenanced by POSIX.
#
#   "The application shall ensure that the target portion is a valid
#   target name (see Target Rules) of the form .s2 or .s1.s2 (where .s1
#   and .s2 are suffixes that have been given as prerequisites of the
#   .SUFFIXES special target and s1 and s2 do not contain any <slash> or
#   <period> characters.) If there is only one <period> in the target,
#   it is a single-suffix inference rule. Targets with two periods are
#   double-suffix inference rules. Inference rules can have only one
#   target before the <colon>."
#     (POSIX Issue 8, make(1), "Inference Rules")
#
# A double-suffix rule won't work in an obvious way because its
# semantics are that the suffix is replaced, not removed.  You have to
# add both suffixes to the .SUFFIXES special target, in order with the
# dependency first.
#   .SUFFIXES: .me.in .me
#   .me.in.me:
#	$(DOC_SED) $< >$@
# Thanks to Automake, we must say
#   SUFFIXES += .me.in .me
# for reason 3 above.  The GNU Automake manual does not explicitly state
# that it preserves the ordering of the suffixes, but for now it does.
#
# It appears to be dumb luck that this works; the rigamarole by itself
# justifies to me the worth of GNU Make's pattern rules (which require
# neither '.SUFFIXES' nor 'SUFFIXES') and establishing semantics for $<
# in target rules.  But I won't hold my breath waiting on other make(1)
# implementors to agree.  -- GBR
.PRECIOUS: $(GENERATEDDOCFILES)
SUFFIXES += .me.in .me
.me.in.me:
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_SED) $< >$@

.me.ps:
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_GROFF) -Tps -me $< >$@

# Use '-K utf8', not '-k', in case 'configure' didn't find uchardet.
# The French translation uses tbl; its English counterpart does not.
doc/meintro_fr.ps: doc/meintro_fr.me preconv
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_GROFF) -K utf8 -t -Tps -me -mfr $< >$@

doc/ms.ps: $(doc_srcdir)/ms.ms eqn tbl
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_GROFF) -et -Tps -ms $(doc_srcdir)/ms.ms >$@

doc/pic.ps: $(doc_srcdir)/pic.ms eqn pic tbl
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_GROFF) -pet -Tps -ms $(doc_srcdir)/pic.ms >$@

doc/webpage.ps: $(DOC_GNU_EPS) tmac/www.tmac tbl
doc/webpage.ps: $(doc_srcdir)/webpage.ms
	$(GROFF_V)$(MKDIR_P) `dirname $@` \
	&& $(DOC_GROFF) -I $(doc_srcdir) -I $(doc_builddir) -t -Tps \
	  -ms -mwww $(doc_srcdir)/webpage.ms >$@

# We have no "generic" ms documents.
#.ms.ps:
#	$(GROFF_V)$(MKDIR_P) `dirname $@` \
#	&& $(DOC_GROFF) -Tps -ms $< >$@

doc/pic.html: eqn pic tbl
doc/pic.html: tmac/www.tmac
doc/pic.html: $(doc_srcdir)/pic.ms
	$(GROFF_V)$(MKDIR_P) $(doc_builddir) \
	&& cd $(doc_builddir) \
	&& $(DOC_GROFF) -pet -P-Ipic -P-Dimg -P-jpic -Thtml -ms \
	  $(doc_srcdir)/pic.ms > pic.html

doc/webpage.html: tbl
doc/webpage.html: tmac/www.tmac
doc/webpage.html: $(DOC_GNU_EPS)
doc/webpage.html: $(doc_srcdir)/groff.css
doc/webpage.html: $(doc_srcdir)/webpage.ms
	$(GROFF_V)$(MKDIR_P) $(doc_builddir) \
	&& cd $(doc_builddir) \
	&& $(DOC_GROFF) -t -I $(doc_srcdir) -P-jwebpage -P-nrb \
	  -P-Iwebpage -P-Dimg -Thtml -ms $(doc_srcdir)/webpage.ms \
	  > webpage.html

# We remove groff.css only from an out-of-source build tree.
mostlyclean-local: mostlyclean_doc
mostlyclean_doc:
if USE_GROHTML
	if test -d $(doc_builddir); then \
	  cd $(doc_builddir) \
	  && for f in $(HTMLDOCFILESALL); do \
	    $(RM) $$f; \
	  done; \
	fi
	if test -d $(doc_builddir)/img; then \
	  cd $(doc_builddir)/img \
	  && for f in $(HTMLDOCIMAGEFILES); do \
	    $(RM) $$f; \
	  done; \
	  rmdir  $(doc_builddir)/img || :; \
	fi
endif
	if test $(top_builddir) != $(top_srcdir); then \
	  $(RM) $(top_builddir)/doc/groff.css; \
	fi
if USE_GROHTML
	if test -d $(doc_builddir); then \
	  cd $(doc_builddir) \
	  && for f in $(HTMLEXAMPLEFILESALL); do \
	    $(RM) $$f; \
	  done; \
	fi
	if test -d $(doc_builddir)/img; then \
	  cd $(doc_builddir)/img \
	  && for f in $(HTMLEXAMPLEIMAGEFILES); do \
	    $(RM) $$f; \
	  done; \
	  rmdir  $(doc_builddir)/img || :; \
	fi
endif

install-data-hook: install_doc_htmldoc
install_doc_htmldoc:
if USE_GROHTML
	cd $(doc_builddir) \
	&& for f in `ls $(HTMLDOCFILESALL)`; do \
	  $(RM) $(DESTDIR)$(htmldocdir)/$$f; \
	  $(INSTALL_DATA) $$f $(DESTDIR)$(htmldocdir)/$$f; \
	done
	-test -d $(DESTDIR)$(htmldocdir)/$(imagedir) \
	  || $(mkinstalldirs) $(DESTDIR)$(htmldocdir)/$(imagedir)
	$(RM) $(DESTDIR)$(htmldocdir)/$(imagedir)/$(HTMLDOCIMAGEFILES)
	$(INSTALL_DATA) $(doc_builddir)/img/$(HTMLDOCIMAGEFILES) \
	  $(DESTDIR)$(htmldocdir)/$(imagedir)
endif

install-data-hook: install_doc_gnu_eps install_doc_examples

install_doc_gnu_eps: $(DOC_GNU_EPS)
	for d in $(doc_builddir) $(doc_srcdir); do \
	  if test -f "$$d/gnu.eps"; then \
	    $(RM) $(DESTDIR)$(exampledir)/gnu.eps; \
	    $(INSTALL_DATA) \
	      $$d/gnu.eps $(DESTDIR)$(exampledir)/gnu.eps; \
	    break; \
	  fi; \
	done

install_doc_examples: $(DOC_GNU_EPS)
if USE_GROHTML
	cd $(doc_builddir) \
	&& for f in `ls $(HTMLEXAMPLEFILESALL)`; do \
	  $(RM) $(DESTDIR)$(exampledir)/$$f; \
	  $(INSTALL_DATA) $$f $(DESTDIR)$(exampledir)/$$f; \
	done
	-test -d $(DESTDIR)$(exampledir)/$(imagedir) \
	  || $(mkinstalldirs) $(DESTDIR)$(exampledir)/$(imagedir)
	$(RM) \
	  $(DESTDIR)$(exampledir)/$(imagedir)/$(HTMLEXAMPLEIMAGEFILES)
	$(INSTALL_DATA) $(doc_builddir)/img/$(HTMLEXAMPLEIMAGEFILES) \
	  $(DESTDIR)$(exampledir)/$(imagedir)
endif

uninstall-hook: \
  uninstall_doc_examples uninstall_doc_htmldoc
uninstall_doc_examples:
	$(RM) $(DESTDIR)$(exampledir)/gnu.eps
if USE_GROHTML
	-test -d $(DESTDIR)$(docexamplesdir) \
	&& cd $(DESTDIR)$(docexamplesdir) \
	&& for f in $(HTMLEXAMPLEFILESALL); do \
	  $(RM) $$f; \
	done
	-test -d $(DESTDIR)$(docexamplesdir)/$(imagedir) \
	&& cd $(DESTDIR)$(docexamplesdir)/$(imagedir) \
	&& for f in $(HTMLEXAMPLEIMAGEFILES); do \
	  $(RM) $$f; \
	done
	-rmdir $(DESTDIR)$(docexamplesdir)/$(imagedir)
	-rmdir $(DESTDIR)$(docexamplesdir)
endif

uninstall_doc_htmldoc:
if USE_GROHTML
	-test -d $(DESTDIR)$(htmldocdir) \
	&& cd $(DESTDIR)$(htmldocdir) \
	&& for f in $(HTMLDOCFILESALL); do \
	  $(RM) $$f; \
	done
	-test -d $(DESTDIR)$(htmldocdir)/$(imagedir) \
	&& cd $(DESTDIR)$(htmldocdir)/$(imagedir) \
	&& for f in $(HTMLDOCIMAGEFILES); do \
	  $(RM) $$f; \
	done
	-rmdir $(DESTDIR)$(htmldocdir)/$(imagedir)
	-rmdir $(DESTDIR)$(htmldocdir)
endif

# groff Texinfo manual
#
# We produce all possible formats by by default and ship them in the
# distribution archive ('make dist') so that people don't need to have
# 'makeinfo' or TeX available.
#
# The GNU info, plain text, and HTML formats require only 'makeinfo'.
#
# DVI and PDF require a working TeX installation.  We can't use
# Automake's facilities for PDF production because its 'dist' target
# attempts to generate 'groff.pdf' by invoking 'texi2dvi' without the
# '-E' option (use 'makeinfo' to expand macros), which is needed to
# build this file.  'texi2dvi' honors the 'MAKEINFO' environment
# variable.
#
# Were the foregoing not true, we would simply say this:
#info_TEXINFOS = doc/groff.texi
#doc_groff_TEXINFOS = doc/fdl.texi

if USE_TEX
GROFF_DVI = doc/groff.dvi
GROFF_PDF = doc/groff.pdf
endif

all: doc/groff.info doc/groff.txt doc/groff.html $(GROFF_DVI) \
  $(GROFF_PDF)

# Distribute the manual in source form as well.
EXTRA_DIST += doc/groff.texi doc/fdl.texi

EXTRA_DIST += doc/groff.info
MAINTAINERCLEANFILES += doc/groff.info
doc/groff.info: $(doc_srcdir)/groff.texi
	$(AM_V_at)$(MKDIR_P) $(doc_builddir)
	$(AM_V_GEN)LANG=C \
	LC_ALL=C \
	$(MAKEINFO) -o doc/groff.info --enable-encoding \
	  -I $(doc_srcdir) $(doc_srcdir)/groff.texi

# Distribute the Info files.
dist-hook: dist-info-bits
dist-info-bits:
	chmod u+w $(distdir)/doc
	for d in $(doc_builddir) $(doc_srcdir); do \
	  if [ -f "$$d"/groff.info ]; then \
	    cp -f "$$d"/groff.info-* $(distdir)/doc; \
	    break; \
	  fi; \
	done

EXTRA_DIST += doc/groff.txt
MAINTAINERCLEANFILES += doc/groff.txt
.texi.txt:
	$(AM_V_at)$(MKDIR_P) $(doc_builddir)
	$(AM_V_GEN)LANG=C \
	LC_ALL=C \
	$(MAKEINFO) --enable-encoding -I $(doc_srcdir) --plaintext \
	  -o $@ $<

# Generate HTML, both split into several files, and as a single file.
# 'html' and its installation counterpart 'install-html' are standard
# Automake targets.
EXTRA_DIST += doc/groff.html doc/groff.html.node
MAINTAINERCLEANFILES += doc/groff.html doc/groff.html.node
.texi.html:
	$(AM_V_at)$(MKDIR_P) $(doc_builddir)/
	$(AM_V_GEN)LANG=C \
	LC_ALL=C \
	$(MAKEINFO) --html -I $(doc_srcdir) \
	  -o doc/`basename $@`.node $<
	$(AM_V_at)LANG=C \
	LC_ALL=C \
	$(MAKEINFO) --html -I $(doc_srcdir) --no-split \
	  -o $@ $<

EXTRA_DIST += doc/groff.dvi doc/groff.pdf

# Define pattern rules to make our Texinfo manual in DVI and PDF
# formats.  'pdf' and 'dvi' and their installation counterparts
# 'install-pdf' and 'install-dvi' are standard Automake targets.
.texi.dvi:
if HAVE_TEXI2DVI
if USE_TEX
	$(AM_V_at)$(MKDIR_P) $(doc_builddir)
	$(AM_V_GEN)LANG=C \
	LC_ALL=C \
	TEXINPUTS="$(top_srcdir)/build-aux:$(TEXINPUTS)" \
	MAKEINFO='$(MAKEINFO) -I $(doc_srcdir)' \
	FORCE_SOURCE_DATE=1 \
	$(PROG_TEXI2DVI) -e --batch --build-dir=doc/`basename $@`.t2d \
	  -o $@ $<
else
	@echo "program 'tex' is missing; cannot generate $@" >&2; \
	exit 1
endif # USE_TEX
else
	@echo "program 'texi2dvi' is missing or too old;" \
	  "cannot generate $@" >&2; \
	exit 1
endif # HAVE_TEXI2DVI

.texi.pdf:
if HAVE_TEXI2DVI
if USE_TEX
	$(AM_V_at)$(MKDIR_P) $(doc_builddir)
	$(AM_V_GEN)LANG=C \
	LC_ALL=C \
	TEXINPUTS="$(top_srcdir)/build-aux:$(TEXINPUTS)" \
	MAKEINFO='$(MAKEINFO) -I $(doc_srcdir)' \
	$(PROG_TEXI2DVI) -e --batch --pdf \
	  --build-dir=doc/`basename $@`.t2p -o $@ $<
else
	@echo "program 'tex' is missing; cannot generate $@" >&2; \
	exit 1
endif # USE_TEX
else
	@echo "program 'texi2dvi' is missing or too old;" \
	  "cannot generate $@" >&2; \
	exit 1
endif # HAVE_TEXI2DVI

install-doc: install-dvi install-html install-pdf

maintainer-clean-local:
	$(RM) $(doc_builddir)/groff.info*
	$(RM) $(doc_builddir)/groff.pdf
	$(RM) $(doc_builddir)/groff.dvi
	$(RM) $(doc_builddir)/groff.txt
	$(RM) -r $(doc_builddir)/groff.html.*

install-data-local: install-txt
install-txt:
	-test -d $(DESTDIR)$(docdir) \
	  || $(mkinstalldirs) $(DESTDIR)$(docdir)
	cp $(top_srcdir)/doc/groff.txt $(DESTDIR)$(docdir)

install-data-local: install_infodoc
install_infodoc: doc/groff.info
	-test -d $(DESTDIR)$(infodir) \
	  || $(mkinstalldirs) $(DESTDIR)$(infodir)
	$(RM) $(DESTDIR)/doc/groff.info*
	for d in $(doc_builddir) $(doc_srcdir); do \
	  if [ -f "$$d"/groff.info ]; then \
	    cp "$$d"/groff.info* $(DESTDIR)$(infodir); \
	    $(INSTALL_INFO) --info-file="$$d"/groff.info \
	      --info-dir=$(DESTDIR)$(infodir); \
	    break; \
	  fi; \
	done
install-pdf-local: doc/groff.pdf
	-test -d $(DESTDIR)$(pdfdocdir) \
	  || $(mkinstalldirs) $(DESTDIR)$(pdfdocdir)
	cp $(top_srcdir)/doc/groff.pdf $(DESTDIR)$(pdfdocdir)
install-html-local: doc/groff.html
	-test -d $(DESTDIR)$(htmldocdir)/groff.html.mono \
	  || $(mkinstalldirs) $(DESTDIR)$(htmldocdir)/groff.html.mono
	cp -r $(top_srcdir)/doc/groff.html \
	  $(DESTDIR)$(htmldocdir)/groff.html.mono
	cp -r $(top_srcdir)/doc/groff.html.node \
	  $(DESTDIR)$(htmldocdir)

uninstall-local: uninstall_infodoc uninstall-pdf uninstall-html \
  uninstall-txt
uninstall_doc: uninstall-local
uninstall-doc: uninstall-local
uninstall_infodoc:
	-$(INSTALL_INFO) --remove --info-dir=$(DESTDIR)$(infodir) \
	  $(DESTDIR)$(infodir)/groff.info
	-for f in `ls $(DESTDIR)$(infodir)/groff.info*`; do \
	  $(RM) $$f; \
	done
uninstall-pdf:
	$(RM) $(DESTDIR)$(pdfdocdir)/groff.pdf
	-rmdir $(DESTDIR)$(pdfdocdir)
uninstall-html:
	$(RM) $(DESTDIR)$(htmldocdir)/groff.html.mono/*
	$(RM) $(DESTDIR)$(htmldocdir)/groff.html.node/*
uninstall-txt:
	$(RM) $(DESTDIR)$(docdir)/groff.txt

# An image of a gnu in enscapsulated PostScript is generated during the
# build process if necessary.  Our configure script assumes pnmdepth is
# available if xpmtoppm is (see macro "GROFF_PROG_XPMTOPPM").
EXTRA_DIST += $(DOC_GNU_EPS) doc/gnu.xpm
$(DOC_GNU_EPS): doc/gnu.xpm
	$(AM_V_GEN)if test "$(XPMTOPPM)" != found; then \
	  echo "program 'xpmtoppm' is missing; can't generate $@" >&2; \
	  exit 1; \
	fi; \
	if test "$(pnmtops)" != found; then \
	  echo "program 'pnmtops' is missing; can't generate $@" >&2; \
	  exit 1; \
	fi; \
	if ! echo "$(pnmtops_nosetpage)" | grep -q nosetpage; then \
	  echo "program 'pnmtops' can't handle -nosetpage option;" \
	    "can't generate $@" >&2; \
	  exit 1; \
	fi; \
	xpmtoppm $(top_srcdir)/doc/gnu.xpm | pnmdepth 15 \
	  | $(pnmtops_nosetpage) -noturn -rle >$@

# Provide a copy of the image in the distribution archive to accommodate
# systems without a tool to generate it from an X pixmap.
dist-hook: dist-gnueps
dist-gnueps:
	chmod u+w $(distdir)/doc
	for d in $(doc_builddir) $(doc_srcdir); do \
	  if [ -f "$$d"/$(DOC_GNU_EPS) ]; then \
	    cp -f "$$d"/$(DOC_GNU_EPS) $(distdir)/doc; \
	    break; \
	  fi; \
	done


# Local Variables:
# fill-column: 72
# mode: makefile-automake
# End:
# vim: set autoindent filetype=automake textwidth=72: