File: //proc/self/root/usr/bin/net-snmp-config-i386
#!/bin/sh
#
# $Id: net-snmp-config.in 15951 2007-03-12 22:31:31Z tanders $
#
# this shell script is designed to merely dump the configuration
# information about how the net-snmp package was compiled. The
# information is particularily 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
}
prefix=/usr
exec_prefix=/usr
includedir=/usr/include/net-snmp
libdir=/usr/lib
NSC_LDFLAGS=""
NSC_INCLUDEDIR=${includedir}
NSC_LIBDIR=-L${libdir}
NSC_LIBS="-lcrypto -lm -L/usr/lib/lib -lwrap"
NSC_AGENTLIBS="-ldl -lrpm -lrpmio -lpopt -lz -lcrypto -lm -lsensors -L/usr/lib/lib -lwrap -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -L/usr/local/lib /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/DynaLoader/DynaLoader.a -L/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc"
NSC_PREFIX=$prefix
NSC_EXEC_PREFIX=$exec_prefix
NSC_SRCDIR=.
NSC_INCDIR=${NSC_PREFIX}/include
NSC_BASE_SUBAGENT_LIBS="-lnetsnmpagent -lnetsnmphelpers -lnetsnmp"
NSC_BASE_AGENT_LIBS="-lnetsnmpmibs -lnetsnmpagent -lnetsnmphelpers -lnetsnmp"
NSC_SRC_LIBDIRS="agent/.libs snmplib/.libs agent/helpers/.libs"
NSC_SRC_LIBDEPS="agent/.libs/libnetsnmpmibs.a agent/.libs/libnetsnmpagent.a agent/helpers/.libs/libnetsnmphelpers.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
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=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--datadir=/usr/share' '--includedir=/usr/include/net-snmp' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--enable-static' '--enable-shared' '--with-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -g -lcrypto -DNETSNMP_NO_INLINE' '--with-ldflags=' '--with-sys-location=Unknown' '--with-logfile=/var/log/snmpd.log' '--with-persistent-directory=/var/net-snmp' '--with-mib-modules=host agentx smux ucd-snmp/diskio tcp-mib udp-mib mibII/mta_sendmail ip-mib/ipv4InterfaceTable ip-mib/ipv6InterfaceTable ip-mib/ipAddressPrefixTable/ipAddressPrefixTable ip-mib/ipDefaultRouterTable/ipDefaultRouterTable ip-mib/ipv6ScopeZoneIndexTable ip-mib/ipIfStatsTable sctp-mib rmon-mib etherlike ucd-snmp/lmSensors disman/event-mib' '--with-libwrap=/usr/lib' '--sysconfdir=/etc' '--enable-ipv6' '--enable-ucd-snmp-compatibility' '--with-openssl' '--with-pic' '--enable-embedded-perl' '--enable-mfd-rewrites' '--enable-local-smux' '--with-sys-contact=root@localhost' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'target_alias=i386-redhat-linux-gnu'"
;;
--snmpd-module-list|--mod*)
echo mibII/ipv6 ucd-snmp/diskio mibII/mta_sendmail ip-mib/ipAddressPrefixTable/ipAddressPrefixTable ip-mib/ipDefaultRouterTable/ipDefaultRouterTable ucd-snmp/lmSensors mibII/system_mib mibII/sysORTable mibII/at mibII/ip mibII/snmp_mib mibII/tcp mibII/icmp mibII/udp mibII/vacm_vars mibII/setSerialNo ucd-snmp/memory ucd-snmp/vmstat ucd-snmp/proc ucd-snmp/versioninfo ucd-snmp/pass ucd-snmp/pass_persist ucd-snmp/disk ucd-snmp/loadave ucd-snmp/extensible agent/extend ucd-snmp/errormib ucd-snmp/file ucd-snmp/dlmod ucd-snmp/proxy ucd-snmp/logmatch snmpv3/snmpEngine snmpv3/snmpMPDStats snmpv3/usmStats snmpv3/usmConf snmpv3/usmUser notification/snmpNotifyTable notification/snmpNotifyFilterProfileTable notification-log-mib/notification_log target/snmpTargetAddrEntry target/snmpTargetParamsEntry target/target target/target_counters agent/nsTransactionTable agent/nsModuleTable agent/nsDebug agent/nsCache agent/nsLogging agentx/master agentx/subagent disman/schedule/schedCore disman/schedule/schedConf disman/schedule/schedTable utilities/override utilities/execute utilities/iquery host/hr_system host/hr_device host/hr_other host/hr_proc host/hr_network host/hr_print host/hr_disk host/hr_partition host/hrh_storage host/hrh_filesys host/hr_swrun host/hr_swinst mibII/var_route mibII/route_write util_funcs smux/smux ip-mib/ipv4InterfaceTable/ipv4InterfaceTable ip-mib/ipv6InterfaceTable/ipv6InterfaceTable ip-mib/ipAddressTable/ipAddressTable 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/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable ip-mib/ipIfStatsTable/ipIfStatsTable ip-mib/ipIfStatsTable/ipIfStatsTable_interface ip-mib/ipIfStatsTable/ipIfStatsTable_data_access sctp-mib/sctpScalars mibII/kernel_linux mibII/ipAddr mibII/tcpTable mibII/udpTable mibII/vacm_context mibII/vacm_conf ip-mib/ip_scalars header_complex snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable agentx/protocol agentx/client agentx/master_admin agentx/agentx_config 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 tcp-mib/tcpConnectionTable/tcpConnectionTable tcp-mib/tcpListenerTable/tcpListenerTable udp-mib/udpEndpointTable/udpEndpointTable if-mib/data_access/interface if-mib/ifTable/ifTable_interface if-mib/ifTable/ifTable_data_access if-mib/ifTable/ifTable ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access ip-mib/ipAddressTable/ipAddressTable_interface ip-mib/ipAddressTable/ipAddressTable_data_access ip-mib/data_access/defaultrouter_common ip-mib/data_access/defaultrouter_linux ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access ip-mib/data_access/systemstats_common ip-mib/data_access/systemstats_linux ip-mib/ipIfStatsTable/ipIfStatsTable_data_get sctp-mib/sctpScalars_common sctp-mib/sctpScalars_linux sctp-mib/sctpTables_common sctp-mib/sctpAssocRemAddrTable sctp-mib/sctpAssocLocalAddrTable sctp-mib/sctpLookupLocalPortTable sctp-mib/sctpLookupRemPortTable sctp-mib/sctpLookupRemHostNameTable sctp-mib/sctpLookupRemPrimIPAddrTable sctp-mib/sctpLookupRemIPAddrTable sctp-mib/sctpAssocTable sctp-mib/sctpTables_linux rmon-mib/etherStatsTable/etherStatsTable rmon-mib/etherStatsTable/etherStatsTable_data_get rmon-mib/etherStatsTable/etherStatsTable_data_set rmon-mib/etherStatsTable/etherStatsTable_data_access rmon-mib/etherStatsTable/etherStatsTable_interface 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 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 if-mib/ifXTable/ifXTable ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable hardware/memory/memory_linux hardware/memory/hw_mem hardware/cpu/cpu_linux hardware/cpu/cpu snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_interface snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_access hardware/fsys/hw_fsys hardware/fsys/fsys_mntent tcp-mib/data_access/tcpConn_common tcp-mib/data_access/tcpConn_linux 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/ipv6scopezone_common ip-mib/data_access/ipv6scopezone_linux rmon-mib/data_access/etherstats_linux etherlike-mib/data_access/dot3stats_linux ip-mib/data_access/arp_common ip-mib/data_access/arp_linux ip-mib/data_access/scalars_linux if-mib/ifXTable/ifXTable_interface if-mib/ifXTable/ifXTable_data_access 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 udp-mib/data_access/udp_endpoint_common udp-mib/data_access/udp_endpoint_linux ip-mib/data_access/ipaddress_ioctl ip-forward-mib/data_access/route_common ip-forward-mib/data_access/route_linux ip-forward-mib/data_access/route_ioctl
;;
--default-mibs|--mibs|--MIBS)
echo IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:SNMPv2-MIB:RFC1213-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:HOST-RESOURCES-TYPES:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DISKIO-MIB:MTA-MIB:NETWORK-SERVICES-MIB:SCTP-MIB:RMON-MIB:EtherLike-MIB:LM-SENSORS-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IP-FORWARD-MIB:NET-SNMP-EXTEND-MIB:UCD-DLMOD-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM
;;
--default-mibdirs|--mibdirs|--MIBDIRS)
echo $HOME/.snmp/mibs:/usr/share/snmp/mibs
;;
--snmpconfpath|--SNMPCONFPATH)
echo "/etc/snmp:/usr/share/snmp:/usr/lib/snmp:$HOME/.snmp:/var/net-snmp"
;;
--persistent-directory|--persistent-dir)
echo /var/net-snmp
;;
--perlprog|--perl)
echo /usr/bin/perl
;;
#################################################### compile
--base-cflags)
echo -DINET6 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -g -lcrypto -DNETSNMP_NO_INLINE -Dlinux -I/usr/include/rpm -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -I${NSC_INCLUDEDIR}
;;
--cflags|--cf*)
echo -DINET6 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -g -lcrypto -DNETSNMP_NO_INLINE -Dlinux -I/usr/include/rpm -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -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
;;
#################################################### client lib
--libs)
# use this one == --netsnmp-libs + --external-libs
echo $NSC_LDFLAGS $NSC_LIBDIR -lnetsnmp $NSC_LIBS
;;
--netsnmp-libs)
echo $NSC_LIBDIR -lnetsnmp
;;
--external-libs)
echo $NSC_LDFLAGS $NSC_LIBS
;;
#################################################### 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_BASE_AGENT_LIBS $NSC_AGENTLIBS
;;
--netsnmp-agent-libs)
echo $NSC_LIBDIR $NSC_BASE_AGENT_LIBS
;;
--external-agent-libs)
echo $NSC_LDFLAGS $NSC_AGENTLIBS
;;
####################################################
--version|--ver*)
echo 5.3.2.2
;;
--help)
usage="yes"
;;
--prefix|--pre*)
echo $NSC_PREFIX
;;
--exec-prefix)
echo $NSC_EXEC_PREFIX
;;
####################################################
--create-snmpv3-user)
if /bin/ps -e | egrep ' snmpd *$' > /dev/null 2>&1 ; then
echo "Apparently at least one snmpd demon is already running."
echo "You must stop them in order to use this command."
exit 1
fi
Aalgorithm="MD5"
Xalgorithm="DES"
token=rwuser
shift
while test "x$done" = "x" -a "x$1" != "x" ; do
case $1 in
-A|-a)
shift
if test "x$1" = "x" ; then
echo "You must specify an authentication algorithm or pass phrase"
exit 1
fi
case $1 in
MD5|SHA)
Aalgorithm=$1
shift
;;
md5|sha)
Aalgorithm=`echo $1 | tr a-z A-Z`
shift
;;
*)
apassphrase=$1
shift
;;
esac
;;
-X|-x)
shift
if test "x$1" = "x" ; then
echo "You must specify an encryption algorithm or pass phrase"
exit 1
fi
case $1 in
DES|AES|AES128)
Xalgorithm=$1
shift
;;
des|aes|aes128)
Xalgorithm=`echo $1 | tr a-z A-Z`
shift
;;
*)
xpassphrase=$1
shift
;;
esac
;;
-ro)
token="rouser"
shift
;;
-*)
echo "unknown suboption to --create-snmpv3-user: $1"
exit 1
;;
*)
done=1
;;
esac
done
if test "x$1" = "x" ; then
prompt=yes
echo "Enter a SNMPv3 user name to create: "
read user
else
user=$1
shift
fi
if test "x$user" = "x" ; then
echo "You must specify a user name"
exit 1
fi
if test "x$apassphrase" = "x" ; then
prompt=yes
echo "Enter authentication pass-phrase: "
read apassphrase
fi
if test "x$apassphrase" = "x" ; then
echo "You must specify an authentication pass-phrase"
exit 1
fi
if test "x$prompt" = "xyes" -a "x$xpassphrase" = "x" ; then
echo "Enter encryption pass-phrase: "
echo " [press return to reuse the authentication pass-phrase]"
read xpassphrase
fi
outdir="/var/net-snmp"
outfile="$outdir/snmpd.conf"
line="createUser $user $Aalgorithm \"$apassphrase\" $Xalgorithm $xpassphrase"
echo "adding the following line to $outfile:"
echo " " $line
# in case it hasn't ever been started yet, start it.
if test ! -d $outdir ; then
mkdir $outdir
fi
if test ! -d $outfile ; then
touch $outfile
fi
echo $line >> $outfile
outfile="/etc/snmp/snmpd.conf"
line="$token $user"
echo "adding the following line to $outfile:"
echo " " $line
if test ! -d $outfile ; then
touch $outfile
fi
echo $line >> $outfile
;;
####################################################
--compile-subagent)
shift
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 tmporary 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
extern int netsnmp_running;
RETSIGTYPE
stop_server(int a) {
netsnmp_running = 0;
}
int
main (int argc, char **argv) {
/* print log errors to stderr */
snmp_enable_stderrlog();
/* we are a subagent */
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
/* initialize tcpip, if necessary */
SOCK_STARTUP;
/* initialize the agent library */
init_agent("$outname");
/* 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
shift
done
# finish file
cat >> $tmpfile <<EOF
/* $outname will be used to read $outname.conf files. */
init_snmp("$outname");
/* 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
/* main loop here... */
while(netsnmp_running) {
agent_check_and_process(1);
}
/* at shutdown time */
snmp_shutdown("$outname");
SOCK_CLEANUP;
exit(0);
}
EOF
if test "$?" != 0 -o ! -f "$tmpfile" ; then
echo "Ack. Can't create $tmpfile."
exit 1
fi
cmd="gcc $cflags -DINET6 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -g -lcrypto -DNETSNMP_NO_INLINE -Dlinux -I/usr/include/rpm -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 tmporary code file: $tmpfile"
rm -f $tmpfile
else
echo "leaving the tmporary code file: $tmpfile"
fi
if test -f $outname ; then
echo "subagent program $outname created"
fi
;;
*)
echo "unknown option $1"
usage="yes"
;;
esac
shift
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 [-ro] [-A authpass] [-X privpass]"
echo " [-a MD5|SHA] [-x DES|AES] [username]"
echo ""
echo " These options produce the various compilation flags needed when"
echo " building external SNMP applications:"
echo ""
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 ""
echo " Automatted 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