try to make snmp optional

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/devmodules/dev-libs/ec@34914 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-03-09 14:28:00 +00:00
parent 06ffe54b11
commit 01a407d753
6 changed files with 335 additions and 4 deletions

View file

@ -35,6 +35,9 @@
#import "EcProcess.h"
static EcAlarmSinkSNMP *alarmSink = nil; // The singleton
static NSLock *classLock = nil;
#if defined(WITH_NET_SNMP)
@interface EcAlarmSinkSNMP (Private)
@ -1005,8 +1008,6 @@ objectsTable_handler(netsnmp_mib_handler *handler,
static NSLock *classLock = nil;
@implementation EcAlarmSinkSNMP
+ (EcAlarmSinkSNMP*) alarmSinkSNMP
@ -1640,3 +1641,64 @@ static NSLock *classLock = nil;
@end
#else
@implementation EcAlarmSinkSNMP
+ (EcAlarmSinkSNMP*) alarmSinkSNMP
{
EcAlarmSinkSNMP *sink;
[classLock lock];
sink = [alarmSink retain];
[classLock unlock];
if (nil == sink)
{
sink = [self new];
}
return [sink autorelease];
}
+ (void) initialize
{
if (nil == classLock)
{
classLock = [NSLock new];
}
}
- (id) init
{
[classLock lock];
if (nil == alarmSink)
{
alarmSink = self = [super init];
}
else
{
[self release];
self = [alarmSink retain];
}
[classLock unlock];
return self;
}
- (id) initWithHost: (NSString*)host name: (NSString*)name
{
[classLock lock];
if (nil == alarmSink)
{
alarmSink = self = [super initWithHost: host name: name];
}
else
{
[self release];
self = [alarmSink retain];
}
[classLock unlock];
return self;
}
@end
#endif

View file

@ -42,6 +42,11 @@ ADDITIONAL_LIB_DIRS +=
# Additional directories to be created during installation
#ADDITIONAL_INSTALL_DIRS +=
EcAlarmSink_OBJCFLAGS += $(shell net-snmp-config --cflags)
LIBRARIES_DEPEND_UPON += $(shell net-snmp-config --agent-libs)
#
# Extras for when building with SNMP support
#
ifeq ($(WITH_NET_SNMP),yes)
EcAlarmSink_OBJCFLAGS += $(shell net-snmp-config --cflags)
LIBRARIES_DEPEND_UPON += $(shell net-snmp-config --agent-libs)
endif

View file

@ -31,6 +31,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the <net-snmp/net-snmp-config.h> header file. */
#undef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
@ -103,6 +106,9 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to enable support for NET-SNMP */
#undef WITH_NET_SNMP
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t

View file

@ -1,3 +1,5 @@
WITH_NET_SNMP=@WITH_NET_SNMP@
Console_TOOL_LIBS += @LIBREADLINE@

230
configure vendored
View file

@ -637,6 +637,8 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
WITH_NET_SNMP
NETSNMPCONFIG
LIBREADLINE
EGREP
GREP
@ -697,6 +699,7 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
with_readline
enable_net_snmp
'
ac_precious_vars='build_alias
host_alias
@ -1326,6 +1329,13 @@ if test -n "$ac_init_help"; then
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-net-snmp
Disables the use of net-snmp to provide SNMP alarms.
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
@ -4306,6 +4316,226 @@ fi
fi
WITH_NET_SNMP="no"
# Check whether --enable-net-snmp was given.
if test "${enable_net_snmp+set}" = set; then
enableval=$enable_net_snmp;
else
enable_net_snmp="yes"
fi
if test $enable_net_snmp = "yes"; then
# Extract the first word of "net-snmp-config", so it can be a program name with args.
set dummy net-snmp-config; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_NETSNMPCONFIG+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $NETSNMPCONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_NETSNMPCONFIG="$NETSNMPCONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_NETSNMPCONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_NETSNMPCONFIG" && ac_cv_path_NETSNMPCONFIG="no"
;;
esac
fi
NETSNMPCONFIG=$ac_cv_path_NETSNMPCONFIG
if test -n "$NETSNMPCONFIG"; then
{ $as_echo "$as_me:$LINENO: result: $NETSNMPCONFIG" >&5
$as_echo "$NETSNMPCONFIG" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$NETSNMPCONFIG" != "xno" ; then
ac_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS `$NETSNMPCONFIG --cflags`"
for ac_header in net-snmp/net-snmp-config.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = "xyes"; then
CFLAGS="$CFLAGS `$NETSNMPCONFIG --cflags`"
SNMP_LIBS=`$NETSNMPCONFIG --libs`
cat >>confdefs.h <<\_ACEOF
#define WITH_NET_SNMP 1
_ACEOF
WITH_NET_SNMP="yes"
fi
else
CPPFLAGS="$ac_save_CPPFLAGS"
fi
if test $WITH_NET_SNMP = "no"; then
{ { $as_echo "$as_me:$LINENO: error: Unable to find/use net-snmp ... you must install the net-snmp development package for your system or disable the use of net-snmp" >&5
$as_echo "$as_me: error: Unable to find/use net-snmp ... you must install the net-snmp development package for your system or disable the use of net-snmp" >&2;}
{ (exit 1); exit 1; }; }
fi
fi
ac_config_files="$ac_config_files config.make"
cat >confcache <<\_ACEOF

View file

@ -40,6 +40,32 @@ LIBREADLINE=
fi
], -lncurses)])
WITH_NET_SNMP="no"
AC_ARG_ENABLE(net-snmp,
[ --disable-net-snmp
Disables the use of net-snmp to provide SNMP alarms.],,
enable_net_snmp="yes")
if test $enable_net_snmp = "yes"; then
AC_PATH_PROG(NETSNMPCONFIG, net-snmp-config, no, )
if test "x$NETSNMPCONFIG" != "xno" ; then
ac_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS `$NETSNMPCONFIG --cflags`"
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h)
if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = "xyes"; then
CFLAGS="$CFLAGS `$NETSNMPCONFIG --cflags`"
SNMP_LIBS=`$NETSNMPCONFIG --libs`
AC_DEFINE(WITH_NET_SNMP, 1, [Define to enable support for NET-SNMP])
WITH_NET_SNMP="yes"
fi
else
CPPFLAGS="$ac_save_CPPFLAGS"
fi
if test $WITH_NET_SNMP = "no"; then
AC_MSG_ERROR([Unable to find/use net-snmp ... you must install the net-snmp development package for your system or disable the use of net-snmp])
fi
fi
AC_SUBST(WITH_NET_SNMP)
AC_OUTPUT(config.make)