Makefile 3.11 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\
Michael Ott's avatar
Michael Ott committed
6
	-I../include/ -fmessage-length=0 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG \
7
8
	-Wno-unused-local-typedef -Wno-unknown-warning-option -Wno-unknown-warning \
	-Wno-deprecated-declarations
9
10

# List of object files to build and the derived list of corresponding source files
11
12
OBJS = src/connection.o \
       src/sensordatastore.o \
Axel Auweter's avatar
Axel Auweter committed
13
       src/timestamp.o \
Axel Auweter's avatar
Axel Auweter committed
14
       src/sensorconfig.o \
15
       src/sensorid.o \
Axel Auweter's avatar
Axel Auweter committed
16
       src/unitconv.o \
17
       src/virtualsensor.o \
18
       src/c_api.o
19
20
21
22

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

23
24
25
# List of non-public headers
PRIVHEADERS = $(shell find include_internal -type f -iname "*.h")

26
# External libraries to link against
Axel Auweter's avatar
Axel Auweter committed
27
LIBS = -L$(DCDBDEPLOYPATH)/lib/ -lcassandra -lboost_random -lboost_system -lboost_date_time -lboost_regex -luv -lpthread
28
29
30
31
32
33
34
35

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

39
40
41
# Determine the expanded path to which the library will be installed
P =	$(shell cd $(DCDBDEPLOYPATH)/lib/ && pwd) 

42
# List of Phony Targets
43
.PHONY : check-target-env all clean install
44
45

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

55
all: $(TARGET) check-target-env
56
57

# Alert the user to put the necessary paths into LD_LIBRARY_PATH (or similar on other platforms)
58
check-target-env:
59
	@if [ "$(OS)" = "Darwin" ]; then \
60
61
62
63
64
	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
65
	@if [ "$(OS)" = "Linux" ]; then \
66
67
68
69
70
	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
71
72
73
74
75
	
# Header check
.header-check: $(PUBHEADERS) $(PRIVHEADERS)
	@touch .header-check
	@touch $(OBJS:.o=.cpp)
76

77
# Build the documentation
78
docs: $(PUBHEADERS) $(PRIVHEADERS) $(SRC)
79
80
81
	@echo "Creating documentation..."
	doxygen

82
# Clean everything
83
clean: clean-docs
84
	rm -f .header-check
85
	rm -f $(OBJS) $(TARGET)
86
87
88
89
	
# Clean the documentation
clean-docs:
	rm -rf docs
90
91

# Install to deploy path
92
install: $(TARGET) check-target-env
93
94
95
96
	mkdir -p $(DCDBDEPLOYPATH)/lib
	mkdir -p $(DCDBDEPLOYPATH)/include/dcdb
	install $(TARGET) $(DCDBDEPLOYPATH)/lib/
	install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb/