~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to local/minimalist/feature-check

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-05-16 21:01:27 UTC
  • mfrom: (1.2.4) (1.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20130516210127-y6meyeiobdx0131q
Tags: 5.7.2~dfsg-4ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/rules: Don't stop service in runlevels 0 and 6.
  - debian/snmpd.init: LSBify the init script.
  - debian/snmp.preinst, debian/snmp.prerm: Kill any/all processes owned
    by snmp user before install/uninstall.
  - Add apport hook.
* debian/patches/ubuntu-fix-lp-587828.patch: Drop. Fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
#
 
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
 
6
# form:
 
7
#
 
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)
 
12
#
 
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.
 
16
#
 
17
# Defines produced when netsnmp_featre_require(bar) is present:
 
18
#   #define NETSNMP_FEATURE_REQUIRE_BAR 1
 
19
#
 
20
# Defines produced when netsnmp_feature_want(bar) is present:
 
21
#   #define NETSNMP_FEATURE_WANT_BAR 1
 
22
#
 
23
# And when all the features have been collected, they are also inverted via
 
24
# the feature-post-check script:
 
25
#
 
26
#   #define NETSNMP_FEATURE_REMOVE_BARX 1  /* never required */
 
27
#   #undef  NETSNMP_FEATURE_REMOVE_BAR      /* required */
 
28
 
 
29
# Usage:
 
30
 
 
31
# feature-check NORMAL-COMPILE-LINE
 
32
 
 
33
SED=sed
 
34
GREP=grep
 
35
CC=gcc
 
36
RM=rm
 
37
 
 
38
if test "x$1" = "x--feature-global" ; then
 
39
    # a global file should be included
 
40
    shift
 
41
    global=$1
 
42
    shift
 
43
fi
 
44
 
 
45
sourcedir=$1
 
46
shift
 
47
 
 
48
source=$1
 
49
shift
 
50
 
 
51
destination=$1
 
52
shift
 
53
 
 
54
tmpf="$destination.1"
 
55
 
 
56
compileline="$@"
 
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
 
64
 
 
65
$RM -f $destination;
 
66
touch $destination;
 
67
 
 
68
# process requires
 
69
firstrequire=1
 
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
 
74
        firstrequire=0
 
75
    fi
 
76
    upper=`echo $i | tr a-z A-Z`
 
77
    echo "#define NETSNMP_FEATURE_REQUIRE_$upper 1" >> $destination
 
78
done
 
79
 
 
80
# process provides
 
81
firstfeature=1
 
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
 
86
        firstfeature=0
 
87
    fi
 
88
    upper=`echo $i | tr a-z A-Z`
 
89
    echo "#define NETSNMP_FEATURE_PROVIDE_$upper 1" >> $destination
 
90
done
 
91
 
 
92
# process children
 
93
firstfeature=1
 
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
 
100
        firstfeature=0
 
101
    fi
 
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
 
106
done
 
107
 
 
108
# process wants
 
109
firstfeature=1
 
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
 
114
        firstfeature=0
 
115
    fi
 
116
    upper=`echo $i | tr a-z A-Z`
 
117
    echo "#define NETSNMP_FEATURE_WANT_$upper 1" >> $destination
 
118
done
 
119
 
 
120
if test "x$global" != "x" ; then
 
121
    cat $destination >> $global
 
122
fi
 
123
 
 
124
 
 
125
# clean up
 
126
#$RM -f $tmpf