summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2010-03-21 19:05:15 +0000
committerMatthew Sackman <matthew@lshift.net>2010-03-21 19:05:15 +0000
commit89a56a4bc9dfeb872ffe381f70f75e59fc6deb90 (patch)
tree503458d17b805cc6121d9dcd455d4099654c7c25
parent134c1ea18d4869b6943582f6bff8a6666e482f60 (diff)
downloadrabbitmq-server-89a56a4bc9dfeb872ffe381f70f75e59fc6deb90.tar.gz
Corrected build system:
a) Do not bother with the intermediate docs/.erl b) Define USAGES_XML and USAGES_ERL correctly and incorporate with SOURCES c) Declare the dependencies between the usage erls and usage xmls dynamically (define, call and eval are our friends here) d) Correct use of automatic variables and take advantage of (a) e) Given use of SOURCE_DIR, EBIN_DIR and such like, define and use DOC_DIR f) Correct order in generate_deps to ensure the .erl is the *first* dep of the .beam. This means we can drop the .erl in the .erl => .beam automatic rule and rely on the deps file populating $< with the .erl g) Tidy .hgignore
-rw-r--r--.hgignore4
-rw-r--r--Makefile61
-rw-r--r--generate_deps5
-rw-r--r--src/rabbit_multi.erl2
4 files changed, 38 insertions, 34 deletions
diff --git a/.hgignore b/.hgignore
index 75ccfb73..caaa3ace 100644
--- a/.hgignore
+++ b/.hgignore
@@ -11,8 +11,7 @@ syntax: regexp
^dist/
^include/rabbit_framing\.hrl$
^src/rabbit_framing\.erl$
-^src/rabbitmqctl_usage\.erl$
-^src/rabbitmqmulti_usage\.erl$
+^src/.*\_usage.erl$
^rabbit\.plt$
^basic.plt$
^ebin/rabbit\.(app|rel|boot|script)$
@@ -28,4 +27,3 @@ syntax: regexp
^docs/.*\.[15]\.gz$
^docs/.*\.man\.xml$
-^docs/.*\.usage.erl$
diff --git a/Makefile b/Makefile
index e50b186c..9f47005d 100644
--- a/Makefile
+++ b/Makefile
@@ -10,14 +10,16 @@ DEPS_FILE=deps.mk
SOURCE_DIR=src
EBIN_DIR=ebin
INCLUDE_DIR=include
+DOCS_DIR=docs
INCLUDES=$(wildcard $(INCLUDE_DIR)/*.hrl) $(INCLUDE_DIR)/rabbit_framing.hrl
-SOURCES=$(wildcard $(SOURCE_DIR)/*.erl) $(SOURCE_DIR)/rabbit_framing.erl $(SOURCE_DIR)/rabbitmqctl_usage.erl $(SOURCE_DIR)/rabbitmqmulti_usage.erl
+SOURCES=$(wildcard $(SOURCE_DIR)/*.erl) $(SOURCE_DIR)/rabbit_framing.erl $(USAGES_ERL)
BEAM_TARGETS=$(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam, $(SOURCES))
TARGETS=$(EBIN_DIR)/rabbit.app $(INCLUDE_DIR)/rabbit_framing.hrl $(BEAM_TARGETS)
WEB_URL=http://stage.rabbitmq.com/
-MANPAGES=$(patsubst %.xml, %.gz, $(wildcard docs/*.[0-9].xml))
-WEB_MANPAGES=$(patsubst %.xml, %.man.xml, $(wildcard docs/*.[0-9].xml) docs/rabbitmq-service.xml)
-USAGES=$(patsubst %.1.xml, %.usage.erl, $(wildcard docs/*.[0-9].xml))
+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)
+USAGES_XML=$(wildcard $(DOCS_DIR)/*.1.xml)
+USAGES_ERL=$(foreach XML, $(USAGES_XML), $(call usage_xml_to_erl, $(XML)))
ifeq ($(shell python -c 'import simplejson' 2>/dev/null && echo yes),yes)
PYTHON=python
@@ -60,6 +62,14 @@ ERL_CALL=erl_call -sname $(RABBITMQ_NODENAME) -e
ERL_EBIN=erl -noinput -pa $(EBIN_DIR)
+define usage_xml_to_erl
+ $(patsubst $(DOCS_DIR)/%.1.xml, $(SOURCE_DIR)/%_usage.erl, $(subst -,_,$(1)))
+endef
+
+define usage_dep
+ $(call usage_xml_to_erl, $(1)): $(1) $(DOCS_DIR)/usage.xsl
+endef
+
all: $(TARGETS)
$(DEPS_FILE): $(SOURCES) $(INCLUDES)
@@ -68,9 +78,8 @@ $(DEPS_FILE): $(SOURCES) $(INCLUDES)
$(EBIN_DIR)/rabbit.app: $(EBIN_DIR)/rabbit_app.in $(BEAM_TARGETS) generate_app
escript generate_app $(EBIN_DIR) $@ < $<
-$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl
+$(EBIN_DIR)/%.beam:
erlc $(ERLC_OPTS) -pa $(EBIN_DIR) $<
-# ERLC_EMULATOR="erl -smp" erlc $(ERLC_OPTS) -pa $(EBIN_DIR) $<
$(INCLUDE_DIR)/rabbit_framing.hrl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.py $(AMQP_SPEC_JSON_PATH)
$(PYTHON) codegen.py header $(AMQP_SPEC_JSON_PATH) $@
@@ -78,12 +87,6 @@ $(INCLUDE_DIR)/rabbit_framing.hrl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.p
$(SOURCE_DIR)/rabbit_framing.erl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.py $(AMQP_SPEC_JSON_PATH)
$(PYTHON) codegen.py body $(AMQP_SPEC_JSON_PATH) $@
-$(SOURCE_DIR)/rabbitmqctl_usage.erl: docs/rabbitmqctl.usage.erl
- cp docs/rabbitmqctl.usage.erl $@
-
-$(SOURCE_DIR)/rabbitmqmulti_usage.erl: docs/rabbitmq-multi.usage.erl
- cp docs/rabbitmq-multi.usage.erl $@
-
dialyze: $(BEAM_TARGETS) $(BASIC_PLT)
$(ERL_EBIN) -eval \
"rabbit_dialyzer:halt_with_code(rabbit_dialyzer:dialyze_files(\"$(BASIC_PLT)\", \"$(BEAM_TARGETS)\"))."
@@ -107,8 +110,8 @@ $(BASIC_PLT): $(BEAM_TARGETS)
clean:
rm -f $(EBIN_DIR)/*.beam
rm -f $(EBIN_DIR)/rabbit.app $(EBIN_DIR)/rabbit.boot $(EBIN_DIR)/rabbit.script $(EBIN_DIR)/rabbit.rel
- rm -f $(INCLUDE_DIR)/rabbit_framing.hrl $(SOURCE_DIR)/rabbit_framing.erl $(SOURCE_DIR)/rabbitmqctl_usage.erl codegen.pyc
- rm -f docs/*.[0-9].gz docs/*.usage.erl docs/*.man.xml docs/*.erl
+ rm -f $(INCLUDE_DIR)/rabbit_framing.hrl $(SOURCE_DIR)/rabbit_framing.erl codegen.pyc
+ rm -f $(DOCS_DIR)/*.[0-9].gz $(DOCS_DIR)/*.man.xml $(DOCS_DIR)/*.erl $(USAGES_ERL)
rm -f $(RABBIT_PLT)
rm -f $(DEPS_FILE)
@@ -184,7 +187,7 @@ srcdist: distclean
cp codegen.py Makefile generate_app generate_deps calculate-relative $(TARGET_SRC_DIR)
cp -r scripts $(TARGET_SRC_DIR)
- cp -r docs $(TARGET_SRC_DIR)
+ cp -r $(DOCS_DIR) $(TARGET_SRC_DIR)
chmod 0755 $(TARGET_SRC_DIR)/scripts/*
(cd dist; tar -zcf $(TARBALL_NAME).tar.gz $(TARBALL_NAME))
@@ -197,25 +200,25 @@ distclean: clean
find . -regex '.*\(~\|#\|\.swp\|\.dump\)' -exec rm {} \;
# xmlto can not read from standard input, so we mess with a tmp file.
-%.gz: %.xml docs/examples-to-end.xsl
- xsltproc docs/examples-to-end.xsl $< > $<.tmp && \
- xmlto man -o docs $<.tmp && \
- gzip -f docs/`basename $< .xml`
+%.gz: %.xml $(DOCS_DIR)/examples-to-end.xsl
+ xsltproc $(DOCS_DIR)/examples-to-end.xsl $< > $<.tmp && \
+ xmlto man -o $(DOCS_DIR) $<.tmp && \
+ gzip -f $(DOCS_DIR)/`basename $< .xml`
rm -f $<.tmp
-%.usage.erl: %.1.xml docs/usage.xsl
- xsltproc --stringparam modulename "`basename $< .1.xml | tr -d -`_usage" \
- docs/usage.xsl $< | sed -e s/\\\"/\\\\\\\"/g | sed -e s/%QUOTE%/\\\"/g | \
- fmt -s > docs/`basename $< .1.xml`.usage.erl
+$(SOURCE_DIR)/%_usage.erl:
+ xsltproc --stringparam modulename "`basename $@ .erl`" \
+ $(DOCS_DIR)/usage.xsl $< | sed -e s/\\\"/\\\\\\\"/g | sed -e s/%QUOTE%/\\\"/g | \
+ fmt -s > $@
# 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/html-to-website-xml.xsl
+%.man.xml: %.xml $(DOCS_DIR)/html-to-website-xml.xsl
cp $< `basename $< .xml`.xml && \
xmlto xhtml-nochunks `basename $< .xml`.xml ; rm `basename $< .xml`.xml
cat `basename $< .xml`.html | \
- xsltproc --novalid docs/remove-namespaces.xsl - | \
- xsltproc --stringparam original `basename $<` docs/html-to-website-xml.xsl - | \
+ xsltproc --novalid $(DOCS_DIR)/remove-namespaces.xsl - | \
+ xsltproc --stringparam original `basename $<` $(DOCS_DIR)/html-to-website-xml.xsl - | \
xmllint --format - > $@
rm `basename $< .xml`.html
@@ -237,8 +240,8 @@ install: all docs_all install_dirs
done
for section in 1 5; do \
mkdir -p $(MAN_DIR)/man$$section; \
- for manpage in docs/*.$$section.pod; do \
- cp docs/`basename $$manpage .pod`.gz $(MAN_DIR)/man$$section; \
+ for manpage in $(DOCS_DIR)/*.$$section.pod; do \
+ cp $(DOCS_DIR)/`basename $$manpage .pod`.gz $(MAN_DIR)/man$$section; \
done; \
done
@@ -246,4 +249,6 @@ install_dirs:
mkdir -p $(SBIN_DIR)
mkdir -p $(TARGET_DIR)/sbin
+$(foreach XML, $(USAGES_XML), $(eval $(call usage_dep, $(XML))))
+
-include $(DEPS_FILE)
diff --git a/generate_deps b/generate_deps
index e16624d2..29587b5a 100644
--- a/generate_deps
+++ b/generate_deps
@@ -23,10 +23,11 @@ main([IncludeDir, ErlDir, EbinDir, TargetFile]) ->
ok;
(Path, Dep, ok) ->
Module = filename:basename(Path, ".erl"),
- ok = file:write(Hdl, [EbinDir, "/", Module, ".beam:"]),
+ ok = file:write(Hdl, [EbinDir, "/", Module, ".beam: ",
+ Path]),
ok = sets:fold(fun (E, ok) -> file:write(Hdl, [" ", E]) end,
ok, Dep),
- file:write(Hdl, [" ", ErlDir, "/", Module, ".erl\n"])
+ file:write(Hdl, ["\n"])
end, ok, Deps),
ok = file:write(Hdl, [TargetFile, ": ", escript:script_name(), "\n"]),
ok = file:sync(Hdl),
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index bc04357b..d9ee6d32 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -86,7 +86,7 @@ stop() ->
ok.
usage() ->
- rabbitmqmulti_usage:usage().
+ rabbitmq_multi_usage:usage().
action(start_all, [NodeCount], RpcTimeout) ->
io:format("Starting all nodes...~n", []),