ohair@425: # ohair@425: # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. ohair@425: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@425: # ohair@425: # This code is free software; you can redistribute it and/or modify it ohair@425: # under the terms of the GNU General Public License version 2 only, as ohair@425: # published by the Free Software Foundation. Oracle designates this ohair@425: # particular file as subject to the "Classpath" exception as provided ohair@425: # by Oracle in the LICENSE file that accompanied this code. ohair@425: # ohair@425: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@425: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@425: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@425: # version 2 for more details (a copy is included in the LICENSE file that ohair@425: # accompanied this code). ohair@425: # ohair@425: # You should have received a copy of the GNU General Public License version ohair@425: # 2 along with this work; if not, write to the Free Software Foundation, ohair@425: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@425: # ohair@425: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@425: # or visit www.oracle.com if you need additional information or have any ohair@425: # questions. ohair@425: # ohair@425: ohair@425: ################################################################ ohair@425: # ohair@425: # Check that GNU make and cygwin are recent enough. ohair@425: # Setup common utility functions. ohair@425: # ohair@425: ################################################################ ohair@425: ohair@425: ifndef _MAKEBASE_GMK ohair@425: _MAKEBASE_GMK := 1 ohair@425: ohair@425: # If the variable that you want to send to stdout for piping into a file or otherwise, ohair@425: # is potentially long, for example the a list of file paths, eg a list of all package directories. ohair@425: # Then you need to use ListPathsSafely, which optimistically splits the output into several shell ohair@425: # calls as well as use compression on recurrent file paths segments, to get around the potential ohair@425: # command line length problem that exists in cygwin and other shells. ohair@494: compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-pre-compress.incl)) ohair@494: compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-post-compress.incl)) ohair@425: compress_paths=$(compress_pre)\ ohair@425: $(subst $(SRC_ROOT),X97,\ ohair@425: $(subst $(OUTPUT_ROOT),X98,\ ohair@425: $(subst X,X00,\ ohair@425: $(subst $(SPACE),\n,$(strip $1)))))\ ohair@425: $(compress_post) ohair@425: ohair@494: decompress_paths=$(SED) -f $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \ ohair@425: -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \ ohair@425: -e 's|X00|X|g' | tr '\n' '$2' ohair@425: jjg@645: # Subst in an extra $ to prevent it from disappearing. ohair@425: define ListPathsSafely_If jjg@645: $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(subst $$,$$$$,$(wordlist $3,$4,$($1)))))) ohair@425: endef ohair@425: ohair@425: define ListPathsSafely_Printf ohair@425: $(if $(strip $($1_LPS$4)),printf -- "$(strip $($1_LPS$4))\n" | $(decompress_paths) $3) ohair@425: endef ohair@425: ohair@425: # Receipt example: ohair@425: # rm -f thepaths ohair@425: # $(call ListPathsSafely,THEPATHS,\n, >> thepaths) ohair@425: # The \n argument means translate spaces into \n ohair@425: # if instead , , (a space) is supplied, then spaces remain spaces. ohair@425: define ListPathsSafely erikj@501: $(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!)) ohair@425: $(call ListPathsSafely_If,$1,$2,1,250) ohair@425: $(call ListPathsSafely_If,$1,$2,251,500) ohair@425: $(call ListPathsSafely_If,$1,$2,501,750) ohair@425: $(call ListPathsSafely_If,$1,$2,751,1000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,1001,1250) ohair@425: $(call ListPathsSafely_If,$1,$2,1251,1500) ohair@425: $(call ListPathsSafely_If,$1,$2,1501,1750) ohair@425: $(call ListPathsSafely_If,$1,$2,1751,2000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,2001,2250) ohair@425: $(call ListPathsSafely_If,$1,$2,2251,2500) ohair@425: $(call ListPathsSafely_If,$1,$2,2501,2750) ohair@425: $(call ListPathsSafely_If,$1,$2,2751,3000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,3001,3250) ohair@425: $(call ListPathsSafely_If,$1,$2,3251,3500) ohair@425: $(call ListPathsSafely_If,$1,$2,3501,3750) ohair@425: $(call ListPathsSafely_If,$1,$2,3751,4000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,4001,4250) ohair@425: $(call ListPathsSafely_If,$1,$2,4251,4500) ohair@425: $(call ListPathsSafely_If,$1,$2,4501,4750) ohair@425: $(call ListPathsSafely_If,$1,$2,4751,5000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,5001,5250) ohair@425: $(call ListPathsSafely_If,$1,$2,5251,5500) ohair@425: $(call ListPathsSafely_If,$1,$2,5501,5750) ohair@425: $(call ListPathsSafely_If,$1,$2,5751,6000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,6001,6250) ohair@425: $(call ListPathsSafely_If,$1,$2,6251,6500) ohair@425: $(call ListPathsSafely_If,$1,$2,6501,6750) ohair@425: $(call ListPathsSafely_If,$1,$2,6751,7000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,7001,7250) ohair@425: $(call ListPathsSafely_If,$1,$2,7251,7500) ohair@425: $(call ListPathsSafely_If,$1,$2,7501,7750) ohair@425: $(call ListPathsSafely_If,$1,$2,7751,8000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,8001,8250) ohair@425: $(call ListPathsSafely_If,$1,$2,8251,8500) ohair@425: $(call ListPathsSafely_If,$1,$2,8501,8750) ohair@425: $(call ListPathsSafely_If,$1,$2,8751,9000) ohair@425: ohair@425: $(call ListPathsSafely_If,$1,$2,9001,9250) ohair@425: $(call ListPathsSafely_If,$1,$2,9251,9500) ohair@425: $(call ListPathsSafely_If,$1,$2,9501,9750) ohair@425: $(call ListPathsSafely_If,$1,$2,9751,10000) ohair@425: erikj@501: $(call ListPathsSafely_If,$1,$2,10001,10250) erikj@501: $(call ListPathsSafely_If,$1,$2,10251,10500) erikj@501: $(call ListPathsSafely_If,$1,$2,10501,10750) erikj@501: $(call ListPathsSafely_If,$1,$2,10751,11000) erikj@501: erikj@501: $(call ListPathsSafely_If,$1,$2,11001,11250) erikj@501: $(call ListPathsSafely_If,$1,$2,11251,11500) erikj@501: $(call ListPathsSafely_If,$1,$2,11501,11750) erikj@501: $(call ListPathsSafely_If,$1,$2,11751,12000) erikj@501: erikj@501: $(call ListPathsSafely_If,$1,$2,12001,12250) erikj@501: $(call ListPathsSafely_If,$1,$2,12251,12500) erikj@501: $(call ListPathsSafely_If,$1,$2,12501,12750) erikj@501: $(call ListPathsSafely_If,$1,$2,12751,13000) erikj@501: erikj@501: $(call ListPathsSafely_If,$1,$2,13001,13250) erikj@501: $(call ListPathsSafely_If,$1,$2,13251,13500) erikj@501: $(call ListPathsSafely_If,$1,$2,13501,13750) erikj@501: $(call ListPathsSafely_If,$1,$2,13751,14000) erikj@501: erikj@501: $(call ListPathsSafely_If,$1,$2,14001,14250) erikj@501: $(call ListPathsSafely_If,$1,$2,14251,14500) erikj@501: $(call ListPathsSafely_If,$1,$2,14501,14750) erikj@501: $(call ListPathsSafely_If,$1,$2,14751,15000) erikj@501: erikj@501: $(call ListPathsSafely_If,$1,$2,15001,15250) erikj@501: $(call ListPathsSafely_If,$1,$2,15251,15500) erikj@501: $(call ListPathsSafely_If,$1,$2,15501,15750) erikj@501: $(call ListPathsSafely_If,$1,$2,15751,16000) erikj@501: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,1) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,1001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,1251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,1501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,1751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,2001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,2251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,2501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,2751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,3001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,3251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,3501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,3751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,4001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,4251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,4501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,4751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,5001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,5251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,5501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,5751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,6001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,6251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,6501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,6751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,7001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,7251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,7501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,7751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,8001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,8251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,8501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,8751) ohair@425: ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,9001) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,9251) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,9501) ohair@425: $(call ListPathsSafely_Printf,$1,$2,$3,9751) erikj@501: erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,10001) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,10251) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,10501) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,10751) erikj@501: erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,11001) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,11251) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,11501) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,11751) erikj@501: erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,12001) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,12251) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,12501) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,12751) erikj@501: erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,13001) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,13251) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,13501) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,13751) erikj@501: erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,14001) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,14251) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,14501) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,14751) erikj@501: erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,15001) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,15251) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,15501) erikj@501: $(call ListPathsSafely_Printf,$1,$2,$3,15751) ohair@425: endef ohair@425: ohair@425: define ListPathsSafelyNow_IfPrintf ohair@425: ifneq (,$$(word $4,$$($1))) ohair@425: $$(eval $1_LPS$4:=$$(call compress_paths,$$(wordlist $4,$5,$$($1)))) ohair@425: $$(shell printf -- "$$(strip $$($1_LPS$4))\n" | $(decompress_paths) $3) ohair@425: endif ohair@425: endef ohair@425: ohair@425: # And an non-receipt version: ohair@425: define ListPathsSafelyNow ohair@425: ifneq (,$$(word 10001,$$($1))) ohair@425: $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!) ohair@425: endif ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1,250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,251,500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,501,750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,751,1000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1001,1250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1251,1500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1501,1750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1751,2000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2001,2250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2251,2500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2501,2750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2751,3000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3001,3250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3251,3500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3501,3750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3751,4000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4001,4250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4251,4500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4501,4750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4751,5000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5001,5250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5251,5500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5501,5750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5751,6000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6001,6250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6251,6500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6501,6750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6751,7000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7001,7250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7251,7500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7501,7750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7751,8000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8001,8250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8251,8500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8501,8750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8751,9000) ohair@425: ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9001,9250) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9251,9500) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9501,9750) ohair@425: $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9751,10000) ohair@425: ohair@425: endef ohair@425: erikj@445: # The source tips can come from the Mercurial repository, or in the files erikj@445: # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same erikj@445: # directory as the original $(HGDIR) directory. erikj@445: # These should not be := assignments, only used from the root Makefile. erikj@445: HG_VERSION = $(shell $(HG) version 2> /dev/null) erikj@445: HG_DIRECTORY=.hg erikj@445: HGTIP_FILENAME=.hgtip erikj@445: HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO erikj@445: REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \ erikj@445: $(shell $(CD) $(SRC_ROOT) ; ( $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) ; \ erikj@445: $(LS) $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) ) \ erikj@445: 2> /dev/null))))) erikj@445: erikj@445: # Emit the repo:tip pairs to $@ erikj@445: define GetSourceTips erikj@445: $(CD) $(SRC_ROOT) ; \ erikj@445: for i in $(REPO_LIST) IGNORE ; do \ erikj@445: if [ "$${i}" = "IGNORE" ] ; then \ erikj@445: continue; \ erikj@445: elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \ erikj@445: $(PRINTF) " %s:%s" \ erikj@445: "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \ erikj@445: elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \ erikj@445: $(PRINTF) " %s:%s" \ erikj@445: "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \ erikj@445: fi; \ erikj@445: done >> $@ erikj@445: $(PRINTF) "\n" >> $@ erikj@445: endef erikj@445: erikj@445: # Create the HGTIP_FILENAME file. Called from jdk/make/closed/bundles.gmk erikj@445: define CreateHgTip erikj@445: $(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME);\ erikj@445: $(ECHO) $1/$(HGTIP_FILENAME) erikj@445: endef erikj@445: erikj@445: define SetupLogging ohair@494: ifeq ($$(LOG), trace) erikj@445: # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make ohair@494: # For each target executed, will print ohair@494: # Building (from ) ( newer) ohair@494: # but with a limit of 20 on , to avoid cluttering logs too much (and causing a crash on Cygwin). erikj@445: OLD_SHELL:=$$(SHELL) ohair@494: WRAPPER_SHELL:=$$(OLD_SHELL) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(TIME),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(OLD_SHELL) ohair@494: 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: endif ohair@494: # Never remove warning messages; this is just for completeness ohair@494: LOG_WARN= ohair@494: ifneq ($$(findstring $$(LOG),info debug trace),) ohair@494: LOG_INFO= ohair@494: else ohair@494: LOG_INFO=> /dev/null ohair@494: endif ohair@494: ifneq ($$(findstring $$(LOG),debug trace),) ohair@494: LOG_DEBUG= ohair@494: else ohair@494: LOG_DEBUG=> /dev/null ohair@494: endif ohair@494: ifneq ($$(findstring $$(LOG),trace),) ohair@494: LOG_TRACE= ohair@494: else ohair@494: LOG_TRACE=> /dev/null erikj@445: endif erikj@445: endef erikj@445: erikj@445: # Make sure logging is setup for everyone that includes MakeBase.gmk. erikj@445: $(eval $(call SetupLogging)) erikj@445: ohair@494: # This is to be called by all SetupFoo macros ohair@494: define LogSetupMacroEntry ohair@494: $(if $(26),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk)) ohair@494: $(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: endef ohair@494: ohair@494: # Make directory without forking mkdir if not needed ohair@494: define MakeDir ohair@494: ifneq ($$(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),$$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9)) ohair@494: $$(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9) ohair@494: endif ohair@494: endef ohair@494: ohair@494: ifeq ($(OPENJDK_TARGET_OS),solaris) ohair@494: # On Solaris, if the target is a symlink and exists, cp won't overwrite. ohair@494: define install-file ohair@494: $(MKDIR) -p $(@D) ohair@494: $(RM) '$@' ohair@494: $(CP) -f -r -P '$<' '$(@D)' ohair@494: endef ohair@494: else ifeq ($(OPENJDK_TARGET_OS),macosx) ohair@494: define install-file ohair@494: $(MKDIR) -p $(@D) ohair@494: $(CP) -fpRP '$<' '$@' ohair@494: endef ohair@494: else ohair@494: define install-file ohair@494: $(MKDIR) -p $(@D) ohair@494: $(CP) -fP '$<' '$@' ohair@494: endef ohair@494: endif ohair@494: erikj@557: # Convenience functions for working around make's limitations with $(filter ). erikj@557: containing = $(foreach v,$2,$(if $(findstring $1,$v),$v)) erikj@557: not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v)) erikj@557: erikj@557: ################################################################################ erikj@557: # In Cygwin, finds are very costly, both because of expensive forks and because erikj@557: # of bad file system caching. Find is used extensively in $(shell) commands to erikj@557: # find source files. This makes rerunning make with no or few changes rather erikj@557: # expensive. To speed this up, these two macros are used to cache the results erikj@557: # of simple find commands for reuse. erikj@557: # erikj@557: # Runs a find and stores both the directories where it was run and the results. erikj@557: # This macro can be called multiple times to add to the cache. Only finds files erikj@557: # with no filters. erikj@557: # erikj@557: # Needs to be called with $(eval ) erikj@557: # erikj@557: # Param 1 - Dir to find in erikj@557: ifeq ($(OPENJDK_BUILD_OS),windows) erikj@557: define FillCacheFind erikj@557: FIND_CACHE_DIR += $1 erikj@557: FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $1 -type f -o -type l)) erikj@557: endef erikj@557: else erikj@557: define FillCacheFind erikj@557: endef erikj@557: endif erikj@557: erikj@557: # Mimics find by looking in the cache if all of the directories have been cached. erikj@557: # Otherwise reverts to shell find. This is safe to call on all platforms, even if erikj@557: # cache is deactivated. erikj@557: # erikj@557: # The extra - is needed when FIND_CACHE_DIR is empty but should be harmless. erikj@557: # Param 1 - Dirs to find in erikj@557: define CacheFind erikj@557: $(if $(filter-out $(addsuffix %,- $(FIND_CACHE_DIR)),$1),\ erikj@557: $(shell $(FIND) $1 -type f -o -type l),\ erikj@557: $(filter $(addsuffix %,$1),$(FIND_CACHE))) erikj@557: endef erikj@557: erikj@557: ################################################################################ erikj@557: ohair@425: endif # _MAKEBASE_GMK