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

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

# List of object files to build and the derived list of corresponding source files
OBJS = src/sensordatastore.o \
Axel Auweter's avatar
Axel Auweter committed
10
11
       src/cassandraBackend.o \
       src/timestamp.o
12
13
14
15

# 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 -lboost_date_time -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

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

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

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

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

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

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