Makefile 13.1 KB
Newer Older
Michael Ott's avatar
Michael Ott committed
1
2
include config.mk

3
MAKEFILENAME := $(lastword $(MAKEFILE_LIST))
Michael Ott's avatar
Michael Ott committed
4

5
SUB_DIRS = lib collectagent dcdbpusher analytics tools scripts
6

7
SOURCEFORGE_MROR  = vorboss
Michael Ott's avatar
Michael Ott committed
8
CASSANDRA_VERSION = 3.0.18
9
MOSQUITTO_VERSION = 1.5.5
Micha Mueller's avatar
Micha Mueller committed
10
BOOST_VERSION     = 1.70.0
11
OPENSSL_VERSION   = 1.1.1c
12
13
CPPDRV_VERSION    = 2.10.0
LIBUV_VERSION     = 1.24.0
14
15
BACNET-STACK_VERSION = 0.8.6
FREEIPMI_VERSION = 1.6.3
Michael Ott's avatar
Michael Ott committed
16
NET-SNMP_VERSION = 5.8
17

18
BOOST_VERSION_U   = $(subst .,_,$(BOOST_VERSION))
Micha Mueller's avatar
Micha Mueller committed
19

20
DISTFILES =	apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://archive.apache.org/dist/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
21
		mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
22
		boost_$(BOOST_VERSION_U).tar.gz;http://$(SOURCEFORGE_MROR).dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
23
		openssl-$(OPENSSL_VERSION).tar.gz;https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz \
di34bap's avatar
di34bap committed
24
		libuv-v$(LIBUV_VERSION).tar.gz;https://dist.libuv.org/dist/v$(LIBUV_VERSION)/libuv-v$(LIBUV_VERSION).tar.gz \
25
		cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/$(CPPDRV_VERSION).tar.gz \
26
		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 \
Micha Mueller's avatar
Micha Mueller committed
27
28
29
        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
    
30
DISTFILES_HASHES = apache-cassandra-3.0.18.tar.gz|94dbdaa58b366166c53f881b8e266bc8;\
Micha Mueller's avatar
Micha Mueller committed
31
                   mosquitto-1.5.5.tar.gz|a17dffc6f63b2a4ab2eb5c51139e60e9;\
Micha Mueller's avatar
Micha Mueller committed
32
                   boost_1_70_0.tar.gz|fea771fe8176828fabf9c09242ee8c26;\
33
                   openssl-1.1.1c.tar.gz|15e21da6efe8aa0e0768ffd8cd37a5f6;\
Micha Mueller's avatar
Micha Mueller committed
34
35
                   cpp-driver-2.10.0.tar.gz|6d15dd2cccd2efd1fdc86089d26971d0;\
                   libuv-v1.24.0.tar.gz|90320330757253b07404d2a97f59c66b;\
36
37
                   bacnet-stack-0.8.6.tgz|544ebd42ed959deb2213209b66bbc460;\
                   freeipmi-1.6.3.tar.gz|b2d97e20db9b81b460ce1b9dad5bf54e;\
Micha Mueller's avatar
Micha Mueller committed
38
                   net-snmp-5.8.tar.gz|63bfc65fbb86cdb616598df1aff6458a
39

40
include common.mk
41
42
43
44
45
46
47
48

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
49
50
CASSANDRA_TOMBSTONE_WARN_THRESHOLD     = 100000
CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD  = 10000000
51

52
53
# If cross-compiling for ARM, adjust the build settings
ifeq ("$(ARCH)", "arm")
54
	OPENSSL_TARGET = "linux-generic32"
55
else
56
	OPENSSL_TARGET = $(if $(findstring $(shell uname),Darwin),"darwin64-x86_64-cc","linux-x86_64")
57
58
endif

59
PUBHEADERS = dcdbdaemon.h
60

61
62
63
FULL_CC = $(shell which $(CC))
FULL_CXX = $(shell which $(CXX))

64
.PHONY : info all clean cleanall cleandoc distclean check-cross-compile deps depsinstall $(SUB_DIRS) doc
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

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"
89
90
91
92
	@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- )"
93

94
clean:
95
	@$(foreach s,$(SUB_DIRS),echo "Cleaning $(s)..." && make -C $(s) clean && echo;)
96

Michael Ott's avatar
Michael Ott committed
97
cleandeps:
98
	@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)
99
	@$(foreach f,cpp-netlib,echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f)_build && echo;)
100
101
102
	
