This file is indexed.

/usr/bin/net-snmp-config is in libsnmp-dev 5.7.3+dfsg-1.8ubuntu3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
#!/bin/sh
#
# $Id$
#
# this shell script is designed to merely dump the configuration
# information about how the net-snmp package was compiled.  The
# information is particularly useful for applications that need to
# link against the net-snmp libraries and hence must know about any
# other libraries that must be linked in as well.

check_build_dir()
{
      build_dir=$1

      if test "x$build_dir" = "x" ; then
         echo "You must specify a build directory."
         exit 1
      fi
      # is it the src dir?
      if test -f $build_dir/net-snmp-config.in ; then
         return
      fi
      # make sure we can find build dir
      if test ! -d $build_dir/snmplib/.libs ; then
         echo "$build_dir does not appear to be a build directory."
         exit 1
      fi
}

# usage: index n arguments
# effect: returns the (n+1)th argument
index()
{
    eval echo \$`expr $1 + 1`
}

# usage: count arguments
# effect: returns the number of arguments
count()
{
    echo $#
}

prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib/x86_64-linux-gnu
datarootdir=${prefix}/share
NSC_LDFLAGS="-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now"

NSC_LIBS="-lm "
NSC_LNETSNMPLIBS=" -lcrypto"
NSC_LAGENTLIBS=" -lwrap -Wl,-E"
NSC_LMIBLIBS="-lsensors -lpci -ldl "

NSC_INCLUDEDIR=${includedir}
NSC_LIBDIR=-L${libdir}

NSC_SNMPLIBS="-lnetsnmp ${NSC_LNETSNMPLIBS}"
NSC_SUBAGENTLIBS="-lnetsnmpagent ${NSC_LAGENTLIBS} ${NSC_SNMPLIBS}"
NSC_AGENTLIBS="-lnetsnmpmibs ${NSC_LMIBLIBS} ${NSC_SUBAGENTLIBS}"

NSC_PREFIX=$prefix
NSC_EXEC_PREFIX=$exec_prefix
NSC_SRCDIR=.
NSC_INCDIR=${NSC_PREFIX}/include

NSC_BASE_SNMP_LIBS="-lnetsnmp"
NSC_BASE_SUBAGENT_LIBS="-lnetsnmpagent ${NSC_BASE_SNMP_LIBS}"
NSC_BASE_AGENT_LIBS="-lnetsnmpmibs ${NSC_BASE_SUBAGENT_LIBS}"

NSC_SRC_LIBDIRS="agent/.libs snmplib/.libs"
NSC_SRC_LIBDEPS="agent/.libs/libnetsnmpmibs.a agent/.libs/libnetsnmpagent.a snmplib/.libs/libnetsnmp.a"

if test "x$NSC_SRCDIR" = "x." ; then
   NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
fi

if test "x$1" = "x"; then
  usage="yes"
else
  while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do
  case "$1" in
    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
    *) optarg= ;;
  esac

  unset shifted
  case $1 in
    --prefix=*)
      prefix=$optarg
      NSC_PREFIX=${prefix}
      NSC_INCLUDEDIR=${prefix}/include
      NSC_LIBDIR=-L${prefix}/lib
      ;;

    --exec-prefix=*)
      exec_prefix=$optarg
      NSC_EXEC_PREFIX=${exec_prefix}
      NSC_LIBDIR=-L${exec_prefix}/lib
      ;;

    --debug-tokens|--deb*|--dbg*)
      echo "find $NSC_SRCDIR -name \"*.c\" -print | xargs grep DEBUGMSGT | grep \\\" | cut -f 2 -d\\\" | sort -u"
      if test "x$NSC_SRCDIR" != "xNET-SNMP-SOURCE-DIR" ; then
        /usr/bin/find $NSC_SRCDIR -name "*.c" -print | xargs grep DEBUGMSGT | grep \" | cut -f 2 -d\" | sort -u
      fi
      ;;
    --indent-options|--in*)
      echo "indent -orig -nbc -bap -nut -nfca `(cd $NSC_INCDIR/net-snmp; perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h)`"
      ;;
    --configure-options|--con*)
      echo " '--build=x86_64-linux-gnu' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--localstatedir=/var' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--prefix=/usr' '--sysconfdir=/etc' '--mandir=/usr/share/man' '--with-persistent-directory=/var/lib/snmp' '--enable-ucd-snmp-compatibility' '--enable-shared' '--with-cflags=-g -O2 -fdebug-prefix-map=/build/net-snmp-UrIPzF/net-snmp-5.7.3+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE' '--with-ldflags=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-perl-modules=INSTALLDIRS=vendor' '--enable-as-needed' '--enable-ipv6' '--with-logfile=none' '--without-rpm' '--with-libwrap' '--with-openssl' '--without-dmalloc' '--without-efence' '--without-rsaref' '--with-sys-contact=root' '--with-sys-location=Unknown' '--with-mib-modules=smux ucd-snmp/dlmod mibII/mta_sendmail disman/event-mib ucd-snmp/diskio ucd-snmp/lmsensorsMib etherlike-mib/dot3StatsTable host' '--with-out-mib-modules=' '--enable-mfd-rewrites' '--with-mnttab=/etc/mtab' '--with-mibdirs=$HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp' '--with-mysql' '--with-defaults' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/net-snmp-UrIPzF/net-snmp-5.7.3+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'"
      ;;
    --snmpd-module-list|--mod*)
