2 include $(top_builddir
)/Makefile.config
6 # A little trick to simplify some of the rules.
7 VPATH
= $(builddir
):$(srcdir):$(top_srcdir
)/contrib
/perl
9 docdir
= $(datadir)/doc
12 HTML_DIR
= $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
13 PDF_DIR
= $(DESTDIR
)$(docdir
)/$(PACKAGE
)/pdf
15 #############################################################################
25 HTML_DOCS-
$(CONFIG_ASCIIDOC
) += \
32 HTML_DOCS-
$(CONFIG_XMLTO
) += \
35 HTML_DOCS-
$(CONFIG_POD2HTML
) += \
39 MAN_DOCS-
$(CONFIG_XMLTO
) += \
44 # Use jw for generating PDF, since xmlto seems to freak out.
45 PDF_DOCS-
$(CONFIG_JW
) += \
49 #############################################################################
50 ## Set the default doc rules
52 MAN_DOCS
= $(MAN_DOCS-yes
)
53 HTML_DOCS
= $(HTML_DOCS-yes
)
54 PDF_DOCS
= $(PDF_DOCS-yes
)
57 html
: txt
$(HTML_DOCS
)
61 all-docs
: man html pdf
63 install-doc
: all-docs update-man
install
64 $(foreach doc
,$(HTML_DOCS
), \
65 if
test -d
$(doc
); then \
66 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
/$(doc
); \
67 $(call ncmd
,installdata
,$(doc
)/*,$(HTML_DIR
)/$(doc
)); \
69 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
; \
70 $(call ncmd
,installdata
,$(doc
),$(HTML_DIR
)); \
72 $(foreach doc
,$(PDF_DOCS
), \
73 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/pdf
; \
74 $(call ncmd
,installdata
,$(doc
),$(PDF_DIR
);))
78 $(call ncmd
,installdata
,elinks
.1,man
/man1
/elinks
.1.in
); \
79 $(call ncmd
,installdata
,elinkskeys
.5,man
/man5
/); \
80 $(call ncmd
,installdata
,elinks.conf
.5,man
/man5
/))
83 @
$(RM
) -r api
$(TXT_DOCS
) $(MAN_DOCS
) $(HTML_DOCS
) $(PDF_DOCS
) *.tmp
*.xml
85 # TODO: perl.pod should be pod2ized during make install. --pasky
89 #############################################################################
90 # Generated asciidoc files
92 # Scripts and Dependencies
93 CODE2DOC
= $(srcdir)tools
/code2doc
94 HELP2DOC
= $(srcdir)tools
/help2doc
95 CONF2DOC
= $(srcdir)tools
/conf2doc
96 KEYS2DOC
= $(srcdir)tools
/keys2doc
97 ELINKS
= $(top_builddir
)/src
/elinks
98 FEATURES
= $(top_srcdir
)/features.conf
99 KBDBIND
= $(top_srcdir
)/src
/config
/kbdbind.c
101 # Locale env vars to override system one to ensure commands
102 # using elinks binary will generate texts in english
103 LOCALES
= LC_ALL
=C LANGUAGE
=en
105 # FIXME: Keep generated .txt files relative to the source directory and files
106 # they are included in.
107 quiet_cmd_help2doc
= ' [$(LINK_COLOR)HELP2DOC$(END_COLOR)] $(RELPATH)$@'
108 cmd_help2doc
= $(LOCALES
) $(HELP2DOC
) $(ELINKS
) $@
> $@
110 quiet_cmd_conf2doc
= ' [$(LINK_COLOR)CONF2DOC$(END_COLOR)] $(RELPATH)$@'
111 cmd_conf2doc
= $(LOCALES
) $(CONF2DOC
) > $@
113 quiet_cmd_keys2doc
= ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@'
114 cmd_keys2doc
= $(LOCALES
) $(KEYS2DOC
) $(KBDBIND
) $@
> $@
116 features.txt
: $(FEATURES
) $(CONF2DOC
)
119 keymap-
%.txt
: $(KBDBIND
) $(KEYS2DOC
)
122 option-
%.txt
: $(ELINKS
) $(HELP2DOC
)
128 ifeq ($(findstring api
,$(MAKECMDGOALS
)),api
)
129 API
= $(shell find
$(top_srcdir
)/src
/ -name
'*.h' -exec grep
-q
'API Doc' \
{\
} \
; -printf
"%p " |
sort)
133 api
/$(2).txt
: $(1) $(CODE2DOC
)
134 @
test -d api ||
$(MKINSTALLDIRS
) api
135 @
$(CODE2DOC
) $(1) > $$@
136 API_TXT
+= api
/$(2).txt
139 api_name
= $(shell sed
-n
's/.*API Doc\s*::\s*\([^ ]*\).*/\1/p' < $(1))
140 $(foreach api
,$(API
),$(eval
$(call api_doc
,$(api
),$(call api_name
,$(api
)))))
142 api
: $(patsubst %.txt
,%.html
,$(API_TXT
))
145 #############################################################################
146 # Build commands and macros
148 quiet_cmd_jw
= ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
149 cmd_jw
= $(JW
) -b
$(2) $<
151 quiet_cmd_xmlto
= ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
152 cmd_xmlto
= $(XMLTO
) $(3) $(2) $<
154 quiet_cmd_pod2html
= ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
155 cmd_pod2html
= $(POD2HTML
) --outfile
=$@
< $<
157 quiet_cmd_asciidoc
= ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
158 cmd_asciidoc
= $(ASCIIDOC
) -f asciidoc.conf
-b
$(2) -d
$(call doctype
,$<) -o
$@
$<
160 # Based on filename in $(1) find out asciidoc doctype.
161 doctype
= $(if
$(findstring .1.
,$(1)),manpage
,$(if
$(findstring .5.
,$(1)),manpage
,book
))
163 # Loosely track dependencies via asciidoc includes.
164 asciidoc_dep
= sed
-n
's@include::\(.*\)\[.*@$@: \1@p' < $< > .deps
/$(@F
).asciidoc
166 -include .deps
/*.asciidoc
168 # Do a little post-processing of man pages. Inserting title headers and date.
169 MAN_DATE
= $(shell date
-I
)
170 man_desc
= `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(subst .xml,.txt,$<)`
171 man_hack
= sed
"s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" \"$(1)\"/" < $@ | \
172 sed
"s/@squote@/\\\\'/g" > $@.tmp
&& mv
$@.tmp
$@
175 #############################################################################
178 %.html
: %.txt asciidoc.conf
179 $(call cmd
,asciidoc
,xhtml11
)
182 %.xml
: %.txt asciidoc.conf
183 $(call cmd
,asciidoc
,docbook
)
187 $(call cmd
,xmlto
,man
)
188 $(call man_hack
,$(call man_desc
))
191 $(call cmd
,xmlto
,man
)
192 $(call man_hack
,$(call man_desc
))
194 %.html-chunked
: %.xml
195 $(call cmd
,xmlto
,html
,-o
$@
)
207 include $(top_srcdir
)/Makefile.lib