2012-04-10 15:18:28 +00:00
|
|
|
#
|
2015-02-27 10:56:57 +00:00
|
|
|
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
2012-04-10 15:18:28 +00:00
|
|
|
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
#
|
|
|
|
# This code is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License version 2 only, as
|
|
|
|
# published by the Free Software Foundation. Oracle designates this
|
|
|
|
# particular file as subject to the "Classpath" exception as provided
|
|
|
|
# by Oracle in the LICENSE file that accompanied this code.
|
|
|
|
#
|
|
|
|
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
# accompanied this code).
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License version
|
|
|
|
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
# or visit www.oracle.com if you need additional information or have any
|
|
|
|
# questions.
|
|
|
|
#
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
#
|
|
|
|
# Setup common utility functions.
|
|
|
|
#
|
|
|
|
################################################################
|
|
|
|
|
|
|
|
ifndef _MAKEBASE_GMK
|
|
|
|
_MAKEBASE_GMK := 1
|
|
|
|
|
2015-03-26 15:17:30 +00:00
|
|
|
ifeq ($(wildcard $(SPEC)),)
|
|
|
|
$(error MakeBase.gmk needs SPEC set to a proper spec.gmk)
|
|
|
|
endif
|
|
|
|
|
2015-04-16 10:39:43 +00:00
|
|
|
# By defining this pseudo target, make will automatically remove targets
|
|
|
|
# if their recipe fails so that a rebuild is automatically triggered on the
|
|
|
|
# next make invocation.
|
|
|
|
.DELETE_ON_ERROR:
|
2015-03-26 15:17:30 +00:00
|
|
|
|
|
|
|
##############################
|
|
|
|
# Functions
|
|
|
|
##############################
|
|
|
|
|
2015-05-06 09:15:27 +00:00
|
|
|
### Debug functions
|
|
|
|
|
|
|
|
# Prints the name and value of a variable
|
|
|
|
PrintVar = \
|
|
|
|
$(info $(strip $1) >$($(strip $1))<)
|
2015-03-26 15:17:30 +00:00
|
|
|
|
|
|
|
### Functions for timers
|
|
|
|
|
|
|
|
# Store the build times in this directory.
|
|
|
|
BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
|
|
|
|
|
|
|
|
# Record starting time for build of a sub repository.
|
|
|
|
define RecordStartTime
|
|
|
|
$(MKDIR) -p $(BUILDTIMESDIR)
|
|
|
|
$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)
|
|
|
|
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Record ending time and calculate the difference and store it in a
|
|
|
|
# easy to read format. Handles builds that cross midnight. Expects
|
|
|
|
# that a build will never take 24 hours or more.
|
|
|
|
define RecordEndTime
|
|
|
|
$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)
|
|
|
|
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
|
|
|
|
$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \
|
|
|
|
$(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
|
|
|
|
M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
|
|
|
|
> $(BUILDTIMESDIR)/build_time_diff_$(strip $1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Hook to be called when starting to execute a top-level target
|
|
|
|
define TargetEnter
|
|
|
|
$(PRINTF) "## Starting $(patsubst %-only,%,$@)\n"
|
|
|
|
$(call RecordStartTime,$(patsubst %-only,%,$@))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Hook to be called when finish executing a top-level target
|
|
|
|
define TargetExit
|
|
|
|
$(call RecordEndTime,$(patsubst %-only,%,$@))
|
|
|
|
$(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \
|
|
|
|
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`"
|
|
|
|
endef
|
|
|
|
|
2014-08-17 14:51:37 +00:00
|
|
|
################################################################################
|
|
|
|
# This macro translates $ into \$ to protect the $ from expansion in the shell.
|
|
|
|
# To make this macro resilient against already escaped strings, first remove
|
|
|
|
# any present escapes before escaping so that no double escapes are added.
|
|
|
|
EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# This macro translates $ into $$ to protect the string from make itself.
|
|
|
|
DoubleDollar = $(subst $$,$$$$,$(strip $1))
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2012-04-10 15:18:28 +00:00
|
|
|
# If the variable that you want to send to stdout for piping into a file or otherwise,
|
|
|
|
# is potentially long, for example the a list of file paths, eg a list of all package directories.
|
|
|
|
# Then you need to use ListPathsSafely, which optimistically splits the output into several shell
|
|
|
|
# calls as well as use compression on recurrent file paths segments, to get around the potential
|
|
|
|
# command line length problem that exists in cygwin and other shells.
|
2013-11-14 09:53:23 +00:00
|
|
|
compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl))
|
|
|
|
compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl))
|
2012-04-10 15:18:28 +00:00
|
|
|
compress_paths=$(compress_pre)\
|
|
|
|
$(subst $(SRC_ROOT),X97,\
|
|
|
|
$(subst $(OUTPUT_ROOT),X98,\
|
|
|
|
$(subst X,X00,\
|
|
|
|
$(subst $(SPACE),\n,$(strip $1)))))\
|
|
|
|
$(compress_post)
|
|
|
|
|
2013-11-14 09:53:23 +00:00
|
|
|
decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \
|
2013-10-10 12:58:19 +00:00
|
|
|
-e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
|
|
|
|
-e 's|X00|X|g' | tr '\n' '$2'
|
2012-04-10 15:18:28 +00:00
|
|
|
|
|
|
|
define ListPathsSafely_If
|
2013-10-10 12:58:19 +00:00
|
|
|
$(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1)))))
|
2012-04-10 15:18:28 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define ListPathsSafely_Printf
|
2013-10-14 09:54:17 +00:00
|
|
|
$(if $(strip $($1_LPS$4)),$(if $(findstring $(LOG_LEVEL),trace),,@)printf \
|
2014-08-17 14:51:37 +00:00
|
|
|
-- "$(strip $(call EscapeDollar, $($1_LPS$4)))\n" | $(decompress_paths) $3)
|
2012-04-10 15:18:28 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Receipt example:
|
2013-10-10 12:58:19 +00:00
|
|
|
# rm -f thepaths
|
|
|
|
# $(call ListPathsSafely,THEPATHS,\n, >> thepaths)
|
|
|
|
# The \n argument means translate spaces into \n
|
|
|
|
# if instead , , (a space) is supplied, then spaces remain spaces.
|
2012-04-10 15:18:28 +00:00
|
|
|
define ListPathsSafely
|
2013-10-10 12:58:19 +00:00
|
|
|
$(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!))
|
2013-10-14 09:54:17 +00:00
|
|
|
$(ECHO) $(LOG_DEBUG) Writing $(words $($1)) paths to '$3'
|
2013-10-10 12:58:19 +00:00
|
|
|
$(call ListPathsSafely_If,$1,$2,1,250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,251,500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,501,750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,751,1000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,1001,1250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,1251,1500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,1501,1750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,1751,2000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,2001,2250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,2251,2500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,2501,2750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,2751,3000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,3001,3250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,3251,3500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,3501,3750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,3751,4000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,4001,4250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,4251,4500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,4501,4750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,4751,5000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,5001,5250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,5251,5500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,5501,5750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,5751,6000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,6001,6250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,6251,6500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,6501,6750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,6751,7000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,7001,7250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,7251,7500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,7501,7750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,7751,8000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,8001,8250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,8251,8500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,8501,8750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,8751,9000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,9001,9250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,9251,9500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,9501,9750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,9751,10000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,10001,10250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,10251,10500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,10501,10750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,10751,11000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,11001,11250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,11251,11500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,11501,11750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,11751,12000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,12001,12250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,12251,12500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,12501,12750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,12751,13000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,13001,13250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,13251,13500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,13501,13750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,13751,14000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,14001,14250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,14251,14500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,14501,14750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,14751,15000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_If,$1,$2,15001,15250)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,15251,15500)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,15501,15750)
|
|
|
|
$(call ListPathsSafely_If,$1,$2,15751,16000)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,1)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,1001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,1251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,1501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,1751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,2001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,2251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,2501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,2751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,3001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,3251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,3501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,3751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,4001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,4251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,4501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,4751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,5001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,5251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,5501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,5751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,6001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,6251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,6501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,6751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,7001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,7251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,7501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,7751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,8001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,8251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,8501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,8751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,9001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,9251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,9501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,9751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,10001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,10251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,10501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,10751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,11001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,11251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,11501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,11751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,12001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,12251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,12501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,12751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,13001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,13251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,13501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,13751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,14001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,14251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,14501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,14751)
|
|
|
|
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,15001)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,15251)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,15501)
|
|
|
|
$(call ListPathsSafely_Printf,$1,$2,$3,15751)
|
2012-04-10 15:18:28 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define ListPathsSafelyNow_IfPrintf
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$(word $4,$$($1)))
|
|
|
|
$$(eval $1_LPS$4:=$$(call compress_paths,$$(wordlist $4,$5,$$($1))))
|
|
|
|
$$(shell printf -- "$$(strip $$($1_LPS$4))\n" | $(decompress_paths) $3)
|
|
|
|
endif
|
2012-04-10 15:18:28 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# And an non-receipt version:
|
|
|
|
define ListPathsSafelyNow
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$(word 10001,$$($1)))
|
|
|
|
$$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!)
|
|
|
|
endif
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1,250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,251,500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,501,750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,751,1000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1001,1250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1251,1500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1501,1750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1751,2000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2001,2250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2251,2500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2501,2750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2751,3000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3001,3250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3251,3500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3501,3750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3751,4000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4001,4250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4251,4500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4501,4750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4751,5000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5001,5250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5251,5500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5501,5750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5751,6000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6001,6250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6251,6500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6501,6750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6751,7000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7001,7250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7251,7500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7501,7750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7751,8000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8001,8250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8251,8500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8501,8750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8751,9000)
|
|
|
|
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9001,9250)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9251,9500)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9501,9750)
|
|
|
|
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9751,10000)
|
2012-04-10 15:18:28 +00:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2012-06-08 03:25:06 +00:00
|
|
|
# The source tips can come from the Mercurial repository, or in the files
|
2013-10-10 12:58:19 +00:00
|
|
|
# $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
|
|
|
|
# directory as the original $(HGDIR) directory.
|
|
|
|
# These should not be := assignments, only used from the root Makefile.
|
2012-06-08 03:25:06 +00:00
|
|
|
HG_VERSION = $(shell $(HG) version 2> /dev/null)
|
|
|
|
HG_DIRECTORY=.hg
|
|
|
|
HGTIP_FILENAME=.hgtip
|
|
|
|
HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
|
|
|
|
REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
|
2015-06-23 13:11:56 +00:00
|
|
|
$(shell $(CD) $(SRC_ROOT) ; \
|
|
|
|
$(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) \
|
|
|
|
$(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) \
|
2013-10-10 12:58:19 +00:00
|
|
|
2> /dev/null)))))
|
2012-06-08 03:25:06 +00:00
|
|
|
|
|
|
|
# Emit the repo:tip pairs to $@
|
|
|
|
define GetSourceTips
|
2013-10-10 12:58:19 +00:00
|
|
|
$(CD) $(SRC_ROOT) ; \
|
|
|
|
for i in $(REPO_LIST) IGNORE ; do \
|
|
|
|
if [ "$${i}" = "IGNORE" ] ; then \
|
|
|
|
continue; \
|
|
|
|
elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
|
|
|
|
$(PRINTF) " %s:%s" \
|
|
|
|
"$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
|
|
|
|
elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
|
|
|
|
$(PRINTF) " %s:%s" \
|
|
|
|
"$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
|
|
|
|
fi; \
|
|
|
|
done >> $@
|
|
|
|
$(PRINTF) "\n" >> $@
|
2012-06-08 03:25:06 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Create the HGTIP_FILENAME file. Called from jdk/make/closed/bundles.gmk
|
|
|
|
define CreateHgTip
|
2013-10-10 12:58:19 +00:00
|
|
|
$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
|
|
|
|
$(ECHO) $1/$(HGTIP_FILENAME)
|
2012-06-08 03:25:06 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define SetupLogging
|
2015-03-26 15:17:30 +00:00
|
|
|
ifeq ($$(LOG_LEVEL), trace)
|
2013-10-10 12:58:19 +00:00
|
|
|
# Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
|
|
|
|
# For each target executed, will print
|
|
|
|
# Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer)
|
|
|
|
# but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much
|
|
|
|
# (and causing a crash on Cygwin).
|
|
|
|
# Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris.
|
|
|
|
# Only use time if it's GNU time which supports format and output file.
|
2015-03-26 15:17:30 +00:00
|
|
|
WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL)
|
|
|
|
SHELL := $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
# Never remove warning messages; this is just for completeness
|
2015-03-26 15:17:30 +00:00
|
|
|
LOG_WARN :=
|
|
|
|
ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),)
|
|
|
|
LOG_INFO :=
|
2013-10-10 12:58:19 +00:00
|
|
|
else
|
2015-03-26 15:17:30 +00:00
|
|
|
LOG_INFO := > /dev/null
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2015-03-26 15:17:30 +00:00
|
|
|
ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
|
|
|
|
LOG_DEBUG :=
|
2013-10-10 12:58:19 +00:00
|
|
|
else
|
2015-03-26 15:17:30 +00:00
|
|
|
LOG_DEBUG := > /dev/null
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2015-03-26 15:17:30 +00:00
|
|
|
ifneq ($$(findstring $$(LOG_LEVEL), trace),)
|
|
|
|
LOG_TRACE :=
|
2013-10-10 12:58:19 +00:00
|
|
|
else
|
2015-03-26 15:17:30 +00:00
|
|
|
LOG_TRACE := > /dev/null
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2012-06-08 03:25:06 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Make sure logging is setup for everyone that includes MakeBase.gmk.
|
|
|
|
$(eval $(call SetupLogging))
|
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
################################################################################
|
|
|
|
# Creates a sequence of increasing numbers (inclusive).
|
|
|
|
# Param 1 - starting number
|
|
|
|
# Param 2 - ending number
|
|
|
|
sequence = \
|
|
|
|
$(wordlist $1, $2, $(strip \
|
|
|
|
$(eval SEQUENCE_COUNT :=) \
|
|
|
|
$(call _sequence-do,$(strip $2))))
|
|
|
|
|
|
|
|
_sequence-do = \
|
|
|
|
$(if $(word $1, $(SEQUENCE_COUNT)),, \
|
|
|
|
$(eval SEQUENCE_COUNT += .) \
|
|
|
|
$(words $(SEQUENCE_COUNT)) \
|
|
|
|
$(call _sequence-do,$1))
|
|
|
|
|
|
|
|
################################################################################
|
2012-10-26 21:29:57 +00:00
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
MAX_PARAMS := 30
|
|
|
|
PARAM_SEQUENCE := $(call sequence, 2, $(MAX_PARAMS))
|
|
|
|
|
|
|
|
# Template for creating a macro taking named parameters. To use it, assign the
|
|
|
|
# template to a variable with the name you want for your macro, using '='
|
|
|
|
# assignment. Then define a macro body with the suffix "Body". The Body macro
|
|
|
|
# should take 1 parameter which should be a unique string for that invocation
|
|
|
|
# of the macro.
|
|
|
|
# Ex:
|
|
|
|
# SetupFoo = $(NamedParamsMacroTemplate)
|
|
|
|
# define SetupFooBody
|
|
|
|
# # do something
|
|
|
|
# # access parameters as $$($1_BAR)
|
|
|
|
# endef
|
|
|
|
# Call it like this
|
|
|
|
# $(eval $(call SetupFoo, BUILD_SOMETHING, \
|
|
|
|
# BAR := some parameter value, \
|
|
|
|
# ))
|
|
|
|
define NamedParamsMacroTemplate
|
|
|
|
$(if $($(MAX_PARAMS)),$(error Internal makefile error: \
|
|
|
|
Too many named arguments to macro, please update MAX_PARAMS in MakeBase.gmk))
|
|
|
|
# Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix
|
|
|
|
$(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\
|
|
|
|
$(strip $1)_$(strip $($i)))$(NEWLINE))
|
|
|
|
# Debug print all named parameter names and values
|
|
|
|
$(if $(findstring $(LOG_LEVEL),debug trace), \
|
|
|
|
$(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \
|
|
|
|
$(if $(strip $($i)),$(NEWLINE) $(strip [$i] $(if $(filter $(LOG_LEVEL), trace), \
|
|
|
|
$($i), $(wordlist 1, 20, $($(i))) $(if $(word 21, $($(i))), ...)))))))
|
|
|
|
|
|
|
|
$(if $(DEBUG_$(strip $1)),
|
|
|
|
$(info -------- <<< Begin expansion of $(strip $1)) \
|
|
|
|
$(info $(call $(0)Body,$(strip $1))) \
|
|
|
|
$(info -------- >>> End expansion of $(strip $1)) \
|
2014-11-26 13:59:10 +00:00
|
|
|
)
|
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
$(call $(0)Body,$(strip $1))
|
2014-11-26 13:59:10 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
################################################################################
|
2012-10-26 21:29:57 +00:00
|
|
|
# Make directory without forking mkdir if not needed
|
2015-01-26 09:28:53 +00:00
|
|
|
MakeDir = \
|
|
|
|
$(strip $(if $(subst $(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),,$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9)),\
|
|
|
|
$(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)))
|
2012-10-26 21:29:57 +00:00
|
|
|
|
2015-04-17 11:54:50 +00:00
|
|
|
################################################################################
|
|
|
|
# Assign a variable only if it is empty
|
|
|
|
# Param 1 - Variable to assign
|
|
|
|
# Param 2 - Value to assign
|
|
|
|
SetIfEmpty = \
|
|
|
|
$(if $($(strip $1)),,$(eval $(strip $1) := $2))
|
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
################################################################################
|
|
|
|
|
2012-10-26 21:29:57 +00:00
|
|
|
ifeq ($(OPENJDK_TARGET_OS),solaris)
|
2013-10-10 12:58:19 +00:00
|
|
|
# On Solaris, if the target is a symlink and exists, cp won't overwrite.
|
|
|
|
# Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the
|
|
|
|
# name of the target file differs from the source file, rename after copy.
|
2014-03-11 11:04:50 +00:00
|
|
|
# If the source and target parent directories are the same, recursive copy doesn't work
|
|
|
|
# so we fall back on regular copy, which isn't preserving symlinks.
|
2013-10-10 12:58:19 +00:00
|
|
|
define install-file
|
2014-11-27 14:41:56 +00:00
|
|
|
$(MKDIR) -p '$(@D)'
|
2012-10-26 21:29:57 +00:00
|
|
|
$(RM) '$@'
|
2014-03-11 11:04:50 +00:00
|
|
|
if [ "$(@D)" != "$(<D)" ]; then \
|
|
|
|
$(CP) -f -r -P '$<' '$(@D)'; \
|
|
|
|
if [ "$(@F)" != "$(<F)" ]; then \
|
|
|
|
$(MV) '$(@D)/$(<F)' '$@'; \
|
|
|
|
fi; \
|
|
|
|
else \
|
|
|
|
if [ -L '$<' ]; then \
|
|
|
|
$(ECHO) "Source file is a symlink and target is in the same directory: $< $@" ; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
|
|
|
$(CP) -f '$<' '$@'; \
|
|
|
|
fi
|
2013-10-10 12:58:19 +00:00
|
|
|
endef
|
2012-10-26 21:29:57 +00:00
|
|
|
else ifeq ($(OPENJDK_TARGET_OS),macosx)
|
2013-10-10 12:58:19 +00:00
|
|
|
# On mac, extended attributes sometimes creep into the source files, which may later
|
|
|
|
# cause the creation of ._* files which confuses testing. Clear these with xattr if
|
|
|
|
# set. Some files get their write permissions removed after being copied to the
|
|
|
|
# output dir. When these are copied again to images, xattr would fail. By only clearing
|
|
|
|
# attributes when they are present, failing on this is avoided.
|
|
|
|
define install-file
|
2014-11-27 14:41:56 +00:00
|
|
|
$(MKDIR) -p '$(@D)'
|
2013-04-05 07:38:54 +00:00
|
|
|
$(CP) -fRP '$<' '$@'
|
|
|
|
if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
|
2013-10-10 12:58:19 +00:00
|
|
|
endef
|
2012-10-26 21:29:57 +00:00
|
|
|
else
|
2014-08-17 14:51:37 +00:00
|
|
|
# Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
|
|
|
|
# significantly.
|
2013-10-10 12:58:19 +00:00
|
|
|
define install-file
|
2014-11-27 14:41:56 +00:00
|
|
|
$(MKDIR) -p '$(@D)' && $(CP) -fP '$<' '$@'
|
2013-10-10 12:58:19 +00:00
|
|
|
endef
|
2012-10-26 21:29:57 +00:00
|
|
|
endif
|
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
################################################################################
|
2012-12-27 19:18:21 +00:00
|
|
|
# Convenience functions for working around make's limitations with $(filter ).
|
2015-02-27 10:56:57 +00:00
|
|
|
containing = \
|
|
|
|
$(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),$v)))
|
|
|
|
not-containing = \
|
|
|
|
$(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),,$v)))
|
2014-08-17 14:51:37 +00:00
|
|
|
|
|
|
|
# Filter out duplicate sub strings while preserving order. Keeps the first occurance.
|
2015-02-27 10:56:57 +00:00
|
|
|
uniq = \
|
|
|
|
$(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
|
|
|
|
|
|
|
# Return a list of all string elements that are duplicated in $1.
|
|
|
|
dups = \
|
|
|
|
$(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \
|
|
|
|
$(words $(filter $v, $1))), $v)))
|
2012-12-27 19:18:21 +00:00
|
|
|
|
2015-01-26 09:28:53 +00:00
|
|
|
# String equals
|
2015-01-28 13:04:05 +00:00
|
|
|
equals = \
|
|
|
|
$(and $(findstring $(strip $1),$(strip $2)),\
|
|
|
|
$(findstring $(strip $2),$(strip $1)))
|
2015-01-26 09:28:53 +00:00
|
|
|
|
2015-05-06 09:15:27 +00:00
|
|
|
# Remove a whole list of prefixes
|
|
|
|
# $1 - List of prefixes
|
|
|
|
# $2 - List of elements to process
|
|
|
|
remove-prefixes = \
|
|
|
|
$(strip $(if $1,$(patsubst $(firstword $1)%,%,\
|
|
|
|
$(call remove-prefixes,$(filter-out $(firstword $1),$1),$2)),$2))
|
|
|
|
|
2015-03-12 11:13:23 +00:00
|
|
|
################################################################################
|
|
|
|
|
2014-03-14 11:31:08 +00:00
|
|
|
ifneq ($(DISABLE_CACHE_FIND), true)
|
2014-04-22 19:55:56 +00:00
|
|
|
# In Cygwin, finds are very costly, both because of expensive forks and because
|
|
|
|
# of bad file system caching. Find is used extensively in $(shell) commands to
|
|
|
|
# find source files. This makes rerunning make with no or few changes rather
|
|
|
|
# expensive. To speed this up, these two macros are used to cache the results
|
|
|
|
# of simple find commands for reuse.
|
|
|
|
#
|
|
|
|
# Runs a find and stores both the directories where it was run and the results.
|
|
|
|
# This macro can be called multiple times to add to the cache. Only finds files
|
|
|
|
# with no filters.
|
|
|
|
#
|
|
|
|
# Needs to be called with $(eval )
|
|
|
|
#
|
2014-03-14 11:31:08 +00:00
|
|
|
# Even if the performance benifit is negligible on other platforms, keep the
|
|
|
|
# functionality active unless explicitly disabled to exercise it more.
|
|
|
|
#
|
|
|
|
# Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable
|
|
|
|
FIND_CACHE_DIRS :=
|
2014-04-22 19:55:56 +00:00
|
|
|
# Param 1 - Dirs to find in
|
|
|
|
# Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
|
2013-10-10 12:58:19 +00:00
|
|
|
define FillCacheFind
|
2014-04-22 19:55:56 +00:00
|
|
|
# Filter out already cached dirs. The - is needed when FIND_CACHE_DIRS is empty
|
2014-03-14 11:31:08 +00:00
|
|
|
# since filter out will then return empty.
|
|
|
|
FIND_CACHE_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
|
|
|
|
- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS), $1)
|
|
|
|
ifneq ($$(FIND_CACHE_NEW_DIRS), )
|
|
|
|
# Remove any trailing slash from dirs in the cache dir list
|
|
|
|
FIND_CACHE_DIRS += $$(patsubst %/,%, $$(FIND_CACHE_NEW_DIRS))
|
2014-04-22 19:55:56 +00:00
|
|
|
FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $$(FIND_CACHE_NEW_DIRS) \( -type f -o -type l \) $2))
|
2014-03-14 11:31:08 +00:00
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
endef
|
2012-12-27 19:18:21 +00:00
|
|
|
|
2014-04-22 19:55:56 +00:00
|
|
|
# Mimics find by looking in the cache if all of the directories have been cached.
|
|
|
|
# Otherwise reverts to shell find. This is safe to call on all platforms, even if
|
|
|
|
# cache is deactivated.
|
|
|
|
#
|
2014-08-17 14:51:37 +00:00
|
|
|
# $1 can be either a directory or a file. If it's a directory, make
|
|
|
|
# sure we have exactly one trailing slash before the wildcard.
|
2014-04-22 19:55:56 +00:00
|
|
|
# The extra - is needed when FIND_CACHE_DIRS is empty but should be harmless.
|
|
|
|
#
|
|
|
|
# Param 1 - Dirs to find in
|
|
|
|
# Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
|
|
|
|
define CacheFind
|
2014-03-14 11:31:08 +00:00
|
|
|
$(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \
|
2014-04-22 19:55:56 +00:00
|
|
|
$(shell $(FIND) $1 \( -type f -o -type l \) $2), \
|
2014-08-17 14:51:37 +00:00
|
|
|
$(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE)))
|
2014-04-22 19:55:56 +00:00
|
|
|
endef
|
2014-08-17 14:51:37 +00:00
|
|
|
|
2014-03-14 11:31:08 +00:00
|
|
|
else
|
|
|
|
# If CacheFind is disabled, just run the find command.
|
2014-04-22 19:55:56 +00:00
|
|
|
# Param 1 - Dirs to find in
|
|
|
|
# Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
|
2014-03-14 11:31:08 +00:00
|
|
|
define CacheFind
|
2014-04-22 19:55:56 +00:00
|
|
|
$(shell $(FIND) $1 \( -type f -o -type l \) $2)
|
2014-03-14 11:31:08 +00:00
|
|
|
endef
|
|
|
|
endif
|
2012-12-27 19:18:21 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2014-08-17 14:51:37 +00:00
|
|
|
define AddFileToCopy
|
|
|
|
# Helper macro for SetupCopyFiles
|
|
|
|
# 1 : Source file
|
|
|
|
# 2 : Dest file
|
|
|
|
# 3 : Variable to add targets to
|
|
|
|
# 4 : Macro to call for copy operation
|
|
|
|
$2: $1
|
|
|
|
$(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@)
|
|
|
|
$$($$(strip $4))
|
|
|
|
|
|
|
|
$3 += $2
|
|
|
|
endef
|
|
|
|
|
2015-01-16 15:02:09 +00:00
|
|
|
# Setup make rules for copying files, with an option to do more complex
|
|
|
|
# processing instead of copying.
|
|
|
|
#
|
|
|
|
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
|
|
|
# and the targets generated are listed in a variable by that name.
|
|
|
|
#
|
|
|
|
# Remaining parameters are named arguments. These include:
|
|
|
|
# SRC : Source root dir (defaults to dir of first file)
|
|
|
|
# DEST : Dest root dir
|
|
|
|
# FILES : List of files to copy with absolute paths, or path relative to SRC.
|
|
|
|
# Must be in SRC.
|
|
|
|
# FLATTEN : Set to flatten the directory structure in the DEST dir.
|
|
|
|
# MACRO : Optionally override the default macro used for making the copy.
|
|
|
|
# Default is 'install-file'
|
2015-03-12 11:13:23 +00:00
|
|
|
SetupCopyFiles = $(NamedParamsMacroTemplate)
|
|
|
|
define SetupCopyFilesBody
|
2014-08-17 14:51:37 +00:00
|
|
|
|
|
|
|
ifeq ($$($1_MACRO), )
|
|
|
|
$1_MACRO := install-file
|
|
|
|
endif
|
|
|
|
|
2015-01-15 15:36:24 +00:00
|
|
|
# Default SRC to the dir of the first file.
|
|
|
|
ifeq ($$($1_SRC), )
|
|
|
|
$1_SRC := $$(dir $$(firstword $$($1_FILES)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Remove any trailing slash from SRC
|
|
|
|
$1_SRC := $$(patsubst %/,%,$$($1_SRC))
|
|
|
|
|
2014-08-17 14:51:37 +00:00
|
|
|
$$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
|
|
|
|
$$(eval $$(call AddFileToCopy, $$($1_SRC)/$$f, \
|
|
|
|
$$($1_DEST)/$$(if $$($1_FLATTEN),$$(notdir $$f),$$f), $1, $$($1_MACRO))))
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2015-01-26 09:28:53 +00:00
|
|
|
################################################################################
|
|
|
|
# ShellQuote
|
|
|
|
#
|
2015-02-27 10:56:57 +00:00
|
|
|
# Quotes a string with single quotes and replaces single quotes with '\'' so
|
2015-01-26 09:28:53 +00:00
|
|
|
# that the contents survives being given to the shell.
|
|
|
|
|
|
|
|
ShellQuote = \
|
|
|
|
$(SQUOTE)$(subst $(SQUOTE),$(SQUOTE)\$(SQUOTE)$(SQUOTE),$(strip $1))$(SQUOTE)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Write to and read from file
|
|
|
|
|
|
|
|
# Param 1 - File to read
|
|
|
|
ReadFile = \
|
|
|
|
$(shell $(CAT) $1)
|
|
|
|
|
|
|
|
# Param 1 - Text to write
|
|
|
|
# Param 2 - File to write to
|
|
|
|
# Use printf to get consistent behavior on all platforms.
|
|
|
|
WriteFile = \
|
|
|
|
$(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# DependOnVariable
|
|
|
|
#
|
2015-02-27 10:56:57 +00:00
|
|
|
# This macro takes a variable name and puts the value in a file only if the
|
|
|
|
# value has changed since last. The name of the file is returned. This can be
|
2015-01-26 09:28:53 +00:00
|
|
|
# used to create rule dependencies on make variable values. The following
|
|
|
|
# example would get rebuilt if the value of SOME_VAR was changed:
|
|
|
|
#
|
|
|
|
# path/to/some-file: $(call DependOnVariable, SOME_VAR)
|
|
|
|
# echo $(SOME_VAR) > $@
|
|
|
|
#
|
|
|
|
# Note that leading and trailing white space in the value is ignored.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Defines the sub directory structure to store variable value file in
|
|
|
|
DependOnVariableDirName = \
|
|
|
|
$(strip $(subst $(SRC_ROOT)/,,\
|
|
|
|
$(if $(filter /%, $(firstword $(MAKEFILE_LIST))), \
|
|
|
|
$(firstword $(MAKEFILE_LIST)), \
|
|
|
|
$(CURDIR)/$(firstword $(MAKEFILE_LIST)))))
|
|
|
|
|
|
|
|
# Defines the name of the file to store variable value in. Generates a name
|
|
|
|
# unless parameter 2 is given.
|
|
|
|
# Param 1 - Name of variable
|
|
|
|
# Param 2 - (optional) name of file to store value in
|
|
|
|
DependOnVariableFileName = \
|
|
|
|
$(strip $(if $(strip $2), $2, \
|
|
|
|
$(MAKESUPPORT_OUTPUTDIR)/vardeps/$(DependOnVariableDirName)/$(strip $1).vardeps))
|
|
|
|
|
|
|
|
# Does the actual work with parameters stripped.
|
|
|
|
# If the file exists AND the contents is the same as the variable, do nothing
|
|
|
|
# else print a new file.
|
|
|
|
# Always returns the name of the file where the value was printed.
|
|
|
|
# Param 1 - Name of variable
|
|
|
|
# Param 2 - (optional) name of file to store value in
|
|
|
|
DependOnVariableHelper = \
|
|
|
|
$(strip $(if $(and $(wildcard $(call DependOnVariableFileName, $1, $2)),\
|
|
|
|
$(call equals, $(strip $($1)), \
|
|
|
|
$(call ReadFile, $(call DependOnVariableFileName, $1, $2)))),,\
|
|
|
|
$(call MakeDir, $(dir $(call DependOnVariableFileName, $1, $2))) \
|
|
|
|
$(if $(findstring $(LOG_LEVEL), trace), \
|
2015-01-28 13:04:05 +00:00
|
|
|
$(info Variable $1: >$(strip $($1))<) \
|
|
|
|
$(info File: >$(call ReadFile, $(call DependOnVariableFileName, $1, $2))<)) \
|
2015-01-26 09:28:53 +00:00
|
|
|
$(call WriteFile, $($1), $(call DependOnVariableFileName, $1, $2))) \
|
|
|
|
$(call DependOnVariableFileName, $1, $2))
|
|
|
|
|
|
|
|
# Main macro
|
|
|
|
# Param 1 - Name of variable
|
|
|
|
# Param 2 - (optional) name of file to store value in
|
|
|
|
DependOnVariable = \
|
|
|
|
$(call DependOnVariableHelper,$(strip $1),$(strip $2))
|
|
|
|
|
2015-06-04 16:27:42 +00:00
|
|
|
################################################################################
|
|
|
|
# Find lib dir for module
|
|
|
|
# Param 1 - module name
|
|
|
|
ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
|
|
|
|
FindLibDirForModule = \
|
|
|
|
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)$(OPENJDK_TARGET_CPU_LIBDIR)
|
|
|
|
else
|
|
|
|
FindLibDirForModule = \
|
|
|
|
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
|
|
|
|
endif
|
|
|
|
|
2014-08-17 14:51:37 +00:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Hook to include the corresponding custom file, if present.
|
|
|
|
$(eval $(call IncludeCustomExtension, , common/MakeBase.gmk))
|
|
|
|
|
2012-04-10 15:18:28 +00:00
|
|
|
endif # _MAKEBASE_GMK
|