echo  mibII/mta_sendmail ucd-snmp/diskio ucd-snmp/dlmod ucd-snmp/lmsensorsMib etherlike-mib/dot3StatsTable/dot3StatsTable etherlike-mib/dot3StatsTable/dot3StatsTable_data_get etherlike-mib/dot3StatsTable/dot3StatsTable_data_set etherlike-mib/dot3StatsTable/dot3StatsTable_data_access etherlike-mib/dot3StatsTable/dot3StatsTable_interface host/hrh_storage host/hrh_filesys host/hrSWInstalledTable host/hrSWRunTable host/hr_system host/hr_device host/hr_other host/hr_proc host/hr_network host/hr_print host/hr_disk host/hr_partition smux/smux util_funcs/header_simple_table snmpv3/snmpMPDStats_5_5 snmpv3/usmStats_5_5 snmpv3/snmpEngine snmpv3/usmConf snmpv3/usmUser mibII/snmp_mib_5_5 mibII/system_mib mibII/sysORTable mibII/vacm_vars mibII/setSerialNo mibII/at mibII/ip mibII/tcp mibII/icmp mibII/udp mibII/ipv6 ucd-snmp/disk_hw ucd-snmp/proc ucd-snmp/versioninfo ucd-snmp/pass ucd-snmp/pass_persist ucd-snmp/loadave agent/extend ucd-snmp/errormib ucd-snmp/file ucd-snmp/proxy ucd-snmp/logmatch ucd-snmp/memory ucd-snmp/vmstat notification/snmpNotifyTable notification/snmpNotifyFilterProfileTable notification-log-mib/notification_log target/target_counters_5_5 target/snmpTargetAddrEntry target/snmpTargetParamsEntry target/target agent/nsTransactionTable agent/nsModuleTable agent/nsDebug agent/nsCache agent/nsLogging agent/nsVacmAccessTable agentx/master agentx/subagent disman/event/mteScalars disman/event/mteTrigger disman/event/mteTriggerTable disman/event/mteTriggerDeltaTable disman/event/mteTriggerExistenceTable disman/event/mteTriggerBooleanTable disman/event/mteTriggerThresholdTable disman/event/mteTriggerConf disman/event/mteEvent disman/event/mteEventTable disman/event/mteEventSetTable disman/event/mteEventNotificationTable disman/event/mteEventConf disman/event/mteObjects disman/event/mteObjectsTable disman/event/mteObjectsConf disman/schedule/schedCore disman/schedule/schedConf disman/schedule/schedTable utilities/override utilities/execute utilities/iquery etherlike-mib/data_access/dot3stats_linux host/data_access/swinst host/data_access/swrun host/hrSWRunPerfTable util_funcs hardware/sensors/hw_sensors hardware/sensors/lmsensors_v3 util_funcs/header_generic mibII/updates mibII/vacm_context mibII/vacm_conf mibII/kernel_linux mibII/ipAddr mibII/var_route mibII/route_write mibII/tcpTable mibII/udpTable ip-mib/ip_scalars util_funcs/restart ucd-snmp/pass_common header_complex snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable agentx/protocol agentx/client agentx/master_admin agentx/agentx_config hardware/memory/hw_mem hardware/memory/memory_linux hardware/fsys/hw_fsys hardware/fsys/fsys_mntent host/data_access/swinst_apt host/data_access/swrun_procfs_status hardware/cpu/cpu hardware/cpu/cpu_linux if-mib/ifTable/ifTable if-mib/ifXTable/ifXTable ip-mib/ipAddressTable/ipAddressTable ip-mib/ipAddressPrefixTable/ipAddressPrefixTable ip-mib/ipDefaultRouterTable/ipDefaultRouterTable ip-mib/inetNetToMediaTable/inetNetToMediaTable ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access ip-mib/ipSystemStatsTable/ipSystemStatsTable ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable ip-mib/ipIfStatsTable/ipIfStatsTable ip-mib/ipIfStatsTable/ipIfStatsTable_interface ip-mib/ipIfStatsTable/ipIfStatsTable_data_access ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable tcp-mib/tcpConnectionTable/tcpConnectionTable tcp-mib/tcpListenerTable/tcpListenerTable udp-mib/udpEndpointTable/udpEndpointTable snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_interface snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_access if-mib/data_access/interface if-mib/ifTable/ifTable_interface if-mib/ifTable/ifTable_data_access if-mib/ifXTable/ifXTable_interface if-mib/ifXTable/ifXTable_data_access ip-mib/ipAddressTable/ipAddressTable_interface ip-mib/ipAddressTable/ipAddressTable_data_access ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get ip-mib/data_access/arp_common ip-mib/data_access/arp_netlink ip-mib/data_access/systemstats_common ip-mib/data_access/systemstats_linux ip-mib/data_access/scalars_linux ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access ip-mib/ipIfStatsTable/ipIfStatsTable_data_get ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access tcp-mib/data_access/tcpConn_common tcp-mib/data_access/tcpConn_linux util_funcs/get_pid_from_inode tcp-mib/tcpConnectionTable/tcpConnectionTable_interface tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access tcp-mib/tcpListenerTable/tcpListenerTable_interface tcp-mib/tcpListenerTable/tcpListenerTable_data_access udp-mib/udpEndpointTable/udpEndpointTable_interface udp-mib/udpEndpointTable/udpEndpointTable_data_access if-mib/data_access/interface_linux if-mib/data_access/interface_ioctl ip-mib/data_access/ipaddress_common ip-mib/data_access/ipaddress_linux ip-mib/data_access/defaultrouter_common ip-mib/data_access/defaultrouter_linux ip-mib/data_access/ipv6scopezone_common ip-mib/data_access/ipv6scopezone_linux ip-forward-mib/data_access/route_common ip-forward-mib/data_access/route_linux ip-forward-mib/data_access/route_ioctl udp-mib/data_access/udp_endpoint_common udp-mib/data_access/udp_endpoint_linux ip-mib/data_access/ipaddress_ioctl
      ;;
    --default-mibs|--mibs|--MIBS)
      echo :SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:HOST-RESOURCES-TYPES:MTA-MIB:NETWORK-SERVICES-MIB:UCD-DISKIO-MIB:UCD-DLMOD-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-FRAMEWORK-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:IP-FORWARD-MIB:NET-SNMP-PASS-MIB:NET-SNMP-EXTEND-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB
      ;;
    --default-mibdirs|--mibdirs|--MIBDIRS)
      echo $HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
      ;;
    --env-separator)
      echo ":"
      ;;
    --exeext)
      echo ""
      ;;
    --snmpconfpath|--SNMPCONFPATH)
      echo "/etc/snmp:/usr/share/snmp:/usr/lib/x86_64-linux-gnu/snmp:$HOME/.snmp:/var/lib/snmp"
      ;;
    --persistent-directory|--persistent-dir)
      echo /var/lib/snmp
      ;;
    --perlprog|--perl)
      echo /usr/bin/perl
      ;;
    #################################################### compile
    --base-cflags)
      echo -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2 -fdebug-prefix-map=/build/net-snmp-UrIPzF/net-snmp-5.7.3+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE -Ulinux -Dlinux=linux  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE  -Wdate-time -D_FORTIFY_SOURCE=2 -I${NSC_INCLUDEDIR}
      ;;
    --base-lib-cflags)
      echo @LIBCFLAGS@ -Wdate-time -D_FORTIFY_SOURCE=2 -I${NSC_INCLUDEDIR}
      ;;
    --cflags|--cf*)
      echo -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2 -fdebug-prefix-map=/build/net-snmp-UrIPzF/net-snmp-5.7.3+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE -Ulinux -Dlinux=linux  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE   -Wdate-time -D_FORTIFY_SOURCE=2 -I. -I${NSC_INCLUDEDIR}
      ;;
    --srcdir)
      echo $NSC_SRCDIR
      ;;
    #################################################### linking
    --libdir|--lib-dir)
      echo $NSC_LIBDIR
      ;;
    --ldflags|--ld*)
      echo $NSC_LDFLAGS
      ;;
    --build-lib-dirs)
      shift
      build_dir=$1
      check_build_dir $build_dir
      for dir in $NSC_SRC_LIBDIRS; do
          result="$result -L$build_dir/$dir"
      done
      echo $result
      ;;
    --build-lib-deps)
      shift
      build_dir=$1
      check_build_dir $build_dir
      for dir in $NSC_SRC_LIBDEPS; do
          result="$result $build_dir/$dir"
      done
      echo $result
      ;;
    --build-includes)
      shift
      build_dir=$1
      check_build_dir $build_dir
      result="-I$build_dir/include"
      if test "$build_dir" != "$NSC_SRCDIR" -a "$NSC_SRCDIR" != "NET-SNMP-SOURCE-DIR"
      then
          result="$result -I$NSC_SRCDIR/include"
      fi
      echo $result
      ;;
    --build-command)
      echo "gcc -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2 -fdebug-prefix-map=/build/net-snmp-UrIPzF/net-snmp-5.7.3+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE -Ulinux -Dlinux=linux  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE  "
      ;;
    #################################################### client lib
    --libs)
      # use this one == --netsnmp-libs + --external-libs
      echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_SNMPLIBS $NSC_LIBS
      ;;
    --netsnmp-libs)
      echo $NSC_LIBDIR $NSC_BASE_SNMP_LIBS
      ;;
    --external-libs)
      echo $NSC_LDFLAGS $NSC_LNETSNMPLIBS $NSC_LIBS -Wl,-E
      ;;
    #################################################### agent lib
    --base-agent-libs)
      echo $NSC_BASE_AGENT_LIBS
      ;;
    --base-subagent-libs)
      echo $NSC_BASE_SUBAGENT_LIBS
      ;;
    --agent-libs)
      # use this one == --netsnmp-agent-libs + --external-libs
      echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_AGENTLIBS $NSC_LIBS
      ;;
    --netsnmp-agent-libs)
      echo $NSC_LIBDIR $NSC_BASE_AGENT_LIBS
      ;;
    --external-agent-libs)
      echo $NSC_LDFLAGS $NSC_LMIBLIBS $NSC_LAGENTLIBS $NSC_LNETSNMPLIBS $NSC_LIBS
      ;;
    ####################################################
    --version|--ver*)
      echo 5.7.3
      ;;
    --help)
      usage="yes"
      ;;
    --prefix|--pre*)
      echo $NSC_PREFIX
      ;;
    --exec-prefix)
      echo $NSC_EXEC_PREFIX
      ;;
    ####################################################
    --create-snmpv3-user)
      done=1
      shift
      net-snmp-create-v3-user $*
      exit $?
      ;;

    ####################################################
    --compile-subagent)
      shift
      shifted=1
      while test "x$done" = "x" -a "x$1" != "x" ; do
	case $1 in
            --norm)
	        norm=1
	        shift
		;;
            --cflags)
	        shift
	        if test "x$1" = "x" ; then
	            echo "You must specify the extra cflags"
	            exit 1
	        fi
	        cflags=$1
	        echo "setting extra cflags: $cflags"
	        shift
		;;
            --ldflags)
	        shift
	        if test "x$1" = "x" ; then
	            echo "You must specify the extra ldflags"
	            exit 1
	        fi
	        ldflags=$1
	        echo "setting extra ldflags: $ldflags"
	        shift
		;;
 	    --*)
		echo "unknown suboption to --compile-subagent: $1"
		exit 1
		;;
	    *)
                if test "x$outname" = "x"; then
                  outname=$1
                  shift
                else
	          done=1
                fi
		;;
	esac
      done
      tmpfile=netsnmptmp.$$.c
      if test -f $tmpfile; then
	echo "Ack.  Can't create $tmpfile: already exists"
	exit 1
      fi
      echo "generating the temporary code file: $tmpfile"
      rm -f $tmpfile
      cat > $tmpfile <<EOF
/* generated from net-snmp-config */
#include <net-snmp/net-snmp-config.h>
#ifdef HAVE_SIGNAL
#include <signal.h>
#endif /* HAVE_SIGNAL */
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
EOF

    # If we were only given a single filename
    # (and no explicit output name)
    # then use that as the base of the output name
    #
    # If we weren't even given that, then bomb out
    if test "x$1" = "x"; then
      if test "x$outname" = "x"; then
        echo "No MIB module codefile specified"
        rm -f $tmpfile
        exit 1
      else
        cfiles=$outname
        outname=`basename $cfiles | sed 's/\.[co]$//'`
        if test -f $outname.h; then
          if grep "init_$outname" $outname.h; then
            echo "  #include \"$outname.h\"" >> $tmpfile
          fi
        fi
      fi
    fi

    # add include files
    while test "$1" != ""; do
      cfiles="$cfiles $1"
      name=`basename $1 | sed 's/\.[co]$//'`
      if test -f $name.h; then
        if grep "init_$name" $name.h; then
          echo "  #include \"$name.h\"" >> $tmpfile
        fi
      fi
      shift
    done

      cat >> $tmpfile <<EOF
const char *app_name = "$outname";
static int reconfig = 0;

extern int netsnmp_running;

#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif

RETSIGTYPE
stop_server(UNUSED int a) {
    netsnmp_running = 0;
}

#ifdef SIGHUP
RETSIGTYPE
hup_handler(int sig)
{
    reconfig = 1;
    signal(SIGHUP, hup_handler);
}
#endif

static void
usage(const char *prog)
{
    fprintf(stderr,
            "USAGE: %s [OPTIONS]\n"
            "\n"
            "OPTIONS:\n", prog);

    fprintf(stderr,
            "  -d\t\t\tdump all traffic\n"
            "  -D TOKEN[,...]\tturn on debugging output for the specified "
            "TOKENs\n"
            "\t\t\t   (ALL gives extremely verbose debugging output)\n"
            "  -f\t\t\tDo not fork() from the calling shell.\n"
            "  -h\t\t\tdisplay this help message\n"
            "  -H\t\t\tdisplay a list of configuration file directives\n"
            "  -L LOGOPTS\t\tToggle various defaults controlling logging:\n");
    snmp_log_options_usage("\t\t\t  ", stderr);
#ifndef DISABLE_MIB_LOADING
    fprintf(stderr,
            "  -m MIB[" ENV_SEPARATOR "...]\t\tload given list of MIBs (ALL loads "
            "everything)\n"
            "  -M DIR[" ENV_SEPARATOR "...]\t\tlook in given list of directories for MIBs\n");
#endif /* DISABLE_MIB_LOADING */
#ifndef DISABLE_MIB_LOADING
    fprintf(stderr,
            "  -P MIBOPTS\t\tToggle various defaults controlling mib "
            "parsing:\n");
    snmp_mib_toggle_options_usage("\t\t\t  ", stderr);
#endif /* DISABLE_MIB_LOADING */
    fprintf(stderr,
            "  -v\t\t\tdisplay package version number\n"
            "  -x TRANSPORT\tconnect to master agent using TRANSPORT\n");
    exit(1);
}

static void
version(void)
{
    fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
    exit(0);
}

int
main (int argc, char **argv)
{
  int arg;
  char* cp = NULL;
  int dont_fork = 0, do_help = 0;

  while ((arg = getopt(argc, argv, "dD:fhHL:"
#ifndef DISABLE_MIB_LOADING
                       "m:M:"
#endif /* DISABLE_MIB_LOADING */
                       "n:"
#ifndef DISABLE_MIB_LOADING
                       "P:"
#endif /* DISABLE_MIB_LOADING */
                       "vx:")) != EOF) {
    switch (arg) {
    case 'd':
      netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
                             NETSNMP_DS_LIB_DUMP_PACKET, 1);
      break;

    case 'D':
      debug_register_tokens(optarg);
      snmp_set_do_debugging(1);
      break;

    case 'f':
      dont_fork = 1;
      break;

    case 'h':
      usage(argv[0]);
      break;

    case 'H':
      do_help = 1;
      break;

    case 'L':
      if (snmp_log_options(optarg, argc, argv) < 0) {
        exit(1);
      }
      break;

#ifndef DISABLE_MIB_LOADING
    case 'm':
      if (optarg != NULL) {
        setenv("MIBS", optarg, 1);
      } else {
        usage(argv[0]);
      }
      break;

    case 'M':
      if (optarg != NULL) {
        setenv("MIBDIRS", optarg, 1);
      } else {
        usage(argv[0]);
      }
      break;
#endif /* DISABLE_MIB_LOADING */

    case 'n':
      if (optarg != NULL) {
        app_name = optarg;
        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
                              NETSNMP_DS_LIB_APPTYPE, app_name);
      } else {
        usage(argv[0]);
      }
      break;

#ifndef DISABLE_MIB_LOADING
    case 'P':
      cp = snmp_mib_toggle_options(optarg);
      if (cp != NULL) {
        fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
        usage(argv[0]);
      }
      break;
#endif /* DISABLE_MIB_LOADING */

    case 'v':
      version();
      break;

    case 'x':
      if (optarg != NULL) {
        netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
                              NETSNMP_DS_AGENT_X_SOCKET, optarg);
      } else {
        usage(argv[0]);
      }
      break;

    default:
      fprintf(stderr, "invalid option: -%c\n", arg);
      usage(argv[0]);
      break;
    }
  }

  if (do_help) {
    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
                           NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
  } else {
    /* we are a subagent */
    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
                           NETSNMP_DS_AGENT_ROLE, 1);

    if (!dont_fork) {
      if (netsnmp_daemonize(1, snmp_stderrlog_status()) != 0)
        exit(1);
    }

    /* initialize tcpip, if necessary */
    SOCK_STARTUP;
  }

  /* initialize the agent library */
  init_agent(app_name);

  /* initialize your mib code here */
EOF

    # add init routines
    for i in $cfiles ; do
      name=`basename $i | sed 's/\.[co]$//'`
      echo checking for init_$name in $i
      if grep "init_$name" $i ; then
        echo "  init_${name}();" >> $tmpfile
      fi
    done

    # handle the main loop
    cat >> $tmpfile <<EOF

  /* $outname will be used to read $outname.conf files. */
  init_snmp("$outname");

  if (do_help) {
    fprintf(stderr, "Configuration directives understood:\n");
    read_config_print_usage("  ");
    exit(0);
  }

  /* In case we received a request to stop (kill -TERM or kill -INT) */
  netsnmp_running = 1;
#ifdef SIGTERM
  signal(SIGTERM, stop_server);
#endif
#ifdef SIGINT
  signal(SIGINT, stop_server);
#endif
#ifdef SIGHUP
  signal(SIGHUP, hup_handler);
#endif

  /* main loop here... */
  while(netsnmp_running) {
    if (reconfig) {
      free_config();
      read_configs();
      reconfig = 0;
    }
    agent_check_and_process(1);
  }

  /* at shutdown time */
  snmp_shutdown(app_name);

  /* deinitialize your mib code here */
EOF

    # add shutdown routines

    i=`count $cfiles`
    while [ $i -gt 0 ] ; do
      fullname=`index $i $cfiles`
      name=`basename $fullname | sed 's/\.[co]$//'`
      echo checking for shutdown_$name in $fullname
      if grep "shutdown_$name" $fullname ; then
        echo "  shutdown_${name}();" >> $tmpfile
      fi
      i=`expr $i - 1`
    done

    # finish file
    cat >> $tmpfile <<EOF

  /* shutdown the agent library */
  shutdown_agent();
  SOCK_CLEANUP;
  exit(0);
}
EOF
      if test "$?" != 0 -o ! -f "$tmpfile" ; then
        echo "Ack.  Can't create $tmpfile."
	exit 1
      fi
      cmd="gcc $cflags -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2 -fdebug-prefix-map=/build/net-snmp-UrIPzF/net-snmp-5.7.3+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE -Ulinux -Dlinux=linux  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE   -I. -I${NSC_INCLUDEDIR} -o $outname $tmpfile $cfiles $NSC_LDFLAGS $NSC_LIBDIR $NSC_BASE_AGENT_LIBS $NSC_AGENTLIBS $ldflags"
      echo "running: $cmd"
      `$cmd`
      if test "x$norm" != "x1" ; then
        echo "removing the temporary code file: $tmpfile"
        rm -f $tmpfile
      else
        echo "leaving the temporary code file: $tmpfile"
      fi
      if test -f $outname ; then
        echo "subagent program $outname created"
      fi
      ;;

    *)
      echo "unknown option $1"
      usage="yes"
      ;;
  esac
  if [ "x$shifted" = "x" ] ; then
      shift
  fi
  done
