common/makefiles/MakeBase.gmk

Mon, 25 Feb 2013 15:08:11 -0800

author
jjg
date
Mon, 25 Feb 2013 15:08:11 -0800
changeset 645
5b0b6ef58dbf
parent 557
d2c1f80118de
child 660
19a59a13b3ef
permissions
-rw-r--r--

8008914: Add nashorn to the tl build
Reviewed-by: mr, tbell, jjh
Contributed-by: erik.joelsson@oracle.com, james.laskey@oracle.com

ohair@425 1 #
ohair@425 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@425 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@425 4 #
ohair@425 5 # This code is free software; you can redistribute it and/or modify it
ohair@425 6 # under the terms of the GNU General Public License version 2 only, as
ohair@425 7 # published by the Free Software Foundation. Oracle designates this
ohair@425 8 # particular file as subject to the "Classpath" exception as provided
ohair@425 9 # by Oracle in the LICENSE file that accompanied this code.
ohair@425 10 #
ohair@425 11 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@425 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@425 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@425 14 # version 2 for more details (a copy is included in the LICENSE file that
ohair@425 15 # accompanied this code).
ohair@425 16 #
ohair@425 17 # You should have received a copy of the GNU General Public License version
ohair@425 18 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@425 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@425 20 #
ohair@425 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@425 22 # or visit www.oracle.com if you need additional information or have any
ohair@425 23 # questions.
ohair@425 24 #
ohair@425 25
ohair@425 26 ################################################################
ohair@425 27 #
ohair@425 28 # Check that GNU make and cygwin are recent enough.
ohair@425 29 # Setup common utility functions.
ohair@425 30 #
ohair@425 31 ################################################################
ohair@425 32
ohair@425 33 ifndef _MAKEBASE_GMK
ohair@425 34 _MAKEBASE_GMK := 1
ohair@425 35
ohair@425 36 # If the variable that you want to send to stdout for piping into a file or otherwise,
ohair@425 37 # is potentially long, for example the a list of file paths, eg a list of all package directories.
ohair@425 38 # Then you need to use ListPathsSafely, which optimistically splits the output into several shell
ohair@425 39 # calls as well as use compression on recurrent file paths segments, to get around the potential
ohair@425 40 # command line length problem that exists in cygwin and other shells.
ohair@494 41 compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-pre-compress.incl))
ohair@494 42 compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-post-compress.incl))
ohair@425 43 compress_paths=$(compress_pre)\
ohair@425 44 $(subst $(SRC_ROOT),X97,\
ohair@425 45 $(subst $(OUTPUT_ROOT),X98,\
ohair@425 46 $(subst X,X00,\
ohair@425 47 $(subst $(SPACE),\n,$(strip $1)))))\
ohair@425 48 $(compress_post)
ohair@425 49
ohair@494 50 decompress_paths=$(SED) -f $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \
ohair@425 51 -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
ohair@425 52 -e 's|X00|X|g' | tr '\n' '$2'
ohair@425 53
jjg@645 54 # Subst in an extra $ to prevent it from disappearing.
ohair@425 55 define ListPathsSafely_If
jjg@645 56 $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(subst $$,$$$$,$(wordlist $3,$4,$($1))))))
ohair@425 57 endef
ohair@425 58
ohair@425 59 define ListPathsSafely_Printf
ohair@425 60 $(if $(strip $($1_LPS$4)),printf -- "$(strip $($1_LPS$4))\n" | $(decompress_paths) $3)
ohair@425 61 endef
ohair@425 62
ohair@425 63 # Receipt example:
ohair@425 64 # rm -f thepaths
ohair@425 65 # $(call ListPathsSafely,THEPATHS,\n, >> thepaths)
ohair@425 66 # The \n argument means translate spaces into \n
ohair@425 67 # if instead , , (a space) is supplied, then spaces remain spaces.
ohair@425 68 define ListPathsSafely
erikj@501 69 $(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!))
ohair@425 70 $(call ListPathsSafely_If,$1,$2,1,250)
ohair@425 71 $(call ListPathsSafely_If,$1,$2,251,500)
ohair@425 72 $(call ListPathsSafely_If,$1,$2,501,750)
ohair@425 73 $(call ListPathsSafely_If,$1,$2,751,1000)
ohair@425 74
ohair@425 75 $(call ListPathsSafely_If,$1,$2,1001,1250)
ohair@425 76 $(call ListPathsSafely_If,$1,$2,1251,1500)
ohair@425 77 $(call ListPathsSafely_If,$1,$2,1501,1750)
ohair@425 78 $(call ListPathsSafely_If,$1,$2,1751,2000)
ohair@425 79
ohair@425 80 $(call ListPathsSafely_If,$1,$2,2001,2250)
ohair@425 81 $(call ListPathsSafely_If,$1,$2,2251,2500)
ohair@425 82 $(call ListPathsSafely_If,$1,$2,2501,2750)
ohair@425 83 $(call ListPathsSafely_If,$1,$2,2751,3000)
ohair@425 84
ohair@425 85 $(call ListPathsSafely_If,$1,$2,3001,3250)
ohair@425 86 $(call ListPathsSafely_If,$1,$2,3251,3500)
ohair@425 87 $(call ListPathsSafely_If,$1,$2,3501,3750)
ohair@425 88 $(call ListPathsSafely_If,$1,$2,3751,4000)
ohair@425 89
ohair@425 90 $(call ListPathsSafely_If,$1,$2,4001,4250)
ohair@425 91 $(call ListPathsSafely_If,$1,$2,4251,4500)
ohair@425 92 $(call ListPathsSafely_If,$1,$2,4501,4750)
ohair@425 93 $(call ListPathsSafely_If,$1,$2,4751,5000)
ohair@425 94
ohair@425 95 $(call ListPathsSafely_If,$1,$2,5001,5250)
ohair@425 96 $(call ListPathsSafely_If,$1,$2,5251,5500)
ohair@425 97 $(call ListPathsSafely_If,$1,$2,5501,5750)
ohair@425 98 $(call ListPathsSafely_If,$1,$2,5751,6000)
ohair@425 99
ohair@425 100 $(call ListPathsSafely_If,$1,$2,6001,6250)
ohair@425 101 $(call ListPathsSafely_If,$1,$2,6251,6500)
ohair@425 102 $(call ListPathsSafely_If,$1,$2,6501,6750)
ohair@425 103 $(call ListPathsSafely_If,$1,$2,6751,7000)
ohair@425 104
ohair@425 105 $(call ListPathsSafely_If,$1,$2,7001,7250)
ohair@425 106 $(call ListPathsSafely_If,$1,$2,7251,7500)
ohair@425 107 $(call ListPathsSafely_If,$1,$2,7501,7750)
ohair@425 108 $(call ListPathsSafely_If,$1,$2,7751,8000)
ohair@425 109
ohair@425 110 $(call ListPathsSafely_If,$1,$2,8001,8250)
ohair@425 111 $(call ListPathsSafely_If,$1,$2,8251,8500)
ohair@425 112 $(call ListPathsSafely_If,$1,$2,8501,8750)
ohair@425 113 $(call ListPathsSafely_If,$1,$2,8751,9000)
ohair@425 114
ohair@425 115 $(call ListPathsSafely_If,$1,$2,9001,9250)
ohair@425 116 $(call ListPathsSafely_If,$1,$2,9251,9500)
ohair@425 117 $(call ListPathsSafely_If,$1,$2,9501,9750)
ohair@425 118 $(call ListPathsSafely_If,$1,$2,9751,10000)
ohair@425 119
erikj@501 120 $(call ListPathsSafely_If,$1,$2,10001,10250)
erikj@501 121 $(call ListPathsSafely_If,$1,$2,10251,10500)
erikj@501 122 $(call ListPathsSafely_If,$1,$2,10501,10750)
erikj@501 123 $(call ListPathsSafely_If,$1,$2,10751,11000)
erikj@501 124
erikj@501 125 $(call ListPathsSafely_If,$1,$2,11001,11250)
erikj@501 126 $(call ListPathsSafely_If,$1,$2,11251,11500)
erikj@501 127 $(call ListPathsSafely_If,$1,$2,11501,11750)
erikj@501 128 $(call ListPathsSafely_If,$1,$2,11751,12000)
erikj@501 129
erikj@501 130 $(call ListPathsSafely_If,$1,$2,12001,12250)
erikj@501 131 $(call ListPathsSafely_If,$1,$2,12251,12500)
erikj@501 132 $(call ListPathsSafely_If,$1,$2,12501,12750)
erikj@501 133 $(call ListPathsSafely_If,$1,$2,12751,13000)
erikj@501 134
erikj@501 135 $(call ListPathsSafely_If,$1,$2,13001,13250)
erikj@501 136 $(call ListPathsSafely_If,$1,$2,13251,13500)
erikj@501 137 $(call ListPathsSafely_If,$1,$2,13501,13750)
erikj@501 138 $(call ListPathsSafely_If,$1,$2,13751,14000)
erikj@501 139
erikj@501 140 $(call ListPathsSafely_If,$1,$2,14001,14250)
erikj@501 141 $(call ListPathsSafely_If,$1,$2,14251,14500)
erikj@501 142 $(call ListPathsSafely_If,$1,$2,14501,14750)
erikj@501 143 $(call ListPathsSafely_If,$1,$2,14751,15000)
erikj@501 144
erikj@501 145 $(call ListPathsSafely_If,$1,$2,15001,15250)
erikj@501 146 $(call ListPathsSafely_If,$1,$2,15251,15500)
erikj@501 147 $(call ListPathsSafely_If,$1,$2,15501,15750)
erikj@501 148 $(call ListPathsSafely_If,$1,$2,15751,16000)
erikj@501 149
ohair@425 150 $(call ListPathsSafely_Printf,$1,$2,$3,1)
ohair@425 151 $(call ListPathsSafely_Printf,$1,$2,$3,251)
ohair@425 152 $(call ListPathsSafely_Printf,$1,$2,$3,501)
ohair@425 153 $(call ListPathsSafely_Printf,$1,$2,$3,751)
ohair@425 154
ohair@425 155 $(call ListPathsSafely_Printf,$1,$2,$3,1001)
ohair@425 156 $(call ListPathsSafely_Printf,$1,$2,$3,1251)
ohair@425 157 $(call ListPathsSafely_Printf,$1,$2,$3,1501)
ohair@425 158 $(call ListPathsSafely_Printf,$1,$2,$3,1751)
ohair@425 159
ohair@425 160 $(call ListPathsSafely_Printf,$1,$2,$3,2001)
ohair@425 161 $(call ListPathsSafely_Printf,$1,$2,$3,2251)
ohair@425 162 $(call ListPathsSafely_Printf,$1,$2,$3,2501)
ohair@425 163 $(call ListPathsSafely_Printf,$1,$2,$3,2751)
ohair@425 164
ohair@425 165 $(call ListPathsSafely_Printf,$1,$2,$3,3001)
ohair@425 166 $(call ListPathsSafely_Printf,$1,$2,$3,3251)
ohair@425 167 $(call ListPathsSafely_Printf,$1,$2,$3,3501)
ohair@425 168 $(call ListPathsSafely_Printf,$1,$2,$3,3751)
ohair@425 169
ohair@425 170 $(call ListPathsSafely_Printf,$1,$2,$3,4001)
ohair@425 171 $(call ListPathsSafely_Printf,$1,$2,$3,4251)
ohair@425 172 $(call ListPathsSafely_Printf,$1,$2,$3,4501)
ohair@425 173 $(call ListPathsSafely_Printf,$1,$2,$3,4751)
ohair@425 174
ohair@425 175 $(call ListPathsSafely_Printf,$1,$2,$3,5001)
ohair@425 176 $(call ListPathsSafely_Printf,$1,$2,$3,5251)
ohair@425 177 $(call ListPathsSafely_Printf,$1,$2,$3,5501)
ohair@425 178 $(call ListPathsSafely_Printf,$1,$2,$3,5751)
ohair@425 179
ohair@425 180 $(call ListPathsSafely_Printf,$1,$2,$3,6001)
ohair@425 181 $(call ListPathsSafely_Printf,$1,$2,$3,6251)
ohair@425 182 $(call ListPathsSafely_Printf,$1,$2,$3,6501)
ohair@425 183 $(call ListPathsSafely_Printf,$1,$2,$3,6751)
ohair@425 184
ohair@425 185 $(call ListPathsSafely_Printf,$1,$2,$3,7001)
ohair@425 186 $(call ListPathsSafely_Printf,$1,$2,$3,7251)
ohair@425 187 $(call ListPathsSafely_Printf,$1,$2,$3,7501)
ohair@425 188 $(call ListPathsSafely_Printf,$1,$2,$3,7751)
ohair@425 189
ohair@425 190 $(call ListPathsSafely_Printf,$1,$2,$3,8001)
ohair@425 191 $(call ListPathsSafely_Printf,$1,$2,$3,8251)
ohair@425 192 $(call ListPathsSafely_Printf,$1,$2,$3,8501)
ohair@425 193 $(call ListPathsSafely_Printf,$1,$2,$3,8751)
ohair@425 194
ohair@425 195 $(call ListPathsSafely_Printf,$1,$2,$3,9001)
ohair@425 196 $(call ListPathsSafely_Printf,$1,$2,$3,9251)
ohair@425 197 $(call ListPathsSafely_Printf,$1,$2,$3,9501)
ohair@425 198 $(call ListPathsSafely_Printf,$1,$2,$3,9751)
erikj@501 199
erikj@501 200 $(call ListPathsSafely_Printf,$1,$2,$3,10001)
erikj@501 201 $(call ListPathsSafely_Printf,$1,$2,$3,10251)
erikj@501 202 $(call ListPathsSafely_Printf,$1,$2,$3,10501)
erikj@501 203 $(call ListPathsSafely_Printf,$1,$2,$3,10751)
erikj@501 204
erikj@501 205 $(call ListPathsSafely_Printf,$1,$2,$3,11001)
erikj@501 206 $(call ListPathsSafely_Printf,$1,$2,$3,11251)
erikj@501 207 $(call ListPathsSafely_Printf,$1,$2,$3,11501)
erikj@501 208 $(call ListPathsSafely_Printf,$1,$2,$3,11751)
erikj@501 209
erikj@501 210 $(call ListPathsSafely_Printf,$1,$2,$3,12001)
erikj@501 211 $(call ListPathsSafely_Printf,$1,$2,$3,12251)
erikj@501 212 $(call ListPathsSafely_Printf,$1,$2,$3,12501)
erikj@501 213 $(call ListPathsSafely_Printf,$1,$2,$3,12751)
erikj@501 214
erikj@501 215 $(call ListPathsSafely_Printf,$1,$2,$3,13001)
erikj@501 216 $(call ListPathsSafely_Printf,$1,$2,$3,13251)
erikj@501 217 $(call ListPathsSafely_Printf,$1,$2,$3,13501)
erikj@501 218 $(call ListPathsSafely_Printf,$1,$2,$3,13751)
erikj@501 219
erikj@501 220 $(call ListPathsSafely_Printf,$1,$2,$3,14001)
erikj@501 221 $(call ListPathsSafely_Printf,$1,$2,$3,14251)
erikj@501 222 $(call ListPathsSafely_Printf,$1,$2,$3,14501)
erikj@501 223 $(call ListPathsSafely_Printf,$1,$2,$3,14751)
erikj@501 224
erikj@501 225 $(call ListPathsSafely_Printf,$1,$2,$3,15001)
erikj@501 226 $(call ListPathsSafely_Printf,$1,$2,$3,15251)
erikj@501 227 $(call ListPathsSafely_Printf,$1,$2,$3,15501)
erikj@501 228 $(call ListPathsSafely_Printf,$1,$2,$3,15751)
ohair@425 229 endef
ohair@425 230
ohair@425 231 define ListPathsSafelyNow_IfPrintf
ohair@425 232 ifneq (,$$(word $4,$$($1)))
ohair@425 233 $$(eval $1_LPS$4:=$$(call compress_paths,$$(wordlist $4,$5,$$($1))))
ohair@425 234 $$(shell printf -- "$$(strip $$($1_LPS$4))\n" | $(decompress_paths) $3)
ohair@425 235 endif
ohair@425 236 endef
ohair@425 237
ohair@425 238 # And an non-receipt version:
ohair@425 239 define ListPathsSafelyNow
ohair@425 240 ifneq (,$$(word 10001,$$($1)))
ohair@425 241 $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!)
ohair@425 242 endif
ohair@425 243 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1,250)
ohair@425 244 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,251,500)
ohair@425 245 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,501,750)
ohair@425 246 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,751,1000)
ohair@425 247
ohair@425 248 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1001,1250)
ohair@425 249 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1251,1500)
ohair@425 250 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1501,1750)
ohair@425 251 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1751,2000)
ohair@425 252
ohair@425 253 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2001,2250)
ohair@425 254 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2251,2500)
ohair@425 255 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2501,2750)
ohair@425 256 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2751,3000)
ohair@425 257
ohair@425 258 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3001,3250)
ohair@425 259 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3251,3500)
ohair@425 260 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3501,3750)
ohair@425 261 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3751,4000)
ohair@425 262
ohair@425 263 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4001,4250)
ohair@425 264 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4251,4500)
ohair@425 265 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4501,4750)
ohair@425 266 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4751,5000)
ohair@425 267
ohair@425 268 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5001,5250)
ohair@425 269 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5251,5500)
ohair@425 270 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5501,5750)
ohair@425 271 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5751,6000)
ohair@425 272
ohair@425 273 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6001,6250)
ohair@425 274 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6251,6500)
ohair@425 275 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6501,6750)
ohair@425 276 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6751,7000)
ohair@425 277
ohair@425 278 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7001,7250)
ohair@425 279 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7251,7500)
ohair@425 280 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7501,7750)
ohair@425 281 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7751,8000)
ohair@425 282
ohair@425 283 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8001,8250)
ohair@425 284 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8251,8500)
ohair@425 285 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8501,8750)
ohair@425 286 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8751,9000)
ohair@425 287
ohair@425 288 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9001,9250)
ohair@425 289 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9251,9500)
ohair@425 290 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9501,9750)
ohair@425 291 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9751,10000)
ohair@425 292
ohair@425 293 endef
ohair@425 294
erikj@445 295 # The source tips can come from the Mercurial repository, or in the files
erikj@445 296 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
erikj@445 297 # directory as the original $(HGDIR) directory.
erikj@445 298 # These should not be := assignments, only used from the root Makefile.
erikj@445 299 HG_VERSION = $(shell $(HG) version 2> /dev/null)
erikj@445 300 HG_DIRECTORY=.hg
erikj@445 301 HGTIP_FILENAME=.hgtip
erikj@445 302 HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
erikj@445 303 REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
erikj@445 304 $(shell $(CD) $(SRC_ROOT) ; ( $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) ; \
erikj@445 305 $(LS) $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) ) \
erikj@445 306 2> /dev/null)))))
erikj@445 307
erikj@445 308 # Emit the repo:tip pairs to $@
erikj@445 309 define GetSourceTips
erikj@445 310 $(CD) $(SRC_ROOT) ; \
erikj@445 311 for i in $(REPO_LIST) IGNORE ; do \
erikj@445 312 if [ "$${i}" = "IGNORE" ] ; then \
erikj@445 313 continue; \
erikj@445 314 elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
erikj@445 315 $(PRINTF) " %s:%s" \
erikj@445 316 "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
erikj@445 317 elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
erikj@445 318 $(PRINTF) " %s:%s" \
erikj@445 319 "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
erikj@445 320 fi; \
erikj@445 321 done >> $@
erikj@445 322 $(PRINTF) "\n" >> $@
erikj@445 323 endef
erikj@445 324
erikj@445 325 # Create the HGTIP_FILENAME file. Called from jdk/make/closed/bundles.gmk
erikj@445 326 define CreateHgTip
erikj@445 327 $(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME);\
erikj@445 328 $(ECHO) $1/$(HGTIP_FILENAME)
erikj@445 329 endef
erikj@445 330
erikj@445 331 define SetupLogging
ohair@494 332 ifeq ($$(LOG), trace)
erikj@445 333 # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
ohair@494 334 # For each target executed, will print
ohair@494 335 # Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer)
ohair@494 336 # but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much (and causing a crash on Cygwin).
erikj@445 337 OLD_SHELL:=$$(SHELL)
ohair@494 338 WRAPPER_SHELL:=$$(OLD_SHELL) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(TIME),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(OLD_SHELL)
ohair@494 339 SHELL=$$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
ohair@494 340 endif
ohair@494 341 # Never remove warning messages; this is just for completeness
ohair@494 342 LOG_WARN=
ohair@494 343 ifneq ($$(findstring $$(LOG),info debug trace),)
ohair@494 344 LOG_INFO=
ohair@494 345 else
ohair@494 346 LOG_INFO=> /dev/null
ohair@494 347 endif
ohair@494 348 ifneq ($$(findstring $$(LOG),debug trace),)
ohair@494 349 LOG_DEBUG=
ohair@494 350 else
ohair@494 351 LOG_DEBUG=> /dev/null
ohair@494 352 endif
ohair@494 353 ifneq ($$(findstring $$(LOG),trace),)
ohair@494 354 LOG_TRACE=
ohair@494 355 else
ohair@494 356 LOG_TRACE=> /dev/null
erikj@445 357 endif
erikj@445 358 endef
erikj@445 359
erikj@445 360 # Make sure logging is setup for everyone that includes MakeBase.gmk.
erikj@445 361 $(eval $(call SetupLogging))
erikj@445 362
ohair@494 363 # This is to be called by all SetupFoo macros
ohair@494 364 define LogSetupMacroEntry
ohair@494 365 $(if $(26),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk))
ohair@494 366 $(if $(findstring $(LOG),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,$(if $($i),$(NEWLINE) $(strip [$i] $($i))))))
ohair@494 367 endef
ohair@494 368
ohair@494 369 # Make directory without forking mkdir if not needed
ohair@494 370 define MakeDir
ohair@494 371 ifneq ($$(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),$$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9))
ohair@494 372 $$(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)
ohair@494 373 endif
ohair@494 374 endef
ohair@494 375
ohair@494 376 ifeq ($(OPENJDK_TARGET_OS),solaris)
ohair@494 377 # On Solaris, if the target is a symlink and exists, cp won't overwrite.
ohair@494 378 define install-file
ohair@494 379 $(MKDIR) -p $(@D)
ohair@494 380 $(RM) '$@'
ohair@494 381 $(CP) -f -r -P '$<' '$(@D)'
ohair@494 382 endef
ohair@494 383 else ifeq ($(OPENJDK_TARGET_OS),macosx)
ohair@494 384 define install-file
ohair@494 385 $(MKDIR) -p $(@D)
ohair@494 386 $(CP) -fpRP '$<' '$@'
ohair@494 387 endef
ohair@494 388 else
ohair@494 389 define install-file
ohair@494 390 $(MKDIR) -p $(@D)
ohair@494 391 $(CP) -fP '$<' '$@'
ohair@494 392 endef
ohair@494 393 endif
ohair@494 394
erikj@557 395 # Convenience functions for working around make's limitations with $(filter ).
erikj@557 396 containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
erikj@557 397 not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
erikj@557 398
erikj@557 399 ################################################################################
erikj@557 400 # In Cygwin, finds are very costly, both because of expensive forks and because
erikj@557 401 # of bad file system caching. Find is used extensively in $(shell) commands to
erikj@557 402 # find source files. This makes rerunning make with no or few changes rather
erikj@557 403 # expensive. To speed this up, these two macros are used to cache the results
erikj@557 404 # of simple find commands for reuse.
erikj@557 405 #
erikj@557 406 # Runs a find and stores both the directories where it was run and the results.
erikj@557 407 # This macro can be called multiple times to add to the cache. Only finds files
erikj@557 408 # with no filters.
erikj@557 409 #
erikj@557 410 # Needs to be called with $(eval )
erikj@557 411 #
erikj@557 412 # Param 1 - Dir to find in
erikj@557 413 ifeq ($(OPENJDK_BUILD_OS),windows)
erikj@557 414 define FillCacheFind
erikj@557 415 FIND_CACHE_DIR += $1
erikj@557 416 FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $1 -type f -o -type l))
erikj@557 417 endef
erikj@557 418 else
erikj@557 419 define FillCacheFind
erikj@557 420 endef
erikj@557 421 endif
erikj@557 422
erikj@557 423 # Mimics find by looking in the cache if all of the directories have been cached.
erikj@557 424 # Otherwise reverts to shell find. This is safe to call on all platforms, even if
erikj@557 425 # cache is deactivated.
erikj@557 426 #
erikj@557 427 # The extra - is needed when FIND_CACHE_DIR is empty but should be harmless.
erikj@557 428 # Param 1 - Dirs to find in
erikj@557 429 define CacheFind
erikj@557 430 $(if $(filter-out $(addsuffix %,- $(FIND_CACHE_DIR)),$1),\
erikj@557 431 $(shell $(FIND) $1 -type f -o -type l),\
erikj@557 432 $(filter $(addsuffix %,$1),$(FIND_CACHE)))
erikj@557 433 endef
erikj@557 434
erikj@557 435 ################################################################################
erikj@557 436
ohair@425 437 endif # _MAKEBASE_GMK

mercurial