### diff make/common/MakeBase.gmk @ 1642:382d23edebb6

8136383: Improve make utilities containing and not-containing Reviewed-by: ihse
author erikj Tue, 15 Sep 2015 18:00:21 +0200 8b56a0ce50f0 216f63a10515 c800f2919a1f
line wrap: on
line diff
```--- a/make/common/MakeBase.gmk	Fri Sep 11 12:59:45 2015 -0700
+++ b/make/common/MakeBase.gmk	Tue Sep 15 18:00:21 2015 +0200
@@ -567,16 +567,22 @@
endif

################################################################################
-# Convenience functions for working around make's limitations with \$(filter ).
-containing = \
-    \$(strip \$(foreach v,\$(strip \$2),\$(if \$(findstring \$(strip \$1),\$v),\$v)))
-not-containing = \
-    \$(strip \$(foreach v,\$(strip \$2),\$(if \$(findstring \$(strip \$1),\$v),,\$v)))
-
# Filter out duplicate sub strings while preserving order. Keeps the first occurance.
uniq = \
\$(if \$1,\$(firstword \$1) \$(call uniq,\$(filter-out \$(firstword \$1),\$1)))

+# Returns all whitespace-separated words in \$2 where at least one of the
+# whitespace-separated words in \$1 is a substring.
+containing = \
+    \$(strip \
+        \$(foreach v,\$(strip \$2),\
+          \$(call uniq,\$(foreach p,\$(strip \$1),\$(if \$(findstring \$p,\$v),\$v)))))
+
+# Returns all whitespace-separated words in \$2 where none of the
+# whitespace-separated words in \$1 is a substring.
+not-containing = \
+    \$(strip \$(filter-out \$(call containing,\$1,\$2),\$2))
+
# Return a list of all string elements that are duplicated in \$1.
dups = \
\$(strip \$(foreach v, \$(sort \$1), \$(if \$(filter-out 1, \```