changeset 654:04feab07416c

Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
author Rob Landley <rob@landley.net>
date Sat, 25 Aug 2012 15:43:02 -0500
parents 2986aa63a021
children e235d7d575e5
files scripts/make.sh
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/make.sh	Sat Aug 25 14:25:22 2012 -0500
+++ b/scripts/make.sh	Sat Aug 25 15:43:02 2012 -0500
@@ -113,14 +113,19 @@
 
 # Extract a list of toys/*/*.c files to compile from the data in ".config":
 
-# 1) Grab the XXX part of all CONFIG_XXX entries, removing everything after the
+# 1) Get a list of C files in toys/* and glue them together into a regex we can
+# feed to grep that will match any one of them (whole word, not substring).
+TOYFILES="^$(ls toys/*/*.c | sed -n 's@^.*/\(.*\)\.c$@\1@;s/-/_/g;H;${g;s/\n//;s/\n/$|^/gp}')\$"
+
+# 2) Grab the XXX part of all CONFIG_XXX entries, removing everything after the
 # second underline
-# 2) Sort the list, keeping only one of each entry.
-# 3) Convert to lower case.
-# 4) Remove toybox itself from the list (as that indicates global symbols).
-# 5) Add "toys/*/" prefix and ".c" suffix.
+# 3) Sort the list, keeping only one of each entry.
+# 4) Convert to lower case.
+# 5) Remove any config symbol not recognized as a filename from step 1.
+# 6) Add "toys/*/" prefix and ".c" suffix.
 
-TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' < .config | sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's@\(.*\)@toys/\*/\1.c@')
+TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' < .config \
+  | sort -u | tr A-Z a-z | grep -E "$TOYFILES" | sed 's@\(.*\)@toys/\*/\1.c@')
 
 echo "Library probe..."