Commit 845c2dfa authored by Michael Ott's avatar Michael Ott
Browse files

Build system awesomeness

parent 6e678683
DCDBBUILDPATH ?= /tmp/dcdb/build/ include ../config.mk
DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/
CXXFLAGS = -O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/ CXXFLAGS = -O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/
OBJS = collectagent.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o OBJS = collectagent.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o
...@@ -25,20 +24,20 @@ check-thrift-env: ...@@ -25,20 +24,20 @@ check-thrift-env:
@if [ "$U" = "Darwin" ]; then \ @if [ "$U" = "Darwin" ]; then \
R=`echo $$DYLD_LIBRARY_PATH | grep $P`; \ R=`echo $$DYLD_LIBRARY_PATH | grep $P`; \
if [ "$$R" = "" ]; then \ if [ "$$R" = "" ]; then \
echo "\n******************************************\nPlease type the following line before running:\n export DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH:$P\n******************************************\n"; \ printf "\n******************************************\nPlease type the following line before running:\n export DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH:$P\n******************************************\n"; \
fi; \ fi; \
fi fi
@if [ "$U" = "Linux" ]; then \ @if [ "$U" = "Linux" ]; then \
R=`echo $$LD_LIBRARY_PATH | grep $P`; \ R=`echo $$LD_LIBRARY_PATH | grep $P`; \
if [ "$$R" = "" ]; then \ if [ "$$R" = "" ]; then \
echo "\n******************************************\nPlease type the following line before running:\n export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$P\n******************************************\n"; \ printf "\n******************************************\nPlease type the following line before running:\n export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$P\n******************************************\n"; \
fi; \ fi; \
fi fi
cassandra/Cassandra.h: cassandra/Cassandra.h:
@if [ ! -e cassandra ]; then \ @if [ ! -e cassandra ]; then \
printf "Building Thrift interface headers... "; \ printf "Building Thrift interface headers... "; \
$(DCDBDEPLOYPATH)/bin/thrift --gen cpp $(DCDBBUILDPATH)/apache-cassandra-1.2.3/interface/cassandra.thrift; \ $(DCDBDEPLOYPATH)/bin/thrift --gen cpp $(DCDBDEPLOYPATH)/cassandra/interface/cassandra.thrift; \
mv gen-cpp cassandra; \ mv gen-cpp cassandra; \
echo "Done."; \ echo "Done."; \
fi fi
......
include config.mk
PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider
DISTFILES = thrift-0.9.0.tar.gz;https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz \ 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 \ 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 \
...@@ -7,9 +9,6 @@ DISTFILES = thrift-0.9.0.tar.gz;https://dist.apache.org/repos/dist/release/thrif ...@@ -7,9 +9,6 @@ DISTFILES = thrift-0.9.0.tar.gz;https://dist.apache.org/repos/dist/release/thrif
FETCH = wget -c --no-check-certificate -O - FETCH = wget -c --no-check-certificate -O -
MAKETHREADS = 4 MAKETHREADS = 4
PWD = $(shell pwd)
DCDBBUILDPATH ?= /tmp/dcdb/build/
DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//')) DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//')) DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//'))
...@@ -20,9 +19,9 @@ info: ...@@ -20,9 +19,9 @@ info:
@echo "DCDB - Data Center Database" @echo "DCDB - Data Center Database"
@echo "Buildsystem description" @echo "Buildsystem description"
@echo "" @echo ""
@echo "Use the DCDBBUILDPATH environment variable to specify a build path." @echo "Use the DCDBDEPSPATH environment variable to specify a build path."
@echo "Currently, the project will be built to:" @echo "Currently, the project will be built to:"
@echo "$(DCDBBUILDPATH)" @echo "$(DCDBDEPSPATH)"
@echo "" @echo ""
@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment" @echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
@echo "of all tools. Currently, the directory for deployment/staging is:" @echo "of all tools. Currently, the directory for deployment/staging is:"
...@@ -36,81 +35,76 @@ info: ...@@ -36,81 +35,76 @@ info:
@echo " make all" @echo " make all"
clean: clean:
ifeq ($(wildcard $(DCDBBUILDPATH)),)
@echo "Nothing to do."
else
@echo "Cleaning up... " @echo "Cleaning up... "
@cd $(DCDBBUILDPATH) && rm -rf $(PROJECTS) @$(foreach p,$(PROJECTS),make -C $(p) clean;)
endif
cleanall: clean cleanall: clean
@cd $(DCDBBUILDPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles @cd $(DCDBDEPSPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles
@cd $(DCDBBUILDPATH) && rm -rf mosquitto_build @cd $(DCDBDEPSPATH) && rm -rf mosquitto_build
@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBBUILDPATH)/$(f);) @$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f);)
distclean: distclean:
@echo "Wiping..." @echo "Wiping..."
@rm -rf $(DCDBBUILDPATH) @rm -rf $(DCDBDEPSPATH)
all: $(DCDBBUILDPATH)/.prerequesites all: $(DCDBDEPSPATH)/.prerequesites
make $(PROJECTS) make $(PROJECTS)
$(DCDBBUILDPATH)/.prerequesites: $(DCDBBUILDPATH)/.extract-distfiles $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
@echo "" @echo ""
@echo "Building Mosquitto library..." @echo "Building Mosquitto library..."
@mkdir -p $(DCDBBUILDPATH)/mosquitto_build @mkdir -p $(DCDBDEPSPATH)/mosquitto_build
$(eval M := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/\ .*//')) $(eval M := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/\ .*//'))
@cd $(DCDBBUILDPATH)/mosquitto_build && cmake -DWITH_TLS=OFF -DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH) $(DCDBBUILDPATH)/$(M) && make -j $(MAKETHREADS) && make install @cd $(DCDBDEPSPATH)/mosquitto_build && cmake -DWITH_TLS=OFF -DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH)/ $(DCDBDEPSPATH)/$(M) && make -j $(MAKETHREADS) && make install
@echo "" @echo ""
@echo "Building Rudeconfig library..." @echo "Building Rudeconfig library..."
$(eval R := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*rudeconfig/rudeconfig/' | sed 's/\ .*//')) $(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 @cd $(DCDBDEPSPATH)/$(R) && ./configure --prefix=$(DCDBDEPLOYPATH) && make -j $(MAKETHREADS) && chmod +x install-sh && make install
@echo "" @echo ""
@echo "Building Boost..." @echo "Building Boost..."
$(eval B := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*boost/boost/' | sed 's/\ .*//')) $(eval B := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*boost/boost/' | sed 's/\ .*//'))
@cd $(DCDBBUILDPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) --with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,thread,timer && ./b2 -j $(MAKETHREADS) install @cd $(DCDBDEPSPATH)/$(B) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) --with-libraries=atomic,chrono,date_time,exception,filesystem,program_options,thread,timer && ./b2 -j $(MAKETHREADS) install
@echo "" @echo ""
@echo "Buidling Thrift..." @echo "Buidling Thrift..."
$(eval T := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/\ .*//')) $(eval T := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/\ .*//'))
@cd $(DCDBBUILDPATH)/$(T) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-qt4 --without-csharp \ @cd $(DCDBDEPSPATH)/$(T) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-qt4 --without-csharp \
--without-java --without-erlang --without-python --without-perl --without-php --without-php_extension \ --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 --without-ruby --without-haskell --without-go --without-d --with-cpp --with-boost=$(DCDBDEPLOYPATH) && make && make install
@echo "" @echo ""
@echo "Staging and configuring Cassandra..." @echo "Staging and configuring Cassandra..."
@$(eval C := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*apache-cassandra/apache-cassandra/' | sed 's/\ .*//')) @$(eval C := $(shell echo "$(DISTFILESPATHS)" | sed 's/.*apache-cassandra/apache-cassandra/' | sed 's/\ .*//'))
@rsync -a $(DCDBBUILDPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra @rsync -a $(DCDBDEPSPATH)/$(C)/ $(DCDBDEPLOYPATH)/cassandra
@$(eval P := $(shell echo "$(DCDBDEPLOYPATH)" | sed 's/\//\\\//g')) @$(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\/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 @sed -i.original -e 's/\/var\/log\/cassandra/$(P)\/var\/log\/cassandra/g' $(DCDBDEPLOYPATH)/cassandra/conf/log4j-server.properties
@touch $(DCDBBUILDPATH)/.prerequesites @touch $(DCDBDEPSPATH)/.prerequesites
$(DCDBBUILDPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBBUILDPATH)/$(f)/.dirstamp) $(DCDBDEPSPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.dirstamp)
@touch $(DCDBBUILDPATH)/.extract-distfiles @touch $(DCDBDEPSPATH)/.extract-distfiles
$(DCDBBUILDPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBBUILDPATH)/distfiles/$(f)) $(DCDBDEPSPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBDEPSPATH)/distfiles/$(f))
@touch $(DCDBBUILDPATH)/.download-distfiles @touch $(DCDBDEPSPATH)/.download-distfiles
$(DCDBBUILDPATH)/distfiles/%: $(DCDBDEPSPATH)/distfiles/%:
@mkdir -p $(DCDBBUILDPATH)/distfiles @mkdir -p $(DCDBDEPSPATH)/distfiles
$(eval F := $(shell echo "$@" | sed 's/.*\///')) $(eval F := $(shell echo "$@" | sed 's/.*\///'))
$(eval FF := $(shell echo "$(DISTFILES)" | sed 's/.*$(F);//' | sed 's/ .*//')) $(eval FF := $(shell echo "$(DISTFILES)" | sed 's/.*$(F);//' | sed 's/ .*//'))
@echo "Downloading $(FF) as $(F)..." @echo "Downloading $(FF) as $(F)..."
@cd $(DCDBBUILDPATH)/distfiles && $(FETCH) $(FF) > $(F) @cd $(DCDBDEPSPATH)/distfiles && $(FETCH) $(FF) > $(F)
$(DCDBBUILDPATH)/%/.dirstamp: $(DCDBBUILDPATH)/.download-distfiles $(DCDBDEPSPATH)/%/.dirstamp: $(DCDBDEPSPATH)/.download-distfiles
$(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///')) $(eval F := $(shell echo "$@" | sed 's/\/.dirstamp//' | sed 's/.*\///'))
@echo "Extracting $(F)..." @echo "Extracting $(F)..."
@cd $(DCDBBUILDPATH) && tar xzf distfiles/$(F).tar.gz @cd $(DCDBDEPSPATH) && tar xzf distfiles/$(F).tar.gz
@touch $@ @touch $@
$(PROJECTS): $(DCDBBUILDPATH)/.prerequesites $(PROJECTS): $(DCDBDEPSPATH)/.prerequesites
@echo "Building $@..." @echo "Building $@..."
@rsync -a $@ $(DCDBBUILDPATH)/ @$(MAKE) -C $@
@$(MAKE) -C $(DCDBBUILDPATH)/$@
@echo "Installing $@..." @echo "Installing $@..."
@$(MAKE) -C $(DCDBBUILDPATH)/$@ install @$(MAKE) -C $@ install
DCDBBASEPATH = $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
DCDBDEPSPATH ?= $(DCDBBASEPATH)/deps
DCDBDEPLOYPATH ?= $(DCDBBASEPATH)/install
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment