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

Michael Ott's avatar
Michael Ott committed
3
LIBRARIES = lib
Michael Ott's avatar
Michael Ott committed
4
PROJECTS = CollectAgent tools scripts
5

6
CASSANDRA_VERSION = 2.2.6
7
MOSQUITTO_VERSION = 1.3.5
8
BOOST_VERSION     = 1.58.0
Michael Ott's avatar
Michael Ott committed
9
OPENSSL_VERSION   = 1.0.1u
Axel Auweter's avatar
Axel Auweter committed
10
CPPDRV_VERSION    = 2.0.1
11
LIBUV_VERSION     = 0.10.36
12
SOURCEFORGE_MROR  = netcologne
13
CPPNET_VERSION 	  = 0.12.0-final
14

15
BOOST_VERSION_U   = $(subst .,_,$(BOOST_VERSION))
16
DISTFILES =	apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://archive.apache.org/dist/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
17
		mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
18
		boost_$(BOOST_VERSION_U).tar.gz;http://$(SOURCEFORGE_MROR).dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
Axel Auweter's avatar
Axel Auweter committed
19
		openssl-$(OPENSSL_VERSION).tar.gz;ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/openssl-$(OPENSSL_VERSION).tar.gz \
20
		cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/$(CPPDRV_VERSION).tar.gz \
21
		libuv-v$(LIBUV_VERSION).tar.gz;http://dist.libuv.org/dist/v$(LIBUV_VERSION)/libuv-v$(LIBUV_VERSION).tar.gz \
22
		cpp-netlib-$(CPPNET_VERSION).tar.gz;http://downloads.cpp-netlib.org/0.12.0/cpp-netlib-$(CPPNET_VERSION).tar.gz 
23

24
DISTFILES_HASHES = apache-cassandra-2.2.6.tar.gz|8e2a8696ced6c4f9db06c40b2f5a7936;mosquitto-1.3.5.tar.gz|55094ad4dc7c7985377f43d4fc3d09da;boost_1_58_0.tar.gz|5a5d5614d9a07672e1ab2a250b5defc5;openssl-1.0.1u.tar.gz|130bb19745db2a5a09f22ccbbf7e69d0;cpp-driver-2.0.1.tar.gz|70bf83e1cbd0d35b7e5ed66fc4dccbb1;libuv-v0.10.36.tar.gz|8eb77b4fee4f311c114a9fee06f5a2ab;cpp-netlib-0.12.0-final.tar.gz|29b87c0e8c1a9e7fbdea5afcec947d53
25

26
include common.mk
27
28
29
30
31
32
33
34

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
35
36
CASSANDRA_TOMBSTONE_WARN_THRESHOLD     = 100000
CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD  = 10000000
37

38
39
HTTPD_PORT = 8080

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

47
PUBHEADERS = pusherpqueue.h dcdbdaemon.h
48

49
.PHONY : info all clean cleanall distclean check-cross-compile $(LIBRARIES) $(PROJECTS)
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

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"
74
75
76
77
	@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- )"
78

79
clean:
80
81
82
83
84
85
86
87
88
89
90
	@$(foreach l,$(LIBRARIES),echo "Cleaning $(l)..." && make -C $(l) clean && echo;)
	@$(foreach p,$(PROJECTS),echo "Cleaning $(p)..." && make -C $(p) clean && echo;)

cleanall: clean
	@cd $(DCDBDEPSPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles
	@cd $(DCDBDEPSPATH) && rm -rf mosquitto_build
	@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)

distclean: clean
	@echo "Wiping dependencies..."
	@rm -rf $(DCDBDEPSPATH)
91
	@rm -rf .md5sums
92
93
94
95
96
97
98
99

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)

100
101
102
103
104
105
106
107
108
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

.md5sums: $(DCDBDEPSPATH)/.download-distfiles
	@$(foreach f,$(DISTFILESNAMES),echo "Checksumming $(f)..." && printf "$(f);" >> .md5sums && $(MD5) $(DCDBDEPSPATH)/distfiles/$(f) | sed -e 's/.*\ //' >> .md5sums; )

109
110
111
112
all: check-cross-compile $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.installed) $(LIBRARIES) $(PROJECTS)
	@mkdir -p $(DCDBDEPLOYPATH)/include/dcdb
	cd include && install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb && cd ..
	@echo DONE
113

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

120
121
122
123
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.installed: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.patched
	@echo "Building OpenSSL library..."
	cd $(@D) && ./Configure shared --prefix=$(DCDBDEPLOYPATH) $(OPENSSL_TARGET) 
	cd $(@D) && make && make install_sw && touch $(@)
124

125
126
127
128
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.installed: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.patched
	@echo "Building Mosquitto library...";
	mkdir -p $(DCDBDEPSPATH)/mosquitto_build; 
	cd $(DCDBDEPSPATH)/mosquitto_build && \
Michael Ott's avatar
Michael Ott committed
129
130
131
132
133
134
		cmake $(CMAKE_CROSS_FLAGS) \
		-DOPENSSL_ROOT_DIR=$(DCDBDEPLOYPATH)/ \
		-DWITH_SRV=no \
		-DWITH_TLS=yes \
		-DWITH_TLS_PSK=yes \
		-DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH)/ \
135
		$(@D) && \
Michael Ott's avatar
Michael Ott committed
136
		make -j $(MAKETHREADS) && make install && \
137
		touch $(@)
138

139
140
141
142
$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.installed: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.patched
	@echo "Building Boost..."
	if [ "$(ARCH)" = "arm" ]; then \
		echo " using gcc : arm : $(CROSS_COMPILE)g++ ; " > $(@D)/tools/build/src/user-config.jam; \
143
	fi
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
	cd $(@D) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) \
		--with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,random,regex,system,thread,timer \
	cd $(@D) && ./b2 -j $(MAKETHREADS) cxxflags="$(CXX11FLAGS)" install && touch $(@)

$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.installed: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.patched
	@echo "Building libuv..."
	cd $(@D) && env CC="$(CC)" CFLAGS="$(CFLAGS)" make -j $(MAKETHREADS)
	@echo "Installing libuv..."
	mkdir -p $(DCDBDEPLOYPATH)/include/uv-private
	cd $(@D) && install -c include/uv.h $(DCDBDEPLOYPATH)/include/
	cd $(@D) && install -c include/uv-private/* $(DCDBDEPLOYPATH)/include/uv-private/
	mkdir -p $(DCDBDEPLOYPATH)/lib/
	if [ -e $(@D)/libuv.a ]; then cd $(@D) && install -c libuv.a $(DCDBDEPLOYPATH)/lib/; fi
	if [ -e $(@D)/libuv.so ]; then cd $(@D) && install -c libuv.so $(DCDBDEPLOYPATH)/lib/; ln -s $(DCDBDEPLOYPATH)/lib/libuv.so $(DCDBDEPLOYPATH)/lib/libuv.so.0.10; fi
	if [ -e $(@D)/libuv.dylib ]; then cd $(@D) && install -c libuv.dylib $(DCDBDEPLOYPATH)/lib/; fi
	touch $(@D)/.installed;

$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.patched
	@echo "Building cpp-driver..."
	mkdir -p $(DCDBDEPSPATH)/cpp-driver_build
	cd $(DCDBDEPSPATH)/cpp-driver_build && \
	cmake $(CMAKE_CROSS_FLAGS) \
		-DCMAKE_CXX_FLAGS="$(CXX11FLAGS) -Wno-unused-command-line-argument -L$(DCDBDEPLOYPATH)/lib " \
		-DOPENSSL_ROOT_DIR=$(DCDBDEPLOYPATH)/ \
		-DLIBUV_ROOT_DIR=$(DCDBDEPLOYPATH)/ \
		-DCASS_BUILD_EXAMPLES=NO \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
		-DCMAKE_EXE_LINKER_FLAGS="-L$(DCDBDEPLOYPATH)/lib -lboost_random" \
		-DCMAKE_SHARED_LINKER_FLAGS="-L$(DCDBDEPLOYPATH)/lib -lboost_random" \
		$(@D) && \
		make -j $(MAKETHREADS) && make install && \
		touch $(@D)/.installed
177
	
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
$(DCDBDEPSPATH)/cpp-netlib-$(CPPNET_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-netlib-$(CPPNET_VERSION)/.patched
	@echo "Building cpp-netlib..."
	mkdir -p $(DCDBDEPSPATH)/cpp-netlib_build
	cd $(DCDBDEPSPATH)/cpp-netlib_build && \
	cmake $(CMAKE_CROSS_FLAGS) \
		-DCMAKE_CXX_FLAGS="$(CXX11FLAGS) -Wno-unused-command-line-argument -L$(DCDBDEPLOYPATH)/lib " \
		-DCPP-NETLIB_ENABLE_HTTPS=off \
		-DCPP-NETLIB_BUILD_TESTS=OFF \
		-DCPP-NETLIB_BUILD_EXAMPLES=OFF \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
		-DBOOST_LIBRARYDIR=$(DCDBDEPLOYPATH)/lib \
		-DBOOST_ROOT=$(DCDBDEPSPATH)/$(B)/ \
		$(@D) && \
		make -j $(MAKETHREADS) && \
		make install && \
		touch $(@D)/.installed
195
		
196
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.installed: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.patched $(DCDBDEPLOYPATH)
197
198
	@echo ""
	@echo "Staging and configuring Cassandra..."
199
	@rsync -rlptD $(@D)/ $(DCDBDEPLOYPATH)/cassandra
200
201
202
203
204
205
206
207
208
	@$(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
209
210
	@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
211
	@touch $@
212
213
	
$(LIBRARIES): 
214
215
	@echo ""
	@echo "Building Library $@..."
216
	@$(MAKE) -j $(MAKETHREADS) CC=$(CC) CXX=$(CXX) -C $@
217
	@echo "Installing Library $@..."
218
	@$(MAKE) CC=$(CC) CXX=$(CXX) -C $@ install
219

220
$(PROJECTS):
221
	$(eval X := $(shell echo "$(SKIP_PROJECTS)" | grep "$@"))
222
	@if [ "$(X)" = "" ]; then \
223
224
225
226
227
228
229
230
231
		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