1- NATIVEINCLUDES += -DNATIVE_INCLUDES
21NATIVEINCLUDES += -I$(RIOTBOARD)/native/include/
3- NATIVEINCLUDES += -I$(RIOTBASE)/core/lib/include/
4- NATIVEINCLUDES += -I$(RIOTBASE)/core/include/
5- NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/
6-
7- # Set "NATIVE_64BIT=1" to compile for x86_64
8- NATIVE_64BIT ?= 0
9-
10- ifeq ($(OS),Darwin)
11- DEBUGGER ?= lldb
12- else
13- DEBUGGER ?= gdb
14- endif
152
163# only use pyterm wrapper if term target is requested
174ifeq (,$(filter term,$(MAKECMDGOALS)))
4835endif
4936endif
5037
51- export VALGRIND ?= valgrind
52- export CGANNOTATE ?= cg_annotate
53- export GPROF ?= gprof
54-
55- # basic cflags:
56- CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT)
57- CFLAGS += -U_FORTIFY_SOURCE
58- CFLAGS_DBG ?= -g3
59-
60- ifneq (,$(filter backtrace,$(USEMODULE)))
61- $(warning module backtrace is used, do not omit frame pointers)
62- CFLAGS_OPT ?= -Og -fno-omit-frame-pointer
63- else
64- CFLAGS_OPT ?= -Og
65- endif
66-
67- # default std set to gnu11 if not overwritten by user
68- ifeq (,$(filter -std=%, $(CFLAGS)))
69- CFLAGS += -std=gnu11
70- endif
71-
72- ifeq ($(OS_ARCH),x86_64)
73- ifeq ($(NATIVE_64BIT), 1)
74- CFLAGS += -m64
75- else
76- CFLAGS += -m32
77- endif
78- endif
79- ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
80- CFLAGS += -fstack-protector-all
81- endif
82- ifeq ($(OS),FreeBSD)
83- ifeq ($(OS_ARCH),amd64)
84- ifeq ($(NATIVE_64BIT), 1)
85- CFLAGS += -m64
86- else
87- CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32
88- endif
89- endif
90- endif
91- ifeq ($(OS),Darwin)
92- CFLAGS += -Wno-deprecated-declarations
93- endif
94-
95- # unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
96- CXXUWFLAGS +=
97- CXXEXFLAGS +=
98-
99- ifeq ($(OS_ARCH),x86_64)
100- ifeq ($(NATIVE_64BIT), 1)
101- LINKFLAGS += -m64
102- else
103- LINKFLAGS += -m32
104- endif
105- endif
106- ifeq ($(OS),FreeBSD)
107- ifeq ($(OS_ARCH),amd64)
108- ifeq ($(NATIVE_64BIT), 1)
109- LINKFLAGS += -m64
110- else
111- LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
112- endif
113- endif
114- LINKFLAGS += -L $(BINDIR)
115- else
116- LINKFLAGS += -ldl
117- endif
118-
119- # XFA (cross file array) support
120- LINKFLAGS += -T$(RIOTBASE)/cpu/native/ldscripts/xfa.ld
121-
122- # fix this warning:
123- # ```
124- # /usr/bin/ld: examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
125- # /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
126- # ```
127- LINKFLAGS += -no-pie
128-
129- # clean up unused functions
130- CFLAGS += -ffunction-sections -fdata-sections
131- ifeq ($(OS),Darwin)
132- LINKFLAGS += -Wl,-dead_strip
133- else
134- LINKFLAGS += -Wl,--gc-sections
135- endif
136- LINKFLAGS += -ffunction-sections
137-
13838# set the tap interface for term/valgrind
13939PORT ?= tap0
14040TERMFLAGS += $(PROCARGS) $(PORT)
@@ -160,80 +60,3 @@ ifneq (,$(filter periph_can,$(FEATURES_USED)))
16060 PERIPH_CAN_FLAGS ?= --can $(VCAN_IFACE)
16161 TERMFLAGS += $(PERIPH_CAN_FLAGS)
16262endif
163-
164-
165- ASFLAGS =
166- ifeq ($(shell basename $(DEBUGGER)),lldb)
167- DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS)
168- else
169- DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS)
170- endif
171- term-valgrind: export VALGRIND_FLAGS ?= \
172- --leak-check=full \
173- --track-origins=yes \
174- --fullpath-after=$(RIOTBASE)/ \
175- --read-var-info=yes
176- debug-valgrind-server: export VALGRIND_FLAGS ?= --vgdb=yes --vgdb-error=0 -v \
177- --leak-check=full --track-origins=yes --fullpath-after=$(RIOTBASE) \
178- --read-var-info=yes
179- term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind
180- term-gprof: TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELFFILE)
181- all-valgrind: CFLAGS += -DHAVE_VALGRIND_H
182- all-valgrind: NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
183- all-gprof: CFLAGS += -pg
184- all-gprof: LINKFLAGS += -pg
185-
186- CFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer -DNATIVE_MEMORY
187- LINKFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer
188- all-asan: CFLAGS += $(CFLAGS_ASAN)
189- all-asan: LINKFLAGS += $(LINKFLAGS_ASAN)
190- all-asan: export AFL_USE_ASAN=1
191-
192- INCLUDES += $(NATIVEINCLUDES)
193-
194- CFLAGS += -DDEBUG_ASSERT_VERBOSE
195-
196- # workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
197- ifneq ($(shell gcc --version | head -1 | grep -E ' (4.6|4.7)'),)
198- CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16
199- endif
200-
201- # clumsy way to enable building native on osx:
202- BUILDOSXNATIVE = 0
203- ifeq ($(CPU),native)
204- ifeq ($(OS),Darwin)
205- BUILDOSXNATIVE = 1
206- endif
207- endif
208-
209- all: # do not override first target
210-
211- all-gprof: all
212-
213- all-asan: all
214-
215- all-valgrind: all
216-
217- all-cachegrind: all
218-
219- term-valgrind:
220- $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
221-
222- debug-valgrind-server:
223- $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
224-
225- debug-valgrind:
226- $(eval VALGRIND_PID ?= $(shell pgrep -n memcheck-x86-li -u $(USER) | cut -d" " -f1))
227- $(eval DEBUGGER_FLAGS := -ex "target remote | vgdb --pid=$(VALGRIND_PID)" $(DEBUGGER_FLAGS))
228- $(DEBUGGER) $(DEBUGGER_FLAGS)
229-
230- term-cachegrind:
231- $(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT)
232-
233- term-gprof: term
234-
235- eval-gprof:
236- $(GPROF) $(ELFFILE) $(shell ls -rt gmon.out* | tail -1)
237-
238- eval-cachegrind:
239- $(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)
0 commit comments