Makefile 14.2 KB
Newer Older
1
MAKEFILENAME := $(lastword $(MAKEFILE_LIST))
Michael Ott's avatar
Michael Ott committed
2

3
SUB_DIRS = lib CollectAgent dcdbpusher tools scripts
4

5
CASSANDRA_VERSION = 2.2.10
6
MOSQUITTO_VERSION = 1.5.5
7
BOOST_VERSION     = 1.58.0
di34bap's avatar
di34bap committed
8
OPENSSL_VERSION   = 1.0.2l
9
10
CPPDRV_VERSION    = 2.10.0
LIBUV_VERSION     = 1.24.0
11
SOURCEFORGE_MROR  = netcologne
12
CPPNET_VERSION 	  = 0.12.0-final
13
14
BACNET-STACK_VERSION = 0.8.5
FREEIPMI_VERSION = 1.5.5
15
NET-SNMP_VERSION = 5.7.3
16

17
BOOST_VERSION_U   = $(subst .,_,$(BOOST_VERSION))
18
DISTFILES =	apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://archive.apache.org/dist/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
19
		mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
20
		boost_$(BOOST_VERSION_U).tar.gz;http://$(SOURCEFORGE_MROR).dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
21
		openssl-$(OPENSSL_VERSION).tar.gz;https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz \
di34bap's avatar
di34bap committed
22
		libuv-v$(LIBUV_VERSION).tar.gz;https://dist.libuv.org/dist/v$(LIBUV_VERSION)/libuv-v$(LIBUV_VERSION).tar.gz \
23
		cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/$(CPPDRV_VERSION).tar.gz \
24
25
26
27
28
		cpp-netlib-$(CPPNET_VERSION).tar.gz;http://downloads.cpp-netlib.org/0.12.0/cpp-netlib-$(CPPNET_VERSION).tar.gz \
		bacnet-stack-$(BACNET-STACK_VERSION).tgz;https://downloads.sourceforge.net/project/bacnet/bacnet-stack/bacnet-stack-$(BACNET-STACK_VERSION)/bacnet-stack-$(BACNET-STACK_VERSION).tgz \
                freeipmi-$(FREEIPMI_VERSION).tar.gz;http://ftp.gnu.org/gnu/freeipmi/freeipmi-$(FREEIPMI_VERSION).tar.gz \
                net-snmp-$(NET-SNMP_VERSION).tar.gz;https://sourceforge.net/projects/net-snmp/files/net-snmp/$(NET-SNMP_VERSION)/net-snmp-$(NET-SNMP_VERSION).tar.gz/download
DISTFILES_HASHES = apache-cassandra-2.2.10.tar.gz|4c58cb7c6753ce26f7c4d650502feece;mosquitto-1.5.5.tar.gz|a17dffc6f63b2a4ab2eb5c51139e60e9;boost_1_58_0.tar.gz|5a5d5614d9a07672e1ab2a250b5defc5;openssl-1.0.2l.tar.gz|f85123cd390e864dfbe517e7616e6566;cpp-driver-2.10.0.tar.gz|6d15dd2cccd2efd1fdc86089d26971d0;libuv-v1.24.0.tar.gz|90320330757253b07404d2a97f59c66b;cpp-netlib-0.12.0-final.tar.gz|29b87c0e8c1a9e7fbdea5afcec947d53;bacnet-stack-$(BACNET-STACK_VERSION).tgz|66b69111d91432fa67a7c6c1a653434d;freeipmi-$(FREEIPMI_VERSION).tar.gz|b8abfefee0b757f351d8fab777e3c1bb;net-snmp-$(NET-SNMP_VERSION).tar.gz|d4a3459e1577d0efa8d96ca70a885e53
29

30
include common.mk
31
32
33
34
35
36
37
38

CASSANDRA_CLUSTER_NAME                 = Datacenter Monitor Database
CASSANDRA_FLUSH_LARGEST_MEMTABLES_AT   = 0.5
CASSANDRA_REDUCE_CACHE_SIZES_AT        = 0.6
CASSANDRA_REDUCE_CACHE_CAPACITY_TO     = 0.4
CASSANDRA_PARTITIONER                  = org.apache.cassandra.dht.ByteOrderedPartitioner
CASSANDRA_COMMITLOG_TOTAL_SPACE_IN_MB  = 256
CASSANDRA_COMMITLOG_SEGMENT_SIZE_IN_MB = 16
Axel Auweter's avatar
Axel Auweter committed
39
40
CASSANDRA_TOMBSTONE_WARN_THRESHOLD     = 100000
CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD  = 10000000
41

