Makefile 4.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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)
DCDBBUILDPATH ?= $(PWD)/build/
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 ""
	@echo "Use DCDBBUILDPATH environment variable to specify build path."
	@echo "Currently, the project will be built to:"
	@echo "$(DCDBBUILDPATH)"
	@echo ""
	@echo "The prefix for installation is:"
	@echo "$(DCDBDEPLOYPATH)"

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
	@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..."; cd $(DCDBBUILDPATH)/$(f) && make clean 2&> /dev/null; true;)

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/\ .*//'))
	@cd $(DCDBBUILDPATH)/mosquitto_build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH) $(DCDBBUILDPATH)/$(M) && make -j $(MAKETHREADS) && make install
	
	@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/\ .*//'))
	@cd $(DCDBBUILDPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) && ./b2 install

	@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

	@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 $@