Makefile 2.78 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 = -O0 -ggdb -Wall -Werror \
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

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

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

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

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

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

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

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

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

50
all: $(TARGET) check-target-env
51
52

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

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

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

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