2020-03-26 10:25:49 +01:00
|
|
|
NATIVEINCLUDES += -DNATIVE_INCLUDES
|
|
|
|
NATIVEINCLUDES += -I$(RIOTBOARD)/native/include/
|
2020-10-22 13:37:31 +02:00
|
|
|
NATIVEINCLUDES += -I$(RIOTBASE)/core/lib/include/
|
2020-03-26 10:25:49 +01:00
|
|
|
NATIVEINCLUDES += -I$(RIOTBASE)/core/include/
|
|
|
|
NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/
|
2013-03-19 22:02:22 +01:00
|
|
|
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),Darwin)
|
2019-05-17 13:52:34 +02:00
|
|
|
DEBUGGER ?= lldb
|
2016-10-27 07:50:16 +02:00
|
|
|
else
|
2019-05-17 13:52:34 +02:00
|
|
|
DEBUGGER ?= gdb
|
2016-10-27 07:50:16 +02:00
|
|
|
endif
|
2017-09-22 14:52:12 +02:00
|
|
|
|
2019-12-20 18:36:34 +01:00
|
|
|
RESET ?= $(RIOTBOARD)/native/dist/reset.sh
|
2021-02-18 11:17:31 +01:00
|
|
|
FLASHER ?=
|
2019-06-27 14:21:18 +02:00
|
|
|
FLASHFILE ?= $(ELFFILE)
|
|
|
|
|
|
|
|
TERMPROG ?= $(FLASHFILE)
|
|
|
|
|
2013-12-02 11:00:43 +01:00
|
|
|
export VALGRIND ?= valgrind
|
2014-03-14 12:56:44 +01:00
|
|
|
export CGANNOTATE ?= cg_annotate
|
|
|
|
export GPROF ?= gprof
|
2013-03-19 22:02:22 +01:00
|
|
|
|
2014-08-13 07:47:00 +02:00
|
|
|
# basic cflags:
|
2021-03-03 21:57:09 +01:00
|
|
|
CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT)
|
2021-03-12 18:23:13 +01:00
|
|
|
CFLAGS += -U_FORTIFY_SOURCE
|
2020-02-20 15:39:14 +01:00
|
|
|
CFLAGS_DBG ?= -g3
|
2021-03-12 18:23:13 +01:00
|
|
|
|
2021-03-11 15:44:10 +01:00
|
|
|
ifneq (,$(filter backtrace,$(USEMODULE)))
|
|
|
|
$(warning module backtrace is used, do not omit frame pointers)
|
|
|
|
CFLAGS_OPT ?= -Og -fno-omit-frame-pointer
|
|
|
|
else
|
|
|
|
CFLAGS_OPT ?= -Og
|
|
|
|
endif
|
2020-02-20 15:39:14 +01:00
|
|
|
|
2020-08-10 11:55:46 +02:00
|
|
|
# default std set to gnu11 if not overwritten by user
|
2018-07-11 14:57:22 +02:00
|
|
|
ifeq (,$(filter -std=%, $(CFLAGS)))
|
2019-10-24 15:46:50 +02:00
|
|
|
CFLAGS += -std=gnu11
|
2018-07-11 14:57:22 +02:00
|
|
|
endif
|
2017-09-22 14:52:12 +02:00
|
|
|
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS_ARCH),x86_64)
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -m32
|
2014-08-29 18:30:37 +02:00
|
|
|
endif
|
2014-08-13 07:47:00 +02:00
|
|
|
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -fstack-protector-all
|
2014-08-13 07:47:00 +02:00
|
|
|
endif
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),FreeBSD)
|
|
|
|
ifeq ($(OS_ARCH),amd64)
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32
|
2017-09-22 14:52:12 +02:00
|
|
|
endif
|
2014-04-10 14:58:12 +02:00
|
|
|
endif
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),Darwin)
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -Wno-deprecated-declarations
|
2015-07-14 13:25:36 +02:00
|
|
|
endif
|
2014-05-09 12:23:34 +02:00
|
|
|
|
2014-06-25 03:17:20 +02:00
|
|
|
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
|
2019-08-27 16:06:41 +02:00
|
|
|
CXXUWFLAGS +=
|
|
|
|
CXXEXFLAGS +=
|
2014-06-25 03:17:20 +02:00
|
|
|
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS_ARCH),x86_64)
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -m32
|
2014-08-29 18:30:37 +02:00
|
|
|
endif
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),FreeBSD)
|
|
|
|
ifeq ($(OS_ARCH),amd64)
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
|
2017-09-22 14:52:12 +02:00
|
|
|
endif
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -L $(BINDIR)
|
2014-04-10 14:58:12 +02:00
|
|
|
else
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -ldl
|
2014-04-10 14:58:12 +02:00
|
|
|
endif
|
2014-05-09 12:23:34 +02:00
|
|
|
|
2020-11-03 11:46:48 +01:00
|
|
|
# XFA (cross file array) support
|
|
|
|
LINKFLAGS += -T$(RIOTBASE)/cpu/native/ldscripts/xfa.ld
|
|
|
|
|
2021-03-11 20:56:00 +01:00
|
|
|
# fix this warning:
|
|
|
|
# ```
|
|
|
|
# /usr/bin/ld: examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
|
|
|
|
# /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
|
|
|
|
# ```
|
|
|
|
LINKFLAGS += -no-pie
|
|
|
|
|
2015-07-14 13:13:13 +02:00
|
|
|
# clean up unused functions
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -ffunction-sections -fdata-sections
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),Darwin)
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -Wl,-dead_strip
|
2016-09-01 09:59:10 +02:00
|
|
|
else
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -Wl,--gc-sections
|
2016-09-01 09:59:10 +02:00
|
|
|
endif
|
2020-01-02 09:47:33 +01:00
|
|
|
LINKFLAGS += -ffunction-sections
|
2015-07-14 13:13:13 +02:00
|
|
|
|
2014-10-21 19:48:22 +02:00
|
|
|
# set the tap interface for term/valgrind
|
2020-08-12 13:34:03 +02:00
|
|
|
ifneq (,$(filter netdev_tap,$(USEMODULE)))
|
2018-06-18 15:16:51 +02:00
|
|
|
PORT ?= tap0
|
2014-10-21 19:48:22 +02:00
|
|
|
endif
|
|
|
|
|
2019-11-14 13:51:25 +01:00
|
|
|
# Configure default eeprom file
|
|
|
|
EEPROM_FILE ?= $(BINDIR)/native.eeprom
|
|
|
|
|
|
|
|
# set the eeprom file flags only when the periph_eeprom feature is used.
|
2020-06-25 10:17:10 +02:00
|
|
|
ifneq (,$(filter periph_eeprom,$(FEATURES_USED)))
|
|
|
|
EEPROM_FILE_FLAGS = --eeprom $(EEPROM_FILE)
|
|
|
|
TERMFLAGS += $(EEPROM_FILE_FLAGS)
|
|
|
|
endif
|
2019-11-14 13:51:25 +01:00
|
|
|
|
2022-04-08 13:51:38 +02:00
|
|
|
VCAN_IFNUM ?= 0
|
|
|
|
VCAN_IFNAME ?= vcan0
|
|
|
|
VCAN_IFACE ?= $(VCAN_IFNUM):$(VCAN_IFNAME)
|
|
|
|
# set the default vcan interface
|
|
|
|
ifneq (,$(filter periph_can,$(FEATURES_USED)))
|
|
|
|
PERIPH_CAN_FLAGS ?= --can $(VCAN_IFACE)
|
|
|
|
TERMFLAGS += $(PERIPH_CAN_FLAGS)
|
|
|
|
endif
|
|
|
|
|
2019-11-14 13:51:25 +01:00
|
|
|
TERMFLAGS += $(PORT)
|
2014-10-21 19:48:22 +02:00
|
|
|
|
2019-08-27 16:06:41 +02:00
|
|
|
ASFLAGS =
|
2016-10-25 09:31:40 +02:00
|
|
|
ifeq ($(shell basename $(DEBUGGER)),lldb)
|
2019-05-17 13:52:34 +02:00
|
|
|
DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS)
|
2016-10-25 09:31:40 +02:00
|
|
|
else
|
2019-05-17 13:52:34 +02:00
|
|
|
DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS)
|
2016-10-25 09:31:40 +02:00
|
|
|
endif
|
2014-08-22 20:05:43 +02:00
|
|
|
term-valgrind: export VALGRIND_FLAGS ?= \
|
2016-06-01 22:33:33 +02:00
|
|
|
--leak-check=full \
|
2014-08-22 20:05:43 +02:00
|
|
|
--track-origins=yes \
|
|
|
|
--fullpath-after=$(RIOTBASE)/ \
|
|
|
|
--read-var-info=yes
|
2016-01-26 17:38:15 +01:00
|
|
|
debug-valgrind-server: export VALGRIND_FLAGS ?= --vgdb=yes --vgdb-error=0 -v \
|
2018-03-22 16:20:19 +01:00
|
|
|
--leak-check=full --track-origins=yes --fullpath-after=$(RIOTBASE) \
|
2016-01-26 17:38:15 +01:00
|
|
|
--read-var-info=yes
|
2014-03-14 12:48:19 +01:00
|
|
|
term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind
|
2019-02-25 16:46:44 +01:00
|
|
|
term-gprof: TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELFFILE)
|
2020-02-21 12:50:02 +01:00
|
|
|
all-valgrind: CFLAGS += -DHAVE_VALGRIND_H
|
2020-03-26 10:25:49 +01:00
|
|
|
all-valgrind: NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
|
2019-08-27 16:06:41 +02:00
|
|
|
all-gprof: CFLAGS += -pg
|
2020-01-02 09:47:33 +01:00
|
|
|
all-gprof: LINKFLAGS += -pg
|
2020-02-21 12:50:02 +01:00
|
|
|
all-asan: CFLAGS += -fsanitize=address -fno-omit-frame-pointer
|
2019-06-24 14:30:43 +02:00
|
|
|
all-asan: CFLAGS += -DNATIVE_MEMORY
|
2020-02-21 12:50:02 +01:00
|
|
|
all-asan: LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer
|
2019-07-01 13:02:53 +02:00
|
|
|
all-asan: export AFL_USE_ASAN=1
|
2014-02-27 10:30:30 +01:00
|
|
|
|
2019-08-27 16:06:41 +02:00
|
|
|
INCLUDES += $(NATIVEINCLUDES)
|
2018-04-12 17:48:07 +02:00
|
|
|
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -DDEBUG_ASSERT_VERBOSE
|
2016-11-18 13:40:47 +01:00
|
|
|
|
2014-12-09 12:22:24 +01:00
|
|
|
# workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
|
|
|
|
ifneq ($(shell gcc --version | head -1 | grep -E ' (4.6|4.7)'),)
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16
|
2014-12-09 12:22:24 +01:00
|
|
|
endif
|
|
|
|
|
2014-02-01 15:39:16 +01:00
|
|
|
# backward compatability with glibc <= 2.17 for native
|
|
|
|
ifeq ($(CPU),native)
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),Linux)
|
2017-09-22 14:52:12 +02:00
|
|
|
ifeq ($(shell ldd --version | awk '/^ldd/{if ($$NF < 2.17) {print "yes"} else {print "no"} }'),yes)
|
|
|
|
LINKFLAGS += -lrt
|
|
|
|
endif
|
|
|
|
endif
|
2014-02-01 15:39:16 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# clumsy way to enable building native on osx:
|
|
|
|
BUILDOSXNATIVE = 0
|
|
|
|
ifeq ($(CPU),native)
|
2019-10-18 08:23:02 +02:00
|
|
|
ifeq ($(OS),Darwin)
|
2017-09-22 14:52:12 +02:00
|
|
|
BUILDOSXNATIVE = 1
|
|
|
|
endif
|
2014-02-01 15:39:16 +01:00
|
|
|
endif
|
|
|
|
|
2013-12-02 11:00:43 +01:00
|
|
|
all: # do not override first target
|
|
|
|
|
2014-03-01 16:48:36 +01:00
|
|
|
all-gprof: all
|
2014-02-26 10:43:07 +01:00
|
|
|
|
2015-07-07 14:37:56 +02:00
|
|
|
all-asan: all
|
|
|
|
|
2013-12-02 11:00:43 +01:00
|
|
|
all-valgrind: all
|
|
|
|
|
2014-03-14 12:48:19 +01:00
|
|
|
all-cachegrind: all
|
|
|
|
|
|
|
|
term-valgrind:
|
2018-01-31 11:00:22 +01:00
|
|
|
$(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
|
2014-02-26 10:43:07 +01:00
|
|
|
|
2016-01-26 17:38:15 +01:00
|
|
|
debug-valgrind-server:
|
2018-01-31 11:00:22 +01:00
|
|
|
$(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
|
2016-01-26 17:38:15 +01:00
|
|
|
|
|
|
|
debug-valgrind:
|
2018-03-22 16:20:19 +01:00
|
|
|
$(eval VALGRIND_PID ?= $(shell pgrep -n memcheck-x86-li -u $(USER) | cut -d" " -f1))
|
|
|
|
$(eval DEBUGGER_FLAGS := -ex "target remote | vgdb --pid=$(VALGRIND_PID)" $(DEBUGGER_FLAGS))
|
2016-01-26 17:38:15 +01:00
|
|
|
$(DEBUGGER) $(DEBUGGER_FLAGS)
|
|
|
|
|
2014-03-14 12:48:19 +01:00
|
|
|
term-cachegrind:
|
2018-01-31 11:00:22 +01:00
|
|
|
$(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT)
|
2014-03-01 16:48:36 +01:00
|
|
|
|
2014-03-14 12:48:19 +01:00
|
|
|
term-gprof: term
|
|
|
|
|
|
|
|
eval-gprof:
|
2018-01-31 11:00:22 +01:00
|
|
|
$(GPROF) $(ELFFILE) $(shell ls -rt gmon.out* | tail -1)
|
2014-03-14 12:48:19 +01:00
|
|
|
|
|
|
|
eval-cachegrind:
|
2014-03-14 12:56:44 +01:00
|
|
|
$(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)
|