2014-09-26 13:59:37 +02:00
|
|
|
export NATIVEINCLUDES += -DNATIVE_INCLUDES
|
|
|
|
export NATIVEINCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
|
2014-02-27 10:30:30 +01:00
|
|
|
export NATIVEINCLUDES += -I$(RIOTBASE)/core/include/
|
|
|
|
export NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/
|
|
|
|
|
2013-03-19 22:02:22 +01:00
|
|
|
export CPU = native
|
2016-10-18 23:27:59 +02:00
|
|
|
export ELF = $(BINDIR)/$(APPLICATION).elf
|
2013-03-19 22:02:22 +01:00
|
|
|
|
2016-03-08 14:19:52 +01:00
|
|
|
USEMODULE += native-drivers
|
|
|
|
|
2014-02-01 13:16:58 +01:00
|
|
|
# toolchain:
|
|
|
|
export PREFIX =
|
|
|
|
export CC ?= $(PREFIX)gcc
|
2014-06-25 03:17:20 +02:00
|
|
|
export CXX ?= $(PREFIX)g++
|
2015-07-14 09:34:58 +02:00
|
|
|
ifeq ($(LTO),1)
|
|
|
|
export AR = $(PREFIX)gcc-ar
|
|
|
|
else
|
|
|
|
export AR = $(PREFIX)ar
|
|
|
|
endif
|
2014-04-20 07:26:12 +02:00
|
|
|
export AS ?= $(PREFIX)as
|
|
|
|
export LINK ?= $(PREFIX)gcc
|
|
|
|
export SIZE ?= $(PREFIX)size
|
2014-11-13 16:00:52 +01:00
|
|
|
ifneq ($(shell uname -s),Darwin)
|
|
|
|
export OBJCOPY ?= $(PREFIX)objcopy
|
|
|
|
else
|
2014-11-28 17:35:14 +01:00
|
|
|
ifeq (0,$(shell which gobjcopy 2>&1 > /dev/null ; echo $$?))
|
|
|
|
export OBJCOPY ?= gobjcopy
|
2014-11-13 16:00:52 +01:00
|
|
|
export OFLAGS ?= -O ihex
|
2014-11-28 17:35:14 +01:00
|
|
|
else
|
|
|
|
# If gobjcopy is not available, just create an empty file. The hexfile
|
|
|
|
# is not used for native anyways.
|
|
|
|
export OBJCOPY ?= touch
|
|
|
|
export OFLAGS =
|
|
|
|
endif
|
2014-11-13 16:00:52 +01:00
|
|
|
endif
|
2013-03-19 22:02:22 +01:00
|
|
|
|
2016-10-27 07:50:16 +02:00
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
export DEBUGGER ?= lldb
|
|
|
|
else
|
|
|
|
export DEBUGGER ?= gdb
|
|
|
|
endif
|
2016-03-23 23:50:52 +01:00
|
|
|
export TERMPROG ?= $(ELF)
|
2014-02-01 13:16:58 +01:00
|
|
|
export FLASHER = true
|
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:
|
2016-09-06 00:16:40 +02:00
|
|
|
export CFLAGS += -Wall -Wextra -pedantic -std=gnu99
|
2014-08-29 18:30:37 +02:00
|
|
|
ifeq ($(shell uname -m),x86_64)
|
|
|
|
export CFLAGS += -m32
|
|
|
|
endif
|
2014-08-13 07:47:00 +02:00
|
|
|
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
|
|
|
|
export CFLAGS += -fstack-protector-all
|
|
|
|
endif
|
2014-04-10 14:58:12 +02:00
|
|
|
ifeq ($(shell uname -s),FreeBSD)
|
|
|
|
ifeq ($(shell uname -m),amd64)
|
2015-07-02 10:56:51 +02:00
|
|
|
export CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32
|
2014-04-10 14:58:12 +02:00
|
|
|
endif
|
|
|
|
endif
|
2015-07-14 13:25:36 +02:00
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
export CFLAGS += -Wno-deprecated-declarations
|
|
|
|
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++
|
|
|
|
export CXXUWFLAGS +=
|
|
|
|
export CXXEXFLAGS +=
|
|
|
|
|
2014-08-29 18:30:37 +02:00
|
|
|
ifeq ($(shell uname -m),x86_64)
|
2014-05-09 12:23:34 +02:00
|
|
|
export LINKFLAGS += -m32
|
2014-08-29 18:30:37 +02:00
|
|
|
endif
|
2014-04-10 14:58:12 +02:00
|
|
|
ifeq ($(shell uname -s),FreeBSD)
|
|
|
|
ifeq ($(shell uname -m),amd64)
|
2015-07-02 10:56:51 +02:00
|
|
|
export LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
|
2014-04-10 14:58:12 +02:00
|
|
|
endif
|
|
|
|
export LINKFLAGS += -L $(BINDIR)
|
|
|
|
else
|
|
|
|
export LINKFLAGS += -ldl
|
|
|
|
endif
|
2014-05-09 12:23:34 +02:00
|
|
|
|
2015-07-14 13:13:13 +02:00
|
|
|
# clean up unused functions
|
|
|
|
export CFLAGS += -ffunction-sections -fdata-sections
|
2016-09-01 09:59:10 +02:00
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
export LINKFLAGS += -Wl,-dead_strip
|
|
|
|
else
|
2015-07-14 13:13:13 +02:00
|
|
|
export LINKFLAGS += -Wl,--gc-sections
|
2016-09-01 09:59:10 +02:00
|
|
|
endif
|
|
|
|
export 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
|
2016-10-24 12:05:10 +02:00
|
|
|
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
|
2014-10-21 19:48:22 +02:00
|
|
|
export PORT ?= tap0
|
|
|
|
else
|
|
|
|
export PORT =
|
|
|
|
endif
|
|
|
|
|
2015-02-20 14:44:16 +01:00
|
|
|
export TERMFLAGS := $(PORT) $(TERMFLAGS)
|
2014-10-21 19:48:22 +02:00
|
|
|
|
2014-02-01 13:16:58 +01:00
|
|
|
export ASFLAGS =
|
2016-10-25 09:31:40 +02:00
|
|
|
ifeq ($(shell basename $(DEBUGGER)),lldb)
|
|
|
|
export DEBUGGER_FLAGS = -- $(ELF) $(TERMFLAGS)
|
|
|
|
else
|
2016-04-22 12:00:10 +02:00
|
|
|
export DEBUGGER_FLAGS = -q --args $(ELF) $(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 \
|
|
|
|
--leak-check=full --track-origins=yes --fullpath-after=${RIOTBASE} \
|
|
|
|
--read-var-info=yes
|
2014-03-14 12:48:19 +01:00
|
|
|
term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind
|
|
|
|
term-gprof: export TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELF)
|
2014-02-08 19:41:50 +01:00
|
|
|
all-valgrind: export CFLAGS += -DHAVE_VALGRIND_H -g
|
2014-02-27 10:30:30 +01:00
|
|
|
all-valgrind: export NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
|
2014-03-14 12:48:19 +01:00
|
|
|
all-debug: export CFLAGS += -g
|
|
|
|
all-cachegrind: export CFLAGS += -g
|
2014-03-01 16:48:36 +01:00
|
|
|
all-gprof: export CFLAGS += -pg
|
|
|
|
all-gprof: export LINKFLAGS += -pg
|
2015-07-07 14:37:56 +02:00
|
|
|
all-asan: export CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
|
|
|
|
all-asan: export CFLAGS += -DNATIVE_IN_CALLOC
|
|
|
|
all-asan: export LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
|
2014-02-27 10:30:30 +01:00
|
|
|
|
|
|
|
export INCLUDES += $(NATIVEINCLUDES)
|
2014-01-06 13:00:16 +01:00
|
|
|
|
2016-11-18 13:40:47 +01:00
|
|
|
export CFLAGS += -DDEBUG_ASSERT_VERBOSE
|
|
|
|
|
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)'),)
|
|
|
|
export CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16
|
|
|
|
endif
|
|
|
|
|
2014-02-01 15:39:16 +01:00
|
|
|
# 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
|
|
|
|
|
2013-12-02 11:00:43 +01:00
|
|
|
all: # do not override first target
|
|
|
|
|
2014-04-22 16:53:08 +02:00
|
|
|
all-debug: all
|
|
|
|
|
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:
|
2013-12-02 11:00:43 +01:00
|
|
|
$(VALGRIND) $(VALGRIND_FLAGS) $(ELF) $(PORT)
|
2014-02-26 10:43:07 +01:00
|
|
|
|
2016-01-26 17:38:15 +01:00
|
|
|
debug-valgrind-server:
|
|
|
|
$(VALGRIND) $(VALGRIND_FLAGS) $(ELF) $(PORT)
|
|
|
|
|
|
|
|
debug-valgrind:
|
2016-03-15 13:53:12 +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:
|
2014-03-01 16:48:36 +01:00
|
|
|
$(VALGRIND) $(CACHEGRIND_FLAGS) $(ELF) $(PORT)
|
|
|
|
|
2014-03-14 12:48:19 +01:00
|
|
|
term-gprof: term
|
|
|
|
|
|
|
|
eval-gprof:
|
2014-03-14 12:56:44 +01:00
|
|
|
$(GPROF) $(ELF) $(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)
|
2014-02-15 12:31:43 +01:00
|
|
|
|
2016-10-18 23:27:59 +02:00
|
|
|
export UNDEF += $(BINDIR)/cpu/startup.o
|