42
43
HTTPD_PORT = 8080

44
45
# If cross-compiling for ARM, adjust the build settings
ifeq ("$(ARCH)", "arm")
46
	OPENSSL_TARGET = "linux-generic32"
47
else
48
	OPENSSL_TARGET = $(if $(findstring $(shell uname),Darwin),"darwin64-x86_64-cc","linux-x86_64")
49
50
endif

51
PUBHEADERS = pusherpqueue.h dcdbdaemon.h
52

53
54
55
FULL_CC = $(shell which $(CC))
FULL_CXX = $(shell which $(CXX))

56
.PHONY : info all clean cleanall distclean check-cross-compile deps depsinstall $(SUB_DIRS)
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

info:
	@echo ""
	@echo "DCDB - Data Center Database"
	@echo "Buildsystem description"
	@echo ""
	@echo "Use the DCDBDEPSPATH environment variable to specify a build path for the"
	@echo "dependencies. Currently, the project dependenceis will be built to:"
	@echo "$(DCDBDEPSPATH)"
	@echo ""
	@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
	@echo "of all tools. Currently, the directory for deployment/staging is:"
	@echo "$(DCDBDEPLOYPATH)"
	@echo ""
	@echo "There should only be a few requirements to build DCDB."
	@echo "On Ubuntu, these are: build-essential, cmake, libssl-dev"
	@echo "To run Cassandra, you should also have a JAVA runtime installed."
	@echo ""
	@echo "To modify the number of parallel build threads, you may set the MAKETHREADS"
	@echo "environment variable. Currently, your system is configured to execute a"
	@echo "parallel build with $(MAKETHREADS) threads."
	@echo ""
	@echo "To start, please type:"
	@echo "     make all"
81
82
83
84
	@echo ""
	@echo "For ARM cross compilation, please type:"
	@echo "     make ARCH=arm CROSS_COMPILE=<X> all"
	@echo "where <X> is your cross copmlier prefix ( e.g. arm-linux-gnueabihf- )"
85

86
clean:
87
	@$(foreach s,$(SUB_DIRS),echo "Cleaning $(s)..." && make -C $(s) clean && echo;)
88
89
90

cleanall: clean
	@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)
91
	@$(foreach f,cpp-netlib,echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f)_build && echo;)
92
93
94
95
96
97
98
99
100
101
102
103

distclean: clean
	@echo "Wiping dependencies..."
	@rm -rf $(DCDBDEPSPATH)

mrproper: distclean
	$(eval U := $(shell whoami))
	@if [ "$(U)" = "root" ]; then echo "Sorry, I won't allow you to use mrproper as root."; exit 1; fi
	@echo ""
	@echo "Wiping installation directory..."
	@rm -rf $(DCDBDEPLOYPATH)

104
105
106
107
108
109
update-distfile-hashes: .md5sums
	$(eval X := $(shell cat .md5sums | tr \\\n \; ))
	@echo "Updating $(MAKEFILENAME)..."
	@sed -i -e 's/^DISTFILES_HASHES\ =.*/DISTFILES_HASHES\ =\ $(X)/' $(MAKEFILENAME) ;
	@rm -f .md5sums

110
all: check-cross-compile deps $(foreach s,$(SUB_DIRS),$(s)-build) 
111
112
113

install: depsinstall $(SUB_DIRS)
	@cd include && install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb && cd ..
114
	@echo DONE
115

116
117
118
119
120
121
check-cross-compile:
	@if [ "$(ARCH)" = "arm" ]; then \
		echo "Info: Cross-compiling for ARM using compiler prefix: $(CROSS_COMPILE_STRP)"; \
		echo; \
	fi;

122
123
124
125
126
deps: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.built)

depsinstall: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.installed)

$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.patched
127
128
	@echo "Building OpenSSL library..."
	cd $(@D) && ./Configure shared --prefix=$(DCDBDEPLOYPATH) $(OPENSSL_TARGET) 
129
	cd $(@D) && make && touch $(@)
130

