Makefile 2.09 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
SRC = 		$(patsubst cassandra/%,,$(OBJS:.o=.cpp))
7
LIBS =		-L$(DCDBDEPLOYPATH)/lib/ -lthrift -lmosquitto -lssl -lcrypto -lpthread
8
TARGET =	collectagent
9

10
SUBTARGETS = cassandra/Cassandra.h
11

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

14
P =		$(shell cd $(DCDBDEPLOYPATH)/lib/ && pwd)
15
U =		$(shell uname)
16

17
18
19
$(TARGET): $(SRC)
	$(MAKE) cassandra/Cassandra.h
	$(MAKE) $(OBJS)
20
21
22
23
	$(CXX) -o $(TARGET) $(OBJS) $(LIBS)

all:	$(TARGET)

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

38
39
40
41
42
43
44
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; \
	mv gen-cpp cassandra; \
	echo "Done."; \
	fi
45
	@if [ "$U" = "Linux" ]; then \
46
	echo "Fixing Thrift includes... "; \
47
48
49
50
	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;\
51
	fi
52
53
54
55
56

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/