setup: support any level of machine conf depth

Modify setup script to support any level of machine conf depth.
Internally Google uses machines that sit yet another layer deep
in the repository. Instead of adding yet another level of depth
to the expansion, look for all configs using `find`, if it's
available. If it's not, ball back to the old wildcard expansion.

Signed-off-by: Maksym Sloyko <maxims@google.com>
Change-Id: I1066fe5f6ece4454e3555ca97f75bd91d6da1dba
diff --git a/setup b/setup
index a5e9047..57b3ded 100755
--- a/setup
+++ b/setup
@@ -31,7 +31,19 @@
 	local target=$1
 	local build_dir=$2
 	local cfg name tmpl
-	for cfg in meta-*/meta-*/conf/machine/*.conf meta-*/conf/machine/*.conf; do
+	local configs
+
+	# zsh requires wordsplit so that variable expansion behaves like bash
+	if [ -n "$ZSH_NAME" ]; then
+		setopt local_options shwordsplit
+	fi
+	if which find > /dev/null 2>&1; then
+		configs=$(find meta-* -path "*/conf/machine/*.conf")
+	else
+		configs=$(ls -1 meta-*/meta-*/conf/machine/*.conf meta-*/conf/machine/*.conf)
+	fi
+
+	for cfg in $configs; do
 		name=${cfg##*/}
 		name=${name%.conf}
 		tmpl=${cfg%/machine/*.conf}