Add missing USB to serial drivers.
[dragonfly.git] / usr.bin / unifdef / unifdefall.sh
blobbefa19e05885760587648a3d71e7b9dbc925d114
1 #!/bin/sh
3 # remove all the #if's from a source file
5 # $dotat: things/unifdefall.sh,v 1.9 2002/09/24 19:43:57 fanf2 Exp $
6 # $FreeBSD: src/usr.bin/unifdef/unifdefall.sh,v 1.1.2.2 2002/10/20 13:44:11 fanf Exp $
7 # $DragonFly: src/usr.bin/unifdef/unifdefall.sh,v 1.2 2003/06/17 04:29:33 dillon Exp $
9 set -e
11 basename=`basename $0`
12 tmp=`mktemp -d -t $basename` || exit 2
14 unifdef -s "$@" | sort | uniq > $tmp/ctrl
15 cpp -dM "$@" | sort |
16 sed -Ee 's/^#define[ ]+(.*[^ ])[ ]*$/\1/' > $tmp/hashdefs
17 sed -Ee 's/^([A-Za-z0-9_]+).*$/\1/' $tmp/hashdefs > $tmp/alldef
18 comm -23 $tmp/ctrl $tmp/alldef > $tmp/undef
19 comm -12 $tmp/ctrl $tmp/alldef > $tmp/def
21 echo unifdef -k \\ > $tmp/cmd
22 sed -Ee 's/^(.*)$/-U\1 \\/' $tmp/undef >> $tmp/cmd
23 while read sym
24 do sed -Ee '/^('"$sym"')([(][^)]*[)])?([ ]+(.*))?$/!d;s//-D\1=\4/' $tmp/hashdefs
25 done < $tmp/def |
26 sed -Ee 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/" \\/' >> $tmp/cmd
27 echo '"$@"' >> $tmp/cmd
28 sh $tmp/cmd "$@"
30 rm -r $tmp