diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 0b530bb8b6b..9373499ace7 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -80,10 +80,15 @@ ifneq ($(MAN_DIR), ) DEPS += $(call CacheFind, $(MAN_DIR)) endif +# If a specific modules_legal dir exists for this module, only pick up files +# from there. These files were explicitly filtered or modified in -copy +# targets. For the rest, just pick up everything from the source legal dirs. LEGAL_NOTICES := \ - $(call uniq, $(SUPPORT_OUTPUTDIR)/modules_legal/java.base \ - $(call FindModuleLegalDirs, $(MODULE))) \ - # + $(SUPPORT_OUTPUTDIR)/modules_legal/common \ + $(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \ + $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \ + $(call FindModuleLegalSrcDirs, $(MODULE)) \ + ) LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES)) DEPS += $(call CacheFind, $(LEGAL_NOTICES)) diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index ec4ec332542..d9e9352e118 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -394,12 +394,11 @@ ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) endif LEGAL_SUBDIRS += share/legal -# Find all legal dirs for a particular module +# Find all legal src dirs for a particular module # $1 - Module to find legal dirs for -FindModuleLegalDirs = \ +FindModuleLegalSrcDirs = \ $(strip $(wildcard \ - $(addsuffix /$(strip $1), $(SUPPORT_OUTPUTDIR)/modules_legal \ - $(IMPORT_MODULES_LEGAL)) \ + $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \ $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \ )) diff --git a/make/copy/Copy-java.base.gmk b/make/copy/Copy-java.base.gmk index 096f6c0e903..6d94bfc16d2 100644 --- a/make/copy/Copy-java.base.gmk +++ b/make/copy/Copy-java.base.gmk @@ -24,6 +24,7 @@ # include CopyCommon.gmk +include Modules.gmk include TextFileProcessing.gmk $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk)) @@ -224,12 +225,27 @@ JDK_ADDITIONAL_LICENSE_INFO ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO) $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \ FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \ - DEST := $(LEGAL_DST_DIR), \ + DEST := $(COMMON_LEGAL_DST_DIR), \ FLATTEN := true, \ )) TARGETS += $(COPY_JDK_NOTICES) +################################################################################ +# +# Copy and filter the legal files depending on what 3rd party components are +# bundled or linked from the OS. +# +ifeq ($(USE_EXTERNAL_LIBZ), true) + LEGAL_EXCLUDES += zlib.md +endif + +$(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \ + EXCLUDES := $(LEGAL_EXCLUDES), \ +)) + +TARGETS += $(COPY_LEGAL) + ################################################################################ # Optionally copy libffi.so.? into the the image diff --git a/make/copy/Copy-java.desktop.gmk b/make/copy/Copy-java.desktop.gmk index b4f28a96a26..a5e1f98302d 100644 --- a/make/copy/Copy-java.desktop.gmk +++ b/make/copy/Copy-java.desktop.gmk @@ -24,6 +24,7 @@ # include CopyCommon.gmk +include Modules.gmk $(eval $(call IncludeCustomExtension, copy/Copy-java.desktop.gmk)) @@ -48,3 +49,34 @@ $(LIB_DST_DIR)/%: $(PSFONTPROPFILE_SRC_DIR)/% TARGETS += $(PSFONTPROPFILE_TARGET_FILES) ################################################################################ +# +# Copy and filter the legal files depending on what 3rd party components are +# bundled or linked from the OS. +# +ifeq ($(USE_EXTERNAL_LIBJPEG), true) + LEGAL_EXCLUDES += jpeg.md +endif + +ifeq ($(USE_EXTERNAL_LIBGIF), true) + LEGAL_EXCLUDES += giflib.md +endif + +ifeq ($(USE_EXTERNAL_LIBPNG), true) + LEGAL_EXCLUDES += libpng.md +endif + +ifeq ($(USE_EXTERNAL_LCMS), true) + LEGAL_EXCLUDES += lcms.md +endif + +ifeq ($(FREETYPE_TO_USE), system) + LEGAL_EXCLUDES += freetype.md +endif + +$(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \ + EXCLUDES := $(LEGAL_EXCLUDES), \ +)) + +TARGETS += $(COPY_LEGAL) + +################################################################################ diff --git a/make/copy/CopyCommon.gmk b/make/copy/CopyCommon.gmk index 6d4cdbaf747..60ae6b3b214 100644 --- a/make/copy/CopyCommon.gmk +++ b/make/copy/CopyCommon.gmk @@ -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 @@ ifneq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), ) 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