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

3
PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider
4
DISTFILES = thrift-0.9.0.tar.gz;https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz \
5
		apache-cassandra-1.2.6.tar.gz;http://mirror.netcologne.de/apache.org/cassandra/1.2.6/apache-cassandra-1.2.6-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 \
Axel Auweter's avatar
Axel Auweter committed
8
		boost_1_54_0.tar.gz;http://netcologne.dl.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.gz
9
FETCH = wget -c --no-check-certificate -O -
10
MAKETHREADS ?= 4
11

Axel Auweter's avatar
Axel Auweter committed
12
13
14
15
16
17
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
18

19
20
21
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//'))

22
.PHONY : info all clean cleanall distclean $(PROJECTS)
23
24
25
26
27
28

info:
	@echo ""
	@echo "DCDB - Data Center Database"
	@echo "Buildsystem description"
	@echo ""
Axel Auweter's avatar
Axel Auweter committed
29
30
	@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
31
	@echo "$(DCDBDEPSPATH)"
32
	@echo ""
33
34
	@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
	@echo "of all tools. Currently, the directory for deployment/staging is:"
35
	@echo "$(DCDBDEPLOYPATH)"
36
37
38
39
40
41
42
	@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"
43
44

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

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

Michael Ott's avatar
Michael Ott committed
52
53
distclean: clean
	@echo "Wiping dependencies..."
Michael Ott's avatar
Michael Ott committed
54
	@rm -rf $(DCDBDEPSPATH)
55

Axel Auweter's avatar
Axel Auweter committed
56
57
58
59
60
61
62
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
63
all: $(DCDBDEPSPATH)/.prerequesites
64
	make -j $(MAKETHREADS) $(PROJECTS)
65

Michael Ott's avatar
Michael Ott committed
66
$(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
67
68
	@echo ""
	@echo "Building Mosquitto library..."
Michael Ott's avatar
Michael Ott committed
69
	@mkdir -p $(DCDBDEPSPATH)/mosquitto_build
70
	$(eval M := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/\ .*//'))
Michael Ott's avatar
Michael Ott committed
71
	@cd $(DCDBDEPSPATH)/mosquitto_build && cmake -DWITH_TLS=OFF -DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH)/ $(DCDBDEPSPATH)/$(M) && make -j $(MAKETHREADS) && make install
72
73
74
75
	
	@echo ""
	@echo "Building Rudeconfig library..."
	$(eval R := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*rudeconfig/rudeconfig/' | sed 's/\ .*//'))
Michael Ott's avatar
Michael Ott committed
76
	@cd $(DCDBDEPSPATH)/$(R) && ./configure --prefix=$(DCDBDEPLOYPATH) && make -j $(MAKETHREADS) && chmod +x install-sh && make install
77
78
79
80
	
	@echo ""
	@echo "Building Boost..."
	$(eval B := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*boost/boost/' | sed 's/\ .*//'))
81
82
	@cd $(DCDBDEPSPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) \
		--with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,thread,timer && ./b2 -j $(MAKETHREADS) install
83
84
85
86

	@echo ""
	@echo "Buidling Thrift..."
	$(eval T := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/\ .*//'))
Michael Ott's avatar
Michael Ott committed
87
	@cd $(DCDBDEPSPATH)/$(T) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-qt4 --without-csharp \
88
		--without-java --without-erlang --without-python --without-perl --without-php --without-php_extension \
Axel Auweter's avatar
Axel Auweter committed
89
		--without-ruby --without-haskell --without-go --without-d --with-cpp --with-boost=$(DCDBDEPLOYPATH) \
90
		--enable-libtool-lock --without-tests && make -j $(MAKETHREADS) && make install
91

92
93
94
	@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
95
	@rsync -a $(DCDBDEPSPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra
96
97
	@$(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
Axel Auweter's avatar
Axel Auweter committed
98
99
100
101
102
103
	@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
104
105
	@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
106
	@touch $(DCDBDEPSPATH)/.prerequesites
107
	
Michael Ott's avatar
Michael Ott committed
108
109
$(DCDBDEPSPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.dirstamp)
	@touch $(DCDBDEPSPATH)/.extract-distfiles
110
	
Michael Ott's avatar
Michael Ott committed
111
112
$(DCDBDEPSPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBDEPSPATH)/distfiles/$(f))
	@touch $(DCDBDEPSPATH)/.download-distfiles
113

Michael Ott's avatar
Michael Ott committed
114
115
$(DCDBDEPSPATH)/distfiles/%: 
	@mkdir -p $(DCDBDEPSPATH)/distfiles
116
117
118
	$(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
119
	@cd $(DCDBDEPSPATH)/distfiles && $(FETCH) $(FF) > $(F)
120

Michael Ott's avatar
Michael Ott committed
121
$(DCDBDEPSPATH)/%/.dirstamp: $(DCDBDEPSPATH)/.download-distfiles
122
123
	$(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///'))
	@echo "Extracting $(F)..."
Michael Ott's avatar
Michael Ott committed
124
	@cd $(DCDBDEPSPATH) && tar xzf distfiles/$(F).tar.gz
125
126
	@touch $@

Michael Ott's avatar
Michael Ott committed
127
$(PROJECTS): $(DCDBDEPSPATH)/.prerequesites
Michael Ott's avatar
Michael Ott committed
128
	@echo ""
129
	@echo "Building $@..."
Michael Ott's avatar
Michael Ott committed
130
	@$(MAKE) -C $@ 
131
	@echo "Installing $@..."
Michael Ott's avatar
Michael Ott committed
132
	@$(MAKE) -C $@ install