aboutsummaryrefslogtreecommitdiff
path: root/scripts/make.sh
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-26 14:14:29 -0600
committerRob Landley <rob@landley.net>2012-11-26 14:14:29 -0600
commit6cf0a115451d6d5ead94860f0731040dc2293db0 (patch)
treef04a6b76ca8572fccf01f1dc0b8b71710bde439c /scripts/make.sh
parent471ce1b29933702bdd63bf27e4470898cb37b451 (diff)
downloadtoybox-6cf0a115451d6d5ead94860f0731040dc2293db0.tar.gz
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Diffstat (limited to 'scripts/make.sh')
-rwxr-xr-xscripts/make.sh32
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index f9fa0a40..921d1994 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -54,11 +54,27 @@ sed -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \
| sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \
| sed 's/[^ ]* //' >> generated/newtoys.h
+# Extract list of command letters from processed header file
+
+function getflags()
+{
+ sed -n -e "s/.*TOY($1"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \
+ -e 't keep;d;:keep' -e 's/^[<>=][0-9]//' -e 's/[?&^]//' \
+ -e 't keep' -e 's/[><=][0-9][0-9]*//g' -e 's/+.//g' \
+ -e 's/([^)]*)//g' -e 's/\[[^]]*\]//g' -e 's/[-?^:&#|@*]//g' -e 'p'
+}
+
# Extract global structure definitions and flag definitions from toys/*/*.c
function getglobals()
{
+ # Run newtoys.h through the compiler's preprocessor to resolve USE macros
+ # against current config.
NEWTOYS="$(cat generated/config.h generated/newtoys.h | gcc -E - | sed 's/" *"//g')"
+
+ # Grab allyesconfig for comparison
+ ALLTOYS="$((sed '/USE_.*([^)]*)$/s/$/ __VA_ARGS__/' generated/config.h && cat generated/newtoys.h) | gcc -E - | sed 's/" *"//g')"
+
for i in toys/*/*.c
do
NAME="$(echo $i | sed 's@.*/\(.*\)\.c@\1@')"
@@ -68,13 +84,9 @@ function getglobals()
-e 's/^GLOBALS(/struct '"$NAME"'_data {/' \
-e 's/^)/};/' -e 'p' $i
- # And get flag definitions
- FLAGS="$(echo "$NEWTOYS" | sed -n \
- -e "s/.*TOY($NAME"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \
- -e 't keep;d;:keep' -e 's/^[<>=][0-9]//' -e 's/[?&^]//' \
- -e 't keep' -e 's/[><=][0-9][0-9]*//g' -e 's/+.//g' \
- -e 's/([^)]*)//g' -e 's/\[[^]]*\]//g' -e 's/[-?^:&#|@*]//g' \
- -e 'p')"
+ FLAGS="$(echo "$NEWTOYS" | getflags "$NAME")"
+ ZFLAGS="$(echo "$ALLTOYS" | getflags "$NAME" | sed 's/[-'"$FLAGS"']//g')"
+
echo "#ifdef FOR_${NAME}"
X=0
while [ $X -lt ${#FLAGS} ]
@@ -83,6 +95,12 @@ function getglobals()
X=$(($X+1))
echo "(1<<$((${#FLAGS}-$X)))"
done
+ X=0
+ while [ $X -lt ${#ZFLAGS} ]
+ do
+ echo "#define FLAG_${ZFLAGS:$X:1} 0"
+ X=$(($X+1))
+ done
echo "#define TT this.${NAME}"
echo "#endif"
done