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

Axel Auweter's avatar
Axel Auweter committed
3
CXXFLAGS =	-O0 -g -Wall -std=c++11 -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/
4
OBJS =		collectagent.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o
5
SRC = 		$(patsubst cassandra/%,,$(OBJS:.o=.cpp))
6
LIBS =		-L$(DCDBDEPLOYPATH)/lib/ -lthrift -lmosquitto -lssl -lcrypto -lpthread
7
TARGET =	collectagent
8

9
SUBTARGETS = cassandra/Cassandra.h
10

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

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

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

all:	$(TARGET)

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

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

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

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

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