-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrules.mk
63 lines (52 loc) · 1.81 KB
/
rules.mk
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
63
parentdir=.
# Allow local overrides if wanted
ifneq ($(wildcard $(TOPDIR)/local.mk),)
include $(TOPDIR)/local.mk
endif
# default html file if not specified
ifeq (,$(HTML_FILES))
HTML_FILES = index.html
endif
CLEANFILES = $(HTML_FILES) $(PDF_FILES)
ADOC_TO_PDF = asciidoctor-pdf -d book -o $@ $< \
--attribute=compat-mode \
--attribute=last-update-label\! \
--attribute=toc=left@ \
--attribute=version=$(VERSION) \
--attribute=shortversion=$(SHORTVERSION)
ADOC_TO_HTML = asciidoctor -d book -o $@ $< \
--attribute=compat-mode \
--attribute=last-update-label\! \
--attribute=toc=left@ \
--attribute=version=$(VERSION) \
--attribute=shortversion=$(SHORTVERSION)
CONCAT_PDFS = gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=$@ $(filter %.pdf,$^)
# default rule
all: html pdf
html: html-recursive html-local
html-local: $(HTML_FILES)
pdf: pdf-recursive pdf-local
pdf-local: $(PDF_FILES)
clean: clean-recursive clean-local
clean-local:
@for f in $(CLEANFILES); do [ -f "$$f" ] && rm "$$f" || true; done
html-recursive pdf-recursive clean-recursive:
@if [ "$(SUBDIRS)" != "" ]; then \
for dir in $(SUBDIRS); do echo "Entering $(parentdir)/$$dir [$(subst -recursive,,$@])" ; $(MAKE) -C $$dir parentdir=$(parentdir)/$$dir $(subst -recursive,,$@) || exit 1; done \
fi
%.html: %.adoc
@if expr X$< : '.*_Frag.adoc' || expr X$< : '.*_frag.adoc' > /dev/null; then \
true; \
else \
$(ADOC_TO_HTML); \
fi
%.pdf:
@if expr X$< : '.*.adoc' > /dev/null; then \
$(ADOC_TO_PDF); \
else \
$(CONCAT_PDFS); \
fi
$(SUBDIRS):
@make -C $@
.SUFFIXES: .pdf .adoc
.PHONY: all clean-recursive clean pdf $(SUBDIRS) html-local pdf-local