Makefile 2.82 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
       src/sensorid.o \
Axel Auweter's avatar
Axel Auweter committed
14
       src/unitconv.o \
15
       src/c_api.o
16
17
18
19

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

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

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

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

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

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

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

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

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

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

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

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