From a892c84601fe7db59a072bc9c3e059b5cba3c097 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 16 Jan 2006 00:18:39 +0100 Subject: [PATCH] Make it possible to build all-docs when $(builddir) != $(srcdir) --- doc/Makefile | 25 +++++++++++++++---------- doc/elinks.1.txt | 2 +- doc/elinks.conf.5.txt | 2 +- doc/elinkskeys.5.txt | 4 ++-- doc/installation.txt | 2 +- doc/tools/conf2doc | 3 ++- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index a421fb481..f5edabb29 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -12,6 +12,9 @@ docdir = $(datadir)/doc HTML_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/html PDF_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/pdf +ASCIIDOC_CONF = $(srcdir)asciidoc.conf +ASCIIDOC_FLAGS = -f $(ASCIIDOC_CONF) -a "builddir=$(CURDIR)/" + ############################################################################# # Build files @@ -108,7 +111,7 @@ 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 = $(LOCALES) $(CONF2DOC) > $@ + cmd_conf2doc = $(LOCALES) $(CONF2DOC) $(FEATURES) > $@ quiet_cmd_keys2doc = ' [$(LINK_COLOR)KEYS2DOC$(END_COLOR)] $(RELPATH)$@' cmd_keys2doc = $(LOCALES) $(KEYS2DOC) $(KBDBIND) $@ > $@ @@ -149,25 +152,27 @@ api: $(patsubst %.txt,%.html,$(API_TXT)) cmd_jw = $(JW) -b $(2) $< quiet_cmd_xmlto = ' [$(LINK_COLOR)XMLTO$(END_COLOR)] $(RELPATH)$@' - cmd_xmlto = $(XMLTO) $(3) $(2) $< + cmd_xmlto = $(XMLTO) -o $(call outdir) $(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 $@ $< + cmd_asciidoc = $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b $(call backend) -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)) +# Based on $@ find out asciidoc doctype or backend + xmlto output dir. +doctype = $(if $(findstring .1.,$@)$(findstring .5.,$@),manpage,book) +backend = $(if $(findstring .xml,$@),docbook,xhtml11) +outdir = $(if $(findstring -chunked,$@),$@,.) # Loosely track dependencies via asciidoc includes. -asciidoc_dep = sed -n 's@include::\(.*\)\[.*@$@: \1@p' < $< > .deps/$(@F).asciidoc +asciidoc_dep = sed -n 's/[{]builddir}//g;s@include::\(.*\)\[.*@$@: $< \1@p' < $< > .deps/$(@F).asciidoc -include .deps/*.asciidoc # Do a little post-processing of man pages. Inserting title headers and date. MAN_DATE = $(shell date -I) -man_desc = `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(subst .xml,.txt,$<)` +man_desc = `sed -n 's/:Description:\s*\(.*\)/\1/p' < $(srcdir)$(subst .xml,.txt,$( $@.tmp && mv $@.tmp $@ @@ -175,11 +180,11 @@ man_hack = sed "s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" ############################################################################# # Build recipies -%.html: %.txt asciidoc.conf +%.html: %.txt $(ASCIIDOC_CONF) $(call cmd,asciidoc,xhtml11) @-$(call asciidoc_dep) -%.xml: %.txt asciidoc.conf +%.xml: %.txt $(ASCIIDOC_CONF) $(call cmd,asciidoc,docbook) @-$(call asciidoc_dep) @@ -192,7 +197,7 @@ man_hack = sed "s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" @$(call man_hack,$(call man_desc)) %.html-chunked: %.xml - $(call cmd,xmlto,html,-o $@) + $(call cmd,xmlto,html) %.pdf: %.xml $(call cmd,jw,pdf) diff --git a/doc/elinks.1.txt b/doc/elinks.1.txt index 0866fa490..060336f69 100644 --- a/doc/elinks.1.txt +++ b/doc/elinks.1.txt @@ -35,7 +35,7 @@ Most options can be set in the user interface or config file, so usually you do not need to care about them. Note that this list is roughly equivalent to the output of running ELinks with the option `--long-help`. -include::option-command.txt[] +include::{builddir}option-command.txt[] ENVIRONMENT VARIABLES --------------------- diff --git a/doc/elinks.conf.5.txt b/doc/elinks.conf.5.txt index 15394cf7e..715d9027c 100644 --- a/doc/elinks.conf.5.txt +++ b/doc/elinks.conf.5.txt @@ -56,7 +56,7 @@ Some sample settings: OPTIONS ------- -include::option-config.txt[] +include::{builddir}option-config.txt[] SEE ALSO -------- diff --git a/doc/elinkskeys.5.txt b/doc/elinkskeys.5.txt index d53230756..a59c15835 100644 --- a/doc/elinkskeys.5.txt +++ b/doc/elinkskeys.5.txt @@ -93,7 +93,7 @@ FIXME: KEYMAP ACTIONS -------------- -include::keymap-actions.txt[] +include::{builddir}keymap-actions.txt[] DEFAULT BINDINGS ---------------- @@ -101,7 +101,7 @@ DEFAULT BINDINGS The default bindings are shown below. Any bindings in `~/.elinks/elinks.conf` will override these. -include::keymap-defaults.txt[] +include::{builddir}keymap-defaults.txt[] AUTHOR ------ diff --git a/doc/installation.txt b/doc/installation.txt index c999f1607..b8e076e73 100644 --- a/doc/installation.txt +++ b/doc/installation.txt @@ -71,6 +71,6 @@ include::small.txt[] include::ecmascript.txt[] -include::features.txt[] +include::{builddir}features.txt[] endif::installation-webpage[] diff --git a/doc/tools/conf2doc b/doc/tools/conf2doc index d8bff9f22..99034bb29 100755 --- a/doc/tools/conf2doc +++ b/doc/tools/conf2doc @@ -4,6 +4,7 @@ # Copyright (c) Jonas Fonseca , 2005 # +CONFFILE="$1" TMPFILE=$(mktemp import-features.conf.XXXXXX) || exit 1 strip_comment() @@ -53,7 +54,7 @@ __END__ fi } -cat ../features.conf | while read line; do +cat "$CONFFILE" | while read line; do case "$line" in "### "*) print_section