1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00
elinks/doc/Makefile

208 lines
5.7 KiB
Makefile
Raw Normal View History

2005-10-19 22:00:35 -04:00
top_builddir=..
include $(top_builddir)/Makefile.config
SUBDIRS = man
# A little trick to simplify some of the rules.
VPATH = $(builddir):$(srcdir):$(top_srcdir)/contrib/perl
2006-01-13 06:42:14 -05:00
docdir = $(datadir)/doc
# Used by install-doc
HTML_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/html
PDF_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/pdf
#############################################################################
# Build files
TXT_DOCS = \
features.txt \
keymap-actions.txt \
keymap-defaults.txt \
option-command.txt \
option-config.txt
2006-01-08 15:46:21 -05:00
HTML_DOCS-$(CONFIG_ASCIIDOC) += \
2006-01-08 15:57:55 -05:00
elinks.1.html \
elinks.conf.5.html \
2006-01-08 15:57:55 -05:00
elinkskeys.5.html \
hacking.html \
manual.html
2006-01-08 15:46:21 -05:00
HTML_DOCS-$(CONFIG_XMLTO) += \
2006-01-08 15:57:55 -05:00
manual.html-chunked
HTML_DOCS-$(CONFIG_POD2HTML) += \
perl.html \
perl-hooks.html \
2006-01-08 15:46:21 -05:00
MAN_DOCS-$(CONFIG_XMLTO) += \
elinks.1 \
elinks.conf.5 \
elinkskeys.5
2005-09-15 22:38:48 -04:00
# Use jw for generating PDF, since xmlto seems to freak out.
2006-01-08 15:46:21 -05:00
PDF_DOCS-$(CONFIG_JW) += \
2006-01-08 15:57:55 -05:00
manual.pdf
#############################################################################
## Set the default doc rules
MAN_DOCS = $(MAN_DOCS-yes)
HTML_DOCS = $(HTML_DOCS-yes)
PDF_DOCS = $(PDF_DOCS-yes)
txt: $(TXT_DOCS)
html: txt $(HTML_DOCS)
pdf: txt $(PDF_DOCS)
2006-01-12 04:29:05 -05:00
man: txt $(MAN_DOCS)
all-docs: man html pdf
install-doc: all-docs update-man install
2006-01-13 06:42:14 -05:00
$(foreach doc,$(HTML_DOCS), \
if test -d $(doc); then \
$(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html/$(doc); \
$(call ncmd,installdata,$(doc)/*,$(HTML_DIR)/$(doc)); \
else \
$(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/html; \
$(call ncmd,installdata,$(doc),$(HTML_DIR)); \
fi;)
$(foreach doc,$(PDF_DOCS), \
$(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/pdf; \
$(call ncmd,installdata,$(doc),$(PDF_DIR);))
2006-01-12 04:29:05 -05:00
update-man: man
$(if $(MAN_DOCS), \
$(call ncmd,installdata,elinks.1,man/man1/elinks.1.in); \
$(call ncmd,installdata,elinkskeys.5,man/man5/); \
$(call ncmd,installdata,elinks.conf.5,man/man5/))
clean-local:
@$(RM) -r api $(TXT_DOCS) $(MAN_DOCS) $(HTML_DOCS) $(PDF_DOCS) *.tmp *.xml
# TODO: perl.pod should be pod2ized during make install. --pasky
install-local:
#############################################################################
# Generated asciidoc files
# Scripts and Dependencies
CODE2DOC = $(srcdir)tools/code2doc
HELP2DOC = $(srcdir)tools/help2doc
IMPORT_FEATURES_CONF = $(srcdir)tools/import-features.conf
MAKE_ELINKSKEYS_MANPAGE = $(srcdir)tools/make-elinkskeys-manpage
ELINKS = $(top_builddir)/src/elinks
FEATURES = $(top_srcdir)/features.conf
KBDBIND = $(top_srcdir)/src/config/kbdbind.c
# Locale env vars to override system one to ensure commands
# using elinks binary will generate texts in english
LOCALES = LC_ALL=C LANGUAGE=en
# FIXME: Keep generated .txt files relative to the source directory and files
# they are included in.
2006-01-12 04:29:05 -05:00
quiet_cmd_help2doc = ' [$(LINK_COLOR)HELP2DOC$(END_COLOR)] $(RELPATH)$@'
cmd_help2doc = $(LOCALES) $(HELP2DOC) $(ELINKS) $@ > $@
quiet_cmd_conf2doc = ' [$(LINK_COLOR)CONF2DOC$(END_COLOR)] $(RELPATH)$@'
cmd_conf2doc = $(IMPORT_FEATURES_CONF) > $@
quiet_cmd_keys2doc = ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@'
cmd_keys2doc = $(LOCALES) $(MAKE_ELINKSKEYS_MANPAGE) $(KBDBIND) $@ > $@
features.txt: $(FEATURES) $(IMPORT_FEATURES_CONF)
$(call cmd,conf2doc)
keymap-%.txt: $(MAKE_ELINKSKEYS_MANPAGE) $(KBDBIND)
$(call cmd,keys2doc)
option-%.txt: $(ELINKS) $(HELP2DOC)
2006-01-12 04:29:05 -05:00
$(call cmd,help2doc)
# API Docs
ifeq ($(findstring api,$(MAKECMDGOALS)),api)
API = $(shell find $(top_srcdir)/src/ -name '*.h' -exec grep -q 'API Doc' \{\} \; -printf "%p " | sort)
endif
define api_doc
api/$(2).txt: $(1) $(CODE2DOC)
@test -d api || $(MKINSTALLDIRS) api
@$(CODE2DOC) $(1) > $$@
API_TXT += api/$(2).txt
endef
api_name = $(shell sed -n 's/.*API Doc\s*::\s*\([^ ]*\).*/\1/p' < $(1))
$(foreach api,$(API),$(eval $(call api_doc,$(api),$(call api_name,$(api)))))
api: $(patsubst %.txt,%.html,$(API_TXT))
#############################################################################
# Build commands and macros
quiet_cmd_jw = ' [$(LINK_COLOR)JW$(END_COLOR)] $(RELPATH)$@'
cmd_jw = $(JW) -b $(2) $<
quiet_cmd_xmlto = ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@'
cmd_xmlto = $(XMLTO) $(3) $(2) $<
quiet_cmd_pod2html = ' [$(LINK_COLOR)POD2HTML$(END_COLOR)] $(RELPATH)$@'
cmd_pod2html = $(POD2HTML) --outfile=$@ < $<
quiet_cmd_asciidoc = ' [$(LINK_COLOR)ASCIIDOC$(END_COLOR)] $(RELPATH)$@'
cmd_asciidoc = $(ASCIIDOC) -f asciidoc.conf -b $(2) -d $(call doctype,$<) -o $@ $<
# Based on filename in $(1) find out asciidoc doctype.
doctype = $(if $(findstring .1.,$(1)),manpage,$(if $(findstring .5.,$(1)),manpage,book))
# Loosely track dependencies via asciidoc includes.
asciidoc_dep = sed -n 's@include::\(.*\)\[.*@$@: \1@p' < $< > .deps/$(@F).asciidoc
-include .deps/*.asciidoc
# Do a little post-processing of man pages. Inserting title headers and date.
2006-01-12 04:29:05 -05:00
MAN_DATE = $(shell date -I)
man_desc = `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(subst .xml,.txt,$<)`
man_hack = sed "s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" \"$(1)\"/" < $@ | \
sed "s/@squote@/\\\\'/g" > $@.tmp && mv $@.tmp $@
#############################################################################
# Build recipies
%.html: %.txt asciidoc.conf
2006-01-11 05:12:03 -05:00
$(call cmd,asciidoc,xhtml11)
$(call asciidoc_dep)
%.xml: %.txt asciidoc.conf
2006-01-11 05:12:03 -05:00
$(call cmd,asciidoc,docbook)
$(call asciidoc_dep)
%.1: %.1.xml
2006-01-11 05:12:03 -05:00
$(call cmd,xmlto,man)
2006-01-12 04:29:05 -05:00
$(call man_hack,$(call man_desc))
%.5: %.5.xml
2006-01-11 05:12:03 -05:00
$(call cmd,xmlto,man)
2006-01-12 04:29:05 -05:00
$(call man_hack,$(call man_desc))
%.html-chunked: %.xml
2006-01-11 05:12:03 -05:00
$(call cmd,xmlto,html,-o $@)
2005-09-15 22:38:48 -04:00
%.pdf: %.xml
2006-01-11 05:12:03 -05:00
$(call cmd,jw,pdf)
%.html: %.pod
2006-01-11 05:12:03 -05:00
$(call cmd,pod2html)
perl-%.html: %.pl
2006-01-11 05:12:03 -05:00
$(call cmd,pod2html)
include $(top_srcdir)/Makefile.lib