1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/boards/native/Makefile.include

197 lines
4.9 KiB
Makefile
Raw Normal View History

2020-03-26 10:25:49 +01:00
NATIVEINCLUDES += -DNATIVE_INCLUDES
NATIVEINCLUDES += -I$(RIOTBOARD)/native/include/
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)
DEBUGGER ?= lldb
else
DEBUGGER ?= gdb
endif
2017-09-22 14:52:12 +02:00
RESET ?= $(RIOTBOARD)/native/dist/reset.sh
2021-02-18 11:17:31 +01:00
FLASHER ?=
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
# basic cflags:
CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT)
CFLAGS += -U_FORTIFY_SOURCE
CFLAGS_DBG ?= -g3
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
# default std set to gnu11 if not overwritten by user
2018-07-11 14:57:22 +02:00
ifeq (,$(filter -std=%, $(CFLAGS)))
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)
CFLAGS += -m32
2014-08-29 18:30:37 +02:00
endif
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
CFLAGS += -fstack-protector-all
endif
2019-10-18 08:23:02 +02:00
ifeq ($(OS),FreeBSD)
ifeq ($(OS_ARCH),amd64)
CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32
2017-09-22 14:52:12 +02:00
endif
endif
2019-10-18 08:23:02 +02:00
ifeq ($(OS),Darwin)
CFLAGS += -Wno-deprecated-declarations
endif
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
CXXUWFLAGS +=
CXXEXFLAGS +=
2019-10-18 08:23:02 +02:00
ifeq ($(OS_ARCH),x86_64)
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)
LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
2017-09-22 14:52:12 +02:00
endif
LINKFLAGS += -L $(BINDIR)
else
LINKFLAGS += -ldl
endif
2020-11-03 11:46:48 +01:00
# XFA (cross file array) support
LINKFLAGS += -T$(RIOTBASE)/cpu/native/ldscripts/xfa.ld
# 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
# clean up unused functions
CFLAGS += -ffunction-sections -fdata-sections
2019-10-18 08:23:02 +02:00
ifeq ($(OS),Darwin)
LINKFLAGS += -Wl,-dead_strip
else
LINKFLAGS += -Wl,--gc-sections
endif
LINKFLAGS += -ffunction-sections
# set the tap interface for term/valgrind
ifneq (,$(filter netdev_tap,$(USEMODULE)))
PORT ?= tap0
endif
# 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
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
TERMFLAGS += $(PORT)
ASFLAGS =
2016-10-25 09:31:40 +02:00
ifeq ($(shell basename $(DEBUGGER)),lldb)
DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS)
2016-10-25 09:31:40 +02:00
else
DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS)
2016-10-25 09:31:40 +02:00
endif
term-valgrind: export VALGRIND_FLAGS ?= \
2016-06-01 22:33:33 +02:00
--leak-check=full \
--track-origins=yes \
--fullpath-after=$(RIOTBASE)/ \
--read-var-info=yes
debug-valgrind-server: export VALGRIND_FLAGS ?= --vgdb=yes --vgdb-error=0 -v \
--leak-check=full --track-origins=yes --fullpath-after=$(RIOTBASE) \
--read-var-info=yes
term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind
term-gprof: TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELFFILE)
all-valgrind: CFLAGS += -DHAVE_VALGRIND_H
2020-03-26 10:25:49 +01:00
all-valgrind: NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
all-gprof: CFLAGS += -pg
all-gprof: LINKFLAGS += -pg
all-asan: CFLAGS += -fsanitize=address -fno-omit-frame-pointer
all-asan: CFLAGS += -DNATIVE_MEMORY
all-asan: LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer
all-asan: export AFL_USE_ASAN=1
INCLUDES += $(NATIVEINCLUDES)
CFLAGS += -DDEBUG_ASSERT_VERBOSE
2016-11-18 13:40:47 +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)'),)
CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16
endif
# 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
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
endif
2013-12-02 11:00:43 +01:00
all: # do not override first target
all-gprof: all
all-asan: all
2013-12-02 11:00:43 +01:00
all-valgrind: all
all-cachegrind: all
term-valgrind:
$(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
debug-valgrind-server:
$(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
debug-valgrind:
$(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))
$(DEBUGGER) $(DEBUGGER_FLAGS)
term-cachegrind:
$(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT)
term-gprof: term
eval-gprof:
$(GPROF) $(ELFFILE) $(shell ls -rt gmon.out* | tail -1)
eval-cachegrind:
2014-03-14 12:56:44 +01:00
$(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)