2
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
26
ifeq (,$(_MAKEBASE_GMK))
27
$(error You must include MakeBase.gmk prior to including CopyFiles.gmk)
30
################################################################################
32
# Code for handling the SetupCopyFiles macro.
34
################################################################################
37
# Helper macro for SetupCopyFiles
40
# 3 : Variable to add targets to
41
# 4 : Macro to call for copy operation
42
# 5 : Action text to log
44
$$(call LogInfo, $(strip $5) $$(patsubst $(OUTPUTDIR)/%,%,$$(call DecodeSpace, $$@)))
51
# Returns the value of the first argument
55
# Setup make rules for copying files, with an option to do more complex
56
# processing instead of copying.
58
# Parameter 1 is the name of the rule. This name is used as variable prefix,
59
# and the targets generated are listed in a variable by that name.
61
# The list of all source files is returned in $1_SOURCES.
63
# Remaining parameters are named arguments. These include:
64
# SRC : Source root dir (defaults to dir of first file)
66
# FILES : List of files to copy with absolute paths, or path relative to SRC.
68
# FLATTEN : Set to flatten the directory structure in the DEST dir.
69
# MACRO : Optionally override the default macro used for making the copy.
70
# Default is 'install-file'
71
# NAME_MACRO : Optionally supply a macro that rewrites the target file name
72
# based on the source file name
73
# LOG_ACTION : Optionally specify a different action text for log messages
74
SetupCopyFiles = $(NamedParamsMacroTemplate)
75
define SetupCopyFilesBody
78
$1_MACRO := install-file
81
# Default SRC to the dir of the first file.
83
$1_SRC := $$(dir $$(firstword $$($1_FILES)))
86
ifeq ($$($1_NAME_MACRO), )
87
$1_NAME_MACRO := identity
90
ifeq ($$($1_LOG_ACTION), )
91
$1_LOG_ACTION := Copying
94
# Remove any trailing slash from SRC and DEST
95
$1_SRC := $$(patsubst %/,%,$$($1_SRC))
96
$1_DEST := $$(patsubst %/,%,$$($1_DEST))
98
# Need to wrap arguments in DoubleDollar because of the eval nested inside an
100
$$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
101
$$(eval $$(call AddFileToCopy, \
102
$$(call DoubleDollar, $$($1_SRC)/$$f), \
103
$$(call DoubleDollar, \
104
$$($1_DEST)/$$(call $$(strip $$($1_NAME_MACRO)),$$(if $$($1_FLATTEN),$$(notdir $$f),$$f)) \