cleandoc:
	@echo "Cleaning doc/html..."
103
	@rm -rf doc/html && rm doc/dcdb_documentation.html && rm doc/dox_stderr.txt
104

105
cleanall: clean cleandeps cleandoc
Michael Ott's avatar
Michael Ott committed
106

107
108
109
110
111
112
113
114
115
116
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)
117
118
119
	
doc:
	@echo "Generating doxygen HTML documentation..."
120
	@cd doc/ && doxygen Doxyfile && ln -sf ./html/index.html ./dcdb_documentation.html
121
	@echo "Generated docs into doc/html"
122

123
all: check-cross-compile deps $(foreach s,$(SUB_DIRS),$(s)-build)
124

125
install: depsinstall $(SUB_DIRS)
126
	@cd common/include && install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb && cd ..
127
	@echo DONE
128

129
130
131
132
133
deps: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.built)

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

$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.patched
134
	@echo "Building OpenSSL library..."
135
	cd $(@D) && ./Configure shared --prefix=$(DCDBDEPLOYPATH) $(OPENSSL_TARGET) 
136
	cd $(@D) && make && touch $(@)
137

138
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.installed: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built | $(DCDBDEPLOYPATH)
139
	@echo "Installing OpenSSL library..."
140
	cd $(@D) && make install_sw && touch $(@)
141
142

$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.patched
143
	@echo "Building Mosquitto library...";
144
145
	mkdir -p $(@D)/build; 
	cd $(@D)/build && \
146
	CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
Michael Ott's avatar
Michael Ott committed
147
148
149
		-DWITH_SRV=no \
		-DWITH_TLS=yes \
		-DWITH_TLS_PSK=yes \
150
		-DDOCUMENTATION=no \
151
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
152
		$(@D) && \
153
		make -j $(MAKETHREADS) && \
154
		touch $(@)
155

156
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.installed: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built | $(DCDBDEPLOYPATH)
157
	@echo "Installing Mosquitto library..."
158
	cd $(@D)/build && make install && touch $(@)
159
160

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

$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.installed: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built
Micha Mueller's avatar
Micha Mueller committed
170
	cd $(@D) && ./b2 -j $(MAKETHREADS) --no-cmake-config install && touch $(@)
171

172
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.patched
173
	@echo "Building libuv..."
174
175
176
177
178
179
180
	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 $(@)
181

182
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.installed: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built | $(DCDBDEPLOYPATH)
183
	@echo "Installing libuv..."
184
	cd $(@D)/build && make install && touch $(@)
185

186
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.patched $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built
187
	@echo "Building cpp-driver..."
188
189
	mkdir -p $(@D)/build
	cd $(@D)/build && \
190
	CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
191
192
		-DOPENSSL_ROOT_DIR=$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION) \
		-DLIBUV_ROOT_DIR=$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION) \
193
194
195
		-DCASS_BUILD_EXAMPLES=NO \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
196
197
		-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" \
198
		.. && \
199
200
		make -j $(MAKETHREADS) && touch $(@)

201
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built | $(DCDBDEPLOYPATH)
202
	@echo "Installing cpp-driver..."
203
	cd $(@D)/build && make install && touch $(@)
204
	
205
206
207
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.patched
	@touch $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built

208
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.installed: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built | $(DCDBDEPLOYPATH)
209
210
	@echo ""
	@echo "Staging and configuring Cassandra..."
211
	@rsync -rlptD $(@D)/ $(DCDBDEPLOYPATH)/cassandra
212
213
214
215
216
217
218
219
220
	@$(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
221
222
	@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
223
	@touch $@
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

$(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..."
Michael Ott's avatar
Michael Ott committed
239
	cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-argp --without-encryption
240
241
242
243
244
245
246
247
248
	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..."
249
	cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-default-snmp-version=3 --with-defaults --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
250
251
252
253
254
255
	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 $(@)
256
	
257
%-build: deps 
258
259
260
261
262
	@echo "Building $*"
	@$(MAKE) -j $(MAKETHREADS) CC=$(CC) CXX=$(CXX) -C $*

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

265
$(PROJECTS): deps
Michael Ott's avatar
Michael Ott committed
266
267
268
269
270
	echo ""; \
	echo "Building $@..."; \
	$(MAKE) -j $(MAKETHREADS) CC=$(CC) CXX=$(CXX) -C $@ ; \
	echo "Installing $@..."; \
	$(MAKE) CC=$(CC) CXX=$(CXX) -C $@ install ; \