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

3
LIBRARIES = DCDBLib
4
PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider IPMIPusher MontBlancPusher SNMPPusher DCDBTools
5

Michael Ott's avatar
Michael Ott committed
6
CASSANDRA_VERSION = 2.1.2
7
MOSQUITTO_VERSION = 1.3.5
Axel Auweter's avatar
Axel Auweter committed
8
BOOST_VERSION     = 1.57.0
9
SNMP_VERSION      = 5.7.2.1
Axel Auweter's avatar
Axel Auweter committed
10
OPENSSL_VERSION   = 1.0.1k
11
CPPDRV_VERSION    = 1.0.0
12
LIBUV_VERSION     = 0.10.32
13

Axel Auweter's avatar
Axel Auweter committed
14
BOOST_VERSION_U   = $(subst .,_,$(BOOST_VERSION))
15
DISTFILES =	apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://apache.cs.utah.edu/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
16
		mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
17
		rudeconfig-5.0.5.tar.gz;http://rudeserver.com/config/download/rudeconfig-5.0.5.tar.gz \
18
		OpenIPMI-2.0.19.tar.gz;http://netcologne.dl.sourceforge.net/project/openipmi/OpenIPMI%202.0%20Library/OpenIPMI-2.0.19.tar.gz \
19
		boost_$(BOOST_VERSION_U).tar.gz;http://netcologne.dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
20
21
		net-snmp-$(SNMP_VERSION).zip;http://netcologne.dl.sourceforge.net/project/net-snmp/net-snmp/$(SNMP_VERSION)/net-snmp-$(SNMP_VERSION).zip \
		openssl-$(OPENSSL_VERSION).tar.gz;https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz \
22
		cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/1.0.0.tar.gz \
23
		libuv-v$(LIBUV_VERSION).tar.gz;http://www.libuv.org/dist/v$(LIBUV_VERSION)/libuv-v$(LIBUV_VERSION).tar.gz
24

25
FETCH = wget -c --no-check-certificate -O -
26

Axel Auweter's avatar
Axel Auweter committed
27
OPENSSL_TARGET = $(if $(findstring $(shell uname),Darwin),"darwin64-x86_64-cc", "linux-x86_64")
28

29
30
MAKETHREADS ?= $(if $(findstring $(shell uname),Darwin),$(shell sysctl machdep.cpu.thread_count | cut -b 27-),\
		$(if $(findstring $(shell uname),Linux),$(shell cat /proc/cpuinfo | grep processor | wc -l),4))
31

32
CASSANDRA_CLUSTER_NAME                 = Datacenter Monitor Database
Axel Auweter's avatar
Axel Auweter committed
33
34
35
36
37
38
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
39

40
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
41
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//' | sed 's/.zip;.*//' ))
42

43
CFLAGS += -I$(DCDBDEPLOYPATH)/include -O0 -g
Axel Auweter's avatar
Axel Auweter committed
44
CXX11FLAGS = --std=c++11 -Wno-c99-extensions -Wno-missing-field-initializers
Axel Auweter's avatar
Axel Auweter committed
45
LDFLAGS += -L$(DCDBDEPLOYPATH)/lib -O0 -g
46

47
.PHONY : info all clean cleanall distclean $(LIBRARIES) $(PROJECTS)
48
49
50
51
52
53

info:
	@echo ""
	@echo "DCDB - Data Center Database"
	@echo "Buildsystem description"
	@echo ""
Axel Auweter's avatar
Axel Auweter committed
54
55
	@echo "Use the DCDBDEPSPATH environment variable to specify a build path for the"
	@echo "dependencies. Currently, the project dependenceis will be built to:"
Michael Ott's avatar
Michael Ott committed
56
	@echo "$(DCDBDEPSPATH)"
57
	@echo ""
58
59
	@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
	@echo "of all tools. Currently, the directory for deployment/staging is:"
60
	@echo "$(DCDBDEPLOYPATH)"
61
62
63
64
65
	@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 ""
66
67
68
69
	@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 ""
70
71
	@echo "To start, please type:"
	@echo "     make all"
72
	@echo $(OPENSSLPREFIX)
73
74

clean:
75
	@$(foreach l,$(LIBRARIES),echo "Cleaning $(l)..." && make -C $(l) clean && echo;)
Michael Ott's avatar
Michael Ott committed
76
	@$(foreach p,$(PROJECTS),echo "Cleaning $(p)..." && make -C $(p) clean && echo;)
77
78

cleanall: clean
Michael Ott's avatar
Michael Ott committed
79
80
	@cd $(DCDBDEPSPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles
	@cd $(DCDBDEPSPATH) && rm -rf mosquitto_build
Michael Ott's avatar
Michael Ott committed
81
	@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)
82

Michael Ott's avatar
Michael Ott committed
83
84
distclean: clean
	@echo "Wiping dependencies..."
Michael Ott's avatar
Michael Ott committed
85
	@rm -rf $(DCDBDEPSPATH)
86

Axel Auweter's avatar
Axel Auweter committed
87
88
89
90
91
92
93
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)

Michael Ott's avatar
Michael Ott committed
94
all: $(DCDBDEPSPATH)/.prerequesites
95
	@make $(LIBRARIES)
96
	@make $(PROJECTS)
97

Michael Ott's avatar
Michael Ott committed
98
$(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
99
100
101
	@echo ""
	@echo "Preparing patches..."
	@cp -a patches $(DCDBDEPSPATH)/
102
103
104
105
106
	
	$(eval S := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*openssl/openssl/' | sed 's/\ .*//'))
	@if [ ! -e $(DCDBDEPSPATH)/$(S)/.installed ]; then \
		echo ""; \
		echo "Building OpenSSL library..."; \
Axel Auweter's avatar
Axel Auweter committed
107
		cd $(DCDBDEPSPATH)/$(S) && ./Configure shared --prefix=$(DCDBDEPLOYPATH) $(OPENSSL_TARGET); \
108
109
110
111
112
		cd $(DCDBDEPSPATH)/$(S) && make && make install_sw && touch $(DCDBDEPSPATH)/$(S)/.installed; \
	else \
		echo "Skipping OpenSSL library (already built)..."; \
	fi

113
	$(eval M := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
114
115
116
	@if [ ! -e $(DCDBDEPSPATH)/$(M)/.installed ]; then \
		echo ""; \
		echo "Building Mosquitto library..."; \
117
118
119
120
		if [ -e $(DCDBDEPSPATH)/patches/$(M).patch ]; then \
			echo "Patching Mosquitto..."; \
			cd $(DCDBDEPSPATH)/$(M) && (patch -N -p0 < $(DCDBDEPSPATH)/patches/$(M).patch || true); \
		fi; \
Axel Auweter's avatar
Axel Auweter committed
121
		mkdir -p $(DCDBDEPSPATH)/mosquitto_build; \
122
123
124
125
		cd $(DCDBDEPSPATH)/mosquitto_build && \
			cmake -DWITH_SRV=no -DWITH_TLS=OFF -DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH)/ $(DCDBDEPSPATH)/$(M) && \
			make -j $(MAKETHREADS) && make install && \
			touch $(DCDBDEPSPATH)/$(M)/.installed; \
Axel Auweter's avatar
Axel Auweter committed
126
127
128
	else \
		echo "Skipping Mosquitto library (already built)..."; \
	fi
129
130
	
	$(eval R := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*rudeconfig/rudeconfig/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
131
132
133
	@if [ ! -e $(DCDBDEPSPATH)/$(R)/.installed ]; then \
		echo ""; \
		echo "Building Rudeconfig library..."; \
134
135
136
137
138
		cd $(DCDBDEPSPATH)/$(R) && ./configure --prefix=$(DCDBDEPLOYPATH) && \
			make -j $(MAKETHREADS) && \
			chmod +x install-sh && \
			make install && \
			touch $(DCDBDEPSPATH)/$(R)/.installed; \
Axel Auweter's avatar
Axel Auweter committed
139
140
141
	else \
		echo "Skipping Rudeconfig library (already built)..."; \
	fi
142
143

	$(eval O := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*OpenIPMI/OpenIPMI/' | sed 's/\ .*//'))
144
	$(eval X := $(shell uname))
Axel Auweter's avatar
Axel Auweter committed
145
146
147
	@if [ ! -e $(DCDBDEPSPATH)/$(O)/.installed ]; then \
		echo ""; \
		echo "Building OpenIPMI library..."; \
148
149
150
151
		if [ -e $(DCDBDEPSPATH)/patches/$(O).patch ]; then \
			echo "Patching OpenIPMI..."; \
			cd $(DCDBDEPSPATH)/$(O) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(O).patch || true); \
		fi; \
152
		if [ "$(X)" == "Darwin" ]; then \
153
154
155
			echo "Fixing OpenIPMI for Mac OS..."; \
			cd $(DCDBDEPSPATH)/$(O) && find . -name 'Makefile*' | xargs sed -i '' -e 's/Map/map/g'; \
		fi; \
156
		cd $(DCDBDEPSPATH)/$(O) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-swig=no --with-perl=no --with-python=no CFLAGS="$(CFLAGS)"; \
Axel Auweter's avatar
Axel Auweter committed
157
158
159
160
		cd $(DCDBDEPSPATH)/$(O) && make -j $(MAKETHREADS) && make install && touch $(DCDBDEPSPATH)/$(O)/.installed; \
	else \
		echo "Skipping OpenIPMI library (already built)..."; \
	fi
161
162
	
	$(eval B := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*boost/boost/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
163
164
165
	@if [ ! -e $(DCDBDEPSPATH)/$(B)/.installed ]; then \
		echo ""; \
		echo "Building Boost..."; \
166
167
168
169
		if [ -e $(DCDBDEPSPATH)/patches/$(B).patch ]; then \
			echo "Patching Boost..."; \
			cd $(DCDBDEPSPATH)/$(B) && (patch -N -p2 < $(DCDBDEPSPATH)/patches/$(B).patch || true); \
		fi; \
Axel Auweter's avatar
Axel Auweter committed
170
		cd $(DCDBDEPSPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) \
Axel Auweter's avatar
Axel Auweter committed
171
			--with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,random,system,thread,timer && \
172
			./b2 -j $(MAKETHREADS) install && touch $(DCDBDEPSPATH)/$(B)/.installed; \
Axel Auweter's avatar
Axel Auweter committed
173
174
175
	else \
		echo "Skipping Boost (already built)..."; \
	fi
176

177
178
179
180
	$(eval S := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*net-snmp/net-snmp/' | sed 's/\ .*//'))
	@if [ ! -e $(DCDBDEPSPATH)/$(S)/.installed ]; then \
		echo ""; \
		echo "Building net-snmp..."; \
181
182
183
184
185
186
		if [ -e $(DCDBDEPSPATH)/patches/$(S).patch ]; then \
			echo "Patching net-snmp..."; \
			cd $(DCDBDEPSPATH)/$(S) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(S).patch || true); \
		fi; \
		cd $(DCDBDEPSPATH)/$(S) && env CFLAGS="$(CFLAGS)" ./configure --prefix=$(DCDBDEPLOYPATH) --with-default-snmp-version="3" \
			--with-sys-contact="@@no.where" --with-sys-location="Unknown" --with-logfile="$(DCDBDEPLOYPATH)/var/log/snmpd.log" \
Axel Auweter's avatar
Axel Auweter committed
187
188
			--with-persistent-directory="$(DCDBDEPLOYPATH)/var/net-snmp" --disable-embedded-perl --without-perl-modules \
			--with-openssl=$(DCDBDEPLOYPATH) ; \
189
190
191
192
193
		cd $(DCDBDEPSPATH)/$(S) && env CFLAGS="$(CFLAGS)" make -j $(MAKETHREADS) && make install && touch $(DCDBDEPSPATH)/$(S)/.installed; \
	else \
		echo "Skipping net-snmp (already built)..."; \
	fi

194
195
196
197
198
199
200
201
202
203
204
205
	$(eval U := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*libuv/libuv/' | sed 's/\ .*//'))
	@if [ ! -e $(DCDBDEPSPATH)/$(U)/.installed ]; then \
		echo ""; \
		echo "Building libuv..."; \
		cd $(DCDBDEPSPATH)/$(U) && \
		env CFLAGS="$(CFLAGS)" make -j $(MAKETHREADS); \
		echo "Installing libuv..."; \
		mkdir -p $(DCDBDEPLOYPATH)/include/uv-private; \
		cd $(DCDBDEPSPATH)/$(U) && install -c include/uv.h $(DCDBDEPLOYPATH)/include/; \
		cd $(DCDBDEPSPATH)/$(U) && install -c include/uv-private/* $(DCDBDEPLOYPATH)/include/uv-private/; \
		mkdir -p $(DCDBDEPLOYPATH)/lib/; \
		if [ -e $(DCDBDEPSPATH)/$(U)/libuv.a ]; then cd $(DCDBDEPSPATH)/$(U) && install -c libuv.a $(DCDBDEPLOYPATH)/lib/; fi; \
206
		if [ -e $(DCDBDEPSPATH)/$(U)/libuv.so ]; then cd $(DCDBDEPSPATH)/$(U) && install -c libuv.so $(DCDBDEPLOYPATH)/lib/; ln -s $(DCDBDEPLOYPATH)/lib/libuv.so $(DCDBDEPLOYPATH)/lib/libuv.so.0.10; fi; \
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
		if [ -e $(DCDBDEPSPATH)/$(U)/libuv.dylib ]; then cd $(DCDBDEPSPATH)/$(U) && install -c libuv.dylib $(DCDBDEPLOYPATH)/lib/; fi; \
		touch $(DCDBDEPSPATH)/$(U)/.installed; \
	else \
		echo "Skipping libuv (already built)..."; \
	fi

	$(eval D := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*cpp-driver/cpp-driver/' | sed 's/\ .*//'))
	@if [ ! -e $(DCDBDEPSPATH)/$(D)/.installed ]; then \
		echo ""; \
		echo "Building cpp-driver..."; \
		if [ -e $(DCDBDEPSPATH)/patches/$(D).patch ]; then \
			echo "Patching cpp-driver..."; \
			cd $(DCDBDEPSPATH)/$(D) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(D).patch || true); \
		fi; \
		mkdir -p $(DCDBDEPSPATH)/cpp-driver_build; \
		cd $(DCDBDEPSPATH)/cpp-driver_build && \
Axel Auweter's avatar
Axel Auweter committed
223
                        cmake -DCMAKE_CXX_FLAGS="$(CXX11FLAGS) -Wno-unused-command-line-argument -L$(DCDBDEPLOYPATH)/lib " \
224
				-DCASS_USE_EXTERNAL_BOOST=YES \
Axel Auweter's avatar
Axel Auweter committed
225
				-DCASS_BUILD_EXAMPLES=NO \
226
227
				-DINSTALL_LIB_DIR=lib \
				-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
228
				-DCMAKE_EXE_LINKER_FLAGS="-L$(DCDBDEPLOYPATH)/lib -lboost_random" \
Axel Auweter's avatar
Axel Auweter committed
229
				$(DCDBDEPSPATH)/$(D) && \
230
231
232
233
234
235
                        make -j $(MAKETHREADS) && make install && \
                        touch $(DCDBDEPSPATH)/$(D)/.installed; \
	else \
		echo "Skipping cpp-driver (already built)..."; \
	fi

236
237
238
	@echo ""
	@echo "Staging and configuring Cassandra..."
	@$(eval C := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*apache-cassandra/apache-cassandra/' | sed 's/\ .*//'))
Michael Ott's avatar
Michael Ott committed
239
	@rsync -a $(DCDBDEPSPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra
240
241
	@$(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
242
	@sed -i -e 's/.*cluster_name:.*/cluster_name:\ '\''$(CASSANDRA_CLUSTER_NAME)'\''/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
Axel Auweter's avatar
Axel Auweter committed
243
244
245
246
247
248
	@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
249

Michael Ott's avatar
Michael Ott committed
250
	@touch $(DCDBDEPSPATH)/.prerequesites
251
	
Michael Ott's avatar
Michael Ott committed
252
253
$(DCDBDEPSPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.dirstamp)
	@touch $(DCDBDEPSPATH)/.extract-distfiles
254
	
Michael Ott's avatar
Michael Ott committed
255
256
$(DCDBDEPSPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBDEPSPATH)/distfiles/$(f))
	@touch $(DCDBDEPSPATH)/.download-distfiles
257

Michael Ott's avatar
Michael Ott committed
258
259
$(DCDBDEPSPATH)/distfiles/%: 
	@mkdir -p $(DCDBDEPSPATH)/distfiles
260
261
262
	$(eval F := $(shell echo "$@" | sed 's/.*\///'))
	$(eval FF := $(shell echo "$(DISTFILES)" | sed 's/.*$(F);//' | sed 's/ .*//'))
	@echo "Downloading $(FF) as $(F)..."
Michael Ott's avatar
Michael Ott committed
263
	@cd $(DCDBDEPSPATH)/distfiles && $(FETCH) $(FF) > $(F)
264

Michael Ott's avatar
Michael Ott committed
265
$(DCDBDEPSPATH)/%/.dirstamp: $(DCDBDEPSPATH)/.download-distfiles
266
267
	$(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///'))
	@echo "Extracting $(F)..."
268
	@if [ "$(suffix $(shell ls $(DCDBDEPSPATH)/distfiles/$(F)*))" = ".gz" ]; then \
269
270
271
272
		cd $(DCDBDEPSPATH) && tar xzf distfiles/$(F).tar.gz; \
	else \
		cd $(DCDBDEPSPATH) && unzip distfiles/$(F).zip > /dev/null; \
	fi
273
274
	@touch $@

275
276
277
278
279
280
281
282
$(LIBRARIES): $(DCDBDEPSPATH)/.prerequesites
	@echo ""
	@echo "Building Library $@..."
	@$(MAKE) -j $(MAKETHREADS) -C $@
	@echo "Installing Library $@..."
	@$(MAKE) -C $@ install

$(PROJECTS):
Michael Ott's avatar
Michael Ott committed
283
	@echo ""
284
	@echo "Building $@..."
285
	@$(MAKE) -j $(MAKETHREADS) -C $@ 
286
	@echo "Installing $@..."
Michael Ott's avatar
Michael Ott committed
287
	@$(MAKE) -C $@ install