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
15 ASCIIDOC_CONF
= $(srcdir)asciidoc.conf
16 ASCIIDOC_FLAGS
+= -f
$(ASCIIDOC_CONF
) -a
"builddir=$(CURDIR)/"
18 #############################################################################
28 HTML_DOCS-
$(CONFIG_ASCIIDOC
) += \
35 HTML_DOCS-
$(CONFIG_XMLTO
) += \
38 HTML_DOCS-
$(CONFIG_POD2HTML
) += \
39 perl-check-accelerator-conflicts.html \
40 perl-gather-accelerator-contexts.html \
44 MAN_DOCS-
$(CONFIG_XMLTO
) += \
49 # Use jw for generating PDF, since xmlto seems to freak out.
50 PDF_DOCS-
$(CONFIG_JW
) += \
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
)
62 html
: txt
$(HTML_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
)); \
74 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
; \
75 $(call ncmd
,installdata
,$(doc
),$(HTML_DIR
)); \
77 @
$(foreach doc
,$(PDF_DOCS
), \
78 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/pdf
; \
79 $(call ncmd
,installdata
,$(doc
),$(PDF_DIR
);))
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
/))
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
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
)
127 keymap-
%.txt
: $(KBDBIND
) $(KEYS2DOC
)
130 option-
%.txt
: $(ELINKS
) $(HELP2DOC
)
136 ifeq ($(findstring api
,$(MAKECMDGOALS
)),api
)
137 API
= $(shell find
$(top_srcdir
)/src
/ -name
'*.h' -exec grep
-q
'API Doc' \
{\
} \
; -printf
"%p " |
sort)
141 API_TXT
+= api
/$(2).txt
142 api
/$(2).txt
: $(1) $(CODE2DOC
)
143 @
test -d api ||
$(MKINSTALLDIRS
) api
144 $$(call cmd
,code2doc
)
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 #############################################################################
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
)
197 $(call cmd
,xmlto
,man
)
198 @
$(call man_hack
,$(call man_desc
))
201 $(call cmd
,xmlto
,man
)
202 @
$(call man_hack
,$(call man_desc
))
204 %.html-chunked
: %.xml
205 $(call cmd
,xmlto
,html
)
217 include $(top_srcdir
)/Makefile.lib