File: Makefile

package info (click to toggle)
docbook2x 0.8.8-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,740 kB
  • sloc: xml: 16,229; sh: 3,674; perl: 3,461; ansic: 639; makefile: 409; sed: 11
file content (29 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- makefile -*-

# Notes:
# 1. you must have package libxml2-python2.3 installed
# 2. your document must have a titleabbrev in the refentryinfo
# 3. your document must have a refmiscinfo with role=infodirsection

XTR=python -c 'import sys, libxml2; \
print libxml2.parseFile(sys.argv[1]).xpathEval(sys.argv[2])[0].content'

all: $(patsubst %.dbk,%.info,$(wildcard *.dbk))

%.info: %.dbk
	docbook2x-texi --info --to-stdout $< | \
	  awk -v base=`basename $< .dbk` \
	    -v sect="`${XTR} $< '//refmiscinfo[@role="infodirsection"]'`" \
	    -v title="`${XTR} $< '/refentry/refentryinfo/titleabbrev'`" \
	    'BEGIN { p=1 } \
	    /^START-INFO-DIR-ENTRY/ { print \
	        "INFO-DIR-SECTION " sect "\n" $$0;  p=0 } \
	    /^END-INFO-DIR-ENTRY/ { p=1 } \
	    /^\* / { if (p==0) { gsub(/.*\./, ""); \
	        print "* " title ": (" base ")." $$0 } } \
	    /^File: stdout,/ { if (p==1) { \
	        gsub(/File: stdout/, "File: " base ".info"); p=2 } } \
	    { if (p) { print } }' > $@

clean::
	rm -f *.info *~