Makefile 1.84 KB
Newer Older
1
2
DCDBBUILDPATH ?= $(PWD)/build/
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
8
TARGET =	CollectAgent

9
SUBTARGETS = cassandra-lib
10

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

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

all:	$(TARGET)

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

33

34
cassandra-lib: cassandra
35
36
37
38
39
40
	@if [ "$U" = "Linux" ]; then \
	echo -n "Fixing Thrift includes... "; \
	sed -i '1i#include <stdint.h>' cassandra/cassandra_types.h; \
	sed -i '1i#include <stdint.h>' cassandra/Cassandra.h; \
	echo "Done."; \
	fi
41

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

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

clean-cassandra-headers:
54
	rm -rf cassandra
55
56
57

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