Debian Codegraph @

local/minimalist/feature-remove

raw
1 #!/bin/sh
2
3 #
4 # feature-remove: removes features by defining special variables
5 # indicating particular code segments are unneeded. This is done by
6 # examining the list of provided features and defining a REMOVE
7 # equivalent if no other module required it.
8 #
9 # Arguments:
10 # feature-remove mainheader.h globalheader.h THEREST
11 #
12 # Where THEREST are a list of features to remove (default) or add.
13 #
14 # --add switches to "adding" and --remove switches back.
15 #
16 # E.G.
17 # feature-remove mainheader.h globalheader.h oid_stash --add container_null
18 #
19 CP=cp
20
21 featureheader="$1"
22 featureheaderin="$1.in"
23 featureheaderglobal="$2"
24 shift
25 shift
26
27 argumenttype="--remove"
28 removethese=""
29 addthese=""
30
31 while test "x$1" != "x" ; do
32 uc=`echo $1 | tr a-z A-Z`
33 case $1 in
34 --*)
35 argumenttype="$1"
36 ;;
37
38 *)
39 if test "x$argumenttype" = "x--remove" ; then
40 removethese="$removethese $uc"
41 else
42 addthese="$addthese $uc"
43 fi
44 ;;
45 esac
46 shift
47 done
48
49 echo "" > $featureheader
50 echo "/* The following defines features that Net-SNMP HAS or has REMOVEd */" >> $featureheader
51
52 haslist=" "
53
54 for i in `grep NETSNMP_FEATURE_PROVIDE_ $featureheaderin | sed 's/.*FEATURE_PROVIDE_//;s/ .*//'` ; do
55 #
56 # If we were specifically asked to include it, then do so
57 #
58 if echo " $addthese " | grep " ${i} " > /dev/null ; then
59 # The user required it ; report we're using it
60 echo "#define NETSNMP_FEATURE_HAS_$i 1" >> $featureheader
61 haslist="${haslist}${i} "
62
63 #
64 # check to see if something requried it
65 #
66 elif grep "NETSNMP_FEATURE_REQUIRE_${i} " $featureheaderglobal > /dev/null ; then
67 # if so, make sure we weren't asked to remove it
68 if echo " $removethese "| grep " $i " > /dev/null ; then
69 # Uh oh; they specifically wanted it removed but it was required
70 echo "Feature Error:"
71 echo " Feature '$i' was asked to be removed but something required it"
72 echo " See the $featureheaderglobal file for dependency details"
73 echo ""
74 rm -f $featureheader
75 exit 1
76 fi
77
78 # something required it ; report we're using it
79 echo "#define NETSNMP_FEATURE_HAS_$i 1" >> $featureheader
80 haslist="${haslist}${i} "
81
82 #
83 # check to see if something "wanted" it
84 #
85 elif grep "NETSNMP_FEATURE_WANT_${i} " $featureheaderglobal > /dev/null ; then
86 # nothing required it, but something "wanted" it
87
88 # check to make sure we weren't asked to exclude it
89 if echo " $removethese " | grep " $i " > /dev/null ; then
90 # we were specifically asked *not* to use this feature
91 echo "#define NETSNMP_FEATURE_REMOVE_$i 1" >> $featureheader
92 else
93 # something wanted it, so we'll include it
94 echo "#define NETSNMP_FEATURE_HAS_$i 1" >> $featureheader
95 haslist="${haslist}${i} "
96 fi
97
98
99 #
100 # check to see if something required a parent
101 #
102 elif egrep NETSNMP_FEATURE_${i}_CHILD_OF $featureheaderglobal > /dev/null ; then
103 parentnames=`egrep NETSNMP_FEATURE_${i}_CHILD_OF $featureheaderglobal | sed 's/.*CHILD_OF_//;s/ .*//;'`
104
105 foundone=0
106 for parentname in $parentnames ; do
107 # if the parent was desired, then we are too:
108
109 if test $foundone = 0 ; then
110 if egrep "NETSNMP_FEATURE_HAS_${parentname} " $featureheader > /dev/null ; then
111 echo "#define NETSNMP_FEATURE_HAS_$i 1" >> $featureheader
112 haslist="${haslist}${i} "
113 foundone=1
114 fi
115 fi
116 done
117 if test $foundone = 0 ; then
118 echo "#define NETSNMP_FEATURE_REMOVE_$i 1" >> $featureheader
119 fi
120
121 #
122 # no one required or wanted it -- it is safe to remove it
123 #
124 else
125 echo "#define NETSNMP_FEATURE_REMOVE_$i 1" >> $featureheader
126 fi
127 done
128