Makefile 2.02 KB
Newer Older
1
DCDBBUILDPATH ?= /tmp/dcdb/build/
2
DCDBDEPLOYPATH ?= $(DCDBBUILDPATH)/deploy/
3

4
CXXFLAGS =	-O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/
5
OBJS =		collectagent.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o
6
LIBS =		-L$(DCDBDEPLOYPATH)/lib/ -lthrift -lmosquitto -lssl -lcrypto -lpthread
7
TARGET =	collectagent
8

9
SUBTARGETS = cassandra-lib
10

11
12
.PHONY : check-thrift-env cassandra-lib clean clean-cassandra-headers install

13
P =		$(shell cd $(DCDBDEPLOYPATH)/lib/ && pwd)
14
U =		$(shell uname)
15
16
17
18
19
20

$(TARGET):	$(SUBTARGETS) $(OBJS) 
	$(CXX) -o $(TARGET) $(OBJS) $(LIBS)

all:	$(TARGET)

21
22
23
24
check-thrift-env:
	@if [ "$U" = "Darwin" ]; then \
	R=`echo $$DYLD_LIBRARY_PATH | grep $P`; \
	if [ "$$R" = "" ]; then \
25
	echo "******************************************\nPlease type the following line before running:\n  export DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH:$P\n******************************************"; \
26
27
	fi; \
	fi
28
29
30
	@if [ "$U" = "Linux" ]; then \
	R=`echo $$LD_LIBRARY_PATH | grep $P`; \
	if [ "$$R" = "" ]; then \
31
	echo "******************************************\nPlease type the following line before running:\n  export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$P\n******************************************"; \
32
33
34
	fi; \
	fi

35

36
cassandra-lib: cassandra
37
	@if [ "$U" = "Linux" ]; then \
38
	echo "Fixing Thrift includes... "; \
39
40
41
42
	grep stdint cassandra/cassandra_types.h > /dev/null; \
	if [ "$$?" -eq "1" ]; then sed -i '1i#include <stdint.h>' cassandra/cassandra_types.h; fi;\
	grep stdint cassandra/Cassandra.h > /dev/null; \
	if [ "$$?" -eq "1" ]; then sed -i '1i#include <stdint.h>' cassandra/Cassandra.h; fi;\
43
	fi
44

45
cassandra:
46
47
	@if [ ! -e cassandra ]; then \
	printf "Building Thrift interface headers... "; \
48
	$(DCDBDEPLOYPATH)/bin/thrift --gen cpp $(DCDBBUILDPATH)/apache-cassandra-1.2.3/interface/cassandra.thrift; \
49
50
51
52
53
54
55
56
	mv gen-cpp cassandra; \
	echo "Done."; \
	fi

clean: clean-cassandra-headers
	rm -f $(OBJS) $(TARGET)

clean-cassandra-headers:
57
	rm -rf cassandra
58
59
60

install: $(TARGET) check-thrift-env
	install $(TARGET) $(DCDBDEPLOYPATH)/bin/