Makefile 2.75 KB
Newer Older
1
2
3
include ../config.mk

# C++ Compiler Flags (use fPIC for our dynamic library)
4
CXXFLAGS = -O0 -g -Wall -Werror -Wno-unused-local-typedefs -Wno-unknown-warning-option\
5
6
	-fPIC --std=c++11 -I$(DCDBDEPLOYPATH)/include -I./include -I./include_internal\
	-I$(DCDBBASEPATH)/include/ -fmessage-length=0
7
8
9

# List of object files to build and the derived list of corresponding source files
OBJS = src/sensordatastore.o \
10
       src/cassandraBackend.o
11
12
13
14
15
SRC = $(patsubst cassandra/%,,$(OBJS:.o=.cpp))

# List of public header files necessary to use this libray
PUBHEADERS = $(shell find include -type f -iname "*.h")

16
17
18
# List of non-public headers
PRIVHEADERS = $(shell find include_internal -type f -iname "*.h")

19
# External libraries to link against
20
LIBS = -L$(DCDBDEPLOYPATH)/lib/ -lcassandra -lboost_random -lboost_system -luv
21
22
23
24
25
26
27
28

# Dynamic library building differs between Linux/BSD and MacOS
OS = $(shell uname)
ifeq ($(OS),Darwin)
	TARGET = libdcdb.dylib
	DLFLAGS = -dynamiclib
else
	TARGET = libdcdb.so
29
	DLFLAGS = -shared -Wl,-soname,$(TARGET) -Wl,--no-undefined
30
31
endif

32
33
34
# Determine the expanded path to which the library will be installed
P =	$(shell cd $(DCDBDEPLOYPATH)/lib/ && pwd) 

35
# List of Phony Targets
36
.PHONY : check-target-env all clean install
37
38
39
40
41
42

# Main Library Target
$(TARGET): $(SRC)
	$(MAKE) $(OBJS)
	@if [ "$(OS)" = "Darwin" ]; then \
		echo "Linking library in Mac OS style: $(TARGET)"; \
43
		$(CXX) $(CXXFLAGS) $(DLFLAGS) -o $(TARGET) $(OBJS) $(LIBS); \
44
45
	else \
		echo "Linking library in Linux style: $(TARGET)"; \
46
		$(CXX) $(CXXFLAGS) $(DLFLAGS) -o $(TARGET) $(OBJS) $(LIBS); \
47
48
49
50
51
	fi

all: $(TARGET)

# Alert the user to put the necessary paths into LD_LIBRARY_PATH (or similar on other platforms)
52
check-target-env:
53
	@if [ "$(OS)" = "Darwin" ]; then \
54
55
56
57
58
	R=`echo $$DYLD_LIBRARY_PATH | grep $P`; \
	if [ "$$R" = "" ]; then \
	printf "\n******************************************\nPlease type the following line before running:\n  export DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH:$P\n******************************************\n"; \
	fi; \
	fi
59
	@if [ "$(OS)" = "Linux" ]; then \
60
61
62
63
64
65
	R=`echo $$LD_LIBRARY_PATH | grep $P`; \
	if [ "$$R" = "" ]; then \
	printf "\n******************************************\nPlease type the following line before running:\n  export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$P\n******************************************\n"; \
	fi; \
	fi

66
# Build the documentation
67
docs: $(PUBHEADERS) $(PRIVHEADERS) $(SRC)
68
69
70
	@echo "Creating documentation..."
	doxygen

71
# Clean everything
72
clean: clean-docs
73
	rm -f $(OBJS) $(TARGET)
74
75
76
77
	
# Clean the documentation
clean-docs:
	rm -rf docs
78
79

# Install to deploy path
80
install: $(TARGET) check-target-env
81
82
83
84
	mkdir -p $(DCDBDEPLOYPATH)/lib
	mkdir -p $(DCDBDEPLOYPATH)/include/dcdb
	install $(TARGET) $(DCDBDEPLOYPATH)/lib/
	install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb/