diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/cfg2files.sh | 11 | ||||
-rwxr-xr-x | scripts/genconfig.sh | 16 | ||||
-rwxr-xr-x | scripts/make.sh | 56 |
3 files changed, 72 insertions, 11 deletions
diff --git a/scripts/cfg2files.sh b/scripts/cfg2files.sh deleted file mode 100755 index 4f24c906..00000000 --- a/scripts/cfg2files.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# cat .config into this to get a list of .c files. - -# Grab the XXX part of all CONFIG_XXX entries, removing everything after the -# second underline. Sort the list, keep only one of each entry, convert -# to lower case, remove toybox itself from the list (as that indicates -# global symbols). - -sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' \ - | sort -u | tr A-Z a-z | grep -v '^toybox$' diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh new file mode 100755 index 00000000..59c63c5b --- /dev/null +++ b/scripts/genconfig.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +mkdir -p generated + +function genconfig() +{ + for i in $(echo toys/*.c | sort) + do + # Grab the config block for Config.in + echo "# $i" + sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || exit 1 + echo + done +} + +genconfig > generated/Config.in diff --git a/scripts/make.sh b/scripts/make.sh new file mode 100755 index 00000000..6cdd01a8 --- /dev/null +++ b/scripts/make.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Grab default values for $CFLAGS and such. + +source ./configure + +echo "Extract configuration information from toys/*.c files." +scripts/genconfig.sh + +# Only recreate generated/help.h if python is installed +if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ] +then + echo "Extract help text from Config.in." + scripts/config2help.py Config.in > generated/help.h || exit 1 +fi + +echo "Make generated/config.h from .config." + +# This long and roundabout sed invocation is to make old versions of sed happy. +# New ones have '\n' so can replace one line with two without all the branches +# and tedious mucking about with hold space. + +sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ + -e 't notset' -e 'b tryisset' -e ':notset' \ + -e 'h' -e 's/.*/#define CFG_& 0/p' \ + -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \ + -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \ + -e 'h' -e 's/.*/#define CFG_& 1/p' \ + -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' .config > \ + generated/config.h || exit 1 + +#for i in $(echo toys/*.c | sort) +#do + # Grab the function command names + # NAME=$(echo $i | sed -e 's@toys/@@' -e 's@\.c@@') + #sed -n '/struct '$NAME'_command {/,/};/p' $i \ + # >> generated/globals_big.h + # echo "struct ${NAME}_command;" >> generated/globals.h +#done + +# Extract a list of toys/*.c files to compile from the data in ".config" with +# sed, sort, and tr: + +# 1) 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. + +TOYFILES=$(cat .config | sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' | sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's@\(.*\)@toys/\1.c@' ) + +echo "Compile toybox..." + +$DEBUG $CC $CFLAGS -I . -o toybox_unstripped $OPTIMIZE main.c lib/*.c $TOYFILES +$DEBUG $STRIP toybox_unstripped -o toybox |