5 kx #!/bin/sh
5 kx #
5 kx # $Id$
5 kx #
5 kx # this shell script is designed to merely dump the configuration
5 kx # information about how the net-snmp package was compiled. The
5 kx # information is particularly useful for applications that need to
5 kx # link against the net-snmp libraries and hence must know about any
5 kx # other libraries that must be linked in as well.
5 kx
5 kx check_build_dir()
5 kx {
5 kx build_dir=$1
5 kx
5 kx if test "x$build_dir" = "x" ; then
5 kx echo "You must specify a build directory."
5 kx exit 1
5 kx fi
5 kx # is it the src dir?
5 kx if test -f $build_dir/net-snmp-config.in ; then
5 kx return
5 kx fi
5 kx # make sure we can find build dir
5 kx if test ! -d $build_dir/snmplib/.libs ; then
5 kx echo "$build_dir does not appear to be a build directory."
5 kx exit 1
5 kx fi
5 kx }
5 kx
5 kx # usage: index n arguments
5 kx # effect: returns the (n+1)th argument
5 kx index()
5 kx {
5 kx [ $# -gt $1 ] || return
5 kx shift $1
5 kx echo $1
5 kx }
5 kx
5 kx # usage: count arguments
5 kx # effect: returns the number of arguments
5 kx count()
5 kx {
5 kx echo $#
5 kx }
5 kx
5 kx prefix=@prefix@
5 kx exec_prefix=@exec_prefix@
5 kx includedir=@includedir@
5 kx libdir=@libdir@
5 kx # Avoid that configure complains that this script ignores @datarootdir@
5 kx echo "@datarootdir@" >/dev/null
5 kx NSC_LDFLAGS="@LDFLAGS@"
5 kx
5 kx NSC_LIBS="@LIBS@"
5 kx NSC_LNETSNMPLIBS="@LNETSNMPLIBS@"
5 kx NSC_LAGENTLIBS="@LAGENTLIBS@ @PERLLDOPTS_FOR_APPS@"
5 kx NSC_LMIBLIBS="@LMIBLIBS@"
5 kx
5 kx NSC_INCLUDEDIR=${includedir}
5 kx NSC_LIBDIR=-L${libdir}
5 kx
5 kx NSC_SNMPLIBS="-lnetsnmp ${NSC_LNETSNMPLIBS}"
5 kx NSC_SUBAGENTLIBS="-lnetsnmpagent ${NSC_LAGENTLIBS} ${NSC_SNMPLIBS}"
5 kx NSC_AGENTLIBS="-lnetsnmpmibs ${NSC_LMIBLIBS} ${NSC_SUBAGENTLIBS}"
5 kx
5 kx NSC_PREFIX=$prefix
5 kx NSC_EXEC_PREFIX=$exec_prefix
5 kx NSC_SRCDIR=@srcdir@
5 kx NSC_INCDIR=${NSC_PREFIX}/include
5 kx
5 kx NSC_BASE_SNMP_LIBS="-lnetsnmp"
5 kx NSC_BASE_SUBAGENT_LIBS="-lnetsnmpagent ${NSC_BASE_SNMP_LIBS}"
5 kx NSC_BASE_AGENT_LIBS="-lnetsnmpmibs ${NSC_BASE_SUBAGENT_LIBS}"
5 kx
5 kx NSC_SRC_LIBDIRS="agent/.libs snmplib/.libs"
5 kx NSC_SRC_LIBDEPS="agent/.libs/libnetsnmpmibs.a agent/.libs/libnetsnmpagent.a snmplib/.libs/libnetsnmp.a"
5 kx
5 kx if test "x$NSC_SRCDIR" = "x." ; then
5 kx NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
5 kx elif test "x$NSC_SRCDIR" = "x" ; then
5 kx NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
5 kx fi
5 kx
5 kx if test "x$1" = "x"; then
5 kx usage="yes"
5 kx else
5 kx while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do
5 kx case "$1" in
5 kx -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
5 kx *) optarg= ;;
5 kx esac
5 kx
5 kx unset shifted
5 kx case $1 in
5 kx --prefix=*)
5 kx prefix=$optarg
5 kx NSC_PREFIX=${prefix}
5 kx NSC_INCLUDEDIR=${prefix}/include
5 kx NSC_LIBDIR=-L${prefix}/lib
5 kx ;;
5 kx
5 kx --exec-prefix=*)
5 kx exec_prefix=$optarg
5 kx NSC_EXEC_PREFIX=${exec_prefix}
5 kx NSC_LIBDIR=-L${exec_prefix}/lib
5 kx ;;
5 kx
5 kx --debug-tokens|--deb*|--dbg*)
5 kx echo "find $NSC_SRCDIR -name \"*.c\" -print | xargs grep DEBUGMSGT | grep \\\" | cut -f 2 -d\\\" | sort -u"
5 kx if test "x$NSC_SRCDIR" != "xNET-SNMP-SOURCE-DIR" ; then
5 kx /usr/bin/find $NSC_SRCDIR -name "*.c" -print | xargs grep DEBUGMSGT | grep \" | cut -f 2 -d\" | sort -u
5 kx fi
5 kx ;;
5 kx --indent-options|--in*)
5 kx echo "indent -orig -nbc -bap -nut -nfca `(cd $NSC_INCDIR/net-snmp; perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h)`"
5 kx ;;
5 kx --configure-options|--con*)
5 kx echo @CONFIGURE_OPTIONS@
5 kx ;;
5 kx --snmpd-module-list|--mod*)
5 kx @MODULE_LIST@
5 kx ;;
5 kx --default-mibs|--mibs|--MIBS)
5 kx echo @NETSNMP_DEFAULT_MIBS@
5 kx ;;
5 kx --default-mibdirs|--mibdirs|--MIBDIRS)
5 kx echo @NETSNMP_DEFAULT_MIBDIRS@
5 kx ;;
5 kx --env-separator)
5 kx echo "@ENV_SEPARATOR@"
5 kx ;;
5 kx --exeext)
5 kx echo "@EXEEXT@"
5 kx ;;
5 kx --snmpconfpath|--SNMPCONFPATH)
5 kx echo "@SNMPCONFPATH@@ENV_SEPARATOR@@SNMPSHAREPATH@@ENV_SEPARATOR@@SNMPLIBPATH@@ENV_SEPARATOR@$HOME/.snmp@ENV_SEPARATOR@@PERSISTENT_DIRECTORY@"
5 kx ;;
5 kx --persistent-directory|--persistent-dir)
5 kx echo @PERSISTENT_DIRECTORY@
5 kx ;;
5 kx --perlprog|--perl)
5 kx echo @PERLPROG@
5 kx ;;
5 kx #################################################### compile
5 kx --base-cflags)
5 kx echo @CFLAGS@ @CPPFLAGS@
5 kx ;;
5 kx --cflags|--cf*)
5 kx echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I.
5 kx ;;
5 kx --srcdir)
5 kx echo $NSC_SRCDIR
5 kx ;;
5 kx #################################################### linking
5 kx --libdir|--lib-dir)
5 kx echo $NSC_LIBDIR
5 kx ;;
5 kx --ldflags|--ld*)
5 kx echo $NSC_LDFLAGS
5 kx ;;
5 kx --build-lib-dirs)
5 kx shift
5 kx build_dir=$1
5 kx check_build_dir $build_dir
5 kx for dir in $NSC_SRC_LIBDIRS; do
5 kx result="$result -L$build_dir/$dir"
5 kx done
5 kx echo $result
5 kx ;;
5 kx --build-lib-deps)
5 kx shift
5 kx build_dir=$1
5 kx check_build_dir $build_dir
5 kx for dir in $NSC_SRC_LIBDEPS; do
5 kx result="$result $build_dir/$dir"
5 kx done
5 kx echo $result
5 kx ;;
5 kx --build-includes)
5 kx shift
5 kx build_dir=$1
5 kx check_build_dir $build_dir
5 kx result="-I$build_dir/include"
5 kx if test "$build_dir" != "$NSC_SRCDIR" -a "$NSC_SRCDIR" != "NET-SNMP-SOURCE-DIR"
5 kx then
5 kx result="$result -I$NSC_SRCDIR/include"
5 kx fi
5 kx echo $result
5 kx ;;
5 kx --build-command)
5 kx echo "@CC@ @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@"
5 kx ;;
5 kx #################################################### client lib
5 kx --libs)
5 kx # use this one == --netsnmp-libs + --external-libs
5 kx echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_SNMPLIBS $NSC_LIBS
5 kx ;;
5 kx --netsnmp-libs)
5 kx echo $NSC_LIBDIR $NSC_BASE_SNMP_LIBS
5 kx ;;
5 kx --external-libs)
5 kx echo $NSC_LDFLAGS $NSC_LNETSNMPLIBS $NSC_LIBS @PERLLDOPTS_FOR_APPS@
5 kx ;;
5 kx #################################################### agent lib
5 kx --base-agent-libs)
5 kx echo $NSC_BASE_AGENT_LIBS
5 kx ;;
5 kx --base-subagent-libs)
5 kx echo $NSC_BASE_SUBAGENT_LIBS
5 kx ;;
5 kx --agent-libs)
5 kx # use this one == --netsnmp-agent-libs + --external-libs
5 kx echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_AGENTLIBS $NSC_LIBS
5 kx ;;
5 kx --netsnmp-agent-libs)
5 kx echo $NSC_LIBDIR $NSC_BASE_AGENT_LIBS
5 kx ;;
5 kx --external-agent-libs)
5 kx echo $NSC_LDFLAGS $NSC_LMIBLIBS $NSC_LAGENTLIBS $NSC_LNETSNMPLIBS $NSC_LIBS
5 kx ;;
5 kx ####################################################
5 kx --version|--ver*)
5 kx echo @VERSION@
5 kx ;;
5 kx --help)
5 kx usage="yes"
5 kx ;;
5 kx --prefix|--pre*)
5 kx echo $NSC_PREFIX
5 kx ;;
5 kx --exec-prefix)
5 kx echo $NSC_EXEC_PREFIX
5 kx ;;
5 kx ####################################################
5 kx --create-snmpv3-user)
5 kx done=1
5 kx shift
5 kx net-snmp-create-v3-user $*
5 kx exit $?
5 kx ;;
5 kx
5 kx ####################################################
5 kx --compile-subagent)
5 kx shift
5 kx shifted=1
5 kx while test "x$done" = "x" -a "x$1" != "x" ; do
5 kx case $1 in
5 kx --norm)
5 kx norm=1
5 kx shift
5 kx ;;
5 kx --cflags)
5 kx shift
5 kx if test "x$1" = "x" ; then
5 kx echo "You must specify the extra cflags"
5 kx exit 1
5 kx fi
5 kx cflags="$1"
5 kx echo "setting extra cflags: $cflags"
5 kx shift
5 kx ;;
5 kx --ldflags)
5 kx shift
5 kx if test "x$1" = "x" ; then
5 kx echo "You must specify the extra ldflags"
5 kx exit 1
5 kx fi
5 kx ldflags="$1"
5 kx echo "setting extra ldflags: $ldflags"
5 kx shift
5 kx ;;
5 kx --*)
5 kx echo "unknown suboption to --compile-subagent: $1"
5 kx exit 1
5 kx ;;
5 kx *)
5 kx if test "x$outname" = "x"; then
5 kx outname=$1
5 kx shift
5 kx else
5 kx done=1
5 kx fi
5 kx ;;
5 kx esac
5 kx done
5 kx tmpfile=netsnmptmp.$$.c
5 kx if test -f $tmpfile; then
5 kx echo "Ack. Can't create $tmpfile: already exists"
5 kx exit 1
5 kx fi
5 kx echo "generating the temporary code file: $tmpfile"
5 kx rm -f $tmpfile
5 kx cat > $tmpfile <<EOF
5 kx /* generated from net-snmp-config */
5 kx #include <net-snmp/net-snmp-config.h>
5 kx #ifdef HAVE_SIGNAL
5 kx #include <signal.h>
5 kx #endif /* HAVE_SIGNAL */
5 kx #ifdef HAVE_SYS_STAT_H
5 kx #include <sys/stat.h>
5 kx #endif /* HAVE_SYS_STAT_H */
5 kx #ifdef HAVE_FCNTL_H
5 kx #include <fcntl.h>
5 kx #endif /* HAVE_FCNTL_H */
5 kx #include <net-snmp/net-snmp-includes.h>
5 kx #include <net-snmp/agent/net-snmp-agent-includes.h>
5 kx EOF
5 kx
5 kx # If we were only given a single filename
5 kx # (and no explicit output name)
5 kx # then use that as the base of the output name
5 kx #
5 kx # If we weren't even given that, then bomb out
5 kx if test "x$1" = "x"; then
5 kx if test "x$outname" = "x"; then
5 kx echo "No MIB module codefile specified"
5 kx rm -f $tmpfile
5 kx exit 1
5 kx else
5 kx cfiles=$outname
5 kx outname=`basename $cfiles | sed 's/\.[co]$//'`
5 kx if test -f $outname.h; then
5 kx if grep "init_$outname" $outname.h; then
5 kx echo " #include \"$outname.h\"" >> $tmpfile
5 kx fi
5 kx fi
5 kx fi
5 kx fi
5 kx
5 kx # add include files
5 kx while test "$1" != ""; do
5 kx cfiles="$cfiles $1"
5 kx name=`basename $1 | sed 's/\.[co]$//'`
5 kx if test -f $name.h; then
5 kx if grep "init_$name" $name.h; then
5 kx echo " #include \"$name.h\"" >> $tmpfile
5 kx fi
5 kx fi
5 kx shift
5 kx done
5 kx
5 kx cat >> $tmpfile <<EOF
5 kx const char *app_name = "$outname";
5 kx static int reconfig = 0;
5 kx
5 kx extern int netsnmp_running;
5 kx
5 kx RETSIGTYPE
5 kx stop_server(int a) {
5 kx netsnmp_running = 0;
5 kx }
5 kx
5 kx #ifdef SIGHUP
5 kx RETSIGTYPE
5 kx hup_handler(int sig)
5 kx {
5 kx reconfig = 1;
5 kx signal(SIGHUP, hup_handler);
5 kx }
5 kx #endif
5 kx
5 kx static void
5 kx usage(const char *prog)
5 kx {
5 kx fprintf(stderr,
5 kx "USAGE: %s [OPTIONS]\n"
5 kx "\n"
5 kx "OPTIONS:\n", prog);
5 kx
5 kx fprintf(stderr,
5 kx " -c FILE[,...]\t\tread FILE(s) as configuration file(s)\n"
5 kx " -C\t\t\tdo not read the default configuration files\n"
5 kx " -d\t\t\tdump all traffic\n"
5 kx " -D TOKEN[,...]\tturn on debugging output for the specified "
5 kx "TOKENs\n"
5 kx "\t\t\t (ALL gives extremely verbose debugging output)\n"
5 kx " -f\t\t\tDo not fork() from the calling shell.\n"
5 kx " -h\t\t\tdisplay this help message\n"
5 kx " -H\t\t\tdisplay a list of configuration file directives\n"
5 kx " -L LOGOPTS\t\tToggle various defaults controlling logging:\n");
5 kx snmp_log_options_usage("\t\t\t ", stderr);
5 kx #ifndef DISABLE_MIB_LOADING
5 kx fprintf(stderr,
5 kx " -m MIB[" ENV_SEPARATOR "...]\t\tload given list of MIBs (ALL loads "
5 kx "everything)\n"
5 kx " -M DIR[" ENV_SEPARATOR "...]\t\tlook in given list of directories for MIBs\n");
5 kx #endif /* DISABLE_MIB_LOADING */
5 kx fprintf(stderr,
5 kx " -p FILE\t\tstore process id in FILE\n");
5 kx #ifndef DISABLE_MIB_LOADING
5 kx fprintf(stderr,
5 kx " -P MIBOPTS\t\tToggle various defaults controlling mib "
5 kx "parsing:\n");
5 kx snmp_mib_toggle_options_usage("\t\t\t ", stderr);
5 kx #endif /* DISABLE_MIB_LOADING */
5 kx fprintf(stderr,
5 kx " -v\t\t\tdisplay package version number\n"
5 kx " -x TRANSPORT\tconnect to master agent using TRANSPORT\n");
5 kx exit(1);
5 kx }
5 kx
5 kx static void
5 kx version(void)
5 kx {
5 kx fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
5 kx exit(0);
5 kx }
5 kx
5 kx int
5 kx main (int argc, char **argv)
5 kx {
5 kx int arg;
5 kx char* cp = NULL;
5 kx int dont_fork = 0, do_help = 0;
5 kx char* pid_file = NULL;
5 kx
5 kx while ((arg = getopt(argc, argv, "c:CdD:fhHL:"
5 kx #ifndef DISABLE_MIB_LOADING
5 kx "m:M:"
5 kx #endif /* DISABLE_MIB_LOADING */
5 kx "n:p:"
5 kx #ifndef DISABLE_MIB_LOADING
5 kx "P:"
5 kx #endif /* DISABLE_MIB_LOADING */
5 kx "vx:")) != EOF) {
5 kx switch (arg) {
5 kx case 'c':
5 kx if (optarg != NULL) {
5 kx netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
5 kx NETSNMP_DS_LIB_OPTIONALCONFIG, optarg);
5 kx } else {
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx
5 kx case 'C':
5 kx netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
5 kx NETSNMP_DS_LIB_DONT_READ_CONFIGS, 1);
5 kx break;
5 kx
5 kx case 'd':
5 kx netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
5 kx NETSNMP_DS_LIB_DUMP_PACKET, 1);
5 kx break;
5 kx
5 kx case 'D':
5 kx debug_register_tokens(optarg);
5 kx snmp_set_do_debugging(1);
5 kx break;
5 kx
5 kx case 'f':
5 kx dont_fork = 1;
5 kx break;
5 kx
5 kx case 'h':
5 kx usage(argv[0]);
5 kx break;
5 kx
5 kx case 'H':
5 kx do_help = 1;
5 kx break;
5 kx
5 kx case 'L':
5 kx if (snmp_log_options(optarg, argc, argv) < 0) {
5 kx exit(1);
5 kx }
5 kx break;
5 kx
5 kx #ifndef DISABLE_MIB_LOADING
5 kx case 'm':
5 kx if (optarg != NULL) {
5 kx setenv("MIBS", optarg, 1);
5 kx } else {
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx
5 kx case 'M':
5 kx if (optarg != NULL) {
5 kx setenv("MIBDIRS", optarg, 1);
5 kx } else {
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx #endif /* DISABLE_MIB_LOADING */
5 kx
5 kx case 'n':
5 kx if (optarg != NULL) {
5 kx app_name = optarg;
5 kx netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
5 kx NETSNMP_DS_LIB_APPTYPE, app_name);
5 kx } else {
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx
5 kx case 'p':
5 kx if (optarg != NULL) {
5 kx pid_file = optarg;
5 kx } else {
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx
5 kx #ifndef DISABLE_MIB_LOADING
5 kx case 'P':
5 kx cp = snmp_mib_toggle_options(optarg);
5 kx if (cp != NULL) {
5 kx fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx #endif /* DISABLE_MIB_LOADING */
5 kx
5 kx case 'v':
5 kx version();
5 kx break;
5 kx
5 kx case 'x':
5 kx if (optarg != NULL) {
5 kx netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
5 kx NETSNMP_DS_AGENT_X_SOCKET, optarg);
5 kx } else {
5 kx usage(argv[0]);
5 kx }
5 kx break;
5 kx
5 kx default:
5 kx fprintf(stderr, "invalid option: -%c\n", arg);
5 kx usage(argv[0]);
5 kx break;
5 kx }
5 kx }
5 kx
5 kx if (do_help) {
5 kx netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
5 kx NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
5 kx } else {
5 kx /* we are a subagent */
5 kx netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
5 kx NETSNMP_DS_AGENT_ROLE, 1);
5 kx
5 kx if (!dont_fork) {
5 kx if (netsnmp_daemonize(1, snmp_stderrlog_status()) != 0)
5 kx exit(1);
5 kx }
5 kx
5 kx #if HAVE_GETPID
5 kx if (pid_file != NULL) {
5 kx /*
5 kx * unlink the pid_file, if it exists, prior to open. Without
5 kx * doing this the open will fail if the user specified pid_file
5 kx * already exists.
5 kx */
5 kx int fd;
5 kx unlink(pid_file);
5 kx fd = open(pid_file, O_CREAT | O_EXCL | O_WRONLY, 0600);
5 kx if (fd == -1) {
5 kx snmp_log_perror(pid_file);
5 kx if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
5 kx NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
5 kx exit(1);
5 kx }
5 kx } else {
5 kx char buf[3 + sizeof(long) * 3];
5 kx int len = snprintf(buf, sizeof(buf), "%ld\n", (long int)getpid());
5 kx write(fd, buf, len);
5 kx close(fd);
5 kx }
5 kx }
5 kx #endif
5 kx
5 kx /* initialize tcpip, if necessary */
5 kx SOCK_STARTUP;
5 kx }
5 kx
5 kx /* initialize the agent library */
5 kx init_agent(app_name);
5 kx
5 kx /* initialize your mib code here */
5 kx EOF
5 kx
5 kx # add init routines
5 kx for i in $cfiles ; do
5 kx name=`basename $i | sed 's/\.[co]$//'`
5 kx echo checking for init_$name in $i
5 kx if grep "init_$name" $i ; then
5 kx echo " init_${name}();" >> $tmpfile
5 kx fi
5 kx done
5 kx
5 kx # handle the main loop
5 kx cat >> $tmpfile <<EOF
5 kx
5 kx /* $outname will be used to read $outname.conf files. */
5 kx init_snmp("$outname");
5 kx
5 kx if (do_help) {
5 kx fprintf(stderr, "Configuration directives understood:\n");
5 kx read_config_print_usage(" ");
5 kx exit(0);
5 kx }
5 kx
5 kx /* In case we received a request to stop (kill -TERM or kill -INT) */
5 kx netsnmp_running = 1;
5 kx #ifdef SIGTERM
5 kx signal(SIGTERM, stop_server);
5 kx #endif
5 kx #ifdef SIGINT
5 kx signal(SIGINT, stop_server);
5 kx #endif
5 kx #ifdef SIGHUP
5 kx signal(SIGHUP, hup_handler);
5 kx #endif
5 kx
5 kx /* main loop here... */
5 kx while(netsnmp_running) {
5 kx if (reconfig) {
5 kx free_config();
5 kx read_configs();
5 kx reconfig = 0;
5 kx }
5 kx agent_check_and_process(1);
5 kx }
5 kx
5 kx /* at shutdown time */
5 kx snmp_shutdown(app_name);
5 kx
5 kx /* deinitialize your mib code here */
5 kx EOF
5 kx
5 kx # add shutdown routines
5 kx
5 kx i=`count $cfiles`
5 kx while [ $i -gt 0 ] ; do
5 kx fullname=`index $i $cfiles`
5 kx name=`basename $fullname | sed 's/\.[co]$//'`
5 kx echo checking for shutdown_$name in $fullname
5 kx if grep "shutdown_$name" $fullname ; then
5 kx echo " shutdown_${name}();" >> $tmpfile
5 kx fi
5 kx i=`expr $i - 1`
5 kx done
5 kx
5 kx # finish file
5 kx cat >> $tmpfile <<EOF
5 kx
5 kx /* shutdown the agent library */
5 kx shutdown_agent();
5 kx
5 kx if (pid_file != NULL) {
5 kx unlink(pid_file);
5 kx }
5 kx
5 kx SOCK_CLEANUP;
5 kx exit(0);
5 kx }
5 kx EOF
5 kx if test "$?" != 0 -o ! -f "$tmpfile" ; then
5 kx echo "Ack. Can't create $tmpfile."
5 kx exit 1
5 kx fi
5 kx cmd="@CC@ $cflags @CFLAGS@ @DEVFLAGS@ -I. -I${NSC_INCLUDEDIR} -o $outname $tmpfile $cfiles $NSC_LDFLAGS $NSC_LIBDIR $NSC_BASE_AGENT_LIBS $NSC_AGENTLIBS $ldflags"
5 kx echo "running: $cmd"
5 kx echo `$cmd`
5 kx result=$?
5 kx if test "x$norm" != "x1" ; then
5 kx echo "removing the temporary code file: $tmpfile"
5 kx rm -f $tmpfile
5 kx else
5 kx echo "leaving the temporary code file: $tmpfile"
5 kx fi
5 kx if test "$result" = "0" -a -f "$outname" ; then
5 kx echo "subagent program $outname created"
5 kx fi
5 kx exit $result
5 kx ;;
5 kx
5 kx *)
5 kx echo "unknown option $1"
5 kx usage="yes"
5 kx ;;
5 kx esac
5 kx if [ "x$shifted" = "x" ] ; then
5 kx shift
5 kx fi
5 kx done
5 kx fi
5 kx
5 kx if test "x$usage" = "xyes"; then
5 kx echo ""
5 kx echo "Usage:"
5 kx echo " net-snmp-config [--cflags] [--agent-libs] [--libs] [--version]"
5 kx echo " ... [see below for complete flag list]"
5 kx echo ""
5 kx echo " --version displays the net-snmp version number"
5 kx echo " --indent-options displays the indent options from the Coding Style"
5 kx echo " --debug-tokens displays a example command line to search to source"
5 kx echo " code for a list of available debug tokens"
5 kx echo ""
5 kx echo " SNMP Setup commands:"
5 kx echo ""
5 kx echo " --create-snmpv3-user creates a SNMPv3 user in Net-SNMP config file."
5 kx echo " See net-snmp-create-v3-user --help for list of"
5 kx echo " accepted options."
5 kx echo ""
5 kx echo " These options produce the various compilation flags needed when"
5 kx echo " building external SNMP applications:"
5 kx echo ""
5 kx echo " --base-cflags lists additional compilation flags needed"
5 kx echo " --cflags lists additional compilation flags needed"
5 kx echo " (includes -I. and extra developer warning flags)"
5 kx echo ""
5 kx echo " These options produce the various link flags needed when"
5 kx echo " building external SNMP applications:"
5 kx echo ""
5 kx echo " --libs lists libraries needed for building applications"
5 kx echo " --agent-libs lists libraries needed for building subagents"
5 kx echo ""
5 kx echo " These options produce various link flags broken down into parts."
5 kx echo " (Most of the time the simple options above should be used.)"
5 kx echo ""
5 kx echo " --libdir path to netsnmp libraries"
5 kx echo ""
5 kx echo " --base-agent-libs netsnmp specific agent libraries"
5 kx echo ""
5 kx echo " --netsnmp-libs netsnmp specific libraries (with path)"
5 kx echo " --netsnmp-agent-libs netsnmp specific agent libraries (with path)"
5 kx echo ""
5 kx echo " --ldflags link flags for external libraries"
5 kx echo " --external-libs external libraries needed by netsnmp libs"
5 kx echo " --external-agent-libs external libraries needed by netsnmp agent libs"
5 kx echo ""
5 kx echo " These options produce various link flags used when linking an"
5 kx echo " external application against an uninstalled build directory."
5 kx echo ""
5 kx echo " --build-includes include path to build/source includes"
5 kx echo " --build-lib-dirs link path to libraries"
5 kx echo " --build-lib-deps path to libraries for dependency target"
5 kx echo " --build-command command to compile \$3... to \$2"
5 kx echo ""
5 kx echo " Automated subagent building (produces an OUTPUTNAME binary file):"
5 kx echo " [this feature has not been tested very well yet. use at your risk.]"
5 kx echo ""
5 kx echo " --compile-subagent OUTPUTNAME [--norm] [--cflags flags]"
5 kx echo " [--ldflags flags] mibmodule1.c [...]]"
5 kx echo ""
5 kx echo " --norm leave the generated .c file around to read."
5 kx echo " --cflags flags extra cflags to use (e.g. -I...)."
5 kx echo " --ldflags flags extra ld flags to use (e.g. -L... -l...)."
5 kx echo ""
5 kx echo " Details on how the net-snmp package was compiled:"
5 kx echo ""
5 kx echo " --configure-options display original configure arguments"
5 kx echo " --prefix display the installation prefix"
5 kx echo " --snmpd-module-list display the modules compiled into the agent"
5 kx echo " --default-mibs display default list of MIBs"
5 kx echo " --default-mibdirs display default list of MIB directories"
5 kx echo " --snmpconfpath display default SNMPCONFPATH"
5 kx echo " --persistent-directory display default persistent directory"
5 kx echo " --perlprog display path to perl for the perl modules"
5 kx echo ""
5 kx exit
5 kx fi