Makefile 5.13 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
PROJECTS = FileSpewer CollectAgent SysFsAgent
DISTFILES = thrift-0.9.0.tar.gz;https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz \
		apache-cassandra-1.2.3.tar.gz;http://mirror.netcologne.de/apache.org/cassandra/1.2.3/apache-cassandra-1.2.3-bin.tar.gz \
		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 \
		boost_1_53_0.tar.gz;http://netcologne.dl.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.tar.gz
FETCH = wget -c --no-check-certificate -O -
MAKETHREADS = 2

PWD = $(shell pwd)
11
DCDBBUILDPATH ?= /tmp/dcdb/build/
12
13
14
15
16
17
18
19
20
21
22
DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//'))

.PHONY : info all clean cleanall distclean

info:
	@echo ""
	@echo "DCDB - Data Center Database"
	@echo "Buildsystem description"
	@echo ""
23
	@echo "Use the DCDBBUILDPATH environment variable to specify a build path."
24
25
26
	@echo "Currently, the project will be built to:"
	@echo "$(DCDBBUILDPATH)"
	@echo ""
27
28
	@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
	@echo "of all tools. Currently, the directory for deployment/staging is:"
29
	@echo "$(DCDBDEPLOYPATH)"
30
31
32
33
34
35
36
	@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"
37
38
39
40
41
42
43
44
45
46
47
48

clean:
ifeq ($(wildcard $(DCDBBUILDPATH)),)
	@echo "Nothing to do."
else
	@echo "Cleaning up... "
	@cd $(DCDBBUILDPATH) && rm -rf $(PROJECTS)
endif

cleanall: clean
	@cd $(DCDBBUILDPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles
	@cd $(DCDBBUILDPATH) && rm -rf mosquitto_build
49
	@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBBUILDPATH)/$(f);)
50
51
52
53
54
55
56
57
58
59
60
61
62
63

distclean:
	@echo "Wiping..."
	@rm -rf $(DCDBBUILDPATH)

all: $(DCDBBUILDPATH)/.prerequesites
	@$(foreach p,$(PROJECTS),echo ""; echo "Building $(p)..."; rsync -a $(p) $(DCDBBUILDPATH)/; \
		make -C $(DCDBBUILDPATH)/$(p); echo "Installing $(p)..."; make -C $(DCDBBUILDPATH)/$(p) install; )

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

	@echo ""
	@echo "Buidling Thrift..."
	$(eval T := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/\ .*//'))
	@cd $(DCDBBUILDPATH)/$(T) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-qt4 --without-csharp \
		--without-java --without-erlang --without-python --without-perl --without-php --without-php_extension \
		--without-ruby --without-haskell --without-go --without-d --with-cpp --with-boost=$(DCDBDEPLOYPATH) && make && make install

83
84
85
86
87
88
89
90
	@echo ""
	@echo "Staging and configuring Cassandra..."
	@$(eval C := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*apache-cassandra/apache-cassandra/' | sed 's/\ .*//'))
	@rsync -a $(DCDBBUILDPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra
	@$(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.original -e 's/\/var\/log\/cassandra/$(P)\/var\/log\/cassandra/g' $(DCDBDEPLOYPATH)/cassandra/conf/log4j-server.properties

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
	@touch $(DCDBBUILDPATH)/.prerequesites
	
$(DCDBBUILDPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBBUILDPATH)/$(f)/.dirstamp)
	@touch $(DCDBBUILDPATH)/.extract-distfiles
	
$(DCDBBUILDPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBBUILDPATH)/distfiles/$(f))
	@touch $(DCDBBUILDPATH)/.download-distfiles

$(DCDBBUILDPATH)/distfiles/%: 
	@mkdir -p $(DCDBBUILDPATH)/distfiles
	$(eval F := $(shell echo "$@" | sed 's/.*\///'))
	$(eval FF := $(shell echo "$(DISTFILES)" | sed 's/.*$(F);//' | sed 's/ .*//'))
	@echo "Downloading $(FF) as $(F)..."
	@cd $(DCDBBUILDPATH)/distfiles && $(FETCH) $(FF) > $(F)

$(DCDBBUILDPATH)/%/.dirstamp: $(DCDBBUILDPATH)/.download-distfiles
	$(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///'))
	@echo "Extracting $(F)..."
	@cd $(DCDBBUILDPATH) && tar xzf distfiles/$(F).tar.gz
	@touch $@