From ae1a3e80973dbe4300136714f00ce203bdadfa33 Mon Sep 17 00:00:00 2001 From: Ben Hood <0x6e6562@gmail.com> Date: Thu, 13 Nov 2008 16:09:27 +0000 Subject: [PATCH] Refactored makefile --- deps/amqp_client/Makefile | 51 ++++++++++++++++++++++++++------------- deps/amqp_client/README | 50 +++++++++++++++----------------------- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/deps/amqp_client/Makefile b/deps/amqp_client/Makefile index d15ecd708c..f338f504cc 100644 --- a/deps/amqp_client/Makefile +++ b/deps/amqp_client/Makefile @@ -26,25 +26,40 @@ EBIN_DIR=ebin SOURCE_DIR=src INCLUDE_DIR=include -ERLC_FLAGS=-W0 DIST_DIR=rabbitmq-erlang-client +LOAD_PATH=ebin rabbitmq_server/ebin + +INCLUDES=$(wildcard $(INCLUDE_DIR)/*.hrl) +SOURCES=$(wildcard $(SOURCE_DIR)/*.erl) +TARGETS=$(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES)) + +ERLC_OPTS=-I $(INCLUDE_DIR) -o $(EBIN_DIR) -W0 -v +debug_info + +BROKER_DIR=../rabbitmq-server +BROKER_SYMLINK=rabbitmq_server + NODENAME=rabbit_test_direct MNESIA_DIR=/tmp/rabbitmq_$(NODENAME)_mnesia LOG_BASE=/tmp - ERL_CALL=erl_call -sname $(NODENAME) -e +all: $(EBIN_DIR) $(TARGETS) -compile: - mkdir -p $(EBIN_DIR) - erlc +debug_info -I $(INCLUDE_DIR) -o $(EBIN_DIR) $(ERLC_FLAGS) $(SOURCE_DIR)/*.erl +$(BROKER_SYMLINK): +ifdef BROKER_DIR + ln -sf $(BROKER_DIR) $(BROKER_SYMLINK) +endif -all: compile +$(EBIN_DIR): + mkdir -p $@ -run_node: compile - LOG_BASE=/tmp SKIP_HEART=true SKIP_LOG_ARGS=true MNESIA_DIR=$(MNESIA_DIR) RABBIT_ARGS="-detached -pa ./ebin" NODENAME=$(NODENAME) rabbitmq-server +$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES) $(BROKER_SYMLINK) + erlc $(ERLC_OPTS) $< + +run_server: + NODE_IP_ADDRESS=$(NODE_IP_ADDRESS) NODE_PORT=$(NODE_PORT) NODE_ONLY=true LOG_BASE=$(LOG_BASE) RABBIT_ARGS="$(RABBIT_ARGS) -s rabbit" MNESIA_DIR=$(MNESIA_DIR) $(BROKER_DIR)/scripts/rabbitmq-server sleep 2 # so that the node is initialized when the tests are run all_tests: test_network test_network_coverage test_direct test_direct_coverage @@ -53,26 +68,28 @@ all_tests: test_network test_network_coverage test_direct test_direct_coverage tests_network: test_network test_network_coverage $(ERL_CALL) -q -test_network: run_node - erl -pa ebin -noshell -eval 'network_client_test:test(),halt().' +test_network: $(TARGETS) + erl -pa $(LOAD_PATH) -noshell -eval 'network_client_test:test(),halt().' -test_network_coverage: run_node - erl -pa ebin -noshell -eval 'network_client_test:test_coverage(),halt().' +test_network_coverage: $(TARGETS) + erl -pa $(LOAD_PATH) -noshell -eval 'network_client_test:test_coverage(),halt().' tests_direct: test_direct test_direct_coverage $(ERL_CALL) -q rm -rf $(MNESIA_DIR) -test_direct: - erl -pa ebin -mnesia dir tmp -boot start_sasl -s rabbit -noshell -eval \ +test_direct: $(TARGETS) + erl -pa $(LOAD_PATH) -mnesia dir tmp -boot start_sasl -s rabbit -noshell -eval \ 'direct_client_test:test(),halt().' -test_direct_coverage: - erl -pa ebin -mnesia dir tmp -boot start_sasl -s rabbit -noshell -eval \ +test_direct_coverage: $(TARGETS) + erl -pa $(LOAD_PATH) -mnesia dir tmp -boot start_sasl -s rabbit -noshell -eval \ 'direct_client_test:test_coverage(),halt().' clean: - rm $(EBIN_DIR)/*.beam + rm -f $(EBIN_DIR)/*.beam + rm -f rabbitmq_server erl_crash.dump + rm -fr cover dist source-tarball: mkdir -p dist/$(DIST_DIR) diff --git a/deps/amqp_client/README b/deps/amqp_client/README index 94c57c57da..bab0cfd154 100644 --- a/deps/amqp_client/README +++ b/deps/amqp_client/README @@ -35,19 +35,31 @@ Prerequisites In order to compile/run this code you must have the following installed: -- Erlang/OTP, R11B-0 or later, http://www.erlang.org/download.html -- The RabbitMQ server, 200710071940 snapshot or later, - http://dev.rabbitmq.com/snapshots/rabbitmq/ - Compile and install this in the OTP library directory. -- Eunit, latest version from svn at - http://svn.process-one.net/contribs/trunk/eunit - Compile and install this in the OTP library directory. +- Erlang/OTP, R12B-5 or later, http://www.erlang.org/download.html +- The RabbitMQ server, 93cc2ca0ba62 or later -Compile the Erlang client +Compiling the Erlang client ------------------------- Go to the base directory of the AMQP Erlang client directory and run 'make'. +* If you have "installed" the RabbitMQ server: + +You will have a symlink to the rabbitmq-server directory in your OTP +directory, so when running the make, you will want to unset the $BROKER_DIR +variable: + + $ make -BROKER_DIR= + +* If you don't have the RabbitMQ server installed: + +You will need to get a copy of the server in order to be able to use it's +header files and runtime libraries. A good place to put this is in the sibling +directory to the Erlang client, which is the default that Makefile expects. If +it is not, then you need to specify the path to this directory: + + $ make -BROKER_DIR=WHEREEVER_YOU_PUT_THIS + Running the network client -------------------------- In order to run the network client, you need to run the RabbitMQ @@ -66,27 +78,5 @@ Running the direct client The direct client has to be run in the same Erlang VM instance as the RabbitMQ server. -The included Makefile will do this if the RabbitMQ server has been installed -such that the script rabbitmq-server is in the path (note that /usr/sbin may -not be in your path). - -After you have checked this, you can run the unit tests: - $ make test_direct -Running the Integration Scenarios ---------------------------------- - -The network_integration_test module demonstrates how the base API can be -extended to implement an Rpc client over AMQP. - -This client does a full Rpc end to end by combining the AMQP transport -with the Hessian data binding protocol. - -To run this test end to end, you will need to install the Erlang module -for hessian into to the default OTP library path. - -The Hessian library can be downloaded from http://code.google.com/p/cotton/, -version 0.2.2 or later is required. - -You will also need to patch the Rabbit java client (using snapshot version rabbitmq-200710291145) with the patch file called primitive_call.patch. The resulting binary from this will need to be put on the classpath of the Java project.