Makefile 2.7 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

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

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

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

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

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

34
# List of Phony Targets
35
.PHONY : check-target-env all clean install
36
37

# Main Library Target
38
$(TARGET): $(OBJS)
39
40
	@if [ "$(OS)" = "Darwin" ]; then \
		echo "Linking library in Mac OS style: $(TARGET)"; \
41
		$(CXX) $(CXXFLAGS) $(DLFLAGS) -o $(TARGET) $(OBJS) $(LIBS); \
42
43
	else \
		echo "Linking library in Linux style: $(TARGET)"; \
44
		$(CXX) $(CXXFLAGS) $(DLFLAGS) -o $(TARGET) $(OBJS) $(LIBS); \
45
46
	fi

47
all: $(TARGET) check-target-env
48
49

# Alert the user to put the necessary paths into LD_LIBRARY_PATH (or similar on other platforms)
50
check-target-env:
51
	@if [ "$(OS)" = "Darwin" ]; then \
52
53
54
55
56
	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
57
	@if [ "$(OS)" = "Linux" ]; then \
58
59
60
61
62
63
	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

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

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

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