fi

if test "x$usage" = "xyes"; then
  echo ""
  echo "Usage:"
  echo "  net-snmp-config [--cflags] [--agent-libs] [--libs] [--version]"
  echo "                  ... [see below for complete flag list]"
  echo ""
  echo "    --version         displays the net-snmp version number"
  echo "    --indent-options  displays the indent options from the Coding Style"
  echo "    --debug-tokens    displays a example command line to search to source"
  echo "                      code for a list of available debug tokens"
  echo ""
  echo "  SNMP Setup commands:"
  echo ""
  echo "    --create-snmpv3-user creates a SNMPv3 user in Net-SNMP config file."
  echo "                         See net-snmp-create-v3-user --help for list of"
  echo "                         accepted options."
  echo ""
  echo "  These options produce the various compilation flags needed when"
  echo "  building external SNMP applications:"
  echo ""
  echo "    --base-lib-cflags lists additional compilation flags needed for linking"
  echo "                      against libsnmp"
  echo "    --base-cflags     lists additional compilation flags needed"
  echo "    --cflags          lists additional compilation flags needed"
  echo "                      (includes -I. and extra developer warning flags)"
  echo ""
  echo "  These options produce the various link flags needed when"
  echo "  building external SNMP applications:"
  echo ""
  echo "    --libs            lists libraries needed for building applications"
  echo "    --agent-libs      lists libraries needed for building subagents"
  echo ""
  echo "  These options produce various link flags broken down into parts."
  echo "  (Most of the time the simple options above should be used.)"
  echo ""
  echo "    --libdir              path to netsnmp libraries"
  echo ""
  echo "    --base-agent-libs     netsnmp specific agent libraries"
  echo ""
  echo "    --netsnmp-libs        netsnmp specific libraries (with path)"
  echo "    --netsnmp-agent-libs  netsnmp specific agent libraries (with path)"
  echo ""
  echo "    --ldflags             link flags for external libraries"
  echo "    --external-libs       external libraries needed by netsnmp libs"
  echo "    --external-agent-libs external libraries needed by netsnmp agent libs"
  echo ""
  echo "  These options produce various link flags used when linking an"
  echo "  external application against an uninstalled build directory."
  echo ""
  echo "    --build-includes      include path to build/source includes"
  echo "    --build-lib-dirs      link path to libraries"
  echo "    --build-lib-deps      path to libraries for dependency target"
  echo "    --build-command       command to compile \$3... to \$2"
  echo ""
  echo "  Automated subagent building (produces an OUTPUTNAME binary file):"
  echo "  [this feature has not been tested very well yet.  use at your risk.]"
  echo ""
  echo "    --compile-subagent OUTPUTNAME [--norm] [--cflags flags]"
  echo "                                  [--ldflags flags] mibmodule1.c [...]]"
  echo ""
  echo "         --norm           leave the generated .c file around to read."
  echo "         --cflags flags   extra cflags to use (e.g. -I...)."
  echo "         --ldflags flags  extra ld flags to use (e.g. -L... -l...)."
  echo ""
  echo "  Details on how the net-snmp package was compiled:"
  echo ""
  echo "    --configure-options   display original configure arguments"
  echo "    --prefix              display the installation prefix"
  echo "    --snmpd-module-list   display the modules compiled into the agent"
  echo "    --default-mibs        display default list of MIBs"
  echo "    --default-mibdirs     display default list of MIB directories"
  echo "    --snmpconfpath        display default SNMPCONFPATH"
  echo "    --persistent-directory display default persistent directory"
  echo "    --perlprog            display path to perl for the perl modules"
  echo ""
  exit
fi