2012-02-10 16:51:35 +00:00
|
|
|
# -*- makefile -*-
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
ifndef CONTIKI
|
2013-02-10 23:28:31 +00:00
|
|
|
${error CONTIKI not defined! You must specify where Contiki resides}
|
2006-06-17 22:41:10 +00:00
|
|
|
endif
|
|
|
|
|
2017-06-21 09:11:09 +00:00
|
|
|
# Enable Werror by default. To disable from command line, use make WERROR=0.
|
|
|
|
# Setting this option is also important for tests on Cooja motes to check for warnings.
|
|
|
|
WERROR ?= 1
|
|
|
|
|
2017-12-18 14:41:31 +00:00
|
|
|
include $(CONTIKI)/Makefile.identify-target
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2018-05-12 16:34:29 +00:00
|
|
|
### Include Makefile.tools to pull in targets that allow us to build tools dir
|
|
|
|
include $(CONTIKI)/Makefile.tools
|
|
|
|
|
2007-12-24 15:24:15 +00:00
|
|
|
ifeq ($(DEFINES),)
|
|
|
|
-include Makefile.$(TARGET).defines
|
2008-01-04 21:01:37 +00:00
|
|
|
ifneq ($(DEFINES),)
|
|
|
|
${info using saved defines '$(DEFINES)'}
|
|
|
|
endif
|
2007-12-24 15:24:15 +00:00
|
|
|
endif
|
|
|
|
|
2012-02-21 23:57:22 +00:00
|
|
|
ifndef HOST_OS
|
|
|
|
ifeq ($(OS),Windows_NT)
|
2012-02-24 10:21:48 +00:00
|
|
|
## TODO: detect more specific Windows set-ups,
|
|
|
|
## e.g. CygWin, MingW, VisualC, Watcom, Interix
|
2012-02-21 23:57:22 +00:00
|
|
|
HOST_OS := Windows
|
|
|
|
else
|
|
|
|
HOST_OS := $(shell uname)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-10-14 08:03:28 +00:00
|
|
|
#More debug information when running in CI
|
|
|
|
ifdef CI
|
|
|
|
ifeq ($(CI),true)
|
|
|
|
V = 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-10-13 22:14:51 +00:00
|
|
|
BUILD_DIR = build
|
|
|
|
BUILD_DIR_TARGET = $(BUILD_DIR)/$(TARGET)
|
2018-10-18 19:14:48 +00:00
|
|
|
BUILD_DIR_BOARD = $(BUILD_DIR_TARGET)/$(BOARD)/$(BUILD_DIR_CONFIG)
|
2018-10-13 22:14:51 +00:00
|
|
|
OBJECTDIR = $(BUILD_DIR_BOARD)/obj
|
|
|
|
|
|
|
|
CONTIKI_NG_TARGET_LIB = $(BUILD_DIR_BOARD)/contiki-ng-$(TARGET).a
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2017-09-01 14:16:16 +00:00
|
|
|
LOWERCASE = -abcdefghijklmnopqrstuvwxyz/
|
|
|
|
UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ_
|
2013-03-16 07:48:36 +00:00
|
|
|
TARGET_UPPERCASE := ${strip ${shell echo $(TARGET) | sed y!$(LOWERCASE)!$(UPPERCASE)!}}
|
2010-10-24 22:31:17 +00:00
|
|
|
CFLAGS += -DCONTIKI=1 -DCONTIKI_TARGET_$(TARGET_UPPERCASE)=1
|
2018-03-23 18:23:55 +00:00
|
|
|
CFLAGS += -DCONTIKI_TARGET_STRING=\"$(TARGET)\"
|
2008-11-14 21:37:45 +00:00
|
|
|
|
2018-05-14 16:22:07 +00:00
|
|
|
CFLAGS += -Wno-unused-const-variable
|
2018-05-14 22:50:24 +00:00
|
|
|
|
|
|
|
LDFLAGS_WERROR ?= -Wl,--fatal-warnings
|
|
|
|
|
|
|
|
ifeq ($(WERROR),1)
|
|
|
|
LDFLAGS += $(LDFLAGS_WERROR)
|
|
|
|
endif
|
2018-04-13 09:16:27 +00:00
|
|
|
|
2017-09-01 18:04:53 +00:00
|
|
|
MODULES += os os/sys os/dev os/lib os/services
|
2013-11-28 13:05:29 +00:00
|
|
|
|
2017-10-07 06:53:04 +00:00
|
|
|
# Automatically include project-conf.h if found
|
|
|
|
ifneq ("$(wildcard project-conf.h)","")
|
2017-10-07 06:57:32 +00:00
|
|
|
CFLAGS += -DPROJECT_CONF_PATH=\"project-conf.h\"
|
2017-10-07 06:53:04 +00:00
|
|
|
endif
|
|
|
|
|
2018-02-25 23:24:41 +00:00
|
|
|
MODULES += os os/net os/net/mac os/net/mac/framer os/net/routing os/storage
|
2017-10-07 16:12:45 +00:00
|
|
|
|
2018-02-27 22:36:42 +00:00
|
|
|
define oname
|
2018-02-26 16:08:26 +00:00
|
|
|
${patsubst %.c,%.o, \
|
|
|
|
${patsubst %.S,%.o, \
|
|
|
|
${patsubst %.s,%.o, \
|
|
|
|
$(1) \
|
|
|
|
}}}
|
|
|
|
endef
|
2017-10-07 16:12:45 +00:00
|
|
|
|
|
|
|
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
|
|
|
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}}
|
|
|
|
|
|
|
|
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
|
|
|
|
|
|
|
### Include target makefile (TODO Unsafe?)
|
|
|
|
|
2018-11-23 09:35:41 +00:00
|
|
|
# Configurable arch path
|
|
|
|
ARCH_PATH ?= $(CONTIKI)/arch
|
|
|
|
|
|
|
|
target_makefile := $(wildcard $(ARCH_PATH)/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)})
|
2017-10-07 16:12:45 +00:00
|
|
|
|
|
|
|
# Check if the target makefile exists, and create the object directory if necessary.
|
|
|
|
ifeq ($(strip $(target_makefile)),)
|
|
|
|
${error The target platform "$(TARGET)" does not exist (maybe it was misspelled?)}
|
|
|
|
else
|
|
|
|
ifneq (1, ${words $(target_makefile)})
|
|
|
|
${error More than one TARGET Makefile found: $(target_makefile)}
|
|
|
|
endif
|
|
|
|
include $(target_makefile)
|
|
|
|
endif
|
|
|
|
|
2018-02-23 17:37:07 +00:00
|
|
|
# Decide whether to build or to skip this target for this platform
|
|
|
|
ifneq ("", "$(PLATFORMS_ONLY)")
|
|
|
|
ifeq ("","$(filter $(TARGET), $(PLATFORMS_ONLY))")
|
|
|
|
PLATFORM_ACTION = skip
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ("", "$(PLATFORMS_EXCLUDE)")
|
|
|
|
ifneq ("","$(filter $(TARGET), $(PLATFORMS_EXCLUDE))")
|
|
|
|
PLATFORM_ACTION = skip
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(BOARD),)
|
|
|
|
ifneq ("", "$(BOARDS_ONLY)")
|
|
|
|
ifeq ("","$(filter $(BOARD), $(BOARDS_ONLY))")
|
|
|
|
PLATFORM_ACTION = skip
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ("", "$(BOARDS_EXCLUDE)")
|
|
|
|
ifneq ("","$(filter $(BOARD), $(BOARDS_EXCLUDE))")
|
|
|
|
PLATFORM_ACTION = skip
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif # $(BOARD) not empty
|
|
|
|
|
|
|
|
PLATFORM_ACTION ?= build
|
|
|
|
|
2018-10-13 22:14:51 +00:00
|
|
|
# Provide way to create $(OBJECTDIR) if it has been removed by make clean
|
|
|
|
$(OBJECTDIR):
|
|
|
|
$(TRACE_MKDIR)
|
|
|
|
$(Q)mkdir -p $@
|
|
|
|
|
2018-10-13 21:07:25 +00:00
|
|
|
ifneq ($(BOARD),)
|
|
|
|
TARGET_BOARD_UPPERCASE := ${strip ${shell echo $(BOARD) | sed y!$(LOWERCASE)!$(UPPERCASE)!}}
|
|
|
|
CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1
|
|
|
|
CFLAGS += -DCONTIKI_BOARD_STRING=\"$(BOARD)\"
|
|
|
|
endif
|
|
|
|
|
2017-09-08 15:48:29 +00:00
|
|
|
# Configure MAC layer
|
|
|
|
|
|
|
|
# The different options
|
|
|
|
MAKE_MAC_NULLMAC = 0
|
|
|
|
MAKE_MAC_CSMA = 1
|
|
|
|
MAKE_MAC_TSCH = 2
|
2018-01-03 13:36:14 +00:00
|
|
|
MAKE_MAC_BLE = 3
|
|
|
|
MAKE_MAC_OTHER = 4
|
2017-09-08 15:48:29 +00:00
|
|
|
|
|
|
|
# Make CSMA the default MAC
|
|
|
|
MAKE_MAC ?= MAKE_MAC_CSMA
|
|
|
|
|
|
|
|
ifeq ($(MAKE_MAC),MAKE_MAC_NULLMAC)
|
2017-10-07 16:12:45 +00:00
|
|
|
MODULES+=os/net/mac/nullmac
|
2017-09-08 15:48:29 +00:00
|
|
|
CFLAGS += -DMAC_CONF_WITH_NULLMAC=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(MAKE_MAC),MAKE_MAC_CSMA)
|
|
|
|
MODULES += os/net/mac/csma
|
|
|
|
CFLAGS += -DMAC_CONF_WITH_CSMA=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(MAKE_MAC),MAKE_MAC_TSCH)
|
|
|
|
MODULES += os/net/mac/tsch
|
|
|
|
CFLAGS += -DMAC_CONF_WITH_TSCH=1
|
|
|
|
endif
|
|
|
|
|
2018-01-03 13:36:14 +00:00
|
|
|
ifeq ($(MAKE_MAC),MAKE_MAC_BLE)
|
|
|
|
MODULES += os/net/mac/ble
|
|
|
|
CFLAGS += -DMAC_CONF_WITH_BLE=1
|
|
|
|
endif
|
2017-09-08 15:48:29 +00:00
|
|
|
|
|
|
|
ifeq ($(MAKE_MAC),MAKE_MAC_OTHER)
|
|
|
|
CFLAGS += -DMAC_CONF_WITH_OTHER=1
|
|
|
|
endif
|
|
|
|
|
2017-10-11 18:58:15 +00:00
|
|
|
# Configure Network layer
|
2014-11-12 09:18:29 +00:00
|
|
|
|
2017-09-08 19:10:37 +00:00
|
|
|
MAKE_NET_NULLNET = 0
|
|
|
|
MAKE_NET_IPV6 = 1
|
|
|
|
MAKE_NET_OTHER = 2
|
2014-11-12 09:18:29 +00:00
|
|
|
|
|
|
|
# Make IPv6 the default stack
|
2017-09-08 19:10:37 +00:00
|
|
|
MAKE_NET ?= MAKE_NET_IPV6
|
|
|
|
|
|
|
|
ifeq ($(MAKE_NET),MAKE_NET_NULLNET)
|
|
|
|
CFLAGS += -DNETSTACK_CONF_WITH_NULLNET=1
|
2018-05-06 11:13:49 +00:00
|
|
|
MODULES += os/net/nullnet
|
2014-11-12 09:18:29 +00:00
|
|
|
endif
|
|
|
|
|
2017-09-08 19:10:37 +00:00
|
|
|
ifeq ($(MAKE_NET),MAKE_NET_IPV6)
|
2014-12-01 20:02:57 +00:00
|
|
|
CFLAGS += -DNETSTACK_CONF_WITH_IPV6=1
|
2017-09-22 13:06:44 +00:00
|
|
|
MODULES += os/net/ipv6
|
2014-12-02 10:29:49 +00:00
|
|
|
endif
|
|
|
|
|
2017-09-08 19:10:37 +00:00
|
|
|
ifeq ($(MAKE_NET),MAKE_NET_OTHER)
|
|
|
|
CFLAGS += -DNETSTACK_CONF_WITH_OTHER=1
|
|
|
|
endif
|
|
|
|
|
2017-10-11 18:58:15 +00:00
|
|
|
ifeq ($(WITH_IP64),1)
|
|
|
|
MODULES += os/services/ip64
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Configure Routing protocol
|
2017-12-10 20:08:03 +00:00
|
|
|
MAKE_ROUTING_NULLROUTING = 0
|
2017-10-11 18:58:15 +00:00
|
|
|
MAKE_ROUTING_RPL_CLASSIC = 1
|
|
|
|
MAKE_ROUTING_RPL_LITE = 2
|
|
|
|
|
|
|
|
# Default routing protocol: RPL for IPv6, None otherwise
|
|
|
|
ifeq ($(MAKE_NET),MAKE_NET_IPV6)
|
|
|
|
MAKE_ROUTING ?= MAKE_ROUTING_RPL_LITE
|
2014-12-02 10:29:49 +00:00
|
|
|
else
|
2017-12-10 20:08:03 +00:00
|
|
|
MAKE_ROUTING ?= MAKE_ROUTING_NULLROUTING
|
2014-11-12 09:18:29 +00:00
|
|
|
endif
|
|
|
|
|
2017-10-11 18:58:15 +00:00
|
|
|
ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC)
|
2017-12-10 20:20:24 +00:00
|
|
|
CFLAGS += -DROUTING_CONF_RPL_CLASSIC=1
|
2017-12-09 12:55:57 +00:00
|
|
|
MODULES += os/net/routing/rpl-classic
|
2017-10-11 18:58:15 +00:00
|
|
|
else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE)
|
2017-12-10 20:20:24 +00:00
|
|
|
CFLAGS += -DROUTING_CONF_RPL_LITE=1
|
2017-12-09 12:55:57 +00:00
|
|
|
MODULES += os/net/routing/rpl-lite
|
2017-12-10 20:08:03 +00:00
|
|
|
else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_NULLROUTING)
|
2017-12-10 20:20:24 +00:00
|
|
|
CFLAGS += -DROUTING_CONF_NULLROUTING=1
|
2017-12-09 13:13:09 +00:00
|
|
|
MODULES += os/net/routing/nullrouting
|
2017-09-22 13:06:44 +00:00
|
|
|
endif
|
|
|
|
|
2017-12-19 13:29:55 +00:00
|
|
|
MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}}
|
|
|
|
UNIQUEMODULES = $(call uniq,$(MODULEDIRS))
|
|
|
|
MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}}
|
2017-12-19 16:24:25 +00:00
|
|
|
CONTIKI_SOURCEFILES += $(MODULES_SOURCES)
|
|
|
|
|
|
|
|
# Include module-specific makefiles
|
2017-12-19 13:29:55 +00:00
|
|
|
MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}}
|
|
|
|
include $(MODULES_INCLUDES)
|
2017-12-19 17:02:21 +00:00
|
|
|
# Iterate once more: include the modules added from the previous include.
|
|
|
|
# Only works with one level of nested module inclusion.
|
|
|
|
include $(MODULES_INCLUDES)
|
2017-12-19 16:24:25 +00:00
|
|
|
|
|
|
|
# C-include module-specific macros using -imacros
|
|
|
|
MODULES_IMACROS = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/module-macros.h}}
|
|
|
|
ifneq ($(MODULES_IMACROS),)
|
|
|
|
CFLAGS += ${foreach d, $(MODULES_IMACROS), -imacros $(d)}
|
|
|
|
endif
|
2013-11-22 08:46:11 +00:00
|
|
|
|
2013-07-29 18:34:07 +00:00
|
|
|
### Verbosity control. Use make V=1 to get verbose builds.
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
TRACE_CC =
|
|
|
|
TRACE_LD =
|
|
|
|
TRACE_AR =
|
|
|
|
TRACE_AS =
|
2018-10-13 21:26:22 +00:00
|
|
|
TRACE_OBJCOPY =
|
|
|
|
TRACE_OBJDUMP =
|
|
|
|
TRACE_MKDIR =
|
|
|
|
TRACE_CP =
|
2013-07-29 18:34:07 +00:00
|
|
|
Q=
|
|
|
|
else
|
|
|
|
TRACE_CC = @echo " CC " $<
|
|
|
|
TRACE_LD = @echo " LD " $@
|
|
|
|
TRACE_AR = @echo " AR " $@
|
|
|
|
TRACE_AS = @echo " AS " $<
|
2018-10-13 21:26:22 +00:00
|
|
|
TRACE_OBJCOPY = @echo " OBJCOPY " $< "-->" $@
|
|
|
|
TRACE_OBJDUMP = @echo " OBJDUMP " $< "-->" $@
|
|
|
|
TRACE_MKDIR = @echo " MKDIR " $@
|
|
|
|
TRACE_CP = @echo " CP " $< "-->" $@
|
2013-07-29 18:34:07 +00:00
|
|
|
Q=@
|
|
|
|
endif
|
2013-03-17 22:24:03 +00:00
|
|
|
|
2007-12-21 10:16:45 +00:00
|
|
|
### Forward comma-separated list of arbitrary defines to the compiler
|
|
|
|
|
|
|
|
COMMA := ,
|
|
|
|
CFLAGS += ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}}
|
|
|
|
|
2007-05-19 07:54:53 +00:00
|
|
|
### Setup directory search path for source and header files
|
2007-05-13 08:41:11 +00:00
|
|
|
|
2012-02-10 15:57:37 +00:00
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix ${dir $(target_makefile)}, \
|
2007-05-13 08:41:11 +00:00
|
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \
|
|
|
|
$(CONTIKI_CPU_DIRS)}
|
2017-06-28 13:57:13 +00:00
|
|
|
CONTIKI_ARCH_DIRS = ${addprefix $(CONTIKI)/, arch}
|
2007-05-13 08:41:11 +00:00
|
|
|
|
2017-06-28 13:57:13 +00:00
|
|
|
SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) $(CONTIKI_ARCH_DIRS) \
|
2017-09-01 14:52:06 +00:00
|
|
|
$(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(MODULEDIRS) $(EXTERNALDIRS) ${dir $(target_makefile)}
|
2007-05-13 08:41:11 +00:00
|
|
|
|
|
|
|
vpath %.c $(SOURCEDIRS)
|
|
|
|
vpath %.S $(SOURCEDIRS)
|
2018-02-26 16:08:26 +00:00
|
|
|
vpath %.s $(SOURCEDIRS)
|
2007-05-13 08:41:11 +00:00
|
|
|
|
2013-11-28 13:54:07 +00:00
|
|
|
CFLAGS += ${addprefix -I,$(SOURCEDIRS) $(CONTIKI)}
|
2007-05-19 07:54:53 +00:00
|
|
|
|
2011-07-16 12:53:44 +00:00
|
|
|
### Check for a git repo and pass version if found
|
|
|
|
### git.exe in Windows cmd shells may require no stderr redirection
|
2014-10-14 08:00:28 +00:00
|
|
|
ifndef RELSTR
|
2018-04-01 15:15:02 +00:00
|
|
|
RELSTR:=${shell git --git-dir ${CONTIKI}/.git --work-tree ${CONTIKI} describe \
|
|
|
|
--tags --always --dirty}
|
2014-10-14 08:00:28 +00:00
|
|
|
endif
|
|
|
|
|
2011-07-16 12:53:44 +00:00
|
|
|
ifneq ($(RELSTR),)
|
2017-10-27 12:54:33 +00:00
|
|
|
CFLAGS += -DCONTIKI_VERSION_STRING=\"Contiki-NG-$(RELSTR)\"
|
2017-05-18 10:03:50 +00:00
|
|
|
else
|
2017-10-27 12:54:33 +00:00
|
|
|
CFLAGS += -DCONTIKI_VERSION_STRING=\"Contiki-NG\"
|
2011-07-16 12:53:44 +00:00
|
|
|
endif
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
### Automatic dependency generation
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
2007-04-14 18:37:06 +00:00
|
|
|
-include ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
|
2013-02-10 23:28:31 +00:00
|
|
|
$(PROJECT_SOURCEFILES:.c=.d)}
|
2006-06-17 22:41:10 +00:00
|
|
|
endif
|
|
|
|
|
2009-07-02 22:36:04 +00:00
|
|
|
### See http://make.paulandlesley.org/autodep.html#advanced
|
|
|
|
|
|
|
|
define FINALIZE_DEPENDENCY
|
|
|
|
cp $(@:.o=.d) $(@:.o=.$$$$); \
|
|
|
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
|
|
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.$$$$) >> $(@:.o=.d); \
|
|
|
|
rm -f $(@:.o=.$$$$)
|
|
|
|
endef
|
|
|
|
|
2018-03-30 19:12:31 +00:00
|
|
|
### Harmonize filename of a .map file, if the platform's build system wants
|
|
|
|
### to create one
|
2018-10-13 22:14:51 +00:00
|
|
|
CONTIKI_NG_PROJECT_MAP = $(BUILD_DIR_BOARD)/$(basename $(notdir $@)).map
|
2018-03-30 19:12:31 +00:00
|
|
|
|
2018-03-30 19:22:03 +00:00
|
|
|
.PHONY: clean distclean usage help targets boards savetarget savedefines viewconf
|
|
|
|
|
2013-06-20 17:20:50 +00:00
|
|
|
clean:
|
2018-10-13 22:14:51 +00:00
|
|
|
-$(Q)rm -f *.d *.e *.o $(CLEAN)
|
|
|
|
-$(Q)rm -rf $(BUILD_DIR_TARGET)
|
2018-05-03 19:39:09 +00:00
|
|
|
-$(Q)rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT))
|
|
|
|
@echo Target $(TARGET) cleaned
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2018-03-30 19:20:55 +00:00
|
|
|
distclean:
|
2018-11-23 09:35:41 +00:00
|
|
|
@for TARG in `ls $(ARCH_PATH)/platform $(TARGETDIRS)`; do \
|
2018-05-27 18:21:08 +00:00
|
|
|
echo Running: $(MAKE) TARGET=$$TARG clean; \
|
|
|
|
$(MAKE) TARGET=$$TARG clean; \
|
2018-03-30 19:20:55 +00:00
|
|
|
done
|
2018-10-23 15:49:54 +00:00
|
|
|
-$(Q)rm -rf $(BUILD_DIR)
|
2013-07-26 15:57:14 +00:00
|
|
|
|
2018-11-23 09:35:41 +00:00
|
|
|
-include $(ARCH_PATH)/platform/$(TARGET)/Makefile.customrules-$(TARGET)
|
2013-12-09 13:56:45 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
2013-07-29 18:34:07 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -MMD -c $< -o $@
|
2009-07-02 22:36:04 +00:00
|
|
|
@$(FINALIZE_DEPENDENCY)
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2007-08-30 20:42:58 +00:00
|
|
|
ifndef CUSTOM_RULE_S_TO_OBJECTDIR_O
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR)
|
2013-07-29 18:34:07 +00:00
|
|
|
$(TRACE_AS)
|
|
|
|
$(Q)$(AS) $(ASFLAGS) -o $@ $<
|
2018-02-26 16:08:26 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.s | $(OBJECTDIR)
|
|
|
|
$(TRACE_AS)
|
|
|
|
$(Q)$(AS) $(ASFLAGS) -o $@ $<
|
2007-08-30 20:42:58 +00:00
|
|
|
endif
|
|
|
|
|
2017-10-09 19:58:27 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_S
|
|
|
|
$(OBJECTDIR)/%.s: %.c | $(OBJECTDIR)
|
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -S $< -o $@
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_E
|
|
|
|
$(OBJECTDIR)/%.e: %.c | $(OBJECTDIR)
|
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -E $< -o $@
|
|
|
|
endif
|
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_O
|
2006-06-17 22:41:10 +00:00
|
|
|
%.o: %.c
|
2013-07-29 18:34:07 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2017-10-09 19:58:27 +00:00
|
|
|
ifndef CUSTOM_RULE_C_TO_S
|
|
|
|
%.s: %.c
|
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -S $< -o $@
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CUSTOM_RULE_C_TO_E
|
|
|
|
%.e: %.c
|
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -E $< -o $@
|
|
|
|
endif
|
2013-07-29 18:34:07 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef AROPTS
|
|
|
|
AROPTS = rcf
|
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef CUSTOM_RULE_ALLOBJS_TO_TARGETLIB
|
2018-03-30 19:14:33 +00:00
|
|
|
$(CONTIKI_NG_TARGET_LIB): $(CONTIKI_OBJECTFILES)
|
2013-07-29 18:34:07 +00:00
|
|
|
$(TRACE_AR)
|
|
|
|
$(Q)$(AR) $(AROPTS) $@ $^
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2006-06-26 02:01:30 +00:00
|
|
|
ifndef LD
|
|
|
|
LD = $(CC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CUSTOM_RULE_LINK
|
2018-10-23 16:45:43 +00:00
|
|
|
$(BUILD_DIR_BOARD)/%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_NG_TARGET_LIB)
|
2013-07-29 18:34:07 +00:00
|
|
|
$(TRACE_LD)
|
|
|
|
$(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \
|
|
|
|
${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
2006-06-26 02:01:30 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2018-10-23 16:45:43 +00:00
|
|
|
%.$(TARGET): $(BUILD_DIR_BOARD)/%.$(TARGET)
|
|
|
|
$(TRACE_CP)
|
|
|
|
$(Q)cp $< $@
|
|
|
|
|
2012-03-26 20:55:57 +00:00
|
|
|
%.ramprof: %.$(TARGET)
|
2012-07-10 23:02:59 +00:00
|
|
|
$(NM) -S -td --size-sort $< | grep -i " [abdrw] " | cut -d' ' -f2,4
|
2012-03-26 20:55:57 +00:00
|
|
|
|
|
|
|
%.flashprof: %.$(TARGET)
|
2012-07-10 23:02:59 +00:00
|
|
|
$(NM) -S -td --size-sort $< | grep -i " [t] " | cut -d' ' -f2,4
|
2012-03-26 20:55:57 +00:00
|
|
|
|
2018-10-14 16:00:40 +00:00
|
|
|
include $(CONTIKI)/Makefile.help
|
2017-10-10 08:50:27 +00:00
|
|
|
|
|
|
|
targets:
|
2018-11-23 09:35:41 +00:00
|
|
|
@ls $(ARCH_PATH)/platform $(TARGETDIRS)
|
2017-10-10 08:50:27 +00:00
|
|
|
|
|
|
|
boards:
|
|
|
|
ifdef BOARD
|
|
|
|
@echo "$(BOARDS) (current: $(BOARD))"
|
|
|
|
else
|
|
|
|
@echo "Platform has no boards"
|
|
|
|
endif
|
|
|
|
|
|
|
|
savetarget:
|
|
|
|
-@rm -f Makefile.target
|
|
|
|
@echo "saving Makefile.target"
|
|
|
|
@echo >Makefile.target "TARGET = $(TARGET)"
|
|
|
|
ifneq ($(BOARD),)
|
|
|
|
@echo >>Makefile.target "BOARD = $(BOARD)"
|
|
|
|
endif
|
|
|
|
|
|
|
|
savedefines:
|
|
|
|
-@rm -f Makefile.$(TARGET).defines
|
|
|
|
@echo "saving Makefile.$(TARGET).defines"
|
|
|
|
@echo >Makefile.$(TARGET).defines "DEFINES = $(DEFINES)"
|
|
|
|
|
2018-05-12 17:14:03 +00:00
|
|
|
VIEWCONF = $(CONTIKI)/tools/viewconf/viewconf.c
|
2017-10-10 08:50:27 +00:00
|
|
|
viewconf:
|
|
|
|
@echo "----------------- Make variables: --------------"
|
|
|
|
@echo "##### \"TARGET\": ________________________________ $(TARGET)"
|
|
|
|
@echo "##### \"BOARD\": _________________________________ $(BOARD)"
|
|
|
|
@echo "##### \"MAKE_MAC\": ______________________________ $(MAKE_MAC)"
|
|
|
|
@echo "##### \"MAKE_NET\": ______________________________ $(MAKE_NET)"
|
2017-10-11 18:58:15 +00:00
|
|
|
@echo "##### \"MAKE_ROUTING\": __________________________ $(MAKE_ROUTING)"
|
2017-10-26 17:47:14 +00:00
|
|
|
ifdef MAKE_COAP_DTLS_KEYSTORE
|
|
|
|
@echo "##### \"MAKE_COAP_DTLS_KEYSTORE\": _______________ $(MAKE_COAP_DTLS_KEYSTORE)"
|
|
|
|
endif
|
2017-10-10 08:50:27 +00:00
|
|
|
@echo "----------------- C variables: -----------------"
|
2018-05-12 17:14:03 +00:00
|
|
|
$(Q)$(CC) $(CFLAGS) -E $(VIEWCONF) | grep \#\#\#\#\#
|
2017-10-10 08:50:27 +00:00
|
|
|
@echo "------------------------------------------------"
|
2017-10-26 15:25:24 +00:00
|
|
|
@echo "'==' Means the flag is set to a given a value"
|
|
|
|
@echo "'->' Means the flag is unset, but will default to a given value"
|
|
|
|
@echo "'><' Means the flag is unset and has no default value"
|
2017-10-10 08:50:27 +00:00
|
|
|
@echo "To view more Make variables, edit $(CONTIKI)/Makefile.include, rule 'viewconf'"
|
2018-05-12 17:14:03 +00:00
|
|
|
@echo "To view more C variables, edit $(VIEWCONF)"
|
2017-10-10 08:50:27 +00:00
|
|
|
|
2018-05-12 16:35:51 +00:00
|
|
|
### Include Makefile.embedded for relevant platforms, in order to pull in
|
|
|
|
### rules for login, serialview etc
|
|
|
|
ifeq ($(findstring $(TARGET),native cooja),)
|
|
|
|
include $(CONTIKI)/Makefile.embedded
|
|
|
|
endif
|
|
|
|
|
2018-10-23 16:45:43 +00:00
|
|
|
# Don't treat $(BUILD_DIR_BOARD)/%.$(TARGET) and $(TARGET) as intermediate
|
|
|
|
# files because for many platforms they are in fact the primary target.
|
|
|
|
.PRECIOUS: $(BUILD_DIR_BOARD)/%.$(TARGET) %.$(TARGET)
|
2007-04-18 21:28:28 +00:00
|
|
|
|
|
|
|
# Cancel the predefined implict rule for compiling and linking
|
|
|
|
# a single C source into a binary to force GNU make to consider
|
|
|
|
# the match-anything rule below instead.
|
|
|
|
%: %.c
|
|
|
|
|
2018-02-23 17:37:07 +00:00
|
|
|
ifeq ($(PLATFORM_ACTION),skip)
|
|
|
|
# Skip this target.
|
|
|
|
$(CONTIKI_PROJECT):
|
2018-02-27 20:43:17 +00:00
|
|
|
@echo "Skipping $@: not for the '$(TARGET)/$(BOARD)' platform!"
|
2018-12-18 17:14:18 +00:00
|
|
|
%.$(TARGET):
|
|
|
|
@echo "Skipping $@: not for the '$(TARGET)/$(BOARD)' platform!"
|
2018-02-23 17:37:07 +00:00
|
|
|
else
|
|
|
|
# Build this target.
|
2007-04-18 21:28:28 +00:00
|
|
|
# Match-anything pattern rule to allow the project makefiles to
|
|
|
|
# abstract from the actual binary name. It needs to contain some
|
|
|
|
# command in order to be a rule, not just a prerequisite.
|
2006-06-17 22:41:10 +00:00
|
|
|
%: %.$(TARGET)
|
|
|
|
@
|
2018-02-23 17:37:07 +00:00
|
|
|
endif
|