Makefile 11.3 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
5
6
7
8

CASSANDRA_VERSION = 1.2.19
THRIFT_VERSION    = 0.9.1
MOSQUITTO_VERSION = 1.3.5
Axel Auweter's avatar
Axel Auweter committed
9
BOOST_VERSION     = 1.56.0
10
SNMP_VERSION      = 5.7.2.1
11

Axel Auweter's avatar
Axel Auweter committed
12
BOOST_VERSION_U   = $(subst .,_,$(BOOST_VERSION))
13
14
15
DISTFILES = thrift-$(THRIFT_VERSION).tar.gz;https://dist.apache.org/repos/dist/release/thrift/$(THRIFT_VERSION)/thrift-$(THRIFT_VERSION).tar.gz \
		apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://apache.cs.utah.edu/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
		mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
16
		rudeconfig-5.0.5.tar.gz;http://rudeserver.com/config/download/rudeconfig-5.0.5.tar.gz \
Axel Auweter's avatar
Axel Auweter committed
17
		OpenIPMI-2.0.19.tar.gz;http://optimate.dl.sourceforge.net/project/openipmi/OpenIPMI%202.0%20Library/OpenIPMI-2.0.19.tar.gz \
18
19
		boost_$(BOOST_VERSION_U).tar.gz;http://netcologne.dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
		net-snmp-$(SNMP_VERSION).tar.gz;http://optimate.dl.sourceforge.net/project/net-snmp/net-snmp/$(SNMP_VERSION)/net-snmp-$(SNMP_VERSION).tar.gz
20

21
FETCH = wget -c --no-check-certificate -O -
22

23
24
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))
25

26
CASSANDRA_CLUSTER_NAME                 = Datacenter Monitor Database
Axel Auweter's avatar
Axel Auweter committed
27
28
29
30
31
32
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
33

34
35
36
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//'))

37
CFLAGS += -I$(DCDBDEPLOYPATH)/include -O0 -g
38
CXX11FLAGS = --std=c++11
Axel Auweter's avatar
Axel Auweter committed
39
LDFLAGS += -L$(DCDBDEPLOYPATH)/lib -O0 -g
40

41
.PHONY : info all clean cleanall distclean $(LIBRARIES) $(PROJECTS)
42
43
44
45
46
47

info:
	@echo ""
	@echo "DCDB - Data Center Database"
	@echo "Buildsystem description"
	@echo ""
Axel Auweter's avatar
Axel Auweter committed
48
49
	@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
50
	@echo "$(DCDBDEPSPATH)"
51
	@echo ""
52
53
	@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
	@echo "of all tools. Currently, the directory for deployment/staging is:"
54
	@echo "$(DCDBDEPLOYPATH)"
55
56
57
58
59
	@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 ""
60
61
62
63
	@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 ""
64
65
	@echo "To start, please type:"
	@echo "     make all"
66
67

clean:
68
	@$(foreach l,$(LIBRARIES),echo "Cleaning $(l)..." && make -C $(l) clean && echo;)
Michael Ott's avatar
Michael Ott committed
69
	@$(foreach p,$(PROJECTS),echo "Cleaning $(p)..." && make -C $(p) clean && echo;)
70
71

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

Michael Ott's avatar
Michael Ott committed
76
77
distclean: clean
	@echo "Wiping dependencies..."
Michael Ott's avatar
Michael Ott committed
78
	@rm -rf $(DCDBDEPSPATH)
79

Axel Auweter's avatar
Axel Auweter committed
80
81
82
83
84
85
86
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
87
all: $(DCDBDEPSPATH)/.prerequesites
88
	@make $(LIBRARIES)
89
	@make $(PROJECTS)
90

Michael Ott's avatar
Michael Ott committed
91
$(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
92
93
94
95
	@echo ""
	@echo "Preparing patches..."
	@cp -a patches $(DCDBDEPSPATH)/

96
	$(eval M := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
97
98
99
	@if [ ! -e $(DCDBDEPSPATH)/$(M)/.installed ]; then \
		echo ""; \
		echo "Building Mosquitto library..."; \
100
		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
101
		mkdir -p $(DCDBDEPSPATH)/mosquitto_build; \
102
		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
103
104
105
	else \
		echo "Skipping Mosquitto library (already built)..."; \
	fi
106
107
	
	$(eval R := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*rudeconfig/rudeconfig/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
108
109
110
111
112
113
114
	@if [ ! -e $(DCDBDEPSPATH)/$(R)/.installed ]; then \
		echo ""; \
		echo "Building Rudeconfig library..."; \
		cd $(DCDBDEPSPATH)/$(R) && ./configure --prefix=$(DCDBDEPLOYPATH) && make -j $(MAKETHREADS) && chmod +x install-sh && make install && touch $(DCDBDEPSPATH)/$(R)/.installed; \
	else \
		echo "Skipping Rudeconfig library (already built)..."; \
	fi
115
116

	$(eval O := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*OpenIPMI/OpenIPMI/' | sed 's/\ .*//'))
117
	$(eval X := $(shell uname))
Axel Auweter's avatar
Axel Auweter committed
118
119
120
121
122
	@if [ ! -e $(DCDBDEPSPATH)/$(O)/.installed ]; then \
		echo ""; \
		echo "Building OpenIPMI library..."; \
		if [ -e $(DCDBDEPSPATH)/patches/$(O).patch ]; then echo "Patching OpenIPMI..."; cd $(DCDBDEPSPATH)/$(O) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(O).patch || true); fi; \
		if [ "$(X)" = "Darwin" ]; then echo "Fixing OpenIPMI for Mac OS..."; cd $(DCDBDEPSPATH)/$(O) && find . -name 'Makefile*' | xargs sed -i '' -e 's/Map/map/g'; fi; \
123
		cd $(DCDBDEPSPATH)/$(O) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-swig=no --with-perl=no --with-python=no CFLAGS="$(CFLAGS)"; \
Axel Auweter's avatar
Axel Auweter committed
124
125
126
127
		cd $(DCDBDEPSPATH)/$(O) && make -j $(MAKETHREADS) && make install && touch $(DCDBDEPSPATH)/$(O)/.installed; \
	else \
		echo "Skipping OpenIPMI library (already built)..."; \
	fi
128
129
	
	$(eval B := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*boost/boost/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
130
131
132
133
134
135
136
137
138
	@if [ ! -e $(DCDBDEPSPATH)/$(B)/.installed ]; then \
		echo ""; \
		echo "Building Boost..."; \
		if [ -e $(DCDBDEPSPATH)/patches/$(B).patch ]; then echo "Patching Boost..."; cd $(DCDBDEPSPATH)/$(B) && (patch -N -p2 < $(DCDBDEPSPATH)/patches/$(B).patch || true); fi; \
		cd $(DCDBDEPSPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) \
			--with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,thread,timer && ./b2 -j $(MAKETHREADS) install && touch $(DCDBDEPSPATH)/$(B)/.installed; \
	else \
		echo "Skipping Boost (already built)..."; \
	fi
139
140

	$(eval T := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/\ .*//'))
Axel Auweter's avatar
Axel Auweter committed
141
142
143
144
145
146
	@if [ ! -e $(DCDBDEPSPATH)/$(T)/.installed ]; then \
		echo ""; \
		echo "Building Thrift..."; \
		if [ -e $(DCDBDEPSPATH)/patches/$(T).patch ]; then echo "Patching Thrift..."; cd $(DCDBDEPSPATH)/$(T) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(T).patch || true); fi; \
		cd $(DCDBDEPSPATH)/$(T) && env CXXFLAGS="$(CXX11FLAGS)" ./configure --prefix=$(DCDBDEPLOYPATH) --without-qt4 --without-csharp \
			--without-java --without-erlang --without-python --without-perl --without-php --without-php_extension \
147
			--without-ruby --without-haskell --without-go --without-d --without-c_glib --with-cpp --with-boost=$(DCDBDEPLOYPATH) \
Axel Auweter's avatar
Axel Auweter committed
148
149
150
151
			--enable-libtool-lock --without-tests && env CXXFLAGS="$(CXX11FLAGS)" make -j $(MAKETHREADS) && env CXXFLAGS="$(CXX11FLAGS)" make install && touch $(DCDBDEPSPATH)/$(T)/.installed; \
	else \
		echo "Skipping Thrift (already built)..."; \
	fi
152

153
154
155
156
157
158
159
160
161
162
163
164
	$(eval S := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*net-snmp/net-snmp/' | sed 's/\ .*//'))
	@if [ ! -e $(DCDBDEPSPATH)/$(S)/.installed ]; then \
		echo ""; \
		echo "Building net-snmp..."; \
		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" --with-persistent-directory="$(DCDBDEPLOYPATH)/var/net-snmp" --disable-embedded-perl --without-perl-modules; \
		cd $(DCDBDEPSPATH)/$(S) && env CFLAGS="$(CFLAGS)" make -j $(MAKETHREADS) && make install && touch $(DCDBDEPSPATH)/$(S)/.installed; \
	else \
		echo "Skipping net-snmp (already built)..."; \
	fi

165
166
167
	@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
168
	@rsync -a $(DCDBDEPSPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra
169
170
	@$(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
171
	@sed -i -e 's/.*cluster_name:.*/cluster_name:\ '\''$(CASSANDRA_CLUSTER_NAME)'\''/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
Axel Auweter's avatar
Axel Auweter committed
172
173
174
175
176
177
	@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
178
179
	@sed -i.original -e 's/\/var\/log\/cassandra/$(P)\/var\/log\/cassandra/g' $(DCDBDEPLOYPATH)/cassandra/conf/log4j-server.properties

Michael Ott's avatar
Michael Ott committed
180
	@touch $(DCDBDEPSPATH)/.prerequesites
181
	
Michael Ott's avatar
Michael Ott committed
182
183
$(DCDBDEPSPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.dirstamp)
	@touch $(DCDBDEPSPATH)/.extract-distfiles
184
	
Michael Ott's avatar
Michael Ott committed
185
186
$(DCDBDEPSPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBDEPSPATH)/distfiles/$(f))
	@touch $(DCDBDEPSPATH)/.download-distfiles
187

Michael Ott's avatar
Michael Ott committed
188
189
$(DCDBDEPSPATH)/distfiles/%: 
	@mkdir -p $(DCDBDEPSPATH)/distfiles
190
191
192
	$(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
193
	@cd $(DCDBDEPSPATH)/distfiles && $(FETCH) $(FF) > $(F)
194

Michael Ott's avatar
Michael Ott committed
195
$(DCDBDEPSPATH)/%/.dirstamp: $(DCDBDEPSPATH)/.download-distfiles
196
197
	$(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///'))
	@echo "Extracting $(F)..."
Michael Ott's avatar
Michael Ott committed
198
	@cd $(DCDBDEPSPATH) && tar xzf distfiles/$(F).tar.gz
199
200
	@touch $@

201
202
203
204
205
206
207
208
$(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
209
	@echo ""
210
	@echo "Building $@..."
211
	@$(MAKE) -j $(MAKETHREADS) -C $@ 
212
	@echo "Installing $@..."
Michael Ott's avatar
Michael Ott committed
213
	@$(MAKE) -C $@ install