NEWS: mention bugs 723, 869
[elinks.git] / doc / Makefile
blobed9b6fdabf97adb9cda16d6d15c7ba8d87899558
1 top_builddir=..
2 include $(top_builddir)/Makefile.config
4 SUBDIRS = man
6 # A little trick to simplify some of the rules.
7 VPATH = $(builddir):$(srcdir):$(top_srcdir)/contrib/perl
9 docdir = $(datadir)/doc
11 # Used by install-doc
12 HTML_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/html
13 PDF_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/pdf
14 TXT_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/txt
16 ASCIIDOC_CONF = $(srcdir)asciidoc.conf
17 ASCIIDOC_FLAGS += -f $(ASCIIDOC_CONF) -a "builddir=$(CURDIR)/"
19 #############################################################################
20 # Build files
22 TXT_DOCS_NOINSTALL = \
23 features.txt \
24 keymap-actions.txt \
25 keymap-defaults.txt \
26 option-command.txt \
27 option-config.txt
29 TXT_DOCS_ASIS = \
30 python.txt
32 HTML_DOCS-$(CONFIG_ASCIIDOC) += \
33 elinks.1.html \
34 elinks.conf.5.html \
35 elinkskeys.5.html \
36 hacking.html \
37 manual.html
39 HTML_DOCS-$(CONFIG_XMLTO) += \
40 manual.html-chunked
42 HTML_DOCS-$(CONFIG_POD2HTML) += \
43 perl.html \
44 perl-hooks.html
46 # We don't nowadays run pod2html on the po/perl/ scripts, because
47 # "make install" does not install them and they do not have the .pl
48 # suffix expected by the pod2html rule below.
50 MAN_DOCS-$(CONFIG_XMLTO) += \
51 elinks.1 \
52 elinks.conf.5 \
53 elinkskeys.5
55 # Use jw for generating PDF, since xmlto seems to freak out.
56 PDF_DOCS-$(CONFIG_JW) += \
57 manual.pdf
60 #############################################################################
61 ## Set the default doc rules
63 MAN_DOCS = $(MAN_DOCS-yes)
64 HTML_DOCS = $(HTML_DOCS-yes)
65 PDF_DOCS = $(PDF_DOCS-yes)
67 txt: $(TXT_DOCS_NOINSTALL)
68 html: txt $(HTML_DOCS)
69 pdf: txt $(PDF_DOCS)
70 man: txt $(MAN_DOCS)
72 all-docs: man html pdf
74 install-doc: all-docs update-man install
75 @$(foreach doc,$(HTML_DOCS), \
76 if test -d $(doc); then \
77 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html/$(doc); \
78 $(call ncmd,installdata,$(doc)/*,$(HTML_DIR)/$(doc)); \
79 else \
80 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html; \
81 $(call ncmd,installdata,$(doc),$(HTML_DIR)); \
82 fi;)
83 @$(foreach doc,$(PDF_DOCS), \
84 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/pdf; \
85 $(call ncmd,installdata,$(doc),$(PDF_DIR));)
86 @$(foreach doc,$(TXT_DOCS_ASIS), \
87 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/txt; \
88 $(call ncmd,installdata,$(srcdir)$(doc),$(TXT_DIR));)
90 update-man: man
91 @$(if $(MAN_DOCS), \
92 $(call ncmd,installdata,elinks.1,$(srcdir)man/man1/elinks.1.in); \
93 $(call ncmd,installdata,elinkskeys.5,$(srcdir)man/man5/); \
94 $(call ncmd,installdata,elinks.conf.5,$(srcdir)man/man5/))
96 clean-local:
97 @$(RM) -r api $(TXT_DOCS_NOINSTALL) $(MAN_DOCS) $(HTML_DOCS) $(PDF_DOCS) *.tmp *.xml
99 # TODO: perl.pod should be pod2ized during make install. --pasky
100 install-local:
103 #############################################################################
104 # Generated asciidoc files
106 # Scripts and Dependencies
107 HELP2DOC = $(srcdir)tools/help2doc
108 CONF2DOC = $(srcdir)tools/conf2doc
109 KEYS2DOC = $(srcdir)tools/keys2doc
110 ELINKS = $(top_builddir)/src/elinks
111 FEATURES = $(top_srcdir)/features.conf
112 KBDBIND = $(top_srcdir)/src/config/kbdbind.c
114 # Locale env vars to override system one to ensure commands
115 # using elinks binary will generate texts in english
116 LOCALES = LC_ALL=C LANGUAGE=en
118 # FIXME: Keep generated .txt files relative to the source directory and files
119 # they are included in.
120 quiet_cmd_help2doc = ' [$(LINK_COLOR)HELP2DOC$(END_COLOR)] $(RELPATH)$@'
121 cmd_help2doc = $(LOCALES) $(HELP2DOC) $(ELINKS) $@ > $@
123 quiet_cmd_conf2doc = ' [$(LINK_COLOR)CONF2DOC$(END_COLOR)] $(RELPATH)$@'
124 cmd_conf2doc = $(LOCALES) $(CONF2DOC) $(FEATURES) > $@
126 quiet_cmd_keys2doc = ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@'
127 cmd_keys2doc = $(LOCALES) $(KEYS2DOC) $(KBDBIND) $@ > $@
129 features.txt: $(FEATURES) $(CONF2DOC)
130 $(call cmd,conf2doc)
132 keymap-%.txt: $(KBDBIND) $(KEYS2DOC)
133 $(call cmd,keys2doc)
135 option-%.txt: $(ELINKS) $(HELP2DOC)
136 $(call cmd,help2doc)
139 #############################################################################
140 # Build commands and macros
142 quiet_cmd_jw = ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
143 cmd_jw = $(JW) -b $(2) $<
145 quiet_cmd_xmlto = ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
146 cmd_xmlto = $(XMLTO) -o $(call outdir) $(3) $(2) $<
148 quiet_cmd_pod2html = ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
149 cmd_pod2html = $(POD2HTML) --outfile=$@ < $<
151 quiet_cmd_asciidoc = ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
152 cmd_asciidoc = $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b $(call backend) -d $(call doctype) -o $@ $<
154 # Based on $@ find out asciidoc doctype or backend + xmlto output dir.
155 doctype = $(if $(findstring .1.,$@)$(findstring .5.,$@),manpage,book)
156 backend = $(if $(findstring .xml,$@),docbook,xhtml11)
157 outdir = $(if $(findstring -chunked,$@),$@,.)
159 # Loosely track dependencies via asciidoc includes.
160 asciidoc_dep = sed -n 's/[{]builddir}//g;s@include::\(.*\)\[.*@$@: $< \1@p' < $< > .deps/$(@F).asciidoc
162 -include .deps/*.asciidoc
164 # Do a little post-processing of man pages. Inserting title headers and date.
165 MAN_DATE = $(shell date -I)
166 man_desc = `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(srcdir)$(subst .xml,.txt,$(<F))`
167 man_hack = sed "s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" \"$(1)\"/" < $@ | \
168 sed "s/@squote@/\\\\'/g" > $@.tmp && mv $@.tmp $@
171 #############################################################################
172 # Build recipies
174 %.html: %.txt $(ASCIIDOC_CONF)
175 $(call cmd,asciidoc,xhtml11)
176 @-$(call asciidoc_dep)
178 %.xml: %.txt $(ASCIIDOC_CONF)
179 $(call cmd,asciidoc,docbook)
180 @-$(call asciidoc_dep)
182 %.1: %.1.xml
183 $(call cmd,xmlto,man)
184 @$(call man_hack,$(call man_desc))
186 %.5: %.5.xml
187 $(call cmd,xmlto,man)
188 @$(call man_hack,$(call man_desc))
190 %.html-chunked: %.xml
191 $(call cmd,xmlto,html)
193 %.pdf: %.xml
194 $(call cmd,jw,pdf)
196 %.html: %.pod
197 $(call cmd,pod2html)
199 perl-%.html: %.pl
200 $(call cmd,pod2html)
203 include $(top_srcdir)/Makefile.lib