makefiles: add common makefile for auto_init modules

This commit is contained in:
Alexandre Abadie 2020-06-07 21:46:49 +02:00
parent d69ef1367b
commit b82c1e8707
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -0,0 +1,16 @@
# Determine the list of modules that provide auto_init from the list of all
# auto_init_xx.c files available in the current directory.
# The rule is to have the file name matching the pattern: auto_init_<module name>.c
AUTO_INIT_PREFIX = auto_init_
AUTO_INIT_SRCS = $(wildcard $(AUTO_INIT_PREFIX)*.c)
AUTO_INIT_MODULES_AVAILABLE = $(subst $(AUTO_INIT_PREFIX),,$(subst .c,,$(AUTO_INIT_SRCS)))
# Compare this list against the modules used in the current build to determine
# which auto_init_xx.c file should be added to the build
AUTO_INIT_MODULES_USED = $(filter $(AUTO_INIT_MODULES_AVAILABLE),$(USEMODULE))
AUTO_INIT_MODULES_USED_SRCS = $(addprefix $(AUTO_INIT_PREFIX),$(addsuffix .c,$(AUTO_INIT_MODULES_USED)))
# Set the list of files to build in the auto_init module
SRC = init.c $(AUTO_INIT_MODULES_USED_SRCS)
include $(RIOTBASE)/Makefile.base