comparison scripts/make.sh @ 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 855b706d10dc
children 1c4c893d4e72
comparison
equal deleted inserted replaced
1207:22739b6d5a0e 1208:c86b1579c383
68 68
69 do_loudly $HOSTCC scripts/mkflags.c -o generated/mkflags || exit 1 69 do_loudly $HOSTCC scripts/mkflags.c -o generated/mkflags || exit 1
70 70
71 echo -n "generated/flags.h " 71 echo -n "generated/flags.h "
72 72
73 # Process config.h and newtoys.h to generate FLAG_x macros. Note we must
74 # always #define the relevant macro, even when it's disabled, because we
75 # allow multiple NEWTOY() in the same C file. (When disabled the FLAG is 0,
76 # so flags&0 becomes a constant 0 allowing dead code elimination.)
77
73 # Parse files through C preprocessor twice, once to get flags for current 78 # Parse files through C preprocessor twice, once to get flags for current
74 # .config and once to get flags for allyesconfig 79 # .config and once to get flags for allyesconfig
75 for I in A B 80 for I in A B
76 do 81 do
77 ( 82 (
96 sed -n -e 's/" *"//g;/^#/d;s/"/"/p' -e 's/ *$//;s/ [^" ]*$/ " "/p' 101 sed -n -e 's/" *"//g;/^#/d;s/"/"/p' -e 's/ *$//;s/ [^" ]*$/ " "/p'
97 102
98 # Sort resulting line pairs and glue them together into triplets of 103 # Sort resulting line pairs and glue them together into triplets of
99 # command "flags" "allflags" 104 # command "flags" "allflags"
100 # to feed into mkflags C program that outputs actual flag macros 105 # to feed into mkflags C program that outputs actual flag macros
106 # If no pair (because command's disabled in config), use " " for flags
107 # so allflags can define the appropriate zero macros.
101 108
102 done | sort | sed -n 's/ A / /;t skip;d;:skip;h;n;s/[^ ]* B //;H;g;s/\n/ /;p' |\ 109 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' |\
103 generated/mkflags > generated/flags.h || exit 1 110 generated/mkflags > generated/flags.h || exit 1
104 111
105 # Extract global structure definitions and flag definitions from toys/*/*.c 112 # Extract global structure definitions and flag definitions from toys/*/*.c
106 113
107 function getglobals() 114 function getglobals()