DCDBBUILDPATH ?= /tmp/dcdb/build/ DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/ CXXFLAGS = -O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/ OBJS = collectagent.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o LIBS = -L$(DCDBDEPLOYPATH)/lib/ -lthrift -lmosquitto -lssl -lcrypto -lpthread TARGET = collectagent SUBTARGETS = cassandra-lib .PHONY : check-thrift-env cassandra-lib clean clean-cassandra-headers install P = $(shell cd $(DCDBDEPLOYPATH)/lib/ && pwd) U = $(shell uname) $(TARGET): $(SUBTARGETS) $(OBJS) $(CXX) -o $(TARGET) $(OBJS) $(LIBS) all: $(TARGET) check-thrift-env: @if [ "$U" = "Darwin" ]; then \ R=`echo $$DYLD_LIBRARY_PATH | grep $P`; \ if [ "$$R" = "" ]; then \ echo "******************************************\nPlease type the following line before running:\n export DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH:$P\n******************************************"; \ fi; \ fi @if [ "$U" = "Linux" ]; then \ R=`echo $$LD_LIBRARY_PATH | grep $P`; \ if [ "$$R" = "" ]; then \ echo "******************************************\nPlease type the following line before running:\n export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$P\n******************************************"; \ fi; \ fi cassandra-lib: cassandra @if [ "$U" = "Linux" ]; then \ echo "Fixing Thrift includes... "; \ grep stdint cassandra/cassandra_types.h > /dev/null; \ if [ "$$?" -eq "1" ]; then sed -i '1i#include ' cassandra/cassandra_types.h; fi;\ grep stdint cassandra/Cassandra.h > /dev/null; \ if [ "$$?" -eq "1" ]; then sed -i '1i#include ' cassandra/Cassandra.h; fi;\ fi cassandra: @if [ ! -e cassandra ]; then \ printf "Building Thrift interface headers... "; \ $(DCDBDEPLOYPATH)/bin/thrift --gen cpp $(DCDBBUILDPATH)/apache-cassandra-1.2.3/interface/cassandra.thrift; \ mv gen-cpp cassandra; \ echo "Done."; \ fi clean: clean-cassandra-headers rm -f $(OBJS) $(TARGET) clean-cassandra-headers: rm -rf cassandra install: $(TARGET) check-thrift-env install $(TARGET) $(DCDBDEPLOYPATH)/bin/