aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-08-25 15:43:02 -0500
committerRob Landley <rob@landley.net>2012-08-25 15:43:02 -0500
commit658b97b85a5b517b2f21a772faa1b3df5bbd782f (patch)
tree2c73a172d0da1d1b2a80d518f4b59e77ace8b6ca /scripts
parent3a9241add947cb6d24b5de7a8927517426a78795 (diff)
downloadtoybox-658b97b85a5b517b2f21a772faa1b3df5bbd782f.tar.gz
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.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/make.sh17
1 files changed, 11 insertions, 6 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index 2f52b21b..713a6b89 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -113,14 +113,19 @@ sed -n \
# 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..."