131
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.installed: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built | $(DCDBDEPLOYPATH)
132
133
134
135
	@echo "Installing OpenSSL library..."
	cd $(@D) && make install && touch $(@)

$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.patched
136
	@echo "Building Mosquitto library...";
137
138
	mkdir -p $(@D)/build; 
	cd $(@D)/build && \
139
	CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
Michael Ott's avatar
Michael Ott committed
140
141
142
		-DWITH_SRV=no \
		-DWITH_TLS=yes \
		-DWITH_TLS_PSK=yes \
143
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
144
		$(@D) && \
145
		make -j $(MAKETHREADS) && \
146
		touch $(@)
147

148
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.installed: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built | $(DCDBDEPLOYPATH)
149
	@echo "Installing Mosquitto library..."
150
	cd $(@D)/build && make install && touch $(@)
151
152

$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.patched
153
	@echo "Building Boost..."
154
	@ if [ "$(ARCH)" = "arm" ]; then \
155
		echo " using gcc : arm : $(CROSS_COMPILE)g++ ; " > $(@D)/tools/build/src/user-config.jam; \
156
	fi
Michael Ott's avatar
Michael Ott committed
157
	cd $(@D) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) --with-libraries=atomic,chrono,date_time,exception,filesystem,log,program_options,random,regex,system,thread,timer && \
158
	./b2 stage && touch $(@)
159
160
161
		

$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.installed: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built
162
	cd $(@D) && ./b2 -j $(MAKETHREADS) install && touch $(@)
163

164
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.patched
165
	@echo "Building libuv..."
166
167
168
169
170
171
172
	mkdir -p $(@D)/build
	cd $(@D)/build && \
	CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
		.. && \
		make -j $(MAKETHREADS) && touch $(@)
173

174
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.installed: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built | $(DCDBDEPLOYPATH)
175
	@echo "Installing libuv..."
176
	cd $(@D)/build && make install && touch $(@)
177

178
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.patched $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built
179
	@echo "Building cpp-driver..."
180
181
	mkdir -p $(@D)/build
	cd $(@D)/build && \
182
	CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
183
184
		-DOPENSSL_ROOT_DIR=$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION) \
		-DLIBUV_ROOT_DIR=$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION) \
185
186
187
		-DCASS_BUILD_EXAMPLES=NO \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
188
189
		-DCMAKE_EXE_LINKER_FLAGS="-L$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/stage/lib -lboost_random" \
		-DCMAKE_SHARED_LINKER_FLAGS="-L$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/stage/lib -lboost_random" \
190
		.. && \
191
192
		make -j $(MAKETHREADS) && touch $(@)

193
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built | $(DCDBDEPLOYPATH)
194
	@echo "Installing cpp-driver..."
195
	cd $(@D)/build && make install && touch $(@)
196
	
197
$(DCDBDEPSPATH)/cpp-netlib-$(CPPNET_VERSION)/.built: $(DCDBDEPSPATH)/cpp-netlib-$(CPPNET_VERSION)/.patched
198
199
200
	@echo "Building cpp-netlib..."
	mkdir -p $(DCDBDEPSPATH)/cpp-netlib_build
	cd $(DCDBDEPSPATH)/cpp-netlib_build && \
201
	CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
202
203
204
205
206
		-DCPP-NETLIB_ENABLE_HTTPS=off \
		-DCPP-NETLIB_BUILD_TESTS=OFF \
		-DCPP-NETLIB_BUILD_EXAMPLES=OFF \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
207
		-DBOOST_ROOT=$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/ \
208
		$(@D) && \
209
210
		make -j $(MAKETHREADS) && touch $(@)
	
211
$(DCDBDEPSPATH)/cpp-netlib-$(CPPNET_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-netlib-$(CPPNET_VERSION)/.built | $(DCDBDEPLOYPATH)
212
213
214
215
216
217
	@echo "Installing cpp-netlib..."
	cd $(DCDBDEPSPATH)/cpp-netlib_build && make install && touch $(@)
	
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.patched
	@touch $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built

218
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.installed: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built | $(DCDBDEPLOYPATH)
219
220
	@echo ""
	@echo "Staging and configuring Cassandra..."
221
	@rsync -rlptD $(@D)/ $(DCDBDEPLOYPATH)/cassandra
222
223
224
225
226
227
228
229
230
	@$(eval P := $(shell echo "$(DCDBDEPLOYPATH)" | sed 's/\//\\\//g'))
	@sed -i.original -e 's/\/var\/lib\/cassandra/$(P)\/var\/lib\/cassandra/g' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*cluster_name:.*/cluster_name:\ '\''$(CASSANDRA_CLUSTER_NAME)'\''/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*flush_largest_memtables_at:.*/flush_largest_memtables_at:\ $(CASSANDRA_FLUSH_LARGEST_MEMTABLES_AT)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*reduce_cache_sizes_at:.*/reduce_cache_sizes_at:\ $(CASSANDRA_REDUCE_CACHE_SIZES_AT)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*reduce_cache_capacity_to:.*/reduce_cache_capacity_to:\ $(CASSANDRA_REDUCE_CACHE_CAPACITY_TO)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*partitioner:.*/partitioner:\ $(CASSANDRA_PARTITIONER)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*commitlog_total_space_in_mb:.*/commitlog_total_space_in_mb: $(CASSANDRA_COMMITLOG_TOTAL_SPACE_IN_MB)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*commitlog_segment_size_in_mb:.*/commitlog_segment_size_in_mb: $(CASSANDRA_COMMITLOG_SEGMENT_SIZE_IN_MB)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
Axel Auweter's avatar
Axel Auweter committed
231
232
	@sed -i -e 's/.*tombstone_warn_threshold:.*/tombstone_warn_threshold: $(CASSANDRA_TOMBSTONE_WARN_THRESHOLD)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
	@sed -i -e 's/.*tombstone_failure_threshold:.*/tombstone_failure_threshold: $(CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
233
	@touch $@
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265

$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.built: $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.patched
	@echo ""
	@echo "Building BACNet-Stack..."
	$(eval BACNET_PORT:= $(if $(filter $(OS),Darwin),bsd,linux))
	cd $(@D) && BACNET_PORT=$(BACNET_PORT) MAKE_DEFINE=-fpic make -j $(MAKETHREADS) library
	touch $(@)

$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.installed: $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.built | $(DCDBDEPLOYPATH)
	@echo "Installing BACNet-Stack..."
	install $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/lib/libbacnet.a /$(DCDBDEPLOYPATH)/lib/ && touch $(@)

$(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.built: $(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.patched
	@echo ""
	@echo "Building FreeIPMI library..."
	cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-argp
	cd $(@D) && make -j $(MAKETHREADS) && touch $(@)

$(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.installed: $(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.built | $(DCDBDEPLOYPATH)
	@echo "Installing FreeIPMI library..."
	cd $(@D) && make install && touch $(@)

$(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.built: $(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.patched
	@echo ""
	@echo "Building net-SNMP library..."
	cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-default-snmp-version=3 --with-sys-contact= --with-sys-location= --with-logfile=none --with-persistent-directory=$(DCDBDEPLOYPATH)/var/net-snmp --disable-embedded-perl --disable-perl-cc-checks --without-perl-modules --disable-agent --disable-applications --disable-manuals --disable-scripts --disable-mibs
	cd $(@D) && make -j $(MAKETHREADS) && touch $(@)

$(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.installed: $(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.built | $(DCDBDEPLOYPATH)
	@echo ""
	@echo "Installing net-SNMP library..."
	cd $(@D) && make install && touch $(@)
266
	
267
%-build: deps 
268
269
270
271
272
	@echo "Building $*"
	@$(MAKE) -j $(MAKETHREADS) CC=$(CC) CXX=$(CXX) -C $*

$(SUB_DIRS): $(foreach s,$(SUB_DIRS),$(s)-build) 
	@echo "Installing $@"
273
	@$(MAKE) CC=$(CC) CXX=$(CXX) -C $@ install
274

275
$(PROJECTS): deps
276
	$(eval X := $(shell echo "$(SKIP_PROJECTS)" | grep "$@"))
277
	@if [ "$(X)" = "" ]; then \
278
279
280
281
282
283
284
285
286
		echo ""; \
		echo "Building $@..."; \
		$(MAKE) -j $(MAKETHREADS) CC=$(CC) CXX=$(CXX) -C $@ ; \
		echo "Installing $@..."; \
		$(MAKE) CC=$(CC) CXX=$(CXX) -C $@ install ; \
	else \
		echo ""; \
		echo "Skipping $@..."; \
	fi