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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
PROJECT = rabbit
DEPS = rabbitmq_common
dep_rabbitmq_common= git file:///home/dumbbell/Projects/pivotal/other-repos/rabbitmq-common master
.DEFAULT_GOAL = all
# --------------------------------------------------------------------
# Man pages.
# --------------------------------------------------------------------
DOCS_DIR = docs
MANPAGES = $(patsubst %.xml, %.gz, $(wildcard $(DOCS_DIR)/*.[0-9].xml))
WEB_MANPAGES = $(patsubst %.xml, %.man.xml, $(wildcard $(DOCS_DIR)/*.[0-9].xml) $(DOCS_DIR)/rabbitmq-service.xml $(DOCS_DIR)/rabbitmq-echopid.xml)
USAGES_XML = $(DOCS_DIR)/rabbitmqctl.1.xml $(DOCS_DIR)/rabbitmq-plugins.1.xml
USAGES_ERL = $(foreach XML, $(USAGES_XML), $(call usage_xml_to_erl, $(XML)))
# xmlto can not read from standard input, so we mess with a tmp file.
%.gz: %.xml $(DOCS_DIR)/examples-to-end.xsl
$(gen_verbose) xmlto --version | \
grep -E '^xmlto version 0\.0\.([0-9]|1[1-8])$$' >/dev/null || \
opt='--stringparam man.indent.verbatims=0' ; \
xsltproc --novalid $(DOCS_DIR)/examples-to-end.xsl $< > $<.tmp && \
xmlto -o $(DOCS_DIR) $$opt man $<.tmp && \
gzip -f $(DOCS_DIR)/`basename $< .xml` && \
rm -f $<.tmp
# Use tmp files rather than a pipeline so that we get meaningful errors
# Do not fold the cp into previous line, it's there to stop the file being
# generated but empty if we fail
src/%_usage.erl:
$(gen_verbose) xsltproc --novalid --stringparam modulename "`basename $@ .erl`" \
$(DOCS_DIR)/usage.xsl $< > $@.tmp && \
sed -e 's/"/\\"/g' -e 's/%QUOTE%/"/g' $@.tmp > $@.tmp2 && \
fold -s $@.tmp2 > $@.tmp3 && \
mv $@.tmp3 $@ && \
rm $@.tmp $@.tmp2
# We rename the file before xmlto sees it since xmlto will use the name of
# the file to make internal links.
%.man.xml: %.xml $(DOCS_DIR)/html-to-website-xml.xsl
$(gen_verbose) cp $< `basename $< .xml`.xml && \
xmlto xhtml-nochunks `basename $< .xml`.xml ; \
rm `basename $< .xml`.xml && \
cat `basename $< .xml`.html | \
xsltproc --novalid $(DOCS_DIR)/remove-namespaces.xsl - | \
xsltproc --novalid --stringparam original `basename $<` $(DOCS_DIR)/html-to-website-xml.xsl - | \
xmllint --format - > $@ && \
rm `basename $< .xml`.html
define usage_xml_to_erl
$(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(subst -,_,$(1))))
endef
define usage_dep
$(call usage_xml_to_erl, $(1)):: $(1) $(DOCS_DIR)/usage.xsl
endef
$(foreach XML,$(USAGES_XML),$(eval $(call usage_dep, $(XML))))
# --------------------------------------------------------------------
# Back to main targets.
# --------------------------------------------------------------------
include erlang.mk
ebin/$(PROJECT).app:: $(USAGES_ERL)
$(if $(strip $?),$(call compile_erl,$?))
clean:: clean-generated
clean-generated:
$(gen_verbose) rm -f $(USAGES_ERL)
COMPILE_FIRST = $(basename \
$(notdir \
$(shell grep -lw '^behaviour_info' src/*.erl)))
ERLC_OPTS += -I $(DEPS_DIR)/rabbitmq_common/include
ifdef INSTRUMENT_FOR_QC
ERLC_OPTS += -DINSTR_MOD=gm_qc
else
ERLC_OPTS += -DINSTR_MOD=gm
endif
ifdef CREDIT_FLOW_TRACING
ERLC_OPTS += -DCREDIT_FLOW_TRACING=true
endif
define boolean_macro
$(if $(filter true,$(1)),-D$(2))
endef
# Our type specs rely on dict:dict/0 etc, which are only available in
# 17.0 upwards.
define compare_version
$(shell awk 'BEGIN {
split("$(1)", v1, "\.");
version1 = v1[1] * 1000000 + v1[2] * 10000 + v1[3] * 100 + v1[4];
split("$(2)", v2, "\.");
version2 = v2[1] * 1000000 + v2[2] * 10000 + v2[3] * 100 + v2[4];
if (version1 $(3) version2) {
print "true";
} else {
print "false";
}
}')
endef
ERTS_VER = $(shell erl -version 2>&1 | sed -E 's/.* version //')
USE_SPECS_MIN_ERTS_VER = 5.11
ifeq ($(call compare_version,$(ERTS_VER),$(USE_SPECS_MIN_ERTS_VER),>=),true)
ERLC_OPTS += -Duse_specs
endif
ifndef USE_PROPER_QC
# PropEr needs to be installed for property checking
# http://proper.softlab.ntua.gr/
USE_PROPER_QC := $(shell erl -noshell -eval 'io:format({module, proper} =:= code:ensure_loaded(proper)), halt().')
ERLC_OPTS += $(call boolean_macro,$(USE_PROPER_QC),use_proper_qc)
endif
|