Code

build system: Improve the detection of the Net-SNMP library.
authorFlorian Forster <octo@crystal.wlan.home.verplant.org>
Tue, 18 Sep 2007 11:45:36 +0000 (13:45 +0200)
committerFlorian Forster <octo@crystal.wlan.home.verplant.org>
Tue, 18 Sep 2007 11:49:57 +0000 (13:49 +0200)
configure.in

index 44d7cfcc7c75fa6e6165ac04a16e43217d71f4f2..16ffe1ad71d433eb7aa939a4d3a155adccace7db 100644 (file)
@@ -773,9 +773,11 @@ AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to l
                if test -x "$withval"
                then
                        with_curl_config="$withval"
+                       with_libcurl="yes"
                else if test -x "$withval/bin/curl-config"
                then
                        with_curl_config="$withval/bin/curl-config"
+                       with_libcurl="yes"
                fi; fi
        fi; fi
 ],
@@ -1223,29 +1225,67 @@ else
 fi
 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
 
+with_snmp_config="net-snmp-config"
+with_snmp_cflags=""
+with_snmp_libs=""
 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 [
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       if test "x$withval" = "xno"
+       then
+               with_libnetsnmp="no"
+       else if "x$withval" = "xyes"
        then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
                with_libnetsnmp="yes"
-       fi
+       else
+               if test -x "$withval"
+               then
+                       with_snmp_config="$withval"
+                       with_libnetsnmp="yes"
+               else
+                       with_snmp_config="$withval/bin/net-snmp-config"
+                       with_libnetsnmp="yes"
+               fi
+       fi; fi
 ],
 [with_libnetsnmp="yes"])
 if test "x$with_libnetsnmp" = "xyes"
 then
-       AC_CHECK_LIB(netsnmp, init_snmp,
-       [
-               AC_DEFINE(HAVE_LIBSNMP, 1, [Define to 1 if you have the Net-SNMP library (-lnetsnmp).])
-       ], [with_libnetsnmp="no (libnetsnmp not found)"])
+       with_snmp_cflags=`$with_snmp_config --cflags >/dev/null`
+       snmp_config_status=$?
+
+       if test $snmp_config_status -ne 0
+       then
+               with_libnetsnmp="no ($with_snmp_config failed)"
+       else
+               SAVE_CFLAGS=$CFLAGS
+               CFLAGS="$CFLAGS $with_snmp_cflags"
+               
+               AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
+
+               CFLAGS="$SAVE_CFLAGS"
+       fi
 fi
 if test "x$with_libnetsnmp" = "xyes"
 then
-       AC_CHECK_HEADERS(net-snmp/net-snmp-config.h,
-       [
-               AC_DEFINE(HAVE_NET_SNMP_NET_SNMP_CONFIG_H, 1, [Define to 1 if you have the <net-snmp/net-snmp-config.h> header file.])
-       ], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
+       with_snmp_libs=`$with_snmp_config --libs >/dev/null`
+       snmp_config_status=$?
+
+       if test $snmp_config_status -ne 0
+       then
+               with_libnetsnmp="no ($with_snmp_config failed)"
+       else
+               AC_CHECK_LIB(netsnmp, init_snmp,
+               [with_libnetsnmp="yes"],
+               [with_libnetsnmp="no (libnetsnmp not found)"],
+               [$with_snmp_libs])
+       fi
+fi
+if test "x$with_libsnmp" = "xyes"
+then
+       BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
+       BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
+       AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
 fi
 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")