I think I have found a bug in FreeRadius' configure script.

I have a FreeBSD-4.4 box with the ucd-snmp-4.0.1 port installed; snmp.h is
in /usr/local/include/ucd-snmp/

configure fails to locate the correct ucd-snmp include directory but still
decides to include snmp support anyway. As a result, compilation crashes
later on, as soon as "oid" is referenced.

Snippet from the './configure' output:

checking for asn1.h... yes
checking for snmp.h... no
checking for snmp_impl.h... no
checking for snmp_build_var_op in -lsnmp... yes

Snippet from the 'gmake' output:

Making all in main...
gmake[4]: Entering directory /u/home/telinco/build/freeradius-0.5/src/main'
gcc  -g -O2 -pthread -D_THREAD_SAFE -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Wall 
-D_GNU_SOURCE -DNDEBUG -I../include -I/usr/include/ucd-snmp  -c radiusd.c
In file included from ../include/radius_snmp.h:26,
                 from radiusd.c:83:
../include/smux.h:47: syntax error before d'
../include/smux.h:51: syntax error before d'
../include/smux.h:81: syntax error before d'
../include/smux.h:88: syntax error before d'
../include/smux.h:127: syntax error before '
../include/smux.h:130: syntax error before d'
../include/smux.h:131: syntax error before d'
../include/smux.h:134: syntax error before d'
../include/smux.h:135: syntax error before *'
../include/smux.h:135: syntax error before *'


Now, a workaround appears to be changing the order in which the directories
are tested in the 'configure' script:

--- configure.orig      Wed Mar  6 16:02:25 2002
+++ configure   Thu Apr  4 11:24:43 2002
@@ -3767,7 +3767,7 @@
 
 if test "x$SNMP_INCLUDE" = "x"; then
   old_CFLAGS="$CFLAGS"
-  for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
+  for try in /usr/local/include/ucd-snmp /usr/include/ucd-snmp $snmp_include_dir; do
     CFLAGS="$old_CFLAGS -I$try"
     cat > conftest.$ac_ext <<EOF
 #line 3774 "configure"

However, if that's the case, clearly something is broken.

As far as I can tell, the logic in the autoconf script is as follows.

(1) First try to find <asn1.h>

This does actually exist on my system, as /usr/include/asn1.h (part
of Kerberos) and /usr/include/openssl/asn1.h, and hence it is found.
There is also /usr/local/include/ucd-snmp/asn1.h, which is probably what it
should have been looking for.

[Aside: a clean FreeBSD-4.5 system does not have /usr/include/asn1.h so this
problem may not occur there]

(2) *Whether or not* asn1.h was found, the script starts looking for it in
other directories anyway. The relevant code is:

--------------------------------------------------------------------------
#include <asn1.h>],
               [ int a = 1;],
               SNMP_INCLUDE="",
               SNMP_INCLUDE=)

dnl #
dnl #  If not, look for it in a number of directories.
dnl #
if test "x$SNMP_INCLUDE" = "x"; then
  old_CFLAGS="$CFLAGS"
  for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir
; do
    CFLAGS="$old_CFLAGS -I$try"
    AC_TRY_COMPILE([
--------------------------------------------------------------------------

Now, the first section has two different results (SNMP_INCLUDE is set to the
empty string or SNMP_INCLUDE is unset), but in both cases, the following
'if' condition will always return TRUE. It then starts searching for asn1.h
again, with /usr/include/ucd-snmp in the include path.

On my system, even though this directory does not exist, it will find asn1.h
anyway, as explained above. Hence it will always decide to add
-I/usr/include/ucd-snmp to the include path, and then finish.

So there seems to be two problems:
1. autoconf is unable to tell the difference between an unset string
   and an empty string
2. asn1.h may exist anyway and spoof autoconf

For 1, I would propose the following solution: initialise SNMP_INCLUDE to
"NOTFOUND", so that the empty string can be interpreted unambiguously as
"found, no special include required"

For 2, I think it would make sense to look for <snmp.h> before <asn1.h>. Of
course, having multiple asn1.h files may still be a problem, but hopefully
the one we -Include first will take precedence.

Regards,

Brian Candler.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to