Makefile 2.36 KB
Newer Older
Michael Ott's avatar
Michael Ott committed
1
include ../config.mk
2

3
4
#CXXFLAGS =	$(shell ./cxx11flags.sh $(CXX) -O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/ | head -1)
CXXFLAGS =	-O0 -g -Wall -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/
5
OBJS =		collectagent.o simplemqttserver.o simplemqttserverthread.o simplemqttservermessage.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o
6
SRC = 		$(patsubst cassandra/%,,$(OBJS:.o=.cpp))
7
8
#LIBS =		$(shell ./cxx11flags.sh $(CXX) -L$(DCDBDEPLOYPATH)/lib/ -lthrift -lssl -lcrypto -lpthread -lboost_system -lboost_thread | tail -1)
LIBS =		-L$(DCDBDEPLOYPATH)/lib/ -lthrift -lssl -lcrypto -lpthread -lboost_system -lboost_thread
9
TARGET =	collectagent
10

11
SUBTARGETS = cassandra/Cassandra.h
12

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

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

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

all:	$(TARGET)

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

39
40
41
cassandra/Cassandra.h:
	@if [ ! -e cassandra ]; then \
	printf "Building Thrift interface headers... "; \
Michael Ott's avatar
Michael Ott committed
42
	$(DCDBDEPLOYPATH)/bin/thrift --gen cpp $(DCDBDEPLOYPATH)/cassandra/interface/cassandra.thrift; \
43
44
45
	mv gen-cpp cassandra; \
	echo "Done."; \
	fi
46
	@if [ "$U" = "Linux" ]; then \
47
	echo "Fixing Thrift includes... "; \
48
49
50
51
	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;\
52
	fi
53
54
55
56
57

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

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

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