4
# feature-check: This script looks for feature statements in a file by
5
# executing a compiler under CPP and extracting lines of the following
8
# netsnmp_feature_provides(foo): used to indicate it provides feature "foo"
9
# netsnmp_feature_require(bar): used to indicate it requires feature "bar"
10
# netsnmp_feature_want(bar): used to indicate it wants feature "bar"
11
# (but can live without it)
13
# Using these lines it then generates a list of feature requirement
14
# defines in "include/net-snmp/net-snmp-features.h" which can then be
15
# loaded in later passes at compile time.
17
# Defines produced when netsnmp_featre_require(bar) is present:
18
# #define NETSNMP_FEATURE_REQUIRE_BAR 1
20
# Defines produced when netsnmp_feature_want(bar) is present:
21
# #define NETSNMP_FEATURE_WANT_BAR 1
23
# And when all the features have been collected, they are also inverted via
24
# the feature-post-check script:
26
# #define NETSNMP_FEATURE_REMOVE_BARX 1 /* never required */
27
# #undef NETSNMP_FEATURE_REMOVE_BAR /* required */
31
# feature-check NORMAL-COMPILE-LINE
38
if test "x$1" = "x--feature-global" ; then
39
# a global file should be included
57
$compileline '-DNETSNMP_FEATURE_CHECKING=1' \
58
'-DNETSNMP_MINIMAL_CODE=1' \
59
'-Dnetsnmp_feature_require(X)=X NSF_RR' \
60
'-Dnetsnmp_feature_provide(X)=X NSF_PP' \
61
'-Dnetsnmp_feature_child_of(X,Y)=X,Y NSF_CO' \
62
'-Dnetsnmp_feature_want(X)=X NSF_WW' $source | \
63
$GREP NSF_ | $GREP -v '^#define' > $tmpf
70
for i in `grep NSF_RR $tmpf | sed 's/ NSF_RR//'` ; do
71
if test $firstrequire = 1 ; then
72
echo "" >> $destination
73
echo "/* required by $sourcedir/$source */" >> $destination
76
upper=`echo $i | tr a-z A-Z`
77
echo "#define NETSNMP_FEATURE_REQUIRE_$upper 1" >> $destination
82
for i in `grep NSF_PP $tmpf | sed 's/ NSF_PP//'` ; do
83
if test $firstfeature = 1 ; then
84
echo "" >> $destination
85
echo "/* features provided by $sourcedir/$source */" >> $destination
88
upper=`echo $i | tr a-z A-Z`
89
echo "#define NETSNMP_FEATURE_PROVIDE_$upper 1" >> $destination
94
for i in `grep NSF_CO $tmpf | sed 's/ NSF_CO//'` ; do
95
parent=`echo $i | sed 's/.*,//'`
96
child=`echo $i | sed 's/,.*//'`
97
if test $firstfeature = 1 ; then
98
echo "" >> $destination
99
echo "/* features provided by $sourcedir/$source */" >> $destination
102
upperchild=`echo $child | tr a-z A-Z`
103
upperparent=`echo $parent | tr a-z A-Z`
104
echo "#define NETSNMP_FEATURE_${upperchild}_CHILD_OF_${upperparent} 1" >> $destination
105
echo "#define NETSNMP_FEATURE_PROVIDE_$upperchild 1" >> $destination
110
for i in `grep NSF_WW $tmpf | sed 's/ NSF_WW//'` ; do
111
if test $firstfeature = 1 ; then
112
echo "" >> $destination
113
echo "/* features wanted by $sourcedir/$source */" >> $destination
116
upper=`echo $i | tr a-z A-Z`
117
echo "#define NETSNMP_FEATURE_WANT_$upper 1" >> $destination
120
if test "x$global" != "x" ; then
121
cat $destination >> $global