Bug 1004: NEWS and AUTHORS
[elinks.git] / doc / Makefile
blob6177874351edd1e389f234be46495bbb1b6eaccf
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
15 ASCIIDOC_CONF = $(srcdir)asciidoc.conf
16 ASCIIDOC_FLAGS += -f $(ASCIIDOC_CONF) \
17 -a "builddir=$(CURDIR)/" \
18 -a asciidoc7compatible \
19 -a elinks_version=$(VERSION)
21 #############################################################################
22 # Build files
24 TXT_DOCS = \
25 features.txt \
26 keymap-actions.txt \
27 keymap-defaults.txt \
28 option-command.txt \
29 option-config.txt
31 HTML_DOCS-$(CONFIG_ASCIIDOC) += \
32 elinks.1.html \
33 elinks.conf.5.html \
34 elinkskeys.5.html \
35 hacking.html \
36 manual.html
38 HTML_DOCS-$(CONFIG_XMLTO) += \
39 manual.html-chunked
41 HTML_DOCS-$(CONFIG_POD2HTML) += \
42 perl.html \
43 perl-hooks.html
45 MAN_DOCS-$(CONFIG_XMLTO) += \
46 elinks.1 \
47 elinks.conf.5 \
48 elinkskeys.5
50 # Use jw for generating PDF, since xmlto seems to freak out.
51 PDF_DOCS-$(CONFIG_JW) += \
52 manual.pdf
55 #############################################################################
56 ## Set the default doc rules
58 MAN_DOCS = $(MAN_DOCS-yes)
59 HTML_DOCS = $(HTML_DOCS-yes)
60 PDF_DOCS = $(PDF_DOCS-yes)
62 txt: $(TXT_DOCS)
63 html: txt $(HTML_DOCS)
64 pdf: txt $(PDF_DOCS)
65 man: txt $(MAN_DOCS)
67 all-docs: man html pdf
69 install-doc: all-docs update-man install
70 @$(foreach doc,$(HTML_DOCS), \
71 if test -d $(doc); then \
72 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html/$(doc); \
73 $(call ncmd,installdata,$(doc)/*,$(HTML_DIR)/$(doc)); \
74 else \
75 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html; \
76 $(call ncmd,installdata,$(doc),$(HTML_DIR)); \
77 fi;)
78 @$(foreach doc,$(PDF_DOCS), \
79 $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/pdf; \
80 $(call ncmd,installdata,$(doc),$(PDF_DIR);))
82 update-man: man
83 @$(if $(MAN_DOCS), \
84 $(call ncmd,installdata,elinks.1,$(srcdir)man/man1/elinks.1.in); \
85 $(call ncmd,installdata,elinkskeys.5,$(srcdir)man/man5/); \
86 $(call ncmd,installdata,elinks.conf.5,$(srcdir)man/man5/))
88 clean-local:
89 @$(RM) -r $(TXT_DOCS) $(MAN_DOCS) $(HTML_DOCS) $(PDF_DOCS) *.tmp *.xml
91 # TODO: perl.pod should be pod2ized during make install. --pasky
92 install-local:
95 #############################################################################
96 # Generated asciidoc files
98 # Scripts and Dependencies
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 #############################################################################
135 # Build commands and macros
137 quiet_cmd_jw = ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
138 cmd_jw = $(JW) -b $(2) $<
140 quiet_cmd_xmlto = ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
141 cmd_xmlto = $(XMLTO) -o $(call outdir) $(3) $(2) $<
143 quiet_cmd_pod2html = ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
144 cmd_pod2html = $(POD2HTML) --outfile=$@ < $<
146 quiet_cmd_asciidoc = ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
147 cmd_asciidoc = $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b $(call backend) -d $(call doctype) -o $@ $<
149 # Based on $@ find out asciidoc doctype or backend + xmlto output dir.
150 doctype = $(if $(findstring .1.,$@)$(findstring .5.,$@),manpage,book)
151 backend = $(if $(findstring .xml,$@),docbook,xhtml11)
152 outdir = $(if $(findstring -chunked,$@),$@,.)
154 # Loosely track dependencies via asciidoc includes.
155 asciidoc_dep = sed -n 's/[{]builddir}//g;s@include::\(.*\)\[.*@$@: $< \1@p' < $< > .deps/$(@F).asciidoc
157 -include .deps/*.asciidoc
160 #############################################################################
161 # Build recipies
163 %.html: %.txt $(ASCIIDOC_CONF)
164 $(call cmd,asciidoc,xhtml11)
165 @-$(call asciidoc_dep)
167 %.xml: %.txt $(ASCIIDOC_CONF)
168 $(call cmd,asciidoc,docbook)
169 @-$(call asciidoc_dep)
171 %.1: %.1.xml
172 $(call cmd,xmlto,man)
174 %.5: %.5.xml
175 $(call cmd,xmlto,man)
177 %.html-chunked: %.xml
178 $(call cmd,xmlto,html)
180 %.pdf: %.xml
181 $(call cmd,jw,pdf)
183 %.html: %.pod
184 $(call cmd,pod2html)
186 perl-%.html: %.pl
187 $(call cmd,pod2html)
190 include $(top_srcdir)/Makefile.lib