diff options
| author | Alan Conway <aconway@apache.org> | 2006-10-30 23:47:19 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2006-10-30 23:47:19 +0000 |
| commit | b2c16c9e0e4e77f86ec48dabd7f116cb1d4c557a (patch) | |
| tree | bdef5c01c0ac64ab71ed494517cba2094a0a4628 /cpp/Makefile | |
| parent | 369308e223f440c7d890c05c704361c33acd9581 (diff) | |
| download | qpid-python-b2c16c9e0e4e77f86ec48dabd7f116cb1d4c557a.tar.gz | |
Reworked Makefile to support multiple builds, see README for details
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@469319 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/Makefile')
| -rw-r--r-- | cpp/Makefile | 160 |
1 files changed, 72 insertions, 88 deletions
diff --git a/cpp/Makefile b/cpp/Makefile index becc5098f2..fe5e40bb26 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -13,40 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# ---------------------------------------------------------------- -# -# Makefile for Qpid C++ project. # -# Build system principles -# * Single Makefile (see http://www.apache.org/licenses/LICENSE-2.0) -# * Build from directories, no explicit source lists in Makefile. -# * Corresponding .cpp and .h files in same directory for easy editing. -# * Source directory structure mirrors C++ namespaces. -# -# Source directories: -# * src/ - .h and .cpp source files, directories mirror namespaces. -# * test/ -# * unit/ - unit tests (cppunit plugins), directories mirror namespaces. -# * include/ - .h files used by tests -# * client/ - sources for client test executables. -# * etc/ - Non-c++ resources, e.g. stylesheets. -# * gen/ - generated code -# -# Output directories: -# * gen/ - (created by make) generated code -# * bin/ lib/ - exes & libraries. -# -# NOTE: always use := rather than = unless you have a specific need -# for delayed evaluation. See the link for details. +# See README for details. # include options.mk -.PHONY: test all all-nogen generate unittest pythontest +.PHONY: test all all-nogen generate unittest pythontest doxygen test: unittest pythontest -# Must run this as two separate make processes to pick up generated files. +# Must run two separate make processes to pick up generated files. all: $(MAKE) generate $(MAKE) all-nogen @@ -57,81 +34,88 @@ SPEC := $(CURDIR)/../specs/amqp-8.0.xml XSL := code_gen.xsl framing.xsl STYLESHEETS := $(XSL:%=$(CURDIR)/etc/stylesheets/%) TRANSFORM := java -jar $(CURDIR)/tools/saxon8.jar -o results.out $(SPEC) -generate: gen/timestamp -gen/timestamp: $(wildcard etc/stylesheets/*.xsl) $(SPEC) - mkdir -p gen/qpid/framing - ( cd gen/qpid/framing && for s in $(STYLESHEETS) ; do $(TRANSFORM) $$s ; done ) && echo > gen/timestamp - -gen $(wildcard gen/qpid/framing/*.cpp): gen/timestamp - -## Libraries - -# Library command, late evaluated for $@ -LIB_CMD = $(CXX) -shared -o $@ $(LDFLAGS) $(CXXFLAGS) -lapr-1 - -# Common library. -COMMON_LIB := lib/libqpid_common.so.1.0 -COMMON_DIRS := qpid/concurrent qpid/framing qpid/io qpid -COMMON_SRC := $(wildcard gen/qpid/framing/*.cpp $(COMMON_DIRS:%=src/%/*.cpp)) -$(COMMON_LIB): gen/timestamp $(COMMON_SRC:.cpp=.o) - $(LIB_CMD) $(COMMON_SRC:.cpp=.o) -all-nogen: $(COMMON_LIB) -UNITTESTS := $(UNITTESTS) $(wildcard $(COMMON_DIRS:%=test/unit/%/*Test.cpp)) - -# Client library. -CLIENT_LIB := lib/libqpid_client.so.1.0 -CLIENT_SRC := $(wildcard src/qpid/client/*.cpp) -$(CLIENT_LIB): $(CLIENT_SRC:.cpp=.o) $(CURDIR)/$(COMMON_LIB) - $(LIB_CMD) $^ -all-nogen: $(CLIENT_LIB) -UNITTESTS := $(UNITTESTS) $(wildcard $(COMMON_DIRS:%=test/unit/%/*Test.cpp)) - -# Broker library. -BROKER_LIB := lib/libqpid_broker.so.1.0 -BROKER_SRC := $(wildcard src/qpid/broker/*.cpp) -$(BROKER_LIB): $(BROKER_SRC:.cpp=.o) $(CURDIR)/$(COMMON_LIB) - $(LIB_CMD) $^ -all-nogen: $(BROKER_LIB) -UNITTESTS := $(UNITTESTS) $(wildcard test/unit/qpid/broker/*Test.cpp) - -# Implicit rule for unit test plugin libraries. -%Test.so: %Test.cpp $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB) - $(CXX) -shared -o $@ $< $(CXXFLAGS) -Itest/include $(LDFLAGS) -lapr-1 -lcppunit $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB) - -## Client tests -CLIENT_TEST_SRC := $(wildcard test/client/*.cpp) -all-nogen: $(CLIENT_TEST_SRC:.cpp=) -clean:: - rm -f $(CLIENT_TEST_SRC:.cpp=) -test/client/%: test/client/%.cpp - $(CXX) -o $@ $< $(CXXFLAGS) -Itest/include $(LDFLAGS) -lapr-1 $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(CLIENT_LIB) +generate: $(GENDIR)/timestamp +$(GENDIR)/timestamp: $(wildcard etc/stylesheets/*.xsl) $(SPEC) + mkdir -p $(GENDIR)/qpid/framing + ( cd $(GENDIR)/qpid/framing && for s in $(STYLESHEETS) ; do $(TRANSFORM) $$s ; done ) && echo > $(GENDIR)/timestamp +$(shell find $(GENDIR) -name *.cpp -o -name *.h): $(GENDIR)/timestamp -## Daemon executable +$(BUILDDIRS): + mkdir -p $(BUILDDIRS) + +## Library rules + +LIB_common := $(call LIBFILE,common,1.0) +$(LIB_common): $(call OBJ_FROM,src,qpid/concurrent qpid/framing qpid/io qpid) $(call OBJ_FROM,$(GENDIR),qpid/framing) + $(LIB_COMMAND) -bin/qpidd: src/qpidd.o $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB) +LIB_client :=$(call LIBFILE,client,1.0) +$(LIB_client): $(call OBJ_FROM,src,qpid/client) $(LIB_common) + $(LIB_COMMAND) + +LIB_broker :=$(call LIBFILE,broker,1.0) +$(LIB_broker): $(call OBJ_FROM,src,qpid/broker) $(LIB_common) + $(LIB_COMMAND) + +## Daemon executable +$(BINDIR)/qpidd: $(OBJDIR)/qpidd.o $(LIB_common) $(LIB_broker) + mkdir -p $(dir $@) $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) -lapr-1 $^ -all-nogen: bin/qpidd +all-nogen: $(BINDIR)/qpidd + +## Unit tests. +UNITTEST_SRC:=$(shell find test/unit -name *Test.cpp) +UNITTESTS:=$(UNITTEST_SRC:test/unit/%.cpp=$(TESTDIR)/%.so) -## Run unit tests. unittest: all DllPlugInTester -c -b $(UNITTESTS:.cpp=.so) -all-nogen: $(UNITTESTS:.cpp=.so) +all-nogen: $(UNITTESTS) ## Run python tests pythontest: all - bin/qpidd > qpidd.log & + $(BINDIR)/qpidd > qpidd.log 2>&1 & cd ../python ; ./run-tests -v -I cpp_failing.txt ## Doxygen documentation. -doxygen: doxygen/doxygen.cfg $(SOURCES) - cd doxygen && doxygen doxygen.cfg +doxygen: generate build/html +build/html: doxygen.cfg + doxygen doxygen.cfg + touch $@ + +## Implicit rules + +# C++ compiile +$(OBJDIR)/%.o: src/%.cpp + mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o $@ $< +$(OBJDIR)/%.o: $(GENDIR)/%.cpp + mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o $@ $< + +# Unit test plugin libraries. +$(TESTDIR)/%Test.so: test/unit/%Test.cpp + mkdir -p $(dir $@) + $(CXX) -shared -o $@ $< $(CXXFLAGS) -Itest/include $(LDFLAGS) -lcppunit $(LIB_common) $(LIB_broker) + +# Client test programs +$(TESTDIR)/%: test/client/%.cpp $(LIB_common) $(LIB_client) + mkdir -p $(dir $@) + $(CXX) -o $@ $(CXXFLAGS) -Itest/include $(LDFLAGS) $^ +CLIENT_TEST_SRC := $(wildcard test/client/*.cpp) +CLIENT_TEST_EXE := $(CLIENT_TEST_SRC:test/client/%.cpp=$(TESTDIR)/%) +all-nogen: $(CLIENT_TEST_EXE) ## #include dependencies --include $(shell find src test -name '*.d') +-include $(shell find src test -name '*.d') dummy-avoid-warning-if-none + + +## Clean up + +# Just the current build. +clean: + rm -rf build/$(BUILD) -## General cleanup -clean:: - rm -f bin/* lib/* qpidd.log - rm -rf gen - rm -f `find src test -name '*.o' -o -name '*.d' -o -name '*.so'` +# Clean all builds +spotless: + rm -rf build |
