--- old/make/copy/CopyCommon.gmk 2018-04-05 17:49:00.025107772 +0200 +++ new/make/copy/CopyCommon.gmk 2018-04-05 17:48:59.517090010 +0200 @@ -26,6 +26,7 @@ LIB_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) CONF_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE) LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE) +COMMON_LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/common ################################################################################ # @@ -60,3 +61,23 @@ TARGETS += $(COPY_EXPORTED_INCLUDE_OS) endif + +################################################################################ +# Setup make rules for copying legal files. This is only needed if the files +# need to be filtered due to optional components being enabled/disabled. +# Otherwise CreateJmods.gmk will find the legal files in the original src dirs. +# +# Parameter 1 is the name of the rule. +# +# Remaining parameters are named arguments. These include: +# EXCLUDES : List of filenames to exclude from copy +SetupCopyLegalFiles = $(NamedParamsMacroTemplate) +define SetupCopyLegalFilesBody + $$(eval $$(call SetupCopyFiles, $1, \ + SRC := $$(CUSTOM_ROOT), \ + DEST := $$(LEGAL_DST_DIR), \ + FILES := $$(filter-out $$(addprefix %/, $$($1_EXCLUDES)), \ + $$(wildcard $$(addsuffix /*, $$(call FindModuleLegalSrcDirs, $$(MODULE))))), \ + FLATTEN := true, \ + )) +endef