Makefile 2.8 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 \
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 \
13
14
       src/sensorid.o \
       src/c_api.o
15
16
17
18

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

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

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

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

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

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

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

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

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

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

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

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