make/common/MakeBase.gmk

changeset 0
75a576e87639
child 1133
50aaf272884f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/make/common/MakeBase.gmk	Wed Apr 27 01:39:08 2016 +0800
     1.3 @@ -0,0 +1,449 @@
     1.4 +#
     1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +################################################################
    1.30 +#
    1.31 +# Check that GNU make and cygwin are recent enough.
    1.32 +# Setup common utility functions.
    1.33 +#
    1.34 +################################################################
    1.35 +
    1.36 +ifndef _MAKEBASE_GMK
    1.37 +_MAKEBASE_GMK := 1
    1.38 +
    1.39 +# If the variable that you want to send to stdout for piping into a file or otherwise,
    1.40 +# is potentially long, for example the a list of file paths, eg a list of all package directories.
    1.41 +# Then you need to use ListPathsSafely, which optimistically splits the output into several shell
    1.42 +# calls as well as use compression on recurrent file paths segments, to get around the potential
    1.43 +# command line length problem that exists in cygwin and other shells.
    1.44 +compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl))
    1.45 +compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl))
    1.46 +compress_paths=$(compress_pre)\
    1.47 +$(subst $(SRC_ROOT),X97,\
    1.48 +$(subst $(OUTPUT_ROOT),X98,\
    1.49 +$(subst X,X00,\
    1.50 +$(subst $(SPACE),\n,$(strip $1)))))\
    1.51 +$(compress_post)
    1.52 +
    1.53 +decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \
    1.54 +    -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
    1.55 +    -e 's|X00|X|g' | tr '\n' '$2'
    1.56 +
    1.57 +define ListPathsSafely_If
    1.58 +	$(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1)))))
    1.59 +endef
    1.60 +
    1.61 +define ListPathsSafely_Printf
    1.62 +	$(if $(strip $($1_LPS$4)),$(if $(findstring $(LOG_LEVEL),trace),,@)printf \
    1.63 +	    -- "$(strip $($1_LPS$4))\n" | $(decompress_paths) $3)
    1.64 +endef
    1.65 +
    1.66 +# Receipt example:
    1.67 +#   rm -f thepaths
    1.68 +#   $(call ListPathsSafely,THEPATHS,\n, >> thepaths)
    1.69 +# The \n argument means translate spaces into \n
    1.70 +# if instead , , (a space) is supplied, then spaces remain spaces.
    1.71 +define ListPathsSafely
    1.72 +	$(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!))
    1.73 +	$(ECHO) $(LOG_DEBUG) Writing $(words $($1)) paths to '$3'
    1.74 +	$(call ListPathsSafely_If,$1,$2,1,250)
    1.75 +	$(call ListPathsSafely_If,$1,$2,251,500)
    1.76 +	$(call ListPathsSafely_If,$1,$2,501,750)
    1.77 +	$(call ListPathsSafely_If,$1,$2,751,1000)
    1.78 +
    1.79 +	$(call ListPathsSafely_If,$1,$2,1001,1250)
    1.80 +	$(call ListPathsSafely_If,$1,$2,1251,1500)
    1.81 +	$(call ListPathsSafely_If,$1,$2,1501,1750)
    1.82 +	$(call ListPathsSafely_If,$1,$2,1751,2000)
    1.83 +
    1.84 +	$(call ListPathsSafely_If,$1,$2,2001,2250)
    1.85 +	$(call ListPathsSafely_If,$1,$2,2251,2500)
    1.86 +	$(call ListPathsSafely_If,$1,$2,2501,2750)
    1.87 +	$(call ListPathsSafely_If,$1,$2,2751,3000)
    1.88 +
    1.89 +	$(call ListPathsSafely_If,$1,$2,3001,3250)
    1.90 +	$(call ListPathsSafely_If,$1,$2,3251,3500)
    1.91 +	$(call ListPathsSafely_If,$1,$2,3501,3750)
    1.92 +	$(call ListPathsSafely_If,$1,$2,3751,4000)
    1.93 +
    1.94 +	$(call ListPathsSafely_If,$1,$2,4001,4250)
    1.95 +	$(call ListPathsSafely_If,$1,$2,4251,4500)
    1.96 +	$(call ListPathsSafely_If,$1,$2,4501,4750)
    1.97 +	$(call ListPathsSafely_If,$1,$2,4751,5000)
    1.98 +
    1.99 +	$(call ListPathsSafely_If,$1,$2,5001,5250)
   1.100 +	$(call ListPathsSafely_If,$1,$2,5251,5500)
   1.101 +	$(call ListPathsSafely_If,$1,$2,5501,5750)
   1.102 +	$(call ListPathsSafely_If,$1,$2,5751,6000)
   1.103 +
   1.104 +	$(call ListPathsSafely_If,$1,$2,6001,6250)
   1.105 +	$(call ListPathsSafely_If,$1,$2,6251,6500)
   1.106 +	$(call ListPathsSafely_If,$1,$2,6501,6750)
   1.107 +	$(call ListPathsSafely_If,$1,$2,6751,7000)
   1.108 +
   1.109 +	$(call ListPathsSafely_If,$1,$2,7001,7250)
   1.110 +	$(call ListPathsSafely_If,$1,$2,7251,7500)
   1.111 +	$(call ListPathsSafely_If,$1,$2,7501,7750)
   1.112 +	$(call ListPathsSafely_If,$1,$2,7751,8000)
   1.113 +
   1.114 +	$(call ListPathsSafely_If,$1,$2,8001,8250)
   1.115 +	$(call ListPathsSafely_If,$1,$2,8251,8500)
   1.116 +	$(call ListPathsSafely_If,$1,$2,8501,8750)
   1.117 +	$(call ListPathsSafely_If,$1,$2,8751,9000)
   1.118 +
   1.119 +	$(call ListPathsSafely_If,$1,$2,9001,9250)
   1.120 +	$(call ListPathsSafely_If,$1,$2,9251,9500)
   1.121 +	$(call ListPathsSafely_If,$1,$2,9501,9750)
   1.122 +	$(call ListPathsSafely_If,$1,$2,9751,10000)
   1.123 +
   1.124 +	$(call ListPathsSafely_If,$1,$2,10001,10250)
   1.125 +	$(call ListPathsSafely_If,$1,$2,10251,10500)
   1.126 +	$(call ListPathsSafely_If,$1,$2,10501,10750)
   1.127 +	$(call ListPathsSafely_If,$1,$2,10751,11000)
   1.128 +
   1.129 +	$(call ListPathsSafely_If,$1,$2,11001,11250)
   1.130 +	$(call ListPathsSafely_If,$1,$2,11251,11500)
   1.131 +	$(call ListPathsSafely_If,$1,$2,11501,11750)
   1.132 +	$(call ListPathsSafely_If,$1,$2,11751,12000)
   1.133 +
   1.134 +	$(call ListPathsSafely_If,$1,$2,12001,12250)
   1.135 +	$(call ListPathsSafely_If,$1,$2,12251,12500)
   1.136 +	$(call ListPathsSafely_If,$1,$2,12501,12750)
   1.137 +	$(call ListPathsSafely_If,$1,$2,12751,13000)
   1.138 +
   1.139 +	$(call ListPathsSafely_If,$1,$2,13001,13250)
   1.140 +	$(call ListPathsSafely_If,$1,$2,13251,13500)
   1.141 +	$(call ListPathsSafely_If,$1,$2,13501,13750)
   1.142 +	$(call ListPathsSafely_If,$1,$2,13751,14000)
   1.143 +
   1.144 +	$(call ListPathsSafely_If,$1,$2,14001,14250)
   1.145 +	$(call ListPathsSafely_If,$1,$2,14251,14500)
   1.146 +	$(call ListPathsSafely_If,$1,$2,14501,14750)
   1.147 +	$(call ListPathsSafely_If,$1,$2,14751,15000)
   1.148 +
   1.149 +	$(call ListPathsSafely_If,$1,$2,15001,15250)
   1.150 +	$(call ListPathsSafely_If,$1,$2,15251,15500)
   1.151 +	$(call ListPathsSafely_If,$1,$2,15501,15750)
   1.152 +	$(call ListPathsSafely_If,$1,$2,15751,16000)
   1.153 +
   1.154 +	$(call ListPathsSafely_Printf,$1,$2,$3,1)
   1.155 +	$(call ListPathsSafely_Printf,$1,$2,$3,251)
   1.156 +	$(call ListPathsSafely_Printf,$1,$2,$3,501)
   1.157 +	$(call ListPathsSafely_Printf,$1,$2,$3,751)
   1.158 +
   1.159 +	$(call ListPathsSafely_Printf,$1,$2,$3,1001)
   1.160 +	$(call ListPathsSafely_Printf,$1,$2,$3,1251)
   1.161 +	$(call ListPathsSafely_Printf,$1,$2,$3,1501)
   1.162 +	$(call ListPathsSafely_Printf,$1,$2,$3,1751)
   1.163 +
   1.164 +	$(call ListPathsSafely_Printf,$1,$2,$3,2001)
   1.165 +	$(call ListPathsSafely_Printf,$1,$2,$3,2251)
   1.166 +	$(call ListPathsSafely_Printf,$1,$2,$3,2501)
   1.167 +	$(call ListPathsSafely_Printf,$1,$2,$3,2751)
   1.168 +
   1.169 +	$(call ListPathsSafely_Printf,$1,$2,$3,3001)
   1.170 +	$(call ListPathsSafely_Printf,$1,$2,$3,3251)
   1.171 +	$(call ListPathsSafely_Printf,$1,$2,$3,3501)
   1.172 +	$(call ListPathsSafely_Printf,$1,$2,$3,3751)
   1.173 +
   1.174 +	$(call ListPathsSafely_Printf,$1,$2,$3,4001)
   1.175 +	$(call ListPathsSafely_Printf,$1,$2,$3,4251)
   1.176 +	$(call ListPathsSafely_Printf,$1,$2,$3,4501)
   1.177 +	$(call ListPathsSafely_Printf,$1,$2,$3,4751)
   1.178 +
   1.179 +	$(call ListPathsSafely_Printf,$1,$2,$3,5001)
   1.180 +	$(call ListPathsSafely_Printf,$1,$2,$3,5251)
   1.181 +	$(call ListPathsSafely_Printf,$1,$2,$3,5501)
   1.182 +	$(call ListPathsSafely_Printf,$1,$2,$3,5751)
   1.183 +
   1.184 +	$(call ListPathsSafely_Printf,$1,$2,$3,6001)
   1.185 +	$(call ListPathsSafely_Printf,$1,$2,$3,6251)
   1.186 +	$(call ListPathsSafely_Printf,$1,$2,$3,6501)
   1.187 +	$(call ListPathsSafely_Printf,$1,$2,$3,6751)
   1.188 +
   1.189 +	$(call ListPathsSafely_Printf,$1,$2,$3,7001)
   1.190 +	$(call ListPathsSafely_Printf,$1,$2,$3,7251)
   1.191 +	$(call ListPathsSafely_Printf,$1,$2,$3,7501)
   1.192 +	$(call ListPathsSafely_Printf,$1,$2,$3,7751)
   1.193 +
   1.194 +	$(call ListPathsSafely_Printf,$1,$2,$3,8001)
   1.195 +	$(call ListPathsSafely_Printf,$1,$2,$3,8251)
   1.196 +	$(call ListPathsSafely_Printf,$1,$2,$3,8501)
   1.197 +	$(call ListPathsSafely_Printf,$1,$2,$3,8751)
   1.198 +
   1.199 +	$(call ListPathsSafely_Printf,$1,$2,$3,9001)
   1.200 +	$(call ListPathsSafely_Printf,$1,$2,$3,9251)
   1.201 +	$(call ListPathsSafely_Printf,$1,$2,$3,9501)
   1.202 +	$(call ListPathsSafely_Printf,$1,$2,$3,9751)
   1.203 +
   1.204 +	$(call ListPathsSafely_Printf,$1,$2,$3,10001)
   1.205 +	$(call ListPathsSafely_Printf,$1,$2,$3,10251)
   1.206 +	$(call ListPathsSafely_Printf,$1,$2,$3,10501)
   1.207 +	$(call ListPathsSafely_Printf,$1,$2,$3,10751)
   1.208 +
   1.209 +	$(call ListPathsSafely_Printf,$1,$2,$3,11001)
   1.210 +	$(call ListPathsSafely_Printf,$1,$2,$3,11251)
   1.211 +	$(call ListPathsSafely_Printf,$1,$2,$3,11501)
   1.212 +	$(call ListPathsSafely_Printf,$1,$2,$3,11751)
   1.213 +
   1.214 +	$(call ListPathsSafely_Printf,$1,$2,$3,12001)
   1.215 +	$(call ListPathsSafely_Printf,$1,$2,$3,12251)
   1.216 +	$(call ListPathsSafely_Printf,$1,$2,$3,12501)
   1.217 +	$(call ListPathsSafely_Printf,$1,$2,$3,12751)
   1.218 +
   1.219 +	$(call ListPathsSafely_Printf,$1,$2,$3,13001)
   1.220 +	$(call ListPathsSafely_Printf,$1,$2,$3,13251)
   1.221 +	$(call ListPathsSafely_Printf,$1,$2,$3,13501)
   1.222 +	$(call ListPathsSafely_Printf,$1,$2,$3,13751)
   1.223 +
   1.224 +	$(call ListPathsSafely_Printf,$1,$2,$3,14001)
   1.225 +	$(call ListPathsSafely_Printf,$1,$2,$3,14251)
   1.226 +	$(call ListPathsSafely_Printf,$1,$2,$3,14501)
   1.227 +	$(call ListPathsSafely_Printf,$1,$2,$3,14751)
   1.228 +
   1.229 +	$(call ListPathsSafely_Printf,$1,$2,$3,15001)
   1.230 +	$(call ListPathsSafely_Printf,$1,$2,$3,15251)
   1.231 +	$(call ListPathsSafely_Printf,$1,$2,$3,15501)
   1.232 +	$(call ListPathsSafely_Printf,$1,$2,$3,15751)
   1.233 +endef
   1.234 +
   1.235 +define ListPathsSafelyNow_IfPrintf
   1.236 +  ifneq (,$$(word $4,$$($1)))
   1.237 +    $$(eval $1_LPS$4:=$$(call compress_paths,$$(wordlist $4,$5,$$($1))))
   1.238 +    $$(shell printf -- "$$(strip $$($1_LPS$4))\n" | $(decompress_paths) $3)
   1.239 +  endif
   1.240 +endef
   1.241 +
   1.242 +# And an non-receipt version:
   1.243 +define ListPathsSafelyNow
   1.244 +  ifneq (,$$(word 10001,$$($1)))
   1.245 +    $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!)
   1.246 +  endif
   1.247 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1,250)
   1.248 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,251,500)
   1.249 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,501,750)
   1.250 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,751,1000)
   1.251 +
   1.252 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1001,1250)
   1.253 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1251,1500)
   1.254 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1501,1750)
   1.255 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1751,2000)
   1.256 +
   1.257 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2001,2250)
   1.258 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2251,2500)
   1.259 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2501,2750)
   1.260 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2751,3000)
   1.261 +
   1.262 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3001,3250)
   1.263 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3251,3500)
   1.264 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3501,3750)
   1.265 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3751,4000)
   1.266 +
   1.267 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4001,4250)
   1.268 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4251,4500)
   1.269 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4501,4750)
   1.270 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4751,5000)
   1.271 +
   1.272 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5001,5250)
   1.273 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5251,5500)
   1.274 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5501,5750)
   1.275 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5751,6000)
   1.276 +
   1.277 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6001,6250)
   1.278 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6251,6500)
   1.279 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6501,6750)
   1.280 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6751,7000)
   1.281 +
   1.282 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7001,7250)
   1.283 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7251,7500)
   1.284 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7501,7750)
   1.285 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7751,8000)
   1.286 +
   1.287 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8001,8250)
   1.288 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8251,8500)
   1.289 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8501,8750)
   1.290 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8751,9000)
   1.291 +
   1.292 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9001,9250)
   1.293 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9251,9500)
   1.294 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9501,9750)
   1.295 +  $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9751,10000)
   1.296 +
   1.297 +endef
   1.298 +
   1.299 +# The source tips can come from the Mercurial repository, or in the files
   1.300 +# $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
   1.301 +# directory as the original $(HGDIR) directory.
   1.302 +# These should not be := assignments, only used from the root Makefile.
   1.303 +HG_VERSION = $(shell $(HG) version 2> /dev/null)
   1.304 +HG_DIRECTORY=.hg
   1.305 +HGTIP_FILENAME=.hgtip
   1.306 +HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
   1.307 +REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
   1.308 +    $(shell $(CD) $(SRC_ROOT) ; ( $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) ; \
   1.309 +        $(LS) $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) ) \
   1.310 +        2> /dev/null)))))
   1.311 +
   1.312 +# Emit the repo:tip pairs to $@
   1.313 +define GetSourceTips
   1.314 +	$(CD) $(SRC_ROOT) ; \
   1.315 +	for i in $(REPO_LIST) IGNORE ; do \
   1.316 +	  if [ "$${i}" = "IGNORE" ] ; then \
   1.317 +	    continue; \
   1.318 +	  elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
   1.319 +	    $(PRINTF) " %s:%s" \
   1.320 +	        "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
   1.321 +	  elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
   1.322 +	    $(PRINTF) " %s:%s" \
   1.323 +	        "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
   1.324 +	  fi; \
   1.325 +	done >> $@
   1.326 +	$(PRINTF) "\n" >> $@
   1.327 +endef
   1.328 +
   1.329 +# Create the HGTIP_FILENAME file. Called from jdk/make/closed/bundles.gmk
   1.330 +define CreateHgTip
   1.331 +	$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
   1.332 +	$(ECHO) $1/$(HGTIP_FILENAME)
   1.333 +endef
   1.334 +
   1.335 +define SetupLogging
   1.336 +  ifeq ($$(LOG_LEVEL),trace)
   1.337 +    # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
   1.338 +    # For each target executed, will print
   1.339 +    # Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer)
   1.340 +    # but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much
   1.341 +    # (and causing a crash on Cygwin).
   1.342 +    # Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris.
   1.343 +    # Only use time if it's GNU time which supports format and output file.
   1.344 +    WRAPPER_SHELL:=/bin/bash $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log /bin/bash
   1.345 +    SHELL=$$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
   1.346 +  endif
   1.347 +  # Never remove warning messages; this is just for completeness
   1.348 +  LOG_WARN=
   1.349 +  ifneq ($$(findstring $$(LOG_LEVEL),info debug trace),)
   1.350 +    LOG_INFO=
   1.351 +  else
   1.352 +    LOG_INFO=> /dev/null
   1.353 +  endif
   1.354 +  ifneq ($$(findstring $$(LOG_LEVEL),debug trace),)
   1.355 +    LOG_DEBUG=
   1.356 +  else
   1.357 +    LOG_DEBUG=> /dev/null
   1.358 +  endif
   1.359 +  ifneq ($$(findstring $$(LOG_LEVEL),trace),)
   1.360 +    LOG_TRACE=
   1.361 +  else
   1.362 +    LOG_TRACE=> /dev/null
   1.363 +  endif
   1.364 +endef
   1.365 +
   1.366 +# Make sure logging is setup for everyone that includes MakeBase.gmk.
   1.367 +$(eval $(call SetupLogging))
   1.368 +
   1.369 +# This is to be called by all SetupFoo macros
   1.370 +define LogSetupMacroEntry
   1.371 +  $(if $(27),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk))
   1.372 +  $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26,$(if $($i),$(NEWLINE) $(strip [$i] $($i))))))
   1.373 +endef
   1.374 +
   1.375 +# Make directory without forking mkdir if not needed
   1.376 +define MakeDir
   1.377 +  ifneq ($$(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),$$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9))
   1.378 +    $$(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)
   1.379 +  endif
   1.380 +endef
   1.381 +
   1.382 +ifeq ($(OPENJDK_TARGET_OS),solaris)
   1.383 +  # On Solaris, if the target is a symlink and exists, cp won't overwrite.
   1.384 +  # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the
   1.385 +  # name of the target file differs from the source file, rename after copy.
   1.386 +  define install-file
   1.387 +	$(MKDIR) -p $(@D)
   1.388 +	$(RM) '$@'
   1.389 +	$(CP) -f -r -P '$<' '$(@D)'
   1.390 +	if [ "$(@F)" != "$(<F)" ]; then $(MV) '$(@D)/$(<F)' '$@'; fi
   1.391 +  endef
   1.392 +else ifeq ($(OPENJDK_TARGET_OS),macosx)
   1.393 +  # On mac, extended attributes sometimes creep into the source files, which may later
   1.394 +  # cause the creation of ._* files which confuses testing. Clear these with xattr if
   1.395 +  # set. Some files get their write permissions removed after being copied to the
   1.396 +  # output dir. When these are copied again to images, xattr would fail. By only clearing
   1.397 +  # attributes when they are present, failing on this is avoided.
   1.398 +  define install-file
   1.399 +	$(MKDIR) -p $(@D)
   1.400 +	$(CP) -fRP '$<' '$@'
   1.401 +	if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
   1.402 +  endef
   1.403 +else
   1.404 +  define install-file
   1.405 +	$(MKDIR) -p $(@D)
   1.406 +	$(CP) -fP '$<' '$@'
   1.407 +  endef
   1.408 +endif
   1.409 +
   1.410 +# Convenience functions for working around make's limitations with $(filter ).
   1.411 +containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
   1.412 +not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
   1.413 +
   1.414 +################################################################################
   1.415 +# In Cygwin, finds are very costly, both because of expensive forks and because
   1.416 +# of bad file system caching. Find is used extensively in $(shell) commands to
   1.417 +# find source files. This makes rerunning make with no or few changes rather
   1.418 +# expensive. To speed this up, these two macros are used to cache the results
   1.419 +# of simple find commands for reuse.
   1.420 +#
   1.421 +# Runs a find and stores both the directories where it was run and the results.
   1.422 +# This macro can be called multiple times to add to the cache. Only finds files
   1.423 +# with no filters.
   1.424 +#
   1.425 +# Needs to be called with $(eval )
   1.426 +#
   1.427 +# Param 1 - Dir to find in
   1.428 +ifeq ($(OPENJDK_BUILD_OS),windows)
   1.429 +  define FillCacheFind
   1.430 +    FIND_CACHE_DIR += $1
   1.431 +    FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $1 -type f -o -type l))
   1.432 +  endef
   1.433 +else
   1.434 +  define FillCacheFind
   1.435 +  endef
   1.436 +endif
   1.437 +
   1.438 +# Mimics find by looking in the cache if all of the directories have been cached.
   1.439 +# Otherwise reverts to shell find. This is safe to call on all platforms, even if
   1.440 +# cache is deactivated.
   1.441 +#
   1.442 +# The extra - is needed when FIND_CACHE_DIR is empty but should be harmless.
   1.443 +# Param 1 - Dirs to find in
   1.444 +define CacheFind
   1.445 +  $(if $(filter-out $(addsuffix %,- $(FIND_CACHE_DIR)),$1), \
   1.446 +    $(shell $(FIND) $1 -type f -o -type l), \
   1.447 +    $(filter $(addsuffix %,$1),$(FIND_CACHE)))
   1.448 +endef
   1.449 +
   1.450 +################################################################################
   1.451 +
   1.452 +endif # _MAKEBASE_GMK

mercurial