From e7912ce2a6373ac4b14ffa4163774a423cbbd728 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 17 Aug 2020 14:32:15 +0200 Subject: [PATCH] pkg/cmsis-nn: use modules to compile package --- pkg/cmsis-nn/Makefile | 17 +++++++++++--- pkg/cmsis-nn/Makefile.cmsis-nn | 41 ++-------------------------------- pkg/cmsis-nn/Makefile.dep | 7 ++++++ pkg/cmsis-nn/Makefile.include | 3 +++ 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/pkg/cmsis-nn/Makefile b/pkg/cmsis-nn/Makefile index 1907e11813..36ac9da177 100644 --- a/pkg/cmsis-nn/Makefile +++ b/pkg/cmsis-nn/Makefile @@ -2,9 +2,20 @@ PKG_NAME=cmsis-nn PKG_URL=https://github.com/ARM-software/CMSIS_5 PKG_VERSION=5.6.0 PKG_LICENSE=Apache-2.0 -CFLAGS += -Wno-strict-aliasing -Wno-unused-parameter include $(RIOTBASE)/pkg/pkg.mk -all: - "$(MAKE)" -C $(PKG_SOURCE_DIR) -f $(CURDIR)/Makefile.$(PKG_NAME) +CMSIS_NN_MODULES = \ + cmsis-nn_ActivationFunctions \ + cmsis-nn_ConvolutionFunctions \ + cmsis-nn_FullyConnectedFunctions \ + cmsis-nn_NNSupportFunctions \ + cmsis-nn_PoolingFunctions \ + cmsis-nn_SoftmaxFunctions \ + +.PHONY: cmsis-nn_% + +all: $(CMSIS_NN_MODULES) + +cmsis-nn_%: + $(MAKE) -C $(PKG_SOURCE_DIR)/CMSIS/NN/Source/$* -f $(CURDIR)/Makefile.cmsis-nn MODULE=$@ diff --git a/pkg/cmsis-nn/Makefile.cmsis-nn b/pkg/cmsis-nn/Makefile.cmsis-nn index fd72e0f10a..6ff9b74a53 100644 --- a/pkg/cmsis-nn/Makefile.cmsis-nn +++ b/pkg/cmsis-nn/Makefile.cmsis-nn @@ -1,42 +1,5 @@ -PKG_NAME=cmsis-nn - -# A list of all the directories to build for CMSIS-NN -CMSIS_DIRS += \ - CMSIS/NN/Source/ActivationFunctions \ - CMSIS/NN/Source/BasicMathFunctions \ - CMSIS/NN/Source/ConcatenationFunctions \ - CMSIS/NN/Source/ConvolutionFunctions \ - CMSIS/NN/Source/FullyConnectedFunctions \ - CMSIS/NN/Source/NNSupportFunctions \ - CMSIS/NN/Source/PoolingFunctions \ - CMSIS/NN/Source/ReshapeFunctions \ - CMSIS/NN/Source/SoftmaxFunctions \ -# - -INCLUDES += -I$(CURDIR)/CMSIS/NN/Include -CMSIS_BINDIRS = $(addprefix $(BINDIR)/$(PKG_NAME)/,$(CMSIS_DIRS)) - -# Override default RIOT search path for sources to include all of the CMSIS-NN -# sources in one library instead of one library per subdirectory. -SRC := $(foreach DIR,$(CMSIS_DIRS),$(wildcard $(DIR)/*.c)) -SRCXX := $(foreach DIR,$(CMSIS_DIRS),$(wildcard $(DIR)/*.cpp)) -ASMSRC := $(foreach DIR,$(CMSIS_DIRS),$(wildcard $(DIR)/*.s)) -ASSMSRC := $(foreach DIR,$(CMSIS_DIRS),$(wildcard $(DIR)/*.S)) - -OBJC := $(SRC:%.c=$(BINDIR)/$(PKG_NAME)/%.o) -OBJCXX := $(SRCXX:%.cpp=$(BINDIR)/$(PKG_NAME)/%.o) -ASMOBJ := $(ASMSRC:%.s=$(BINDIR)/$(PKG_NAME)/%.o) -ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)/$(PKG_NAME)/%.o) -OBJ = $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ) - -# Create subdirectories if they do not already exist -$(OBJ): | $(CMSIS_BINDIRS) - -$(CMSIS_BINDIRS): - @mkdir -p $@ - -# Reset the default goal. -.DEFAULT_GOAL := +CFLAGS += -Wno-strict-aliasing +CFLAGS += -Wno-unused-parameter # Include RIOT settings and recipes include $(RIOTBASE)/Makefile.base diff --git a/pkg/cmsis-nn/Makefile.dep b/pkg/cmsis-nn/Makefile.dep index 6eaa9a1f20..e554ad9d10 100644 --- a/pkg/cmsis-nn/Makefile.dep +++ b/pkg/cmsis-nn/Makefile.dep @@ -1 +1,8 @@ FEATURES_REQUIRED += cpu_core_cortexm + +USEMODULE += cmsis-nn_ActivationFunctions +USEMODULE += cmsis-nn_ConvolutionFunctions +USEMODULE += cmsis-nn_FullyConnectedFunctions +USEMODULE += cmsis-nn_NNSupportFunctions +USEMODULE += cmsis-nn_PoolingFunctions +USEMODULE += cmsis-nn_SoftmaxFunctions diff --git a/pkg/cmsis-nn/Makefile.include b/pkg/cmsis-nn/Makefile.include index 24dc9b160d..410b923237 100644 --- a/pkg/cmsis-nn/Makefile.include +++ b/pkg/cmsis-nn/Makefile.include @@ -4,3 +4,6 @@ INCLUDES += -I$(PKGDIRBASE)/cmsis-nn/CMSIS/NN/Include INCLUDES += -I$(PKGDIRBASE)/cmsis-nn/CMSIS/DSP/Include CFLAGS += -Wno-sign-compare + +# cmsis-nn module is not a concrete module, so declare it as a pseudomodule +PSEUDOMODULES += cmsis-nn