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

Build system awesomeness

parent 6e678683
DCDBBUILDPATH ?= /tmp/dcdb/build/
DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/
include ../config.mk
CXXFLAGS = -O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/
OBJS = collectagent.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o
......@@ -25,20 +24,20 @@ check-thrift-env:
@if [ "$U" = "Darwin" ]; then \
R=`echo $$DYLD_LIBRARY_PATH | grep $P`; \
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
@if [ "$U" = "Linux" ]; then \
R=`echo $$LD_LIBRARY_PATH | grep $P`; \
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
cassandra/Cassandra.h:
@if [ ! -e cassandra ]; then \
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; \
echo "Done."; \
fi
......
include config.mk
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 \
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
FETCH = wget -c --no-check-certificate -O -
MAKETHREADS = 4
PWD = $(shell pwd)
DCDBBUILDPATH ?= /tmp/dcdb/build/
DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//'))
......@@ -20,9 +19,9 @@ info:
@echo "DCDB - Data Center Database"
@echo "Buildsystem description"
@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 "$(DCDBBUILDPATH)"
@echo "$(DCDBDEPSPATH)"
@echo ""
@echo "Use the DCDBDEPLOYPATH environment variable to specifiy the path for deployment"
@echo "of all tools. Currently, the directory for deployment/staging is:"
......@@ -36,81 +35,76 @@ info:
@echo " make all"
clean:
ifeq ($(wildcard $(DCDBBUILDPATH)),)
@echo "Nothing to do."
else
@echo "Cleaning up... "
@cd $(DCDBBUILDPATH) && rm -rf $(PROJECTS)
endif
@$(foreach p,$(PROJECTS),make -C $(p) clean;)
cleanall: clean
@cd $(DCDBBUILDPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles
@cd $(DCDBBUILDPATH) && rm -rf mosquitto_build
@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBBUILDPATH)/$(f);)
@cd $(DCDBDEPSPATH) && rm -f .prerequesites .extract-distfiles .download-distfiles
@cd $(DCDBDEPSPATH) && rm -rf mosquitto_build
@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f);)
distclean:
@echo "Wiping..."
@rm -rf $(DCDBBUILDPATH)
@rm -rf $(DCDBDEPSPATH)
all: $(DCDBBUILDPATH)/.prerequesites
all: $(DCDBDEPSPATH)/.prerequesites
make $(PROJECTS)
$(DCDBBUILDPATH)/.prerequesites: $(DCDBBUILDPATH)/.extract-distfiles
$(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
@echo ""
@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/\ .*//'))
@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 "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
@cd $(DCDBDEPSPATH)/$(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) --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 "Buidling Thrift..."
$(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-ruby --without-haskell --without-go --without-d --with-cpp --with-boost=$(DCDBDEPLOYPATH) && make && make install
@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
@rsync -a $(DCDBDEPSPATH)/$(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
@touch $(DCDBBUILDPATH)/.prerequesites
@touch $(DCDBDEPSPATH)/.prerequesites
$(DCDBBUILDPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBBUILDPATH)/$(f)/.dirstamp)
@touch $(DCDBBUILDPATH)/.extract-distfiles
$(DCDBDEPSPATH)/.extract-distfiles: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.dirstamp)
@touch $(DCDBDEPSPATH)/.extract-distfiles
$(DCDBBUILDPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBBUILDPATH)/distfiles/$(f))
@touch $(DCDBBUILDPATH)/.download-distfiles
$(DCDBDEPSPATH)/.download-distfiles: $(foreach f,$(DISTFILESNAMES),$(DCDBDEPSPATH)/distfiles/$(f))
@touch $(DCDBDEPSPATH)/.download-distfiles
$(DCDBBUILDPATH)/distfiles/%:
@mkdir -p $(DCDBBUILDPATH)/distfiles
$(DCDBDEPSPATH)/distfiles/%:
@mkdir -p $(DCDBDEPSPATH)/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)
@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/.*\///'))
@echo "Extracting $(F)..."
@cd $(DCDBBUILDPATH) && tar xzf distfiles/$(F).tar.gz
@cd $(DCDBDEPSPATH) && tar xzf distfiles/$(F).tar.gz
@touch $@
$(PROJECTS): $(DCDBBUILDPATH)/.prerequesites
$(PROJECTS): $(DCDBDEPSPATH)/.prerequesites
@echo "Building $@..."
@rsync -a $@ $(DCDBBUILDPATH)/
@$(MAKE) -C $(DCDBBUILDPATH)/$@
@$(MAKE) -C $@
@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