elinks -remote 'ping' says:
[elinks.git] / doc / Makefile
blob75355c594dcda686e3d083c026cbfa49db35d81a
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:$(top_srcdir)/po/perl
9 docdir = $(datadir)/doc
11 # Used by install-doc
12 HTML_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/html
13 PDF_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/pdf
15 ASCIIDOC_CONF = $(srcdir)asciidoc.conf
16 ASCIIDOC_FLAGS += -f $(ASCIIDOC_CONF) -a "builddir=$(CURDIR)/"
18 #############################################################################
19 # Build files
21 TXT_DOCS = \
22 features.txt \
23 keymap-actions.txt \
24 keymap-defaults.txt \
25 option-command.txt \
26 option-config.txt
28 HTML_DOCS-$(CONFIG_ASCIIDOC) += \
29 elinks.1.html \
30 elinks.conf.5.html \
31 elinkskeys.5.html \
32 hacking.html \
33 manual.html
35 HTML_DOCS-$(CONFIG_XMLTO) += \
36 manual.html-chunked
38 HTML_DOCS-$(CONFIG_POD2HTML) += \
39 perl-check-accelerator-conflicts.html \
40 perl-gather-accelerator-contexts.html \
41 perl.html \
42 perl-hooks.html
44 MAN_DOCS-$(CONFIG_XMLTO) += \
45 elinks.1 \
46 elinks.conf.5 \
47 elinkskeys.5
49 # Use jw for generating PDF, since xmlto seems to freak out.
50 PDF_DOCS-$(CONFIG_JW) += \
51 manual.pdf
54 #############################################################################
55 ## Set the default doc rules
57 MAN_DOCS = $(MAN_DOCS-yes)
58 HTML_DOCS = $(HTML_DOCS-yes)
59 PDF_DOCS = $(PDF_DOCS-yes)
61 txt: $(TXT_DOCS)
62 html: txt $(HTML_DOCS)
63 pdf: txt $(PDF_DOCS)
64 man: txt $(MAN_DOCS)
66 all-docs: man html pdf
68 install-doc: all-docs update-man install
69 @$(foreach doc,$(HTML_DOCS), \
70 if test -d $(doc); then \
71 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html/$(doc); \
72 $(call ncmd,installdata,$(doc)/*,$(HTML_DIR)/$(doc)); \
73 else \
74 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html; \
75 $(call ncmd,installdata,$(doc),$(HTML_DIR)); \
76 fi;)
77 @$(foreach doc,$(PDF_DOCS), \
78 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/pdf; \
79 $(call ncmd,installdata,$(doc),$(PDF_DIR);))
81 update-man: man
82 @$(if $(MAN_DOCS), \
83 $(call ncmd,installdata,elinks.1,man/man1/elinks.1.in); \
84 $(call ncmd,installdata,elinkskeys.5,man/man5/); \
85 $(call ncmd,installdata,elinks.conf.5,man/man5/))
87 clean-local:
88 @$(RM) -r api $(TXT_DOCS) $(MAN_DOCS) $(HTML_DOCS) $(PDF_DOCS) *.tmp *.xml
90 # TODO: perl.pod should be pod2ized during make install. --pasky
91 install-local:
94 #############################################################################
95 # Generated asciidoc files
97 # Scripts and Dependencies
98 CODE2DOC = $(srcdir)tools/code2doc
99 HELP2DOC = $(srcdir)tools/help2doc
100 CONF2DOC = $(srcdir)tools/conf2doc
101 KEYS2DOC = $(srcdir)tools/keys2doc
102 ELINKS = $(top_builddir)/src/elinks
103 FEATURES = $(top_srcdir)/features.conf
104 KBDBIND = $(top_srcdir)/src/config/kbdbind.c
106 # Locale env vars to override system one to ensure commands
107 # using elinks binary will generate texts in english
108 LOCALES = LC_ALL=C LANGUAGE=en
110 # FIXME: Keep generated .txt files relative to the source directory and files
111 # they are included in.
112 quiet_cmd_help2doc = ' [$(LINK_COLOR)HELP2DOC$(END_COLOR)] $(RELPATH)$@'
113 cmd_help2doc = $(LOCALES) $(HELP2DOC) $(ELINKS) $@ > $@
115 quiet_cmd_conf2doc = ' [$(LINK_COLOR)CONF2DOC$(END_COLOR)] $(RELPATH)$@'
116 cmd_conf2doc = $(LOCALES) $(CONF2DOC) $(FEATURES) > $@
118 quiet_cmd_keys2doc = ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@'
119 cmd_keys2doc = $(LOCALES) $(KEYS2DOC) $(KBDBIND) $@ > $@
121 quiet_cmd_code2doc = ' [$(LINK_COLOR)CODE2DOC$(END_COLOR)] $(RELPATH)$@'
122 cmd_code2doc = $(LOCALES) $(CODE2DOC) $< > $@
124 features.txt: $(FEATURES) $(CONF2DOC)
125 $(call cmd,conf2doc)
127 keymap-%.txt: $(KBDBIND) $(KEYS2DOC)
128 $(call cmd,keys2doc)
130 option-%.txt: $(ELINKS) $(HELP2DOC)
131 $(call cmd,help2doc)
134 # API Docs
136 ifeq ($(findstring api,$(MAKECMDGOALS)),api)
137 API = $(shell find $(top_srcdir)/src/ -name '*.h' -exec grep -q 'API Doc' \{\} \; -printf "%p " | sort)
138 endif
140 define api_doc
141 API_TXT += api/$(2).txt
142 api/$(2).txt: $(1) $(CODE2DOC)
143 @test -d api || $(MKINSTALLDIRS) api
144 $$(call cmd,code2doc)
145 endef
147 api_name = $(shell sed -n 's/.*API Doc\s*::\s*\([^ ]*\).*/\1/p' < $(1))
148 $(foreach api,$(API),$(eval $(call api_doc,$(api),$(call api_name,$(api)))))
150 api: $(patsubst %.txt,%.html,$(API_TXT))
153 #############################################################################
154 # Build commands and macros
156 quiet_cmd_jw = ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
157 cmd_jw = $(JW) -b $(2) $<
159 quiet_cmd_xmlto = ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
160 cmd_xmlto = $(XMLTO) -o $(call outdir) $(3) $(2) $<
162 quiet_cmd_pod2html = ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
163 cmd_pod2html = $(POD2HTML) --outfile=$@ < $<
165 quiet_cmd_asciidoc = ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
166 cmd_asciidoc = $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b $(call backend) -d $(call doctype) -o $@ $<
168 # Based on $@ find out asciidoc doctype or backend + xmlto output dir.
169 doctype = $(if $(findstring .1.,$@)$(findstring .5.,$@),manpage,book)
170 backend = $(if $(findstring .xml,$@),docbook,xhtml11)
171 outdir = $(if $(findstring -chunked,$@),$@,.)
173 # Loosely track dependencies via asciidoc includes.
174 asciidoc_dep = sed -n 's/[{]builddir}//g;s@include::\(.*\)\[.*@$@: $< \1@p' < $< > .deps/$(@F).asciidoc
176 -include .deps/*.asciidoc
178 # Do a little post-processing of man pages. Inserting title headers and date.
179 MAN_DATE = $(shell date -I)
180 man_desc = `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(srcdir)$(subst .xml,.txt,$(<F))`
181 man_hack = sed "s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" \"$(1)\"/" < $@ | \
182 sed "s/@squote@/\\\\'/g" > $@.tmp && mv $@.tmp $@
185 #############################################################################
186 # Build recipies
188 %.html: %.txt $(ASCIIDOC_CONF)
189 $(call cmd,asciidoc,xhtml11)
190 @-$(call asciidoc_dep)
192 %.xml: %.txt $(ASCIIDOC_CONF)
193 $(call cmd,asciidoc,docbook)
194 @-$(call asciidoc_dep)
196 %.1: %.1.xml
197 $(call cmd,xmlto,man)
198 @$(call man_hack,$(call man_desc))
200 %.5: %.5.xml
201 $(call cmd,xmlto,man)
202 @$(call man_hack,$(call man_desc))
204 %.html-chunked: %.xml
205 $(call cmd,xmlto,html)
207 %.pdf: %.xml
208 $(call cmd,jw,pdf)
210 %.html: %.pod
211 $(call cmd,pod2html)
213 perl-%.html: %.pl
214 $(call cmd,pod2html)
217 include $(top_srcdir)/Makefile.lib