2017-05-19 01:02:19 +02:00
|
|
|
PKG_NAME=openthread
|
|
|
|
PKG_URL=https://github.com/openthread/openthread.git
|
2019-05-16 23:08:30 +02:00
|
|
|
PKG_VERSION=thread-reference-20180926
|
2019-10-04 13:50:44 +02:00
|
|
|
PKG_LICENSE=BSD-3-Clause
|
2017-05-19 01:02:19 +02:00
|
|
|
|
2020-06-13 21:01:04 +02:00
|
|
|
# OpenThread build system doesn't support (yet) out-of-source builds
|
|
|
|
# so clone and build OpenThread within the application build directory
|
|
|
|
PKG_BUILD_OUT_OF_SOURCE = 0
|
|
|
|
|
2019-10-02 12:47:02 +02:00
|
|
|
include $(RIOTBASE)/pkg/pkg.mk
|
|
|
|
|
2019-05-08 14:44:38 +02:00
|
|
|
ifneq (,$(filter openthread-ftd,$(USEMODULE)))
|
|
|
|
TD = ftd
|
|
|
|
else ifneq (,$(filter openthread-mtd,$(USEMODULE)))
|
|
|
|
TD = mtd
|
|
|
|
JOINER_ARG = --enable-joiner
|
|
|
|
else
|
|
|
|
$(error "Please use either USEMODULE=openthread-ftd or USEMODULE=openthread-mtd")
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$(filter openthread-cli,$(USEMODULE)))
|
2019-05-16 23:08:30 +02:00
|
|
|
CLI_ARG = --enable-cli --enable-$(TD)
|
2018-06-12 17:40:27 +02:00
|
|
|
endif
|
2019-05-08 14:44:38 +02:00
|
|
|
|
|
|
|
OPENTHREAD_ARGS += $(CLI_ARG) $(JOINER_ARG) --enable-application-coap
|
2018-06-12 17:40:27 +02:00
|
|
|
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"platform_config.h\"'
|
2017-05-19 01:02:19 +02:00
|
|
|
|
2018-02-22 09:14:25 +01:00
|
|
|
OPENTHREAD_COMMON_FLAGS = -fdata-sections -ffunction-sections -Os
|
2018-06-12 17:40:27 +02:00
|
|
|
OPENTHREAD_COMMON_FLAGS += -Wno-implicit-fallthrough -Wno-unused-parameter
|
2020-02-24 14:12:13 +01:00
|
|
|
OPENTHREAD_CXXFLAGS += -Wno-class-memaccess
|
2018-02-22 09:14:25 +01:00
|
|
|
|
2020-06-13 21:01:04 +02:00
|
|
|
OT_LIB_DIR = $(PKG_BUILD_DIR)/output/lib
|
2020-06-13 22:33:33 +02:00
|
|
|
MODULE_LIBS = mbedcrypto.a openthread-$(TD).a
|
|
|
|
ifneq (,$(filter openthread-cli,$(USEMODULE)))
|
|
|
|
MODULE_LIBS += openthread-cli.a
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: $(addprefix $(BINDIR)/,$(MODULE_LIBS))
|
|
|
|
@true
|
|
|
|
|
|
|
|
$(BINDIR)/openthread-$(TD).a: $(OT_LIB_DIR)/libopenthread-$(TD).a
|
|
|
|
@cp $< $@
|
|
|
|
|
|
|
|
$(BINDIR)/mbedcrypto.a: $(BINDIR)/openthread-$(TD).a
|
|
|
|
@cp $(OT_LIB_DIR)/libmbedcrypto.a $@
|
|
|
|
|
|
|
|
$(BINDIR)/openthread-cli.a: $(BINDIR)/openthread-$(TD).a
|
|
|
|
@cp $(OT_LIB_DIR)/libopenthread-cli-$(TD).a $@
|
|
|
|
|
2020-06-13 21:01:04 +02:00
|
|
|
$(OT_LIB_DIR)/libopenthread-$(TD).a: $(PKG_BUILD_DIR)/Makefile
|
2020-07-03 11:18:31 +02:00
|
|
|
$(MAKE) -C $(PKG_BUILD_DIR) --no-print-directory install DESTDIR=$(PKG_BUILD_DIR)/output PREFIX=/
|
2020-06-13 22:33:33 +02:00
|
|
|
$(Q)printf "OpenThread built for %s device\n" $(TD)
|
|
|
|
|
2020-06-13 21:01:04 +02:00
|
|
|
$(PKG_BUILD_DIR)/Makefile: $(PKG_BUILD_DIR)/configure
|
|
|
|
$(Q)cd $(PKG_BUILD_DIR) && CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)"\
|
2017-05-19 01:02:19 +02:00
|
|
|
OBJC="" OBJCXX="" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" \
|
|
|
|
STRIP="$(STRIP)" \
|
2018-06-12 17:40:27 +02:00
|
|
|
CPPFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -D$(CONFIG_FILE)" \
|
2017-05-19 01:02:19 +02:00
|
|
|
CFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) " \
|
2020-02-24 14:12:13 +01:00
|
|
|
CXXFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(OPENTHREAD_CXXFLAGS) \
|
|
|
|
$(CFLAGS_CPU) -fno-exceptions -fno-rtti " \
|
2017-05-19 01:02:19 +02:00
|
|
|
LDFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -nostartfiles -specs=nano.specs \
|
|
|
|
-specs=nosys.specs -Wl,--gc-sections -Wl,-Map=map.map " \
|
|
|
|
./configure --disable-docs --host=$(TARGET_ARCH) --target=$(TARGET_ARCH) \
|
2018-03-22 09:12:12 +01:00
|
|
|
--prefix=/ --enable-default-logging $(OPENTHREAD_ARGS)
|
2019-05-08 14:44:38 +02:00
|
|
|
|
2020-06-13 21:01:04 +02:00
|
|
|
$(PKG_BUILD_DIR)/configure: $(PKG_PREPARED)
|
2020-06-13 22:33:33 +02:00
|
|
|
$(Q)printf "OPENTHREAD_ARGS is [$(OPENTHREAD_ARGS)]\n"
|
2020-06-13 21:01:04 +02:00
|
|
|
$(Q)cd $(PKG_BUILD_DIR) && PREFIX="/" ./bootstrap
|