You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2006/10/31 00:47:20 UTC
svn commit: r469319 - in /incubator/qpid/trunk/qpid/cpp: Makefile README
bin/ doxygen.cfg doxygen/ etc/stylesheets/code_utils.xsl lib/ options.mk
Author: aconway
Date: Mon Oct 30 15:47:19 2006
New Revision: 469319
URL: http://svn.apache.org/viewvc?view=rev&rev=469319
Log:
Reworked Makefile to support multiple builds, see README for details
Added:
incubator/qpid/trunk/qpid/cpp/doxygen.cfg
- copied, changed from r469145, incubator/qpid/trunk/qpid/cpp/doxygen/doxygen.cfg
Removed:
incubator/qpid/trunk/qpid/cpp/bin/
incubator/qpid/trunk/qpid/cpp/doxygen/
incubator/qpid/trunk/qpid/cpp/lib/
Modified:
incubator/qpid/trunk/qpid/cpp/Makefile
incubator/qpid/trunk/qpid/cpp/README
incubator/qpid/trunk/qpid/cpp/etc/stylesheets/code_utils.xsl
incubator/qpid/trunk/qpid/cpp/options.mk
Modified: incubator/qpid/trunk/qpid/cpp/Makefile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/Makefile?view=diff&rev=469319&r1=469318&r2=469319
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/Makefile (original)
+++ incubator/qpid/trunk/qpid/cpp/Makefile Mon Oct 30 15:47:19 2006
@@ -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 @@
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
+
+$(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)
+
+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
-
-bin/qpidd: src/qpidd.o $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB)
+$(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
Modified: incubator/qpid/trunk/qpid/cpp/README
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/README?view=diff&rev=469319&r1=469318&r2=469319
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/README (original)
+++ incubator/qpid/trunk/qpid/cpp/README Mon Oct 30 15:47:19 2006
@@ -9,23 +9,60 @@
* CppUnit 1.11.4: http://cppunit.sourceforge.net
* boost 1.33.1: http://www.boost.org
-Optional: to generate source code documentation you need:
+Optional: to generate documentation from source code comments you need:
* doxygen 1.4.6: http://sourceforge.net/projects/doxygen/
* graphviz 2.8: http://www.graphviz.org/
If you use yum to install packages:
# yum install apr apr-devel cppunit cppunit-devel boost boost-devel doxygen graphviz
-== Build and test ==
-For a debug build:
-> make
-For an optimized release build:
-> make BUILD=RELEASE
+== Building ==
-The default target "test" builds everything and runs all tests. See
-the Makefile for more targets.
+You can have mutltiple builds in the same working copy.
+For example for a release build using APR platform:
+
+ make PLATFORM=apr TYPE=release
+
+This will create build/apr-release containing the bin/ lib/ and test/ subdirs.
+
+To set your preferred default create file options-local.mk with
+PLATFORM=<my platform>
+TYPE=<my type>
+
+Generated code goes in build/gen and is shared between all builds.
+
+All other build output is under build/<build name>/
+ * bin/ lib/ - executables and libraries.
+ * test/ - test executables, directories with unit test .so plugins.
+ * obj/ - compiled .o files.
+ * include - exported header files
+
+Main targets:
+ * test: (default) build & run all tests
+ * all: build all
+ * usage: this message
+ * unittest: run unit tests
+ * pythontest: run python tests.
+ * doxygen: generate documentation in build/html
+ * clean: cleans the current build only. Does not clean generated code.
+ * spotless: cleans up all build output and removes the build directory.
+
+The source tree is structured as follows:
+ * src/ - .h and .cpp source files, directories mirror namespaces.
+ * etc/ - Non-c++ resources, e.g. stylesheets.
+ * test/
+ * unit/ - unit tests (cppunit plugins), directories mirror namespaces.
+ * include/ - .h files used by tests
+ * client/ - sources for client test executables.
+
+Build system principles:
+ * Single Makefile (see http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html)
+ * Calculate sources from directories, no explicit source lists.
+ * Corresponding .cpp and .h files in same directory for easy editing.
+ * Source directory structure mirrors C++ namespaces.
=== Unit tests ===
+
Unit tests are built as .so files containing CppUnit plugins.
DllPlugInTester is provided as part of cppunit. You can use it to run
Copied: incubator/qpid/trunk/qpid/cpp/doxygen.cfg (from r469145, incubator/qpid/trunk/qpid/cpp/doxygen/doxygen.cfg)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/doxygen.cfg?view=diff&rev=469319&p1=incubator/qpid/trunk/qpid/cpp/doxygen/doxygen.cfg&r1=469145&p2=incubator/qpid/trunk/qpid/cpp/doxygen.cfg&r2=469319
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/doxygen/doxygen.cfg (original)
+++ incubator/qpid/trunk/qpid/cpp/doxygen.cfg Mon Oct 30 15:47:19 2006
@@ -32,7 +32,7 @@
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY = .
+OUTPUT_DIRECTORY = build
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
@@ -408,7 +408,7 @@
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
-QUIET = NO
+QUIET = YES
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
@@ -461,7 +461,7 @@
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = ..
+INPUT = src build/gen
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
Modified: incubator/qpid/trunk/qpid/cpp/etc/stylesheets/code_utils.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/etc/stylesheets/code_utils.xsl?view=diff&rev=469319&r1=469318&r2=469319
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/etc/stylesheets/code_utils.xsl (original)
+++ incubator/qpid/trunk/qpid/cpp/etc/stylesheets/code_utils.xsl Mon Oct 30 15:47:19 2006
@@ -7,30 +7,30 @@
========================
Print out a standard Apache copyright notice and generated code warning.
-->
- <xsl:function name="amqp:copyright">/**
-*
-* Copyright (c) 2006 The Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-*/
+ <xsl:function name="amqp:copyright">//
+//
+// Copyright (c) 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
-/**
-*
-* NOTE: This file is generated directly from the AMQP XML specification.
-* === DO NOT EDIT ===
-*
-*/
</xsl:function>
+//
+//
+// NOTE: This file is generated directly from the AMQP XML specification.
+// === DO NOT EDIT ===
+//
+//
</xsl:function>
<!--
==========================
Modified: incubator/qpid/trunk/qpid/cpp/options.mk
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/options.mk?view=diff&rev=469319&r1=469318&r2=469319
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/options.mk (original)
+++ incubator/qpid/trunk/qpid/cpp/options.mk Mon Oct 30 15:47:19 2006
@@ -14,6 +14,38 @@
# limitations under the License.
#
+## Build platform and type.
+
+# Default type
+TYPE := debug
+# Known platforms
+PLATFORMS := apr
+# TODO aconway 2006-10-30: Remove Default platform when there's more than 1.
+PLATFORM := apr
+
+# Local options, may override PLATFORM and/or TYPE
+-include options-local.mk
+
+DUMMY := $(if $(filter $(PLATFORM),$(PLATFORMS)),OK,$(error PLATFORM is not set. Use 'make PLATFORM=<name>' or create file options-local.mk with PLATFORM=<name>. Valid names: $(PLATFORMS)))
+DUMMY := $(if $(filter $(TYPE),debug release),OK,$(error TYPE must be 'debug' or 'release'))
+
+
+## Platform specific options
+
+# apr: Apache Portable Runtime.
+CXXFLAGS_apr := -D_USE_APR_IO_ -I/usr/local/apr/include
+LDFLAGS_apr := -L/usr/local/apr/lib -lapr-1
+
+## Build directories.
+
+BUILD=$(PLATFORM)-$(TYPE)
+GENDIR:=build/gen
+BINDIR:=build/$(BUILD)/bin
+LIBDIR:=build/$(BUILD)/lib
+OBJDIR:=build/$(BUILD)/obj
+TESTDIR:=build/$(BUILD)/test
+
+BUILDDIRS:= $(BINDIR) $(LIBDIR) $(OBJDIR) $(TESTDIR) $(GENDIR)
## External dependencies:
@@ -23,13 +55,9 @@
## Compile flags
-# Release vs. debug flags, default to debug
+# Release vs. debug flags.
DEBUG := -ggdb3
RELEASE := -O3 -DNDEBUG
-BUILD := DEBUG
-
-# _USE_APR_IO_ set when APR IO build is desired.
-DEFINES := -D _USE_APR_IO_
# Warnings: Enable as many as possible, keep the code clean. Please
# do not disable warnings or remove -Werror without discussing on
@@ -40,8 +68,16 @@
#
WARN := -Werror -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch
-INCLUDES := -Isrc -Igen $(EXTRA_INCLUDES)
-CXXFLAGS := $($(BUILD)) $(DEFINES) $(WARN) -MMD -fpic $(INCLUDES)
-## Link flags
-# Allow exes to find libs without env changes. Remove for release builds.
-LDFLAGS := -Llib $(EXTRA_LIBDIRS)
+INCLUDES := -Isrc -I$(GENDIR) $(EXTRA_INCLUDES)
+LDFLAGS := -L$(LIBDIR) $(LDFLAGS_$(PLATFORM))
+CXXFLAGS := $(DEFINES) $(WARN) -MMD -fpic $(INCLUDES) $(CXXFLAGS_$(PLATFORM))
+
+## Macros for linking, must be late evaluated
+
+# $(call OBJ_FROM,root,subdirs)
+OBJ_FROM = $(foreach sub,$2,$(patsubst $1/%.cpp,$(OBJDIR)/%.o,$(wildcard $1/$(sub)/*.cpp)))
+# $(call LIBFILE,name,version)
+LIBFILE =$(CURDIR)/$(LIBDIR)/libqpid_$1.so.$2
+
+LIB_COMMAND = mkdir -p $(dir $@) && $(CXX) -shared -o $@ $(LDFLAGS) $(CXXFLAGS) $^
+