< prev index next >

make/common/MakeBase.gmk

Print this page




 558     )
 559 
 560 # Convert a partial path into as many directory levels of ../, removing
 561 # leading and following /.
 562 # Ex: foo/bar/baz/ -> ../../..
 563 #     foo/bar -> ../..
 564 #     /foo -> ..
 565 DirToDotDot = \
 566     $(subst $(SPACE),/,$(foreach d, $(subst /,$(SPACE),$1),..))
 567 
 568 # Computes the relative path from a directory to a file
 569 # $1 - File to compute the relative path to
 570 # $2 - Directory to compute the relative path from
 571 RelativePath = \
 572     $(eval $1_prefix := $(call FindCommonPathPrefix, $1, $2)) \
 573     $(eval $1_dotdots := $(call DirToDotDot, $(patsubst $($(strip $1)_prefix)/%, %, $2))) \
 574     $(eval $1_suffix := $(patsubst $($(strip $1)_prefix)/%, %, $1)) \
 575     $($(strip $1)_dotdots)/$($(strip $1)_suffix)
 576 
 577 ################################################################################
 578 # link-file-* works similarly to install file but creates a symlink instead on
 579 # platforms that support it. There are two versions, either creating a relative
 580 # or an absolute link.
 581 ifeq ($(OPENJDK_BUILD_OS), windows)
 582   link-file-absolute = $(install-file)
 583   link-file-relative = $(install-file)
 584 else
 585   define link-file-relative
 586         $(call MakeDir, $(@D))
 587         $(RM) $@
 588         $(LN) -s $(call RelativePath, $<, $(@D)) $@
 589   endef
 590 
 591   define link-file-absolute
 592         $(call MakeDir, $(@D))
 593         $(RM) $@
 594         $(LN) -s $< $@
 595   endef
 596 endif
 597 
 598 ################################################################################
 599 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
 600 uniq = \
 601     $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
 602 
 603 # Returns all whitespace-separated words in $2 where at least one of the
 604 # whitespace-separated words in $1 is a substring.
 605 containing = \
 606     $(strip \
 607         $(foreach v,$(strip $2),\
 608           $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v)))))
 609 
 610 # Returns all whitespace-separated words in $2 where none of the
 611 # whitespace-separated words in $1 is a substring.
 612 not-containing = \
 613     $(strip $(filter-out $(call containing,$1,$2),$2))
 614 
 615 # Return a list of all string elements that are duplicated in $1.
 616 dups = \




 558     )
 559 
 560 # Convert a partial path into as many directory levels of ../, removing
 561 # leading and following /.
 562 # Ex: foo/bar/baz/ -> ../../..
 563 #     foo/bar -> ../..
 564 #     /foo -> ..
 565 DirToDotDot = \
 566     $(subst $(SPACE),/,$(foreach d, $(subst /,$(SPACE),$1),..))
 567 
 568 # Computes the relative path from a directory to a file
 569 # $1 - File to compute the relative path to
 570 # $2 - Directory to compute the relative path from
 571 RelativePath = \
 572     $(eval $1_prefix := $(call FindCommonPathPrefix, $1, $2)) \
 573     $(eval $1_dotdots := $(call DirToDotDot, $(patsubst $($(strip $1)_prefix)/%, %, $2))) \
 574     $(eval $1_suffix := $(patsubst $($(strip $1)_prefix)/%, %, $1)) \
 575     $($(strip $1)_dotdots)/$($(strip $1)_suffix)
 576 
 577 ################################################################################
 578 # link-file-* works similarly to install-file but creates a symlink instead.
 579 # There are two versions, either creating a relative or an absolute link. Be
 580 # careful when using this on Windows since the symlink created is only valid in
 581 # the unix emulation environment.
 582 define link-file-relative



 583         $(call MakeDir, $(@D))
 584         $(RM) $@
 585         $(LN) -s $(call RelativePath, $<, $(@D)) $@
 586 endef
 587 
 588 define link-file-absolute
 589         $(call MakeDir, $(@D))
 590         $(RM) $@
 591         $(LN) -s $< $@
 592 endef

 593 
 594 ################################################################################
 595 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
 596 uniq = \
 597     $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
 598 
 599 # Returns all whitespace-separated words in $2 where at least one of the
 600 # whitespace-separated words in $1 is a substring.
 601 containing = \
 602     $(strip \
 603         $(foreach v,$(strip $2),\
 604           $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v)))))
 605 
 606 # Returns all whitespace-separated words in $2 where none of the
 607 # whitespace-separated words in $1 is a substring.
 608 not-containing = \
 609     $(strip $(filter-out $(call containing,$1,$2),$2))
 610 
 611 # Return a list of all string elements that are duplicated in $1.
 612 dups = \


< prev index next >