617 ################################################################################
618 # link-file-* works similarly to install-file but creates a symlink instead.
619 # There are two versions, either creating a relative or an absolute link. Be
620 # careful when using this on Windows since the symlink created is only valid in
621 # the unix emulation environment.
622 define link-file-relative
623 $(call MakeTargetDir)
624 $(RM) '$(call DecodeSpace, $@)'
625 $(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)'
626 endef
627
628 define link-file-absolute
629 $(call MakeTargetDir)
630 $(RM) '$(call DecodeSpace, $@)'
631 $(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
632 endef
633
634 ################################################################################
635 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
636 uniq = \
637 $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
638
639 # Returns all whitespace-separated words in $2 where at least one of the
640 # whitespace-separated words in $1 is a substring.
641 containing = \
642 $(strip \
643 $(foreach v,$(strip $2),\
644 $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v)))))
645
646 # Returns all whitespace-separated words in $2 where none of the
647 # whitespace-separated words in $1 is a substring.
648 not-containing = \
649 $(strip $(filter-out $(call containing,$1,$2),$2))
650
651 # Return a list of all string elements that are duplicated in $1.
652 dups = \
653 $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \
654 $(words $(filter $v, $1))), $v)))
655
656 # String equals
657 equals = \
|
617 ################################################################################
618 # link-file-* works similarly to install-file but creates a symlink instead.
619 # There are two versions, either creating a relative or an absolute link. Be
620 # careful when using this on Windows since the symlink created is only valid in
621 # the unix emulation environment.
622 define link-file-relative
623 $(call MakeTargetDir)
624 $(RM) '$(call DecodeSpace, $@)'
625 $(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)'
626 endef
627
628 define link-file-absolute
629 $(call MakeTargetDir)
630 $(RM) '$(call DecodeSpace, $@)'
631 $(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
632 endef
633
634 ################################################################################
635 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
636 uniq = \
637 $(strip $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))))
638
639 # Returns all whitespace-separated words in $2 where at least one of the
640 # whitespace-separated words in $1 is a substring.
641 containing = \
642 $(strip \
643 $(foreach v,$(strip $2),\
644 $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v)))))
645
646 # Returns all whitespace-separated words in $2 where none of the
647 # whitespace-separated words in $1 is a substring.
648 not-containing = \
649 $(strip $(filter-out $(call containing,$1,$2),$2))
650
651 # Return a list of all string elements that are duplicated in $1.
652 dups = \
653 $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \
654 $(words $(filter $v, $1))), $v)))
655
656 # String equals
657 equals = \
|