-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (84 loc) · 2.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#Compiler Directives
CXX=g++
CPPFLAGS= -std=c++11 \
-fPIC
#-v \
#-ftime-report
LDFLAGS=
#-L/usr/local/lib
LIBS= -ldwf
#Directories
IDIR=include
LDIR=lib
ODIR=obj
#Files
SRC= Helper.cpp \
Exceptions.cpp \
Device.cpp \
AnalogInput.cpp \
DigitalInput.cpp \
DigitalInputConfigurations.cpp \
AnalogInputConfigurations.cpp
_OBJ=$(SRC:.cpp=.o)
OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ))
_DEPS= Helper.h \
Exceptions.h \
Configuration.h \
Device.h \
AnalogInput.h \
DigitalInput.h \
DigitalInputConfigurations.h \
AnalogInputConfigurations.h \
easylogging++.h
DEPS=$(patsubst %,$(IDIR)/%,$(_DEPS))
TEST_DIR=test
SONAME_ROOT=dwfobj
SO_MAJOR=1
SO_MINOR=0
PART_SONAME=lib$(SONAME_ROOT).so
REAL_SONAME=$(PART_SONAME).$(SO_MAJOR)
SO_FILE=$(REAL_SONAME).$(SO_MINOR)
INSTALL_INC_ROOT= /usr/local/include
INSTALL_INC=$(INSTALL_INC_ROOT)/$(SONAME_ROOT)
INSTALL_LIB= /usr/local/lib
#Flag Handling
ifdef DEBUG
CPPFLAGS := $(CPPFLAGS) -g
endif
ifdef VERBOSE
Q =
E = @true
else
Q = @
E = @echo
endif
.PHONY: all install test help clean
all: $(SO_FILE)
install: $(SO_FILE)
$(E)Creating symlinks in $(INSTALL_LIB) of $(SO_FILE)
$(Q)cp $(SO_FILE) $(INSTALL_LIB)/$(SO_FILE)
$(Q)ln -sf $(INSTALL_LIB)/$(SO_FILE) $(INSTALL_LIB)/$(REAL_SONAME)
$(Q)ln -sf $(INSTALL_LIB)/$(SO_FILE) $(INSTALL_LIB)/$(PART_SONAME)
$(Q)mkdir -p $(INSTALL_INC)
$(Q)cp $(DEPS) $(INSTALL_INC)/
test: install
$(E)Recursing into $(TEST_DIR) and running make there
$(Q)$(MAKE) -C $(TEST_DIR)
help:
$(E)
$(E)all: Create a shared object file
$(E)install: Create symlinks of shared object file in $(INSTALL_LIB), and
$(E) symlinks of headers in $(INSTALL_INC)
$(E)test: Recurse into $(TEST_DIR) to run make and produce test binary
$(E)clean: Removes all created files
$(ODIR)/%.o: $(LDIR)/%.cpp $(DEPS)
$(E)C++-compiling $<
$(Q)if [ ! -d `dirname $@` ]; then mkdir -p `dirname $@`; fi
$(Q)$(CXX) -o $@ -c $< $(CPPFLAGS) -I$(IDIR)
$(SO_FILE): $(OBJ) $(DEPS)
$(E)Creating shared library for $@
$(Q)$(CXX) -shared -Wl,-soname,$(REAL_SONAME) -o $(SO_FILE) $(OBJ)
clean:
$(E)Removing Files
$(Q)rm -f $(ODIR)/*.o $(SO_FILE)
$(Q)if [ -d $(ODIR) ]; then rmdir $(ODIR); fi