2 include $(top_builddir
)/Makefile.config
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
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 #############################################################################
22 TXT_DOCS_NOINSTALL
= \
32 HTML_DOCS-
$(CONFIG_ASCIIDOC
) += \
39 HTML_DOCS-
$(CONFIG_XMLTO
) += \
42 HTML_DOCS-
$(CONFIG_POD2HTML
) += \
46 # Don't install these documents, because the corresponding scripts
47 # are not installed either. However, generating them may be useful.
48 HTML_DOCS_NOINSTALL-
$(CONFIG_POD2HTML
) += \
49 perl-check-accelerator-conflicts.html \
50 perl-gather-accelerator-contexts.html
52 MAN_DOCS-
$(CONFIG_XMLTO
) += \
57 # Use jw for generating PDF, since xmlto seems to freak out.
58 PDF_DOCS-
$(CONFIG_JW
) += \
62 #############################################################################
63 ## Set the default doc rules
65 MAN_DOCS
= $(MAN_DOCS-yes
)
66 HTML_DOCS
= $(HTML_DOCS-yes
)
67 HTML_DOCS_NOINSTALL
= $(HTML_DOCS_NOINSTALL-yes
)
68 PDF_DOCS
= $(PDF_DOCS-yes
)
70 txt
: $(TXT_DOCS_NOINSTALL
)
71 html
: txt
$(HTML_DOCS
) $(HTML_DOCS_NOINSTALL
)
75 all-docs
: man html pdf
77 install-doc
: all-docs update-man
install
78 @
$(foreach doc
,$(HTML_DOCS
), \
79 if
test -d
$(doc
); then \
80 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
/$(doc
); \
81 $(call ncmd
,installdata
,$(doc
)/*,$(HTML_DIR
)/$(doc
)); \
83 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
; \
84 $(call ncmd
,installdata
,$(doc
),$(HTML_DIR
)); \
86 @
$(foreach doc
,$(PDF_DOCS
), \
87 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/pdf
; \
88 $(call ncmd
,installdata
,$(doc
),$(PDF_DIR
));)
89 @
$(foreach doc
,$(TXT_DOCS_ASIS
), \
90 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/txt
; \
91 $(call ncmd
,installdata
,$(srcdir)$(doc
),$(TXT_DIR
));)
95 $(call ncmd
,installdata
,elinks
.1,$(srcdir)man
/man1
/elinks
.1.in
); \
96 $(call ncmd
,installdata
,elinkskeys
.5,$(srcdir)man
/man5
/); \
97 $(call ncmd
,installdata
,elinks.conf
.5,$(srcdir)man
/man5
/))
100 @
$(RM
) -r api
$(TXT_DOCS_NOINSTALL
) $(MAN_DOCS
) $(HTML_DOCS
) $(HTML_DOCS_NOINSTALL
) $(PDF_DOCS
) *.tmp
*.xml
102 # TODO: perl.pod should be pod2ized during make install. --pasky
106 #############################################################################
107 # Generated asciidoc files
109 # Scripts and Dependencies
110 HELP2DOC
= $(srcdir)tools
/help2doc
111 CONF2DOC
= $(srcdir)tools
/conf2doc
112 KEYS2DOC
= $(srcdir)tools
/keys2doc
113 ELINKS
= $(top_builddir
)/src
/elinks
114 FEATURES
= $(top_srcdir
)/features.conf
115 KBDBIND
= $(top_srcdir
)/src
/config
/kbdbind.c
117 # Locale env vars to override system one to ensure commands
118 # using elinks binary will generate texts in english
119 LOCALES
= LC_ALL
=C LANGUAGE
=en
121 # FIXME: Keep generated .txt files relative to the source directory and files
122 # they are included in.
123 quiet_cmd_help2doc
= ' [$(LINK_COLOR)HELP2DOC$(END_COLOR)] $(RELPATH)$@'
124 cmd_help2doc
= $(LOCALES
) $(HELP2DOC
) $(ELINKS
) $@
> $@
126 quiet_cmd_conf2doc
= ' [$(LINK_COLOR)CONF2DOC$(END_COLOR)] $(RELPATH)$@'
127 cmd_conf2doc
= $(LOCALES
) $(CONF2DOC
) $(FEATURES
) > $@
129 quiet_cmd_keys2doc
= ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@'
130 cmd_keys2doc
= $(LOCALES
) $(KEYS2DOC
) $(KBDBIND
) $@
> $@
132 features.txt
: $(FEATURES
) $(CONF2DOC
)
135 keymap-
%.txt
: $(KBDBIND
) $(KEYS2DOC
)
138 option-
%.txt
: $(ELINKS
) $(HELP2DOC
)
142 #############################################################################
143 # Build commands and macros
145 quiet_cmd_jw
= ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
146 cmd_jw
= $(JW
) -b
$(2) $<
148 quiet_cmd_xmlto
= ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
149 cmd_xmlto
= $(XMLTO
) -o
$(call outdir
) $(3) $(2) $<
151 quiet_cmd_pod2html
= ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
152 cmd_pod2html
= $(POD2HTML
) --outfile
=$@
< $<
154 quiet_cmd_asciidoc
= ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
155 cmd_asciidoc
= $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b
$(call backend
) -d
$(call doctype
) -o
$@
$<
157 # Based on $@ find out asciidoc doctype or backend + xmlto output dir.
158 doctype
= $(if
$(findstring .1.
,$@
)$(findstring .5.
,$@
),manpage
,book
)
159 backend
= $(if
$(findstring .xml
,$@
),docbook
,xhtml11
)
160 outdir
= $(if
$(findstring -chunked
,$@
),$@
,.
)
162 # Loosely track dependencies via asciidoc includes.
163 asciidoc_dep
= sed
-n
's/[{]builddir}//g;s@include::\(.*\)\[.*@$@: $< \1@p' < $< > .deps
/$(@F
).asciidoc
165 -include .deps
/*.asciidoc
167 # Do a little post-processing of man pages. Inserting title headers and date.
168 # - Change SYNOPSIS to OVERVIEW in elinkskeys.5 (but not in elinks.1).
169 # SYNOPSIS isn't supposed to contain running text. But AsciiDoc
170 # 7.1.2 complains "ERROR: elinkskeys.5.txt: line 10: second section
171 # must be named SYNOPSIS" so we can't change this in elinkskeys.5.txt.
172 # - Write backslash as "\e" not "\\", but be careful not to replace
173 # double-backslashes that actually mean something else. This is
174 # apparently a bug in db2man, which xmlto runs.
175 # Run all the hacks together in one sed command so that we get the right
176 # exit code if there is an error somewhere in the middle.
177 MAN_DATE
= $(shell date
-I
)
178 man_desc
= `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(srcdir)$(subst .xml,.txt,$(<F))`
179 man_hack
= sed
-e
"s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" \"$(1)\"/" \
180 -e
's/\\\\\\\\ /\\e\\e /' \
181 -e
's/\(\\fI\)\\\\\(\\fR\)/\1\\e\2/' \
182 -e
"s/@squote@/\\\\'/g" \
183 $(if
$(findstring elinkskeys
.5,$(<F
)),-e
's/^\.SH "SYNOPSIS"$$/.SH "OVERVIEW"/') \
187 #############################################################################
190 %.html
: %.txt
$(ASCIIDOC_CONF
)
191 $(call cmd
,asciidoc
,xhtml11
)
192 @
-$(call asciidoc_dep
)
194 %.xml
: %.txt
$(ASCIIDOC_CONF
)
195 $(call cmd
,asciidoc
,docbook
)
196 @
-$(call asciidoc_dep
)
199 $(call cmd
,xmlto
,man
)
200 @
$(call man_hack
,$(call man_desc
))
203 $(call cmd
,xmlto
,man
)
204 @
$(call man_hack
,$(call man_desc
))
206 %.html-chunked
: %.xml
207 $(call cmd
,xmlto
,html
)
219 include $(top_srcdir
)/Makefile.lib