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
Gaëtan Harter 9c5688ea27
boards/native: remove toolchain variables duplication
The toolchain variables were overwritten anyway in
`makefiles/toolchain/gnu|llvm.inc.mk` as they use `=` affectation,
except for `OBJCOPY`.

On my Linux ubuntu bionic machine, the only difference for `info-build`
with both gnu/llvm and also with LTO=1
is that it now uses an absolute path for `objcopy`

    -OBJCOPY: objcopy
    +OBJCOPY: /usr/bin/objcopy

On the OSX 17.7.0 I tested, there was no difference.
2019-06-04 16:00:24 +02:00

165 lines
4.3 KiB
Makefile

export NATIVEINCLUDES += -DNATIVE_INCLUDES
export NATIVEINCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
export NATIVEINCLUDES += -I$(RIOTBASE)/core/include/
export NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/
export CPU = native
USEMODULE += native-drivers
ifeq ($(shell uname -s),Darwin)
DEBUGGER ?= lldb
else
DEBUGGER ?= gdb
endif
TERMPROG ?= $(ELFFILE)
FLASHER = true
export VALGRIND ?= valgrind
export CGANNOTATE ?= cg_annotate
export GPROF ?= gprof
# basic cflags:
export CFLAGS += -Wall -Wextra -pedantic
# default std set to gnu99 of not overwritten by user
ifeq (,$(filter -std=%, $(CFLAGS)))
export CFLAGS += -std=gnu99
endif
ifeq ($(shell uname -m),x86_64)
export CFLAGS += -m32
endif
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
export CFLAGS += -fstack-protector-all
endif
ifeq ($(shell uname -s),FreeBSD)
ifeq ($(shell uname -m),amd64)
export CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32
endif
endif
ifeq ($(shell uname -s),Darwin)
export CFLAGS += -Wno-deprecated-declarations
endif
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=
ifeq ($(shell uname -m),x86_64)
export LINKFLAGS += -m32
endif
ifeq ($(shell uname -s),FreeBSD)
ifeq ($(shell uname -m),amd64)
export LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
endif
export LINKFLAGS += -L $(BINDIR)
else
export LINKFLAGS += -ldl
endif
# clean up unused functions
export CFLAGS += -ffunction-sections -fdata-sections
ifeq ($(shell uname -s),Darwin)
export LINKFLAGS += -Wl,-dead_strip
else
export LINKFLAGS += -Wl,--gc-sections
endif
export LINKFLAGS += -ffunction-sections
# set the tap interface for term/valgrind
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
export PORT ?= tap0
else
export PORT =
endif
TERMFLAGS := $(PORT) $(TERMFLAGS)
export ASFLAGS =
ifeq ($(shell basename $(DEBUGGER)),lldb)
DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS)
else
DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS)
endif
term-valgrind: export VALGRIND_FLAGS ?= \
--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: export CFLAGS += -DHAVE_VALGRIND_H -g3
all-valgrind: export NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
all-debug: export CFLAGS += -g3
all-cachegrind: export CFLAGS += -g3
all-gprof: export CFLAGS += -pg
all-gprof: export LINKFLAGS += -pg
all-asan: export CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g3
all-asan: export CFLAGS += -DNATIVE_IN_CALLOC
all-asan: export LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer -g3
export INCLUDES += $(NATIVEINCLUDES)
export CFLAGS += -DDEBUG_ASSERT_VERBOSE
# workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
ifneq ($(shell gcc --version | head -1 | grep -E ' (4.6|4.7)'),)
export CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16
endif
# backward compatability with glibc <= 2.17 for native
ifeq ($(CPU),native)
ifeq ($(shell uname -s),Linux)
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)
ifeq ($(shell uname -s),Darwin)
BUILDOSXNATIVE = 1
endif
endif
all: # do not override first target
all-debug: all
all-gprof: all
all-asan: all
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:
$(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)
export UNDEF += $(BINDIR)/cpu/startup.o