-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathMakefile.common
126 lines (107 loc) · 2.96 KB
/
Makefile.common
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
default: all
DESTDIR ?= .
BLD ?= bld
CUSTOM ?= n
CONFIG_ENABLE_FCS32 ?= y
CONFIG_ENABLE_FCS16 ?= y
CONFIG_ENABLE_CHECKSUM ?= y
LOG_LEVEL ?=
ifeq ($(ENABLE_LOGS),y)
ENABLE_HDLC_LOGS ?= y
ENABLE_FD_LOGS ?= y
endif
VERSION=1.0.0
CPPFLAGS += -I./src
CFLAGS += -std=gnu99
CPPFLAGS += -Os -Wall -Werror -ffunction-sections -fdata-sections $(EXTRA_CPPFLAGS)
# Uncomment for performance profiling
# CPPFLAGS += -pg
CXXFLAGS += -std=c++17
ifneq ($(LOG_LEVEL),)
CPPFLAGS += -DTINY_LOG_LEVEL_DEFAULT=$(LOG_LEVEL)
endif
ifeq ($(CUSTOM),y)
CPPFLAGS += -DTINY_CUSTOM_PLATFORM=1
endif
ifeq ($(ENABLE_HDLC_LOGS),y)
CPPFLAGS += -DTINY_HDLC_DEBUG=1
ENABLE_DEBUG=y
endif
ifeq ($(ENABLE_FD_LOGS),y)
CPPFLAGS += -DTINY_FD_DEBUG=1
ENABLE_DEBUG=y
endif
ifeq ($(CONFIG_ENABLE_CPP_HAL),y)
CPPFLAGS += -DCONFIG_ENABLE_CPP_HAL=1
endif
ifeq ($(ENABLE_DEBUG),y)
CPPFLAGS += -DTINY_DEBUG=1
endif
ifeq ($(CONFIG_ENABLE_FCS32),y)
CPPFLAGS += -DCONFIG_ENABLE_FCS32
endif
ifeq ($(CONFIG_ENABLE_FCS16),y)
CPPFLAGS += -DCONFIG_ENABLE_FCS16
endif
ifeq ($(CONFIG_ENABLE_CHECKSUM),y)
CPPFLAGS += -DCONFIG_ENABLE_CHECKSUM
endif
ifeq ($(CONFIG_ENABLE_STATS),y)
CPPFLAGS += -DCONFIG_ENABLE_STATS
endif
.PHONY: prep clean library all install docs release
####################### Compiling library #########################
TARGET_LIB ?= libtinyprotocol.a
OBJ_LIB += \
src/proto/crc/tiny_crc.o \
src/proto/light/tiny_light.o \
src/proto/hdlc/high_level/hdlc.o \
src/proto/hdlc/low_level/hdlc.o \
src/proto/fd/tiny_fd.o \
src/proto/fd/tiny_fd_frames.o \
src/hal/tiny_list.o \
src/hal/tiny_types.o \
src/hal/tiny_types_cpp.o \
src/hal/tiny_serial.o \
src/hal/tiny_serial_cpp.o \
src/TinyProtocolHdlc.o \
src/TinyProtocolFd.o \
src/TinyLightProtocol.o \
src/TinyProtocol.o \
src/link/TinyLinkLayer.o \
src/link/TinyFdLinkLayer.o \
src/link/TinyHdlcLinkLayer.o \
src/link/TinySerialLinkLayer.o \
src/link/TinySerialFdLink.o \
src/link/TinySerialHdlcLink.o \
src/interface/TinySerial.o \
prep:
ifdef CONFIG_FOR_WINDOWS_BUILD
if not exist $(BLD) mkdir $(BLD)
else
mkdir -p $(BLD)
endif
library: prep $(OBJ_LIB)
$(AR) rcs $(BLD)/$(TARGET_LIB) $(OBJ_LIB)
install: library
ifdef CONFIG_FOR_WINDOWS_BUILD
if not exist $(DESTDIR)\include mkdir $(DESTDIR)\include &\
xcopy src $(DESTDIR)\include /y /s &\
for /R $(DESTDIR)\include %%G in (*) do ( if not %%~xG==.h del /F/Q/S %%G )
else
mkdir -p $(DESTDIR)/include $(DESTDIR)/lib
cp -r $(BLD)/$(TARGET_LIB) $(DESTDIR)/lib/
DST=`realpath $(DESTDIR)` && cd src && find ./ -name \*.h -not -name \*_int.h -exec cp --parents {} $${DST}/include/ \; && cd ..
endif
docs:
doxygen doxygen.cfg
all: library
clean:
ifdef CONFIG_FOR_WINDOWS_BUILD
if exist $(BLD) rd $(BLD) /q /s &\
for /R .\src\ %%G in (*.o) do ( del /F/Q/S %%G )
else
rm -rf $(BLD)
rm -rf $(OBJ_LIB) $(OBJ_LIB:.o=.gcno) $(OBJ_LIB:.o=.gcda) $(OBJ_LIB:.o=.gcov)
rm -rf gmon.out
endif