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 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
) += \
42 MAN_DOCS-
$(CONFIG_XMLTO
) += \
47 # Use jw for generating PDF, since xmlto seems to freak out.
48 PDF_DOCS-
$(CONFIG_JW
) += \
52 #############################################################################
53 ## Set the default doc rules
55 MAN_DOCS
= $(MAN_DOCS-yes
)
56 HTML_DOCS
= $(HTML_DOCS-yes
)
57 PDF_DOCS
= $(PDF_DOCS-yes
)
60 html
: txt
$(HTML_DOCS
)
64 all-docs
: man html pdf
66 install-doc
: all-docs update-man
install
67 @
$(foreach doc
,$(HTML_DOCS
), \
68 if
test -d
$(doc
); then \
69 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
/$(doc
); \
70 $(call ncmd
,installdata
,$(doc
)/*,$(HTML_DIR
)/$(doc
)); \
72 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/html
; \
73 $(call ncmd
,installdata
,$(doc
),$(HTML_DIR
)); \
75 @
$(foreach doc
,$(PDF_DOCS
), \
76 $(MKINSTALLDIRS
) $(DESTDIR
)$(docdir
)/$(PACKAGE
)/pdf
; \
77 $(call ncmd
,installdata
,$(doc
),$(PDF_DIR
);))
81 $(call ncmd
,installdata
,elinks
.1,man
/man1
/elinks
.1.in
); \
82 $(call ncmd
,installdata
,elinkskeys
.5,man
/man5
/); \
83 $(call ncmd
,installdata
,elinks.conf
.5,man
/man5
/))
86 @
$(RM
) -r
$(TXT_DOCS
) $(MAN_DOCS
) $(HTML_DOCS
) $(PDF_DOCS
) *.tmp
*.xml
88 # TODO: perl.pod should be pod2ized during make install. --pasky
92 #############################################################################
93 # Generated asciidoc files
95 # Scripts and Dependencies
96 HELP2DOC
= $(srcdir)tools
/help2doc
97 CONF2DOC
= $(srcdir)tools
/conf2doc
98 KEYS2DOC
= $(srcdir)tools
/keys2doc
99 ELINKS
= $(top_builddir
)/src
/elinks
100 FEATURES
= $(top_srcdir
)/features.conf
101 KBDBIND
= $(top_srcdir
)/src
/config
/kbdbind.c
103 # Locale env vars to override system one to ensure commands
104 # using elinks binary will generate texts in english
105 LOCALES
= LC_ALL
=C LANGUAGE
=en
107 # FIXME: Keep generated .txt files relative to the source directory and files
108 # they are included in.
109 quiet_cmd_help2doc
= ' [$(LINK_COLOR)HELP2DOC$(END_COLOR)] $(RELPATH)$@'
110 cmd_help2doc
= $(LOCALES
) $(HELP2DOC
) $(ELINKS
) $@
> $@
112 quiet_cmd_conf2doc
= ' [$(LINK_COLOR)CONF2DOC$(END_COLOR)] $(RELPATH)$@'
113 cmd_conf2doc
= $(LOCALES
) $(CONF2DOC
) $(FEATURES
) > $@
115 quiet_cmd_keys2doc
= ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@'
116 cmd_keys2doc
= $(LOCALES
) $(KEYS2DOC
) $(KBDBIND
) $@
> $@
118 quiet_cmd_code2doc
= ' [$(LINK_COLOR)CODE2DOC$(END_COLOR)] $(RELPATH)$@'
119 cmd_code2doc
= $(LOCALES
) $(CODE2DOC
) $< > $@
121 features.txt
: $(FEATURES
) $(CONF2DOC
)
124 keymap-
%.txt
: $(KBDBIND
) $(KEYS2DOC
)
127 option-
%.txt
: $(ELINKS
) $(HELP2DOC
)
131 #############################################################################
132 # Build commands and macros
134 quiet_cmd_jw
= ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
135 cmd_jw
= $(JW
) -b
$(2) $<
137 quiet_cmd_xmlto
= ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
138 cmd_xmlto
= $(XMLTO
) -o
$(call outdir
) $(3) $(2) $<
140 quiet_cmd_pod2html
= ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
141 cmd_pod2html
= $(POD2HTML
) --outfile
=$@
< $<
143 quiet_cmd_asciidoc
= ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
144 cmd_asciidoc
= $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b
$(call backend
) -d
$(call doctype
) -o
$@
$<
146 # Based on $@ find out asciidoc doctype or backend + xmlto output dir.
147 doctype
= $(if
$(findstring .1.
,$@
)$(findstring .5.
,$@
),manpage
,book
)
148 backend
= $(if
$(findstring .xml
,$@
),docbook
,xhtml11
)
149 outdir
= $(if
$(findstring -chunked
,$@
),$@
,.
)
151 # Loosely track dependencies via asciidoc includes.
152 asciidoc_dep
= sed
-n
's/[{]builddir}//g;s@include::\(.*\)\[.*@$@: $< \1@p' < $< > .deps
/$(@F
).asciidoc
154 -include .deps
/*.asciidoc
156 # Do a little post-processing of man pages. Inserting title headers and date.
157 MAN_DATE
= $(shell date
-I
)
158 man_desc
= `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(srcdir)$(subst .xml,.txt,$(<F))`
159 man_hack
= sed
"s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" \"$(1)\"/" < $@ | \
160 sed
"s/@squote@/\\\\'/g" > $@.tmp
&& mv
$@.tmp
$@
163 #############################################################################
166 %.html
: %.txt
$(ASCIIDOC_CONF
)
167 $(call cmd
,asciidoc
,xhtml11
)
168 @
-$(call asciidoc_dep
)
170 %.xml
: %.txt
$(ASCIIDOC_CONF
)
171 $(call cmd
,asciidoc
,docbook
)
172 @
-$(call asciidoc_dep
)
175 $(call cmd
,xmlto
,man
)
176 @
$(call man_hack
,$(call man_desc
))
179 $(call cmd
,xmlto
,man
)
180 @
$(call man_hack
,$(call man_desc
))
182 %.html-chunked
: %.xml
183 $(call cmd
,xmlto
,html
)
195 include $(top_srcdir
)/Makefile.lib