1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #14282 from aabadie/pr/pkg/openthread_make_rework

pkg/openthread: improve package Makefile
This commit is contained in:
Francisco 2020-06-16 21:13:04 +02:00 committed by GitHub
commit e3c9894402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,15 +2,12 @@ PKG_NAME=openthread
PKG_URL=https://github.com/openthread/openthread.git
PKG_VERSION=thread-reference-20180926
PKG_LICENSE=BSD-3-Clause
PKG_BUILDDIR ?= $(PKGDIRBASE)/$(PKG_NAME)
include $(RIOTBASE)/pkg/pkg.mk
ifneq (,$(filter openthread-ftd,$(USEMODULE)))
TD = ftd
$(info Compile OpenThread for FTD device)
else ifneq (,$(filter openthread-mtd,$(USEMODULE)))
$(info Compile OpenThread for MTD device)
TD = mtd
JOINER_ARG = --enable-joiner
else
@ -23,15 +20,35 @@ endif
OPENTHREAD_ARGS += $(CLI_ARG) $(JOINER_ARG) --enable-application-coap
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"platform_config.h\"'
$(info $$OPENTHREAD_ARGS is [${OPENTHREAD_ARGS}])
OPENTHREAD_COMMON_FLAGS = -fdata-sections -ffunction-sections -Os
OPENTHREAD_COMMON_FLAGS += -Wno-implicit-fallthrough -Wno-unused-parameter
OPENTHREAD_CXXFLAGS += -Wno-class-memaccess
all:
cd $(PKG_BUILDDIR) && PREFIX="/" ./bootstrap
cd $(PKG_BUILDDIR) && CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)"\
OT_LIB_DIR = $(PKG_BUILDDIR)/output/lib
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 $@
$(OT_LIB_DIR)/libopenthread-$(TD).a: $(PKG_BUILDDIR)/Makefile
make -C $(PKG_BUILDDIR) -j4 --no-print-directory install DESTDIR=$(PKG_BUILDDIR)/output PREFIX=/
$(Q)printf "OpenThread built for %s device\n" $(TD)
$(PKG_BUILDDIR)/Makefile: $(PKG_BUILDDIR)/configure
$(Q)cd $(PKG_BUILDDIR) && CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)"\
OBJC="" OBJCXX="" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" \
STRIP="$(STRIP)" \
CPPFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -D$(CONFIG_FILE)" \
@ -42,11 +59,7 @@ all:
-specs=nosys.specs -Wl,--gc-sections -Wl,-Map=map.map " \
./configure --disable-docs --host=$(TARGET_ARCH) --target=$(TARGET_ARCH) \
--prefix=/ --enable-default-logging $(OPENTHREAD_ARGS)
cd $(PKG_BUILDDIR) && DESTDIR=$(PKG_BUILDDIR)/output PREFIX=/ make -j4 --no-print-directory install
cp $(PKG_BUILDDIR)/output/lib/libmbedcrypto.a ${BINDIR}/mbedcrypto.a
cp $(PKG_BUILDDIR)/output/lib/libopenthread-$(TD).a ${BINDIR}/openthread-$(TD).a
ifneq (,$(filter openthread-cli,$(USEMODULE)))
cp $(PKG_BUILDDIR)/output/lib/libopenthread-cli-$(TD).a ${BINDIR}/openthread-cli.a
endif
$(PKG_BUILDDIR)/configure: $(PKG_PREPARED)
$(Q)printf "OPENTHREAD_ARGS is [$(OPENTHREAD_ARGS)]\n"
$(Q)cd $(PKG_BUILDDIR) && PREFIX="/" ./bootstrap