69 HAS_FILE_FUNCTION := true
70 endif
71
72 ##############################
73 # Functions
74 ##############################
75
76 ### Debug functions
77
78 # Prints the name and value of a variable
79 PrintVar = \
80 $(info $(strip $1) >$($(strip $1))<)
81
82 ### Functions for timers
83
84 # Store the build times in this directory.
85 BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
86
87 # Record starting time for build of a sub repository.
88 define RecordStartTime
89 $(MKDIR) -p $(BUILDTIMESDIR)
90 $(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)
91 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
92 endef
93
94 # Record ending time and calculate the difference and store it in a
95 # easy to read format. Handles builds that cross midnight. Expects
96 # that a build will never take 24 hours or more.
97 define RecordEndTime
98 $(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)
99 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
100 $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \
101 $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
102 M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
103 > $(BUILDTIMESDIR)/build_time_diff_$(strip $1)
104 endef
105
106 # Hook to be called when starting to execute a top-level target
107 define TargetEnter
108 $(PRINTF) "## Starting $(patsubst %-only,%,$@)\n"
109 $(call RecordStartTime,$(patsubst %-only,%,$@))
110 endef
216 $$(call ListPathsSafely_IfPrintf,$1,$2,6501,6750)
217 $$(call ListPathsSafely_IfPrintf,$1,$2,6751,7000)
218
219 $$(call ListPathsSafely_IfPrintf,$1,$2,7001,7250)
220 $$(call ListPathsSafely_IfPrintf,$1,$2,7251,7500)
221 $$(call ListPathsSafely_IfPrintf,$1,$2,7501,7750)
222 $$(call ListPathsSafely_IfPrintf,$1,$2,7751,8000)
223
224 $$(call ListPathsSafely_IfPrintf,$1,$2,8001,8250)
225 $$(call ListPathsSafely_IfPrintf,$1,$2,8251,8500)
226 $$(call ListPathsSafely_IfPrintf,$1,$2,8501,8750)
227 $$(call ListPathsSafely_IfPrintf,$1,$2,8751,9000)
228
229 $$(call ListPathsSafely_IfPrintf,$1,$2,9001,9250)
230 $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500)
231 $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
232 $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
233 endef
234 endif # HAS_FILE_FUNCTION
235
236 # The source tips can come from the Mercurial repository, or in the files
237 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
238 # directory as the original $(HGDIR) directory.
239 # These should not be := assignments, only used from the root Makefile.
240 HG_VERSION = $(shell $(HG) version 2> /dev/null)
241 HG_DIRECTORY=.hg
242 HGTIP_FILENAME=.hgtip
243 HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
244 REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
245 $(shell $(CD) $(SRC_ROOT) ; \
246 $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) \
247 $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) \
248 2> /dev/null)))))
249
250 # Emit the repo:tip pairs to $@
251 define GetSourceTips
252 $(CD) $(SRC_ROOT) ; \
253 for i in $(REPO_LIST) IGNORE ; do \
254 if [ "$${i}" = "IGNORE" ] ; then \
255 continue; \
256 elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
257 $(PRINTF) " %s:%s" \
258 "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
259 elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
260 $(PRINTF) " %s:%s" \
261 "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
262 fi; \
263 done >> $@
264 $(PRINTF) "\n" >> $@
265 endef
266
267 # Create the HGTIP_FILENAME file. Called from jdk/make/closed/bundles.gmk
268 define CreateHgTip
269 $(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
270 $(ECHO) $1/$(HGTIP_FILENAME)
271 endef
272
273 define SetupLogging
274 ifeq ($$(LOG_LEVEL), trace)
275 # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
276 # For each target executed, will print
277 # Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer)
278 # but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much
279 # (and causing a crash on Cygwin).
280 # Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris.
281 # Only use time if it's GNU time which supports format and output file.
282 WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL)
283 SHELL := $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
284 endif
285 # Never remove warning messages; this is just for completeness
286 LOG_WARN :=
287 ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),)
288 LogInfo = $$(info $$(strip $$1))
289 LOG_INFO :=
290 else
291 LogInfo =
292 LOG_INFO := > /dev/null
351 # Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix
352 $(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\
353 $(strip $1)_$(strip $($i)))$(NEWLINE))
354 # Debug print all named parameter names and values
355 $(if $(findstring $(LOG_LEVEL),debug trace), \
356 $(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \
357 $(if $(strip $($i)),$(NEWLINE) $(strip [$i] $(if $(filter $(LOG_LEVEL), trace), \
358 $($i), $(wordlist 1, 20, $($(i))) $(if $(word 21, $($(i))), ...)))))))
359
360 $(if $(DEBUG_$(strip $1)),
361 $(info -------- <<< Begin expansion of $(strip $1)) \
362 $(info $(call $(0)Body,$(strip $1))) \
363 $(info -------- >>> End expansion of $(strip $1)) \
364 )
365
366 $(call $(0)Body,$(strip $1))
367 endef
368
369 ################################################################################
370 # Make directory without forking mkdir if not needed
371 MakeDir = \
372 $(strip $(if $(subst $(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),,$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9)),\
373 $(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)))
374
375 ################################################################################
376 # Assign a variable only if it is empty
377 # Param 1 - Variable to assign
378 # Param 2 - Value to assign
379 SetIfEmpty = \
380 $(if $($(strip $1)),,$(eval $(strip $1) := $2))
381
382 ################################################################################
383
384 ifeq ($(OPENJDK_TARGET_OS),solaris)
385 # On Solaris, if the target is a symlink and exists, cp won't overwrite.
386 # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the
387 # name of the target file differs from the source file, rename after copy.
388 # If the source and target parent directories are the same, recursive copy doesn't work
389 # so we fall back on regular copy, which isn't preserving symlinks.
390 define install-file
391 $(MKDIR) -p '$(@D)'
392 $(RM) '$@'
393 if [ "$(@D)" != "$(<D)" ]; then \
401 exit 1; \
402 fi; \
403 $(CP) -f '$<' '$@'; \
404 fi
405 endef
406 else ifeq ($(OPENJDK_TARGET_OS),macosx)
407 # On mac, extended attributes sometimes creep into the source files, which may later
408 # cause the creation of ._* files which confuses testing. Clear these with xattr if
409 # set. Some files get their write permissions removed after being copied to the
410 # output dir. When these are copied again to images, xattr would fail. By only clearing
411 # attributes when they are present, failing on this is avoided.
412 define install-file
413 $(MKDIR) -p '$(@D)'
414 $(CP) -fRP '$<' '$@'
415 if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
416 endef
417 else
418 # Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
419 # significantly.
420 define install-file
421 $(MKDIR) -p '$(@D)' && $(CP) -fP '$<' '$@'
422 endef
423 endif
424
425 ################################################################################
426 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
427 uniq = \
428 $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
429
430 # Returns all whitespace-separated words in $2 where at least one of the
431 # whitespace-separated words in $1 is a substring.
432 containing = \
433 $(strip \
434 $(foreach v,$(strip $2),\
435 $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v)))))
436
437 # Returns all whitespace-separated words in $2 where none of the
438 # whitespace-separated words in $1 is a substring.
439 not-containing = \
440 $(strip $(filter-out $(call containing,$1,$2),$2))
441
524 endef
525
526 else
527 # If CacheFind is disabled, just run the find command.
528 # Param 1 - Dirs to find in
529 # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
530 define CacheFind
531 $(shell $(FIND) $1 \( -type f -o -type l \) $2)
532 endef
533 endif
534
535 ################################################################################
536
537 define AddFileToCopy
538 # Helper macro for SetupCopyFiles
539 # 1 : Source file
540 # 2 : Dest file
541 # 3 : Variable to add targets to
542 # 4 : Macro to call for copy operation
543 $2: $1
544 $(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@)
545 $$($$(strip $4))
546
547 $3 += $2
548 endef
549
550 # Returns the value of the first argument
551 identity = \
552 $(strip $1)
553
554 # Setup make rules for copying files, with an option to do more complex
555 # processing instead of copying.
556 #
557 # Parameter 1 is the name of the rule. This name is used as variable prefix,
558 # and the targets generated are listed in a variable by that name.
559 #
560 # Remaining parameters are named arguments. These include:
561 # SRC : Source root dir (defaults to dir of first file)
562 # DEST : Dest root dir
563 # FILES : List of files to copy with absolute paths, or path relative to SRC.
564 # Must be in SRC.
669 $(call DependOnVariableFileName, $1, $2) \
670 )
671
672 # Main macro
673 # Param 1 - Name of variable
674 # Param 2 - (optional) name of file to store value in
675 DependOnVariable = \
676 $(call DependOnVariableHelper,$(strip $1),$(strip $2))
677
678 ################################################################################
679 # Failure logging support macros. These are supposed to be used by the Setup*
680 # compilation macros.
681 #
682 # LogFailures will run a command and store a copy of output in a specified file.
683 # If the command succeeds, the file is deleted, otherwise it is moved to the
684 # failure-logs directory.
685 # Param 1 - The log file of the failed command
686 # Param 2 - A compact but representative name to describe this command
687 # Param 3 - Command to run
688 LogFailures = \
689 ( ($(BASH) $(SRC_ROOT)/common/bin/logger.sh $1 $3 && $(RM) $1) || \
690 (exitcode=$(DOLLAR)$(DOLLAR)? && $(MV) $1 $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(strip $2).log && exit $(DOLLAR)$(DOLLAR)exitcode) )
691
692 ################################################################################
693 # Find lib dir for module
694 # Param 1 - module name
695 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
696 FindLibDirForModule = \
697 $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)$(OPENJDK_TARGET_CPU_LIBDIR)
698 else
699 FindLibDirForModule = \
700 $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
701 endif
702
703 ################################################################################
704 # Return a string suitable for use after a -classpath option. It will correct and safe to use
705 # on all platforms. Arguments are given as space separate classpath entries.
706 # param 1 : A space separated list of classpath entries
707 # The surrounding strip is needed to keep additional whitespace out
708 PathList = \
709 "$(subst $(SPACE),$(PATH_SEP),$(strip $1))"
710
|
69 HAS_FILE_FUNCTION := true
70 endif
71
72 ##############################
73 # Functions
74 ##############################
75
76 ### Debug functions
77
78 # Prints the name and value of a variable
79 PrintVar = \
80 $(info $(strip $1) >$($(strip $1))<)
81
82 ### Functions for timers
83
84 # Store the build times in this directory.
85 BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
86
87 # Record starting time for build of a sub repository.
88 define RecordStartTime
89 $(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) && \
90 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
91 endef
92
93 # Record ending time and calculate the difference and store it in a
94 # easy to read format. Handles builds that cross midnight. Expects
95 # that a build will never take 24 hours or more.
96 define RecordEndTime
97 $(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)
98 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
99 $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \
100 $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
101 M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
102 > $(BUILDTIMESDIR)/build_time_diff_$(strip $1)
103 endef
104
105 # Hook to be called when starting to execute a top-level target
106 define TargetEnter
107 $(PRINTF) "## Starting $(patsubst %-only,%,$@)\n"
108 $(call RecordStartTime,$(patsubst %-only,%,$@))
109 endef
215 $$(call ListPathsSafely_IfPrintf,$1,$2,6501,6750)
216 $$(call ListPathsSafely_IfPrintf,$1,$2,6751,7000)
217
218 $$(call ListPathsSafely_IfPrintf,$1,$2,7001,7250)
219 $$(call ListPathsSafely_IfPrintf,$1,$2,7251,7500)
220 $$(call ListPathsSafely_IfPrintf,$1,$2,7501,7750)
221 $$(call ListPathsSafely_IfPrintf,$1,$2,7751,8000)
222
223 $$(call ListPathsSafely_IfPrintf,$1,$2,8001,8250)
224 $$(call ListPathsSafely_IfPrintf,$1,$2,8251,8500)
225 $$(call ListPathsSafely_IfPrintf,$1,$2,8501,8750)
226 $$(call ListPathsSafely_IfPrintf,$1,$2,8751,9000)
227
228 $$(call ListPathsSafely_IfPrintf,$1,$2,9001,9250)
229 $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500)
230 $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
231 $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
232 endef
233 endif # HAS_FILE_FUNCTION
234
235 ################################################################################
236 # The source tips can come from the Mercurial repository, or in the files
237 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
238 # directory as the original $(HGDIR) directory.
239 # These should not be := assignments, only used from the root Makefile.
240 HG_VERSION = $(shell $(HG) version 2> /dev/null)
241 HG_DIRECTORY=.hg
242 HGTIP_FILENAME=.hgtip
243 HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
244 REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
245 $(shell $(CD) $(SRC_ROOT) ; \
246 $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) \
247 $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) \
248 2> /dev/null)))))
249
250 # Emit the repo:tip pairs to $@
251 define GetSourceTips
252 $(CD) $(SRC_ROOT) ; \
253 for i in $(REPO_LIST) IGNORE ; do \
254 if [ "$${i}" = "IGNORE" ] ; then \
255 continue; \
256 elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
257 $(PRINTF) " %s:%s" \
258 "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
259 elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
260 $(PRINTF) " %s:%s" \
261 "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
262 fi; \
263 done >> $@
264 $(PRINTF) "\n" >> $@
265 endef
266
267 # Create the HGTIP_FILENAME file. Called from closed/make/SourceBundles.gmk
268 define CreateHgTip
269 $(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
270 $(ECHO) $1/$(HGTIP_FILENAME)
271 endef
272
273 ################################################################################
274
275 define SetupLogging
276 ifeq ($$(LOG_LEVEL), trace)
277 # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
278 # For each target executed, will print
279 # Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer)
280 # but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much
281 # (and causing a crash on Cygwin).
282 # Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris.
283 # Only use time if it's GNU time which supports format and output file.
284 WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL)
285 SHELL := $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
286 endif
287 # Never remove warning messages; this is just for completeness
288 LOG_WARN :=
289 ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),)
290 LogInfo = $$(info $$(strip $$1))
291 LOG_INFO :=
292 else
293 LogInfo =
294 LOG_INFO := > /dev/null
353 # Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix
354 $(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\
355 $(strip $1)_$(strip $($i)))$(NEWLINE))
356 # Debug print all named parameter names and values
357 $(if $(findstring $(LOG_LEVEL),debug trace), \
358 $(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \
359 $(if $(strip $($i)),$(NEWLINE) $(strip [$i] $(if $(filter $(LOG_LEVEL), trace), \
360 $($i), $(wordlist 1, 20, $($(i))) $(if $(word 21, $($(i))), ...)))))))
361
362 $(if $(DEBUG_$(strip $1)),
363 $(info -------- <<< Begin expansion of $(strip $1)) \
364 $(info $(call $(0)Body,$(strip $1))) \
365 $(info -------- >>> End expansion of $(strip $1)) \
366 )
367
368 $(call $(0)Body,$(strip $1))
369 endef
370
371 ################################################################################
372 # Make directory without forking mkdir if not needed
373 # 1: List of directories to create
374 MakeDir = \
375 $(strip $(if $(wildcard $1), , $(shell $(MKDIR) -p $1)))
376
377 ################################################################################
378 # Assign a variable only if it is empty
379 # Param 1 - Variable to assign
380 # Param 2 - Value to assign
381 SetIfEmpty = \
382 $(if $($(strip $1)),,$(eval $(strip $1) := $2))
383
384 ################################################################################
385
386 ifeq ($(OPENJDK_TARGET_OS),solaris)
387 # On Solaris, if the target is a symlink and exists, cp won't overwrite.
388 # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the
389 # name of the target file differs from the source file, rename after copy.
390 # If the source and target parent directories are the same, recursive copy doesn't work
391 # so we fall back on regular copy, which isn't preserving symlinks.
392 define install-file
393 $(MKDIR) -p '$(@D)'
394 $(RM) '$@'
395 if [ "$(@D)" != "$(<D)" ]; then \
403 exit 1; \
404 fi; \
405 $(CP) -f '$<' '$@'; \
406 fi
407 endef
408 else ifeq ($(OPENJDK_TARGET_OS),macosx)
409 # On mac, extended attributes sometimes creep into the source files, which may later
410 # cause the creation of ._* files which confuses testing. Clear these with xattr if
411 # set. Some files get their write permissions removed after being copied to the
412 # output dir. When these are copied again to images, xattr would fail. By only clearing
413 # attributes when they are present, failing on this is avoided.
414 define install-file
415 $(MKDIR) -p '$(@D)'
416 $(CP) -fRP '$<' '$@'
417 if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
418 endef
419 else
420 # Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
421 # significantly.
422 define install-file
423 $(call MakeDir, $(@D))
424 $(CP) -fP '$<' '$@'
425 endef
426 endif
427
428 ################################################################################
429 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
430 uniq = \
431 $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
432
433 # Returns all whitespace-separated words in $2 where at least one of the
434 # whitespace-separated words in $1 is a substring.
435 containing = \
436 $(strip \
437 $(foreach v,$(strip $2),\
438 $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v)))))
439
440 # Returns all whitespace-separated words in $2 where none of the
441 # whitespace-separated words in $1 is a substring.
442 not-containing = \
443 $(strip $(filter-out $(call containing,$1,$2),$2))
444
527 endef
528
529 else
530 # If CacheFind is disabled, just run the find command.
531 # Param 1 - Dirs to find in
532 # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
533 define CacheFind
534 $(shell $(FIND) $1 \( -type f -o -type l \) $2)
535 endef
536 endif
537
538 ################################################################################
539
540 define AddFileToCopy
541 # Helper macro for SetupCopyFiles
542 # 1 : Source file
543 # 2 : Dest file
544 # 3 : Variable to add targets to
545 # 4 : Macro to call for copy operation
546 $2: $1
547 $$(call LogInfo, Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@))
548 $$($$(strip $4))
549
550 $3 += $2
551 endef
552
553 # Returns the value of the first argument
554 identity = \
555 $(strip $1)
556
557 # Setup make rules for copying files, with an option to do more complex
558 # processing instead of copying.
559 #
560 # Parameter 1 is the name of the rule. This name is used as variable prefix,
561 # and the targets generated are listed in a variable by that name.
562 #
563 # Remaining parameters are named arguments. These include:
564 # SRC : Source root dir (defaults to dir of first file)
565 # DEST : Dest root dir
566 # FILES : List of files to copy with absolute paths, or path relative to SRC.
567 # Must be in SRC.
672 $(call DependOnVariableFileName, $1, $2) \
673 )
674
675 # Main macro
676 # Param 1 - Name of variable
677 # Param 2 - (optional) name of file to store value in
678 DependOnVariable = \
679 $(call DependOnVariableHelper,$(strip $1),$(strip $2))
680
681 ################################################################################
682 # Failure logging support macros. These are supposed to be used by the Setup*
683 # compilation macros.
684 #
685 # LogFailures will run a command and store a copy of output in a specified file.
686 # If the command succeeds, the file is deleted, otherwise it is moved to the
687 # failure-logs directory.
688 # Param 1 - The log file of the failed command
689 # Param 2 - A compact but representative name to describe this command
690 # Param 3 - Command to run
691 LogFailures = \
692 ( $3 > >($(TEE) $1) 2> >($(TEE) $1 >&2) || \
693 (exitcode=$(DOLLAR)$(DOLLAR)? && \
694 $(CP) $1 $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(strip $2).log && \
695 exit $(DOLLAR)$(DOLLAR)exitcode) )
696
697 ################################################################################
698 # Find lib dir for module
699 # Param 1 - module name
700 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
701 FindLibDirForModule = \
702 $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)$(OPENJDK_TARGET_CPU_LIBDIR)
703 else
704 FindLibDirForModule = \
705 $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
706 endif
707
708 ################################################################################
709 # Return a string suitable for use after a -classpath option. It will correct and safe to use
710 # on all platforms. Arguments are given as space separate classpath entries.
711 # param 1 : A space separated list of classpath entries
712 # The surrounding strip is needed to keep additional whitespace out
713 PathList = \
714 "$(subst $(SPACE),$(PATH_SEP),$(strip $1))"
715
|