File: net-snmp-configure

package info (click to toggle)
net-snmp 5.9+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 36,760 kB
  • sloc: ansic: 283,039; perl: 17,712; sh: 11,887; makefile: 2,705; xml: 663; python: 623; pascal: 62; sql: 47
file content (404 lines) | stat: -rwxr-xr-x 13,055 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#!/usr/bin/env bash

ssl_include_path() {
    case "$(uname)" in
	MINGW32*)
	    echo /mingw32/include/openssl;;
	MINGW64*)
	    echo /mingw64/include/openssl;;
	*)
	    echo "${with_openssl:-/usr}/include/openssl"
	    ;;
    esac
}

freebsd_pkg_version() {
    local pkg ver

    for pkg in "$@"; do
	ver=$(pkg info "$pkg" 2>/dev/null |
		     sed -n 's/^Version[[:blank:]]*:[[:blank:]]*//p') &&
	    [ -n "$ver" ] && echo "$ver" && return
    done
    return 1
}

branch_name="$1"
shift

is_5_7_or_above="false"
is_5_8_or_above="false"
if [ "${branch_name#master}" != "${branch_name}" ]; then
  is_5_8_or_above="true"
  is_5_7_or_above="true"
elif [ "${branch_name#V5-7-}" != "${branch_name}" ]; then
  is_5_7_or_above="true"
fi

libatmver="$(for p in linux-atm-devel; do
                rpm -q --qf '%{version}\n' $p 2>/dev/null |
                  grep -v 'not installed';
              done |
              head -n1;
	      for p in libatm1-dev; do
	        dpkg-query --show -f '${Version}\n' $p 2>/dev/null;
              done | grep -v '^$';
              pacman -Q no-such-library 2>/dev/null |
                sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')"
echo "libatmver=$libatmver"

libmysqlver="$(for p in libmariadb-devel; do
                rpm -q --qf '%{version}\n' $p 2>/dev/null |
                  grep -v 'not installed';
              done |
              head -n1;
	      for p in libmariadbclient-dev libmariadb-client-lgpl-dev; do
	        dpkg-query --show -f '${Version}\n' $p 2>/dev/null;
              done | grep -v '^$';
              pacman -Q mingw-w64-x86_64-libmariadbclient 2>/dev/null |
                sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')"
echo "libmysqlver=$libmysqlver"

libsensorsver="$(for p in libsensors4-devel; do
                rpm -q --qf '%{version}\n' $p 2>/dev/null |
                  grep -v 'not installed';
              done |
              head -n1;
	      for p in libsensors4-dev; do
	        dpkg-query --show -f '${Version}\n' $p 2>/dev/null;
              done | grep -v '^$';
              pacman -Q no-such-package 2>/dev/null |
                sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')"
echo "libsensorsver=$libsensorsver"

if ! echo "$*" | grep -Eq 'with-openssl=(no|internal)|without-openssl'; then
    case "$(uname -a)" in
	FreeBSD*)
	    opensslver="$(freebsd_pkg_version libressl-devel openssl111 openssl\
	                  2>/dev/null)"
	    if [ -z "$opensslver" ]; then
		opensslver="$(openssl version 2>&1 |
				{ read -r a b c; echo "$b"; })"
	    fi
	    ;;
	Linux*)
	    opensslver="$(
	    for p in openssl-devel libopenssl-devel libressl-devel; do
	      rpm -q --qf '%{version}\n' $p 2>/dev/null |
                grep -v 'not installed';
            done;
	    dpkg-query --show -f '${Version}\n' libssl-dev 2>/dev/null;
	    pacman -Q mingw-w64-x86_64-openssl 2>/dev/null |
	      sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')";;
	MSYS*x86_64*)
	    opensslver="$(pacman -Q openssl-devel 2>/dev/null |
	      sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')";;
	MINGW64*)
	    opensslver="$(pacman -Q mingw-w64-x86_64-openssl 2>/dev/null |
	      sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')";;
	*)
	    opensslver=1.0;;
    esac
fi
if grep -q 'CentOS release 4' /etc/issue 2>/dev/null; then
  opensslver=""
fi
echo "opensslver=$opensslver"

case "$(uname)" in
    FreeBSD*)
	libssh2ver="$(freebsd_pkg_version libssh2 2>/dev/null)";;
    Linux*)
	libssh2ver="$(for p in openssh-devel libssh2-devel libssh-devel; do
                rpm -q --qf '%{version}\n' $p 2>/dev/null |
                  grep -v 'not installed';
              done |
              head -n1;
              for p in libopenssh2 libssh2-1-dev libssh-dev; do
                dpkg-query --show -f '${Version}\n' $p 2>/dev/null;
              done | grep -v '^$';
              pacman -Q mingw-w64-x86_64-libssh2 2>/dev/null |
                sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')"
	;;
esac
echo "libssh2ver=$libssh2ver"

case "$(uname)" in
    FreeBSD*)
	perldevver="$(freebsd_pkg_version perl5 2>/dev/null)";;
    Linux*)
	perldevver="$(for p in perl; do
                rpm -q --qf '%{version}\n' $p 2>/dev/null |
                  grep -v 'not installed';
              done |
              head -n1;
	      for p in libperl-dev; do
	        dpkg-query --show -f '${Version}\n' $p 2>/dev/null;
              done | grep -v '^$';
              pacman -Q mingw-w64-x86_64-perl 2>/dev/null |
                sed -n 's/^[^[:blank:]]*[[:blank:]]*//p')"
	;;
esac
echo "perldevver=$perldevver"

options=()
options+=(--enable-developer)
options+=(--enable-ipv6)
options+=("--prefix=/usr/local/net-snmp-${branch_name}")
options+=("--with-cflags=$cflags")
options+=(--with-defaults)
transports=()
# Mib names can be found as follows:
# (cd agent/mibgroup &&
# git grep -lE 'void[[:blank:]]*init_.*\(void\)|config_require\(' |
#  sed -n 's/\.h$//p')
mibs=()
case "$MODE" in
    read-only)
        ;;
    *)
        mibs+=(examples/data_set)
        mibs+=(examples/delayed_instance)
        mibs+=(examples/example)
        mibs+=(examples/notification)
        mibs+=(examples/scalar_int)
        mibs+=(examples/ucdDemoPublic)
        mibs+=(examples/watched)
        mibs+=(smux)
        ;;
esac

case "$(uname)" in
  Linux*)
      options+=(--enable-new-features)
      case "$MODE" in
          mini*|read-only)
              ;;
          *)
              $is_5_7_or_above && mibs+=(deliver/deliverByNotify)
              mibs+=(disman/event)
              #mibs+=(disman/expression) - to do: figure out why this fails on Travis
              mibs+=(disman/mteEventNotificationTable)
              mibs+=(disman/mteEventTable)
              mibs+=(disman/mteObjectsTable)
              mibs+=(disman/mteTriggerBooleanTable)
              mibs+=(disman/mteTriggerDeltaTable)
              mibs+=(disman/mteTriggerExistenceTable)
              mibs+=(disman/mteTriggerTable)
              mibs+=(disman/mteTriggerThresholdTable)
              mibs+=(disman/nslookup-mib)
              mibs+=(disman/ping-mib)
              mibs+=(disman/schedule)
              mibs+=(disman/traceroute-mib)
              mibs+=(etherlike-mib)
              mibs+=(examples/netSnmpHostsTable)
              mibs+=(hardware/cpu)
              mibs+=(hardware/fsys)
              mibs+=(hardware/memory)
              mibs+=(host)
              mibs+=(ip-forward-mib)
              mibs+=(ip-mib/inetNetToMediaTable)
              mibs+=(ip-mib/ipDefaultRouterTable)
              mibs+=(ip-mib/ipv4InterfaceTable)
              mibs+=(ip-mib/ipv6InterfaceTable)
              mibs+=(ip-mib/ipv6ScopeZoneIndexTable)
              mibs+=(mibII/mta_sendmail)
              mibs+=(misc/ipfwacc)
              mibs+=(sctp-mib)
              mibs+=(snmp-notification-mib)
              mibs+=(tcp-mib)
              mibs+=(testhandler)
              mibs+=(tunnel)
              mibs+=(ucd-snmp/diskio)
	      if [ -n "$libsensorsver" ]; then
		  mibs+=(hardware/sensors)
		  mibs+=(ucd-snmp/lmsensorsMib)
	      fi
              mibs+=(ucd-snmp/extensible)
              mibs+=(udp-mib)
	      mibs+=(rmon-mib)
              ;;
      esac
      # Disable MySQL support because of the following Perl test failure on
      # Travis:
      # t/1.t .. Can't load '/home/travis/build/bvanassche/net-snmp/perl/TrapReceiver/../blib/arch/auto/NetSNMP/TrapReceiver/TrapReceiver.so' for module NetSNMP::TrapReceiver: /home/travis/build/bvanassche/net-snmp/apps/.libs/libnetsnmptrapd.so.35: undefined symbol: mysql_sqlstate at /usr/lib/x86_64-linux-gnu/perl/5.22/DynaLoader.pm line 187.
      # at t/1.t line 16.
      if false && [ -n "$libmysqlver" ]; then
	  options+=(--with-mysql)
      fi
      if [ -n "$perldevver" ]; then
	  options+=(--with-perl-modules)
      else
	  options+=(--disable-embedded-perl --without-perl-modules)
      fi
      if [ -n "$libatmver" ]; then
	  transports+=(AAL5PVC)
      fi
      transports+=(IPX)
      transports+=(STD)
      $is_5_8_or_above && transports+=(UDPshared)
      options+=("--with-default-snmp-version=2")
      options+=("--with-systemd")
      # Disabled modules because troublesome: Rmon ipfwchains/ipfwchains ucd-snmp/lmSensors
    ;;
  darwin*|Darwin*)
      case "$MODE" in
          mini*|read-only)
              ;;
          *)
              mibs+=(disman/nslookup-mib)
              mibs+=(host)
              mibs+=(if-mib)
              mibs+=(mibII/mta_sendmail)
              mibs+=(misc/ipfwacc)
              mibs+=(snmp-notification-mib)
              mibs+=(tcp-mib)
              mibs+=(ucd-snmp/diskio)
              mibs+=(ucd-snmp/extensible)
              mibs+=(udp-mib)
              mibs+=(Rmon)
              ;;
      esac
      if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
          options+=("--with-openssl=$(brew --prefix openssl)")
          # On Travis OS/X linking the Perl modules fails with "undefined symbol
          # _BN_bin2bn" etc.
          options+=(--disable-embedded-perl --without-perl-modules)
      fi
    ;;
  FreeBSD*)
      case "$MODE" in
          mini*|read-only)
              ;;
          *)
              mibs+=(disman/nslookup-mib)
              mibs+=(host)
              mibs+=(if-mib)
              mibs+=(mibII/mta_sendmail)
              mibs+=(misc/ipfwacc)
              mibs+=(sctp-mib)
              mibs+=(snmp-notification-mib)
              mibs+=(tcp-mib)
              mibs+=(ucd-snmp/diskio)
              mibs+=(ucd-snmp/extensible)
              mibs+=(udp-mib)
              mibs+=(Rmon)
              ;;
      esac
      options+=(--disable-embedded-perl --without-perl-modules)
    ;;
  CYGWIN*)
      export ENV_SEPARATOR=":"
      mibs+=(ucd-snmp/extensible)
      mibs+=(winExtDLL)
      options+=(--disable-embedded-perl --without-perl-modules)
    ;;
  MINGW*)
      options+=(--disable-embedded-perl)
      mibs+=(host)
      mibs+=(snmp-notification-mib)
      mibs+=(ucd-snmp/dlmod)
      mibs+=(ucd-snmp/extensible)
      mibs+=(winExtDLL)
      options+=(--without-perl-modules)
    ;;
  MSYS*)
      options+=(--disable-embedded-perl)
      mibs+=(host)
      mibs+=(snmp-notification-mib)
      mibs+=(ucd-snmp/dlmod)
      mibs+=(ucd-snmp/extensible)
      mibs+=(winExtDLL)
      options+=(--without-perl-modules)
      # The config.guess script in the Net-SNMP source tree is too old to
      # recognize the MSYS2 environment. Hence the explicit --build=... option.
      # See also
      # http://git.savannah.gnu.org/cgit/automake.git/tree/lib/config.guess.
      options+=("--build=x86_64-pc-mingw32")
    ;;
  *)
    echo "Unknown OS $(uname)."
    ;;
esac

with_openssl=""
for o in "${options[@]}"; do
    if [ "${o#--with-openssl=}" != "$o" ]; then
        with_openssl="${o#--with-openssl=}"
    fi
done
if [ "$opensslver" = "" ]; then
    options+=("--with-openssl=internal")
    with_openssl="internal"
else
    if grep -rqw BIO_dgram_get_peer "$(ssl_include_path)" 2>/dev/null; then
	transports+=(DTLSUDP TLSTCP)
    fi
    if [ "$MODE" != "read-only" ]; then
	# these MIB modules do not support read-only
	if [ -e "$(ssl_include_path)/dh.h" ]; then
	    mibs+=(snmp-usm-dh-objects-mib)
	fi
	if [ -e "$(ssl_include_path)/ssl.h" ]; then
	    mibs+=(tlstm-mib)
	fi
	mibs+=(tsm-mib)
    fi
fi
if [ "$with_openssl" != "internal" ] && $is_5_8_or_above &&
       [ -e "$(ssl_include_path)/aes.h" ] &&
       [ -e "$(ssl_include_path)/evp.h" ]; then
       options+=(--enable-blumenthal-aes)
fi
security_modules=(usm tsm)
if [ -e /usr/include/krb5.h ]; then
    security_modules+=(ksm)
fi
case "$(uname)" in
    MSYS*|MINGW*)
	# Do not enable Python support on MinGW32 nor for the MSYS build
	# environment because the Python interpreter has been built on these
	# environments with Visual C++. That compiler is incompatible with gcc.
        ;;
    Darwin*)
	case "$(uname -r)" in
	    11.*|12.*)
		if python3 -c 'import setuptools' 1>/dev/null 2>&1; then
		    options+=(--with-python-modules)
		fi
		;;
	    *)
		;;
	esac
	;;
    *)
	# Do not enable Python support for Cirrus CI because on Cirrus linking
	# with Python fails as follows (this is probably a bug in Net-SNMP):
	# /usr/bin/ld: /tmp/cirrus-ci-build/snmplib/.libs/libnetsnmp.a(snmp_client.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
	if python3 -c 'import setuptools' 1>/dev/null 2>&1 &&
	       [ -z "$CIRRUS_CI" ]; then
	    options+=(--with-python-modules)
	fi
    esac

case "$MODE" in
    disable-set)
        options+=(--disable-set-support);;
    mini)
        options+=(--enable-mini-agent);;
    minimalist)
        options+=(--enable-minimalist);;
    read-only)
        options+=(--enable-read-only);;
    regular|"")
        ;;
    *)
        echo "Error: unknown build type $MODE"
        exit 1;;
esac

[ "${libssh2ver#2}" != "${libssh2ver}" ] && transports+=(SSH)
set -x
./configure "${options[@]}" --with-transports="${transports[*]}" \
            --with-security-modules="${security_modules[*]}"	 \
	    --with-mib-modules="${mibs[*]}" "$@"