summaryrefslogtreecommitdiff
path: root/cpp/Makefile
blob: ed1699f026d9bcc6f92fa90c1e5b0612586abaff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#
# 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.

# ----------------------------------------------------------------
#
# 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.
#

include options.mk

.PHONY: test all all-nogen generate unittest pythontest

test: all unittest pythontest

# Must run this as two separate make processes to pick up generated files.
all:
	$(MAKE) generate
	$(MAKE) all-nogen

## Generaged code

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
	echo > gen/timestamp
	cd gen/qpid/framing && for s in $(STYLESHEETS) ; do $(TRANSFORM) $$s ;	done
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 
	$(CXX) -shared -o $@ $< $($(LIB)_FLAGS) -Itest/include $(CXXFLAGS) $(LDFLAGS) -lapr-1 -lcppunit $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB)

## Client tests

all-nogen: $(wildcard test/client/*.cpp:.cpp=)
test/client/%: test/client/%.cpp
	$(CXX) -o $@ $< $($(LIB)_FLAGS) -Itest/include $(CXXFLAGS) $(LDFLAGS) -lapr-1 $(LINK_WITH_$(LIB)) $(LINK_WITH_$(LIB)_DEPS)

## Daemon executable

bin/qpidd: src/qpidd.o $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB)
	$(CXX) -o $@ $(LDFLAGS) -lapr-1 $^ 
all-nogen: bin/qpidd

## Run unit tests.
unittest: $(UNITTESTS:.cpp=.so)
	DllPlugInTester -c -b $(UNITTESTS:.cpp=.so)

## Run python tests
pythontest: bin/qpidd
	bin/qpidd > qpidd.log &
	cd ../python ; ./run-tests -v -I cpp_failing.txt	

## Doxygen documentation.
doxygen: doxygen/doxygen.cfg $(SOURCES)
	cd doxygen && doxygen doxygen.cfg

## Cleanup
clean::
	rm -f bin/* lib/* qpidd.log
	rm -rf gen
	rm -f `find src test -name '*.o' -o -name '*.d' -o -name '*.so'`