2014-02-03 15:58:18 +01:00
|
|
|
include $(RIOTBOARD)/$(BOARD)/Makefile.dep
|
|
|
|
|
2014-02-27 10:30:30 +01:00
|
|
|
export NATIVEINCLUDES = -I$(RIOTBOARD)/$(BOARD)/include/
|
|
|
|
export NATIVEINCLUDES += -I$(RIOTBASE)/core/include/
|
|
|
|
export NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/
|
|
|
|
|
2013-03-19 22:02:22 +01:00
|
|
|
export CPU = native
|
2014-02-01 13:16:58 +01:00
|
|
|
export ELF = $(BINDIR)$(PROJECT).elf
|
2013-03-19 22:02:22 +01:00
|
|
|
|
2014-02-01 13:16:58 +01:00
|
|
|
# toolchain:
|
|
|
|
export PREFIX =
|
|
|
|
export CC ?= $(PREFIX)gcc
|
2014-01-03 19:00:41 +01:00
|
|
|
export AR = $(PREFIX)ar
|
2013-03-19 22:02:22 +01:00
|
|
|
export AS = $(PREFIX)as
|
|
|
|
export LINK = $(PREFIX)gcc
|
|
|
|
export SIZE = $(PREFIX)size
|
2014-02-01 15:39:16 +01:00
|
|
|
export OBJCOPY = true
|
2013-03-19 22:02:22 +01:00
|
|
|
|
2014-02-01 13:16:58 +01:00
|
|
|
export DEBUGGER = gdb
|
|
|
|
export TERMPROG = $(ELF)
|
|
|
|
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-02-01 13:16:58 +01:00
|
|
|
# flags:
|
2014-02-12 17:32:34 +01:00
|
|
|
export CFLAGS += -Wall -Wextra -pedantic -m32
|
2014-02-01 13:16:58 +01:00
|
|
|
export LINKFLAGS += -m32 -gc -ldl
|
|
|
|
export ASFLAGS =
|
|
|
|
export DEBUGGER_FLAGS = $(ELF)
|
2014-03-14 12:48:19 +01:00
|
|
|
term-memcheck: export VALGRIND_FLAGS ?= --track-origins=yes
|
|
|
|
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
|
2014-02-27 10:30:30 +01:00
|
|
|
|
|
|
|
export INCLUDES += $(NATIVEINCLUDES)
|
2014-01-06 13:00:16 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
|
# set the tap interface for term/valgrind
|
2014-02-14 14:30:16 +01:00
|
|
|
ifneq (,$(filter nativenet,$(USEMODULE)))
|
2014-02-01 13:16:58 +01:00
|
|
|
export PORT ?= tap0
|
2014-01-06 13:00:16 +01:00
|
|
|
else
|
2014-02-01 13:16:58 +01:00
|
|
|
export PORT =
|
2013-03-19 22:02:22 +01:00
|
|
|
endif
|
2013-04-10 12:52:19 +02:00
|
|
|
|
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
|
|
|
|
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
|
|
|
# use this if you want to attach gdb from valgrind:
|
|
|
|
# echo 0 > /proc/sys/kernel/yama/ptrace_scope
|
|
|
|
# VALGRIND_FLAGS += --db-attach=yes
|
|
|
|
$(VALGRIND) $(VALGRIND_FLAGS) $(ELF) $(PORT)
|
2014-02-26 10:43:07 +01:00
|
|
|
|
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)
|