summaryrefslogtreecommitdiff
path: root/common/Makefile.doc
blob: 68f2cf065b0629e7071b05af9baa41478d683855 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Symlink me to (or include me from) locale/*/Makefile

#### configuration

ASCIIDOC      = asciidoc
AWK           = awk

LOCALE   = $(shell basename `pwd`)
DOCLANG  = $(shell basename `pwd` | $(AWK) -F- '{ print ($$1 ~ /^[a-z][a-z]$$/) ? $$1 : "en" }')

ADC_SRC_FILES = $(wildcard *.txt)
ADC_FILES     = $(ADC_SRC_FILES:%.txt=%.html)
ADC_DEPS      = $(wildcard asciidoc.conf lang-$(DOCLANG).conf)

DOC_FILES     = $(ADC_FILES) version.html

.SILENT:

#### rules

.PHONY: all help doc asciidoc check-asciidoc clean distclean
all: doc

doc: asciidoc

help:
	@echo "$(NAME) $(VERSION) build"
	@echo
	@echo "  make help      - display this help"
	@echo "  make doc       - build doc files"
	@echo "  make clean     - clean up"
	@echo "  make distclean - clean up more"

clean:
	@echo "Cleanup of $(LOCALE) documentation..."

distclean: clean
	@echo "More cleanup of $(LOCALE) documentation..."
	rm -f $(DOC_FILES)

#### Makes single-file makes easier to type

%: %.html %.txt ;

#### asciidoc

asciidoc: check-asciidoc $(DOC_FILES)

check-asciidoc:
	@$(ASCIIDOC) --version | $(AWK) '{ exit $$2 !~ /^8\.2\./ }' || \
		echo >&2 "Warning: asciidoc versions other than 8.2.x are unsupported"

$(ADC_FILES): %.html: %.txt $(BASE)/Makefile.doc $(ADC_DEPS)
	@echo "DOC locale/$(LOCALE)/$@"
	$(ASCIIDOC) --unsafe -a linkcss -a quirks! -a lang=$(DOCLANG) -a doctitle="$(shell basename $@)" -o $@ $<

version.html: ../../NEWS $(BASE)/Makefile.doc $(ADC_DEPS)
	@echo "DOC locale/$(LOCALE)/$@"
	# NOTE: asciidoc doesn't source the conf file implicitly when processing stdin
	sed -e '1i\
HEADER' -e '/^[0-9]/d' -e '/^ \+\* version /s/.*version \+\([0-9.]\+\).*/section:Version{nbsp}\1[version-\1]\
/' ../../NEWS | ${ASCIIDOC} -f asciidoc.conf -a doctitle=version.html -o version.html -