565 $(MKDIR) -p '$(@D)' && $(CP) -fP '$<' '$@' |
565 $(MKDIR) -p '$(@D)' && $(CP) -fP '$<' '$@' |
566 endef |
566 endef |
567 endif |
567 endif |
568 |
568 |
569 ################################################################################ |
569 ################################################################################ |
570 # Convenience functions for working around make's limitations with $(filter ). |
|
571 containing = \ |
|
572 $(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),$v))) |
|
573 not-containing = \ |
|
574 $(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),,$v))) |
|
575 |
|
576 # Filter out duplicate sub strings while preserving order. Keeps the first occurance. |
570 # Filter out duplicate sub strings while preserving order. Keeps the first occurance. |
577 uniq = \ |
571 uniq = \ |
578 $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) |
572 $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) |
|
573 |
|
574 # Returns all whitespace-separated words in $2 where at least one of the |
|
575 # whitespace-separated words in $1 is a substring. |
|
576 containing = \ |
|
577 $(strip \ |
|
578 $(foreach v,$(strip $2),\ |
|
579 $(call uniq,$(foreach p,$(strip $1),$(if $(findstring $p,$v),$v))))) |
|
580 |
|
581 # Returns all whitespace-separated words in $2 where none of the |
|
582 # whitespace-separated words in $1 is a substring. |
|
583 not-containing = \ |
|
584 $(strip $(filter-out $(call containing,$1,$2),$2)) |
579 |
585 |
580 # Return a list of all string elements that are duplicated in $1. |
586 # Return a list of all string elements that are duplicated in $1. |
581 dups = \ |
587 dups = \ |
582 $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \ |
588 $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \ |
583 $(words $(filter $v, $1))), $v))) |
589 $(words $(filter $v, $1))), $v))) |