From 09895b5a01369aed04ebdb2fb3a3388abdc7d77b Mon Sep 17 00:00:00 2001 From: Vlad Ionescu Date: Mon, 19 Jul 2010 13:07:33 +0100 Subject: [PATCH 1/2] cleaning up all makefiles in the client; make -j works; client does not do unnecessary builds anymore; source tarball makefile does not contain unnecessary make targets (some of which would not work); other smaller makefile fixes --- Makefile | 91 ++++++++++++++++++++++++++++++++------------------- common.mk | 66 ++++++++----------------------------- test/Makefile | 5 ++- 3 files changed, 74 insertions(+), 88 deletions(-) mode change 100644 => 100755 Makefile mode change 100644 => 100755 test/Makefile diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 07e2ce45..cc0d665e --- a/Makefile +++ b/Makefile @@ -28,22 +28,34 @@ DEPS=$(shell erl -noshell -eval '{ok,[{_,_,[_,_,{modules, Mods},_,_,_]}]} = \ [io:format("~p ",[M]) || M <- Mods], halt().') VERSION=0.0.0 -SOURCE_PACKAGE_NAME=$(PACKAGE)-$(VERSION)-src +SOURCE_PACKAGE_DIR=$(PACKAGE)-$(VERSION)-src +SOURCE_PACKAGE_TAR_GZ=$(SOURCE_PACKAGE_DIR).tar.gz -INFILES=$(shell find . -name '*.app.in') -INTARGETS=$(patsubst %.in, %, $(INFILES)) - -.PHONY: common_package +BROKER_HEADERS=$(wildcard $(BROKER_DIR)/$(INCLUDE_DIR)/*.hrl) +BROKER_SOURCES=$(wildcard $(BROKER_DIR)/$(SOURCE_DIR)/*.erl) +BROKER_DEPS=$(BROKER_HEADERS) $(BROKER_SOURCES) include common.mk +run_in_broker: compile $(BROKER_DEPS) $(EBIN_DIR)/$(PACKAGE).app + $(MAKE) RABBITMQ_SERVER_START_ARGS='$(PA_LOAD_PATH)' -C $(BROKER_DIR) run + clean: common_clean rm -f $(INTARGETS) - rm -fr $(DIST_DIR) + rm -rf $(DIST_DIR) %.app: %.app.in sed -e 's:%%VSN%%:$(VERSION):g' < $< > $@ +doc: $(DOC_DIR)/index.html + +$(DOC_DIR)/overview.edoc: $(SOURCE_DIR)/overview.edoc.in + mkdir -p $(DOC_DIR) + sed -e 's:%%VERSION%%:$(VERSION):g' < $< > $@ + +$(DOC_DIR)/index.html: $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) $(DOC_DIR)/overview.edoc $(SOURCES) + $(LIBS_PATH) erl -noshell -eval 'edoc:application(amqp_client, ".", [{preprocess, true}])' -run init stop + ############################################################################### ## Testing ############################################################################### @@ -62,39 +74,52 @@ test_common_package: common_package package prepare_tests $(MAKE) stop_test_broker_node && \ $$OK +compile_tests: $(TEST_DIR) $(EBIN_DIR)/$(PACKAGE).app + +$(TEST_DIR)/%.beam: $(TEST_DIR) + +.PHONY: $(TEST_DIR) +$(TEST_DIR): $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) + $(MAKE) -C $(TEST_DIR) + ############################################################################### ## Packaging ############################################################################### COPY=cp -pR -common_package: $(DIST_DIR)/$(COMMON_PACKAGE_NAME) +common_package: $(DIST_DIR)/$(COMMON_PACKAGE_EZ) + +$(DIST_DIR)/$(COMMON_PACKAGE_EZ): $(DIST_DIR)/$(COMMON_PACKAGE_DIR) | $(DIST_DIR) + (cd $(DIST_DIR); zip -r $(COMMON_PACKAGE_EZ) $(COMMON_PACKAGE_DIR)) -$(DIST_DIR)/$(COMMON_PACKAGE_NAME): $(BROKER_SOURCES) $(BROKER_HEADERS) $(COMMON_PACKAGE).app +$(DIST_DIR)/$(COMMON_PACKAGE_DIR): $(BROKER_DEPS) $(COMMON_PACKAGE_DIR).app | $(DIST_DIR) $(MAKE) -C $(BROKER_DIR) - mkdir -p $(DIST_DIR)/$(COMMON_PACKAGE)/$(INCLUDE_DIR) - mkdir -p $(DIST_DIR)/$(COMMON_PACKAGE)/$(EBIN_DIR) - cp $(COMMON_PACKAGE).app $(DIST_DIR)/$(COMMON_PACKAGE)/$(EBIN_DIR) + rm -rf $(DIST_DIR)/$(COMMON_PACKAGE_DIR) + mkdir -p $(DIST_DIR)/$(COMMON_PACKAGE_DIR)/$(INCLUDE_DIR) + mkdir -p $(DIST_DIR)/$(COMMON_PACKAGE_DIR)/$(EBIN_DIR) + cp $(COMMON_PACKAGE_DIR).app $(DIST_DIR)/$(COMMON_PACKAGE_DIR)/$(EBIN_DIR)/ $(foreach DEP, $(DEPS), \ - ( cp $(BROKER_DIR)/$(EBIN_DIR)/$(DEP).beam \ - $(DIST_DIR)/$(COMMON_PACKAGE)/$(EBIN_DIR) \ - );) - cp $(BROKER_DIR)/$(INCLUDE_DIR)/*.hrl $(DIST_DIR)/$(COMMON_PACKAGE)/$(INCLUDE_DIR) - (cd $(DIST_DIR); zip -r $(COMMON_PACKAGE_NAME) $(COMMON_PACKAGE)) - -source_tarball: clean $(DIST_DIR)/$(COMMON_PACKAGE_NAME) - mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(DIST_DIR) - $(COPY) $(DIST_DIR)/$(COMMON_PACKAGE_NAME) $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(DIST_DIR)/ - $(COPY) README $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/ - $(COPY) common.mk $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/ - $(COPY) Makefile.in $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/Makefile - mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(SOURCE_DIR) - $(COPY) $(SOURCE_DIR)/*.erl $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(SOURCE_DIR)/ - mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(EBIN_DIR) - $(COPY) $(EBIN_DIR)/*.app $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(EBIN_DIR)/ - mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(INCLUDE_DIR) - $(COPY) $(INCLUDE_DIR)/*.hrl $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(INCLUDE_DIR)/ - mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(TEST_DIR) - $(COPY) $(TEST_DIR)/*.erl $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(TEST_DIR)/ - $(COPY) $(TEST_DIR)/Makefile $(DIST_DIR)/$(SOURCE_PACKAGE_NAME)/$(TEST_DIR)/ - cd $(DIST_DIR) ; tar cvzf $(SOURCE_PACKAGE_NAME).tar.gz $(SOURCE_PACKAGE_NAME) + ( cp $(BROKER_DIR)/ebin/$(DEP).beam $(DIST_DIR)/$(COMMON_PACKAGE_DIR)/$(EBIN_DIR)/ \ + );) + cp $(BROKER_DIR)/include/*.hrl $(DIST_DIR)/$(COMMON_PACKAGE_DIR)/$(INCLUDE_DIR)/ + +source_tarball: clean $(DIST_DIR)/$(COMMON_PACKAGE_EZ) | $(DIST_DIR) + mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(DIST_DIR) + $(COPY) $(DIST_DIR)/$(COMMON_PACKAGE_EZ) $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(DIST_DIR)/ + $(COPY) README $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/ + $(COPY) common.mk $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/ + $(COPY) Makefile.in $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/Makefile + mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(SOURCE_DIR) + $(COPY) $(SOURCE_DIR)/*.erl $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(SOURCE_DIR)/ + mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(EBIN_DIR) + $(COPY) $(EBIN_DIR)/*.app $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(EBIN_DIR)/ + mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(INCLUDE_DIR) + $(COPY) $(INCLUDE_DIR)/*.hrl $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(INCLUDE_DIR)/ + mkdir -p $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(TEST_DIR) + $(COPY) $(TEST_DIR)/*.erl $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(TEST_DIR)/ + $(COPY) $(TEST_DIR)/Makefile $(DIST_DIR)/$(SOURCE_PACKAGE_DIR)/$(TEST_DIR)/ + cd $(DIST_DIR) ; tar cvzf $(SOURCE_PACKAGE_TAR_GZ) $(SOURCE_PACKAGE_DIR) + +$(DIST_DIR): + mkdir -p $@ diff --git a/common.mk b/common.mk index eb96b158..10f48223 100644 --- a/common.mk +++ b/common.mk @@ -47,9 +47,8 @@ TMPDIR := /tmp endif EBIN_DIR=ebin -export BROKER_DIR=../rabbitmq-server +BROKER_DIR=../rabbitmq-server export INCLUDE_DIR=include -export INCLUDE_SERV_DIR=$(BROKER_DIR)/include TEST_DIR=test SOURCE_DIR=src DIST_DIR=dist @@ -70,12 +69,8 @@ DEPS=$(shell erl -noshell -eval '{ok,[{_,_,[_,_,{modules, Mods},_,_,_]}]} = \ PACKAGE=amqp_client PACKAGE_NAME=$(PACKAGE).ez -COMMON_PACKAGE=rabbit_common -COMMON_PACKAGE_NAME=$(COMMON_PACKAGE).ez - -COMPILE_DEPS=$(DEPS_DIR)/$(COMMON_PACKAGE)/$(INCLUDE_DIR)/rabbit.hrl \ - $(DEPS_DIR)/$(COMMON_PACKAGE)/$(INCLUDE_DIR)/rabbit_framing.hrl \ - $(DEPS_DIR)/$(COMMON_PACKAGE)/$(EBIN_DIR) +export COMMON_PACKAGE_DIR=rabbit_common +COMMON_PACKAGE_EZ=$(COMMON_PACKAGE_DIR).ez INCLUDES=$(wildcard $(INCLUDE_DIR)/*.hrl) SOURCES=$(wildcard $(SOURCE_DIR)/*.erl) @@ -83,9 +78,6 @@ TARGETS=$(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam, $(SOURCES)) TEST_SOURCES=$(wildcard $(TEST_DIR)/*.erl) TEST_TARGETS=$(patsubst $(TEST_DIR)/%.erl, $(TEST_DIR)/%.beam, $(TEST_SOURCES)) -BROKER_HEADERS=$(wildcard $(BROKER_DIR)/$(INCLUDE_DIR)/*.hrl) -BROKER_SOURCES=$(wildcard $(BROKER_DIR)/$(SOURCE_DIR)/*.erl) - LIBS_PATH=ERL_LIBS=$(DEPS_DIR):$(DIST_DIR)$(ERL_LIBS) LOAD_PATH=$(EBIN_DIR) $(BROKER_DIR)/ebin $(TEST_DIR) $(ERL_PATH) @@ -130,62 +122,41 @@ endif PLT=$(HOME)/.dialyzer_plt DIALYZER_CALL=dialyzer --plt $(PLT) -.PHONY: all compile compile_tests run run_in_broker dialyzer dialyze_all \ - add_broker_to_plt prepare_tests all_tests test_suites \ - test_suites_coverage run_test_broker start_test_broker_node \ - stop_test_broker_node test_network test_direct test_network_coverage \ - test_direct_coverage test_common_package clean source_tarball package \ - boot_broker unboot_broker all: package common_clean: rm -f $(EBIN_DIR)/*.beam rm -f erl_crash.dump - rm -fr $(DOC_DIR) + rm -rf $(DEPS_DIR) + rm -rf $(DOC_DIR) $(MAKE) -C $(TEST_DIR) clean compile: $(TARGETS) -compile_tests: $(TEST_DIR) $(COMPILE_DEPS) $(EBIN_DIR)/$(PACKAGE).app - $(MAKE) -C $(TEST_DIR) - run: compile $(EBIN_DIR)/$(PACKAGE).app $(LIBS_PATH) erl -pa $(LOAD_PATH) -run_in_broker: compile $(BROKER_DIR) $(EBIN_DIR)/$(PACKAGE).app - $(MAKE) RABBITMQ_SERVER_START_ARGS='$(PA_LOAD_PATH)' -C $(BROKER_DIR) run - dialyze: $(TARGETS) $(DIALYZER_CALL) -c $^ dialyze_all: $(TARGETS) $(TEST_TARGETS) $(DIALYZER_CALL) -c $^ -add_broker_to_plt: $(BROKER_DIR)/ebin - $(DIALYZER_CALL) --add_to_plt -r $< - -$(DOC_DIR)/overview.edoc: $(SOURCE_DIR)/overview.edoc.in - mkdir -p $(DOC_DIR) - sed -e 's:%%VERSION%%:$(VERSION):g' < $< > $@ - -$(DOC_DIR)/index.html: $(COMPILE_DEPS) $(DOC_DIR)/overview.edoc $(SOURCES) - $(LIBS_PATH) erl -noshell -eval 'edoc:application(amqp_client, ".", [{preprocess, true}])' -run init stop - -doc: $(DOC_DIR)/index.html - ############################################################################### ## Packaging ############################################################################### -$(DIST_DIR)/$(PACKAGE_NAME): $(TARGETS) $(EBIN_DIR)/$(PACKAGE).app +$(DIST_DIR)/$(PACKAGE_NAME): $(DIST_DIR)/$(PACKAGE) | $(DIST_DIR) + (cd $(DIST_DIR); zip -r $(PACKAGE_NAME) $(PACKAGE)) + +$(DIST_DIR)/$(PACKAGE): $(TARGETS) $(EBIN_DIR)/$(PACKAGE).app | $(DIST_DIR) rm -rf $(DIST_DIR)/$(PACKAGE) mkdir -p $(DIST_DIR)/$(PACKAGE)/$(EBIN_DIR) cp -r $(EBIN_DIR)/*.beam $(DIST_DIR)/$(PACKAGE)/$(EBIN_DIR) cp -r $(EBIN_DIR)/*.app $(DIST_DIR)/$(PACKAGE)/$(EBIN_DIR) mkdir -p $(DIST_DIR)/$(PACKAGE)/$(INCLUDE_DIR) cp -r $(INCLUDE_DIR)/* $(DIST_DIR)/$(PACKAGE)/$(INCLUDE_DIR) - (cd $(DIST_DIR); zip -r $(PACKAGE_NAME) $(PACKAGE)) package: $(DIST_DIR)/$(PACKAGE_NAME) @@ -193,22 +164,13 @@ package: $(DIST_DIR)/$(PACKAGE_NAME) ## Internal targets ############################################################################### -$(COMPILE_DEPS): $(DIST_DIR)/$(COMMON_PACKAGE_NAME) - mkdir -p $(DEPS_DIR) - unzip -o -d $(DEPS_DIR) $(DIST_DIR)/$(COMMON_PACKAGE_NAME) +$(DEPS_DIR)/$(COMMON_PACKAGE_DIR): $(DIST_DIR)/$(COMMON_PACKAGE_EZ) | $(DEPS_DIR) + rm -rf $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) + mkdir -p $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) + unzip -o $< -d $(DEPS_DIR) -$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES) $(COMPILE_DEPS) +$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES) $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) $(LIBS_PATH) erlc $(ERLC_OPTS) $< -$(TEST_DIR)/%.beam: compile_tests - -$(BROKER_DIR): - test -e $(BROKER_DIR) - $(MAKE_BROKER) - -$(DIST_DIR): - mkdir -p $@ - $(DEPS_DIR): mkdir -p $@ - diff --git a/test/Makefile b/test/Makefile old mode 100644 new mode 100755 index a44dad8c..f17067fc --- a/test/Makefile +++ b/test/Makefile @@ -27,16 +27,15 @@ TEST_SOURCES=$(wildcard *.erl) TEST_TARGETS=$(patsubst %.erl, %.beam, $(TEST_SOURCES)) INCLUDES=$(wildcard ../$(INCLUDE_DIR)/*.hrl) DEPS_DIR=../deps -COMMON_PACKAGE=rabbit_common -ERLC_OPTS=-I ../include -o ./ -Wall -v +debug_info +ERLC_OPTS=-I ../$(INCLUDE_DIR) -o ./ -Wall -v +debug_info LIBS_PATH=ERL_LIBS=$(DEPS_DIR) all: compile compile: $(TEST_TARGETS) -%.beam: %.erl $(DEPS_DIR)/$(COMMON_PACKAGE) $(INCLUDES) +%.beam: %.erl $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) $(INCLUDES) $(LIBS_PATH) erlc $(ERLC_OPTS) $< clean: From 014666cc04a476c7ab57a11c58ec4baf44358bfe Mon Sep 17 00:00:00 2001 From: Vlad Ionescu Date: Mon, 19 Jul 2010 15:02:31 +0100 Subject: [PATCH 2/2] removing dialyze make target from source tarball makefile; other small fixes --- Makefile | 25 +++++++++++++++++++++++-- common.mk | 9 --------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index cc0d665e..1d1f9912 100755 --- a/Makefile +++ b/Makefile @@ -35,6 +35,9 @@ BROKER_HEADERS=$(wildcard $(BROKER_DIR)/$(INCLUDE_DIR)/*.hrl) BROKER_SOURCES=$(wildcard $(BROKER_DIR)/$(SOURCE_DIR)/*.erl) BROKER_DEPS=$(BROKER_HEADERS) $(BROKER_SOURCES) +INFILES=$(shell find . -name '*.app.in') +INTARGETS=$(patsubst %.in, %, $(INFILES)) + include common.mk run_in_broker: compile $(BROKER_DEPS) $(EBIN_DIR)/$(PACKAGE).app @@ -47,6 +50,24 @@ clean: common_clean %.app: %.app.in sed -e 's:%%VSN%%:$(VERSION):g' < $< > $@ +############################################################################### +## Dialyzer +############################################################################### + +RABBIT_PLT=$(BROKER_DIR)/rabbit.plt + +dialyze: $(RABBIT_PLT) $(TARGETS) $(TEST_TARGETS) + $(LIBS_PATH) erl -noshell -pa $(LOAD_PATH) -eval \ + "rabbit_dialyzer:halt_with_code(rabbit_dialyzer:dialyze_files(\"$(RABBIT_PLT)\", \"$(TARGETS) $(TEST_TARGETS)\"))." + +.PHONY: $(RABBIT_PLT) +$(RABBIT_PLT): + $(MAKE) -C $(BROKER_DIR) create-plt + +############################################################################### +## Documentation +############################################################################### + doc: $(DOC_DIR)/index.html $(DOC_DIR)/overview.edoc: $(SOURCE_DIR)/overview.edoc.in @@ -74,9 +95,9 @@ test_common_package: common_package package prepare_tests $(MAKE) stop_test_broker_node && \ $$OK -compile_tests: $(TEST_DIR) $(EBIN_DIR)/$(PACKAGE).app +compile_tests: $(TEST_TARGETS) $(EBIN_DIR)/$(PACKAGE).app -$(TEST_DIR)/%.beam: $(TEST_DIR) +$(TEST_TARGETS): $(TEST_DIR) .PHONY: $(TEST_DIR) $(TEST_DIR): $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) diff --git a/common.mk b/common.mk index d2eecc20..6090a88e 100644 --- a/common.mk +++ b/common.mk @@ -119,8 +119,6 @@ ALL_SSL_COVERAGE := true SSL_BROKER_ARGS := endif -RABBIT_PLT=$(BROKER_DIR)/rabbit.plt - all: package common_clean: @@ -135,10 +133,6 @@ compile: $(TARGETS) run: compile $(EBIN_DIR)/$(PACKAGE).app $(LIBS_PATH) erl -pa $(LOAD_PATH) -dialyze: $(RABBIT_PLT) $(TARGETS) compile_tests - $(LIBS_PATH) erl -noshell -pa $(LOAD_PATH) -eval \ - "rabbit_dialyzer:halt_with_code(rabbit_dialyzer:dialyze_files(\"$(RABBIT_PLT)\", \"$(TARGETS) $(TEST_TARGETS)\"))." - ############################################################################### ## Packaging ############################################################################### @@ -170,6 +164,3 @@ $(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES) $(DEPS_DIR)/$(COMMON_PACKAGE $(DEPS_DIR): mkdir -p $@ - -$(RABBIT_PLT): - $(MAKE) -C $(BROKER_DIR) create-plt