changeset 1208:c86b1579c383 draft

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.
author Rob Landley <rob@landley.net>
date Sun, 23 Feb 2014 20:11:06 -0600
parents 22739b6d5a0e
children f170f978e81e
files scripts/make.sh
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/make.sh	Sat Feb 22 08:02:09 2014 -0600
+++ b/scripts/make.sh	Sun Feb 23 20:11:06 2014 -0600
@@ -70,6 +70,11 @@
 
 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 @@
 # 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