From d7ddf57596b13bac87bbc121e507bd5acc83de5b Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 13 Jun 2020 22:33:33 +0200 Subject: [PATCH] pkg/openthread: improve package Makefile This commit improves the target dependencis so that bootstrap and configure command are not run for each rebuild --- pkg/openthread/Makefile | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/pkg/openthread/Makefile b/pkg/openthread/Makefile index e9d7cd9e44..1c09a8c1fd 100644 --- a/pkg/openthread/Makefile +++ b/pkg/openthread/Makefile @@ -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