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

3
PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider IPMIPusher
Axel Auweter's avatar
Axel Auweter committed
4
DISTFILES = thrift-0.9.1.tar.gz;https://dist.apache.org/repos/dist/release/thrift/0.9.1/thrift-0.9.1.tar.gz \
Axel Auweter's avatar
Axel Auweter committed
5
		apache-cassandra-1.2.12.tar.gz;http://mirror.netcologne.de/apache.org/cassandra/1.2.12/apache-cassandra-1.2.12-bin.tar.gz \
6
7
		mosquitto-1.1.3.tar.gz;http://mosquitto.org/files/source/mosquitto-1.1.3.tar.gz \
		rudeconfig-5.0.5.tar.gz;http://rudeserver.com/config/download/rudeconfig-5.0.5.tar.gz \
8
		popt-1.16.tar.gz;http://rpm5.org/files/popt/popt-1.16.tar.gz \
Axel Auweter's avatar
Axel Auweter committed
9
		OpenIPMI-2.0.19.tar.gz;http://optimate.dl.sourceforge.net/project/openipmi/OpenIPMI%202.0%20Library/OpenIPMI-2.0.19.tar.gz \
Axel Auweter's avatar
Axel Auweter committed
10
		boost_1_55_0.tar.gz;http://netcologne.dl.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.gz
11
FETCH = wget -c --no-check-certificate -O -
12
MAKETHREADS ?= 4
13

14
CASSANDRA_CLUSTER_NAME                 = Datacenter Monitor Database
Axel Auweter's avatar
Axel Auweter committed
15
16
17
18
19
20
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
21

22
23
24
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//'))

25
CFLAGS += -I$(DCDBDEPLOYPATH)/include -O0 -g
26
CXX11FLAGS = --std=c++11
Axel Auweter's avatar
Axel Auweter committed
27
LDFLAGS += -L$(DCDBDEPLOYPATH)/lib -O0 -g
28

29
.PHONY : info all clean cleanall distclean $(PROJECTS)
30
31
32
33
34
35

info:
	@echo ""
	@echo "DCDB - Data Center Database"
	@echo "Buildsystem description"
	@echo ""
Axel Auweter's avatar
Axel Auweter committed
36
37
	@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
38
	@echo "$(DCDBDEPSPATH)"
39
	@echo ""
40
41
	@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
	@echo "of all tools. Currently, the directory for deployment/staging is:"
42
	@echo "$(DCDBDEPLOYPATH)"
43
44
45
46
47
48
49
	@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 start, please type:"
	@echo "     make all"
50
51

clean:
Michael Ott's avatar
Michael Ott committed
52
	@$(foreach p,$(PROJECTS),echo "Cleaning $(p)..." && make -C $(p) clean && echo;)
53
54

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

Michael Ott's avatar
Michael Ott committed
59
60
distclean: clean
	@echo "Wiping dependencies..."
Michael Ott's avatar
Michael Ott committed
61
	@rm -rf $(DCDBDEPSPATH)
62

Axel Auweter's avatar
Axel Auweter committed
63
64
65
66
67
68
69
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
70
all: $(DCDBDEPSPATH)/.prerequesites
71
	@make $(PROJECTS)
72

Michael Ott's avatar
Michael Ott committed
73
$(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
74
75
76
77
	@echo ""
	@echo "Preparing patches..."
	@cp -a patches $(DCDBDEPSPATH)/

78
79
	@echo ""
	@echo "Building Mosquitto library..."
Michael Ott's avatar
Michael Ott committed
80
	@mkdir -p $(DCDBDEPSPATH)/mosquitto_build
81
	$(eval M := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/\ .*//'))
Michael Ott's avatar
Michael Ott committed
82
	@cd $(DCDBDEPSPATH)/mosquitto_build && cmake -DWITH_TLS=OFF -DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH)/ $(DCDBDEPSPATH)/$(M) && make -j $(MAKETHREADS) && make install
83
84
85
86
	
	@echo ""
	@echo "Building Rudeconfig library..."
	$(eval R := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*rudeconfig/rudeconfig/' | sed 's/\ .*//'))
Michael Ott's avatar
Michael Ott committed
87
	@cd $(DCDBDEPSPATH)/$(R) && ./configure --prefix=$(DCDBDEPLOYPATH) && make -j $(MAKETHREADS) && chmod +x install-sh && make install
88
89
90
91
92
93
94
95

	@echo ""
	@echo "Buidling Popt library..."
	$(eval P := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*popt/popt/' | sed 's/\ .*//'))
	@cd $(DCDBDEPSPATH)/$(P) && ./configure --prefix=$(DCDBDEPLOYPATH) && make -j $(MAKETHREADS) && make install

	@echo ""
	@echo "Buidling OpenIPMI library..."
96
	$(eval X := $(shell uname))
97
	$(eval O := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*OpenIPMI/OpenIPMI/' | sed 's/\ .*//'))
98
	@if [ -e $(DCDBDEPSPATH)/patches/$(O).patch ]; then echo "Patching OpenIPMI..."; cd $(DCDBDEPSPATH)/$(O) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(O).patch || true); fi
99
100
101
	@cd $(DCDBDEPSPATH)/$(O) && env CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --prefix=$(DCDBDEPLOYPATH) --with-swig=no --with-perl=no --with-python=no; \
	if [ "$$?" -ne "0" ]; then echo "Configure failed. Will try to re-run autoconf..." && cd $(DCDBDEPSPATH)/$(O) && autoconf && env CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --prefix=$(DCDBDEPLOYPATH) --with-swig=no --with-perl=no --with-python=no; 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
102
	@cd $(DCDBDEPSPATH)/$(O) && env CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" make -j $(MAKETHREADS) && make install
103
104
105
106
	
	@echo ""
	@echo "Building Boost..."
	$(eval B := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*boost/boost/' | sed 's/\ .*//'))
107
108
	@cd $(DCDBDEPSPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) \
		--with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,thread,timer && ./b2 -j $(MAKETHREADS) install
109
110
111
112

	@echo ""
	@echo "Buidling Thrift..."
	$(eval T := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/\ .*//'))
113
	@if [ -e $(DCDBDEPSPATH)/patches/$(T).patch ]; then echo "Patching Thrift..."; cd $(DCDBDEPSPATH)/$(T) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(T).patch || true); fi
114
	@cd $(DCDBDEPSPATH)/$(T) && env CXXFLAGS="$(CXX11FLAGS)" ./configure --prefix=$(DCDBDEPLOYPATH) --without-qt4 --without-csharp \
115
		--without-java --without-erlang --without-python --without-perl --without-php --without-php_extension \
Axel Auweter's avatar
Axel Auweter committed
116
		--without-ruby --without-haskell --without-go --without-d --with-cpp --with-boost=$(DCDBDEPLOYPATH) \
117
		--enable-libtool-lock --without-tests && env CXXFLAGS="$(CXX11FLAGS)" make -j $(MAKETHREADS) && env CXXFLAGS="$(CXX11FLAGS)" make install
118

119
120
121
	@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
122
	@rsync -a $(DCDBDEPSPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra
123
124
	@$(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
125
	@sed -i -e 's/.*cluster_name:.*/cluster_name:\ '\''$(CASSANDRA_CLUSTER_NAME)'\''/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
Axel Auweter's avatar
Axel Auweter committed
126
127
128
129
130
131
	@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
132
133
	@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
134
	@touch $(DCDBDEPSPATH)/.prerequesites
135
	
Michael Ott's avatar
Michael Ott committed
136
137
$(DCDBDEPSPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.dirstamp)
	@touch $(DCDBDEPSPATH)/.extract-distfiles
138
	
Michael Ott's avatar
Michael Ott committed
139
140
$(DCDBDEPSPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBDEPSPATH)/distfiles/$(f))
	@touch $(DCDBDEPSPATH)/.download-distfiles
141

Michael Ott's avatar
Michael Ott committed
142
143
$(DCDBDEPSPATH)/distfiles/%: 
	@mkdir -p $(DCDBDEPSPATH)/distfiles
144
145
146
	$(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
147
	@cd $(DCDBDEPSPATH)/distfiles && $(FETCH) $(FF) > $(F)
148

Michael Ott's avatar
Michael Ott committed
149
$(DCDBDEPSPATH)/%/.dirstamp: $(DCDBDEPSPATH)/.download-distfiles
150
151
	$(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///'))
	@echo "Extracting $(F)..."
Michael Ott's avatar
Michael Ott committed
152
	@cd $(DCDBDEPSPATH) && tar xzf distfiles/$(F).tar.gz
153
154
	@touch $@

Michael Ott's avatar
Michael Ott committed
155
$(PROJECTS): $(DCDBDEPSPATH)/.prerequesites
Michael Ott's avatar
Michael Ott committed
156
	@echo ""
157
	@echo "Building $@..."
158
	@$(MAKE) -j $(MAKETHREADS) -C $@ 
159
	@echo "Installing $@..."
Michael Ott's avatar
Michael Ott committed
160
	@$(MAKE) -C $@ install