# HG changeset patch # User Rob Landley # Date 1345927382 18000 # Node ID 04feab07416c5bd3a2721da2045121defe76ff5f # Parent 2986aa63a02192a2ed88685202c41bc354d650b0 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. diff -r 2986aa63a021 -r 04feab07416c scripts/make.sh --- 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..."