-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
69 lines (50 loc) · 1.12 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
INCDIR = include
SRCDIR = src
LIBDIR = lib
TESTDIR = test
# Compile the library
LIBNAME = can
LIBSRCS = $(wildcard $(SRCDIR)/*.cpp)
LIBOBJS = $(LIBSRCS:.cpp=.o)
# Support for Vector stuff
ifdef ENABLE_VECTOR
LIBSRCS += $(wildcard $(SRCDIR)/Vector/*.cpp)
LIBSRCS += $(wildcard $(SRCDIR)/Vector/CANalyzer/*.cpp)
LIBSRCS += $(wildcard $(SRCDIR)/Vector/XLDriverLibrary/*.cpp)
CPPFLAGS += -DENABLE_VECTOR
endif
TEST_ELF = $(TESTDIR)/test.elf
#
# Toolchain setup
#
CPP = g++
CPPFLAGS += -fdiagnostics-color=auto
CPPFLAGS += -std=gnu++14
CPPFLAGS += -Wall -Wextra -pedantic
CPPFLAGS += -g
CPPFLAGS += -O3
# Required for linking to shared library:
CPPFLAGS += -fPIC
CPPFLAGS += -I$(INCDIR)
CPPFLAGS += -lpthread
#
# Targets
#
all: lib $(TESTDIR)/$(TESTNAME)
lib: lib$(LIBNAME).so
lib$(LIBNAME).so: $(LIBOBJS)
@$(RM) $@
$(CPP) -shared -o $@ $^ $(CPPFLAGS)
$(TEST_ELF): $(TESTDIR)/test.o lib$(LIBNAME).so
@$(RM) $@
$(CPP) -o $@ $^ $(CPPFLAGS)
test: $(TEST_ELF)
@./$<
%.o: %.cpp
$(CPP) -o $@ -c $^ $(CPPFLAGS)
clean:
@rm -fv $(SRCDIR)/*.o lib$(LIBNAME).so $(TEST_ELF) $(TESTDIR)/test-pcan.exe
#
# Windows targets
#
include windows.mk