-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
107 lines (88 loc) · 2.63 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
default: libtinyslip
UNITTEST ?= n
include buildsys/toolchain.mk
include buildsys/project.mk
include buildsys/package_make.mk
######################## Custom options #########################
ifeq ($(PLATFORM),linux)
CONFIG_ENABLE_FCS32 ?= y
CONFIG_ENABLE_FCS16 ?= y
CONFIG_ENABLE_CHECKSUM ?= y
CONFIG_ENABLE_STATS ?=y
endif
ifeq ($(PLATFORM),avr)
CONFIG_ENABLE_FCS32 ?= n
CONFIG_ENABLE_FCS16 ?= n
CONFIG_ENABLE_CHECKSUM ?= y
CONFIG_ENABLE_STATS ?= n
endif
LOG_LEVEL ?=
ifeq ($(ENABLE_LOGS),y)
ENABLE_SLIP_LOGS ?= y
endif
ifneq ($(LOG_LEVEL),)
CPPFLAGS += -DTINY_LOG_LEVEL_DEFAULT=$(LOG_LEVEL)
endif
ifeq ($(ENABLE_SLIP_LOGS),y)
CPPFLAGS += -DTINY_SLIP_DEBUG=1
ENABLE_DEBUG=y
endif
ifeq ($(ENABLE_DEBUG),y)
CPPFLAGS += -DTINY_DEBUG=1
endif
###################### Added HAL library #########################
PKG = tinyhal
$(PKG)_SRCDIR = ./deps/tinyhal
$(PKG)_MAKE_OPTS = PLATFORM=$(PLATFORM)
$(eval $(package-make))
##################################################################
CFLAGS += -std=gnu99
CPPFLAGS += -Os -Wall -Werror -ffunction-sections -fdata-sections $(EXTRA_CPPFLAGS)
CXXFLAGS += -std=c++11
####################### Compiling library #########################
PKG = libtinyslip
$(PKG)_DEPENDENCIES = tinyhal
$(PKG)_LIBRARIES = tinyhal
$(PKG)_PKGCONFIG = tinyslip.pc
$(PKG)_CMAKE_MODULE = Findtinyslip.cmake
$(PKG)_SOURCES = src/proto/slip/tiny_slip.c \
src/TinyProtocolSlip.cpp
$(PKG)_CPPFLAGS += -I./src
$(eval $(project-static-lib))
####################### Compiling tools #########################
ifeq ($(PLATFORM),linux)
PKG = tinyslip_loopback
$(PKG)_SOURCES = examples/linux/loopback/tinyslip_loopback.cpp
$(PKG)_DEPENDENCIES = libtinyslip tinyhal
$(PKG)_LIBRARIES = tinyhal
$(PKG)_CPPFLAGS = -pthread -I./src
$(PKG)_LDFLAGS = -pthread -lm -L. -ltinyslip
$(eval $(project-binary))
endif
####################### Compiling unit tests ####################
ifeq ($(PLATFORM),linux)
PKG = unittest
$(PKG)_NAME = unit_test
$(PKG)_SOURCES = \
unittest/cpputils/fake_wire.cpp \
unittest/cpputils/fake_connection.cpp \
unittest/cpputils/fake_endpoint.cpp \
unittest/cpputils/tiny_base_helper.cpp \
unittest/helpers/tiny_slip_helper.cpp \
unittest/main.cpp \
unittest/packet_tests.cpp \
unittest/slip_tests.cpp
$(PKG)_DEPENDENCIES = libtinyslip tinyhal
$(PKG)_LIBRARIES = tinyhal
$(PKG)_CPPFLAGS = -pthread -I./src -I./unittest -I./unittest/cpputils
$(PKG)_LDFLAGS = -pthread -lm -L. -ltinyslip -lCppUTest -lCppUTestExt
$(eval $(project-binary))
.PHONY: check
unit_test: .ts_unittest_build
check:
./unit_test
ifeq ($(UNITTEST),y)
check: unittest
all: unittest
endif
endif