From 658b97b85a5b517b2f21a772faa1b3df5bbd782f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 25 Aug 2012 15:43:02 -0500 Subject: 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. --- scripts/make.sh | 17 +++++++++++------ 1 file 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..." -- cgit v1.2.3