aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-02-23 20:11:06 -0600
committerRob Landley <rob@landley.net>2014-02-23 20:11:06 -0600
commite36a9dda21ca656dd5dc96fbbe9eacf7e3995e78 (patch)
treecb8e7490d623ec37ad3f8bf094b5f85ace3902eb
parent2992a66e2c7f1c5225f49c68274a8a323e445a80 (diff)
downloadtoybox-e36a9dda21ca656dd5dc96fbbe9eacf7e3995e78.tar.gz
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
-rwxr-xr-xscripts/make.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index d2799a8e..9a37b960 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -70,6 +70,11 @@ do_loudly $HOSTCC scripts/mkflags.c -o generated/mkflags || exit 1
echo -n "generated/flags.h "
+# Process config.h and newtoys.h to generate FLAG_x macros. Note we must
+# always #define the relevant macro, even when it's disabled, because we
+# allow multiple NEWTOY() in the same C file. (When disabled the FLAG is 0,
+# so flags&0 becomes a constant 0 allowing dead code elimination.)
+
# Parse files through C preprocessor twice, once to get flags for current
# .config and once to get flags for allyesconfig
for I in A B
@@ -98,8 +103,10 @@ do
# Sort resulting line pairs and glue them together into triplets of
# command "flags" "allflags"
# to feed into mkflags C program that outputs actual flag macros
+# If no pair (because command's disabled in config), use " " for flags
+# so allflags can define the appropriate zero macros.
-done | sort | sed -n 's/ A / /;t skip;d;:skip;h;n;s/[^ ]* B //;H;g;s/\n/ /;p' |\
+done | sort | sed -n 's/ A / /;t pair;h;s/\([^ ]*\).*/\1 " "/;x;b single;:pair;h;n;:single;s/[^ ]* B //;H;g;s/\n/ /;p' |\
generated/mkflags > generated/flags.h || exit 1
# Extract global structure definitions and flag definitions from toys/*/*.c