Question

Given the following autoconf snippet:

if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes" -a x"$ac_cv_type_struct_addrinfo" = x"yes"; then
    # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
    # something else so we must include <netdb.h> to get the
    # redefinition.
    AC_CHECK_FUNCS(getaddrinfo, ,
            [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
            AC_TRY_LINK([#include <sys/types.h>
            #include <sys/socket.h>
            #include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
                    [AC_MSG_RESULT([yes])
                    AC_DEFINE(HAVE_GETADDRINFO, 1,
                            [Define to 1 if you have the "getaddrinfo" function and required types.])],
                    [AC_MSG_RESULT([no])
                    AC_LIBOBJ([getaddrinfo])])])
else
    AC_LIBOBJ([getaddrinfo])
fi

When running either autoconf or autoreconf -fi in that project, I get the error:

configure.ac:529: error: possibly undefined macro: AC_LIBOBJ

which points to the first AC_LIBOBJ occurrence.

Running the following sequence instead works:

aclocal
autoreconf

The problem is that in this particular project, the configure-script should be named configure.sh (and get called using a wrapper), so I'd have to use this sequence instead:

autoconf -o configure.sh
autoreconf

which always generates the error above.

This is with autoconf-2.69 plus I have the following (related) options set:

AM_INIT_AUTOMAKE([subdir-objects tar-ustar foreign])
AC_CONFIG_LIBOBJ_DIR([lib])

I will most likely replace that whole detection by the one contained in gnulib at some point in the future, but at the moment I would like to keep it the way it is.

Was it helpful?

Solution 2

The problem as it seems was the following code earlier in the configure.ac:

# define the directory for replacement function since AC_LIBOBJ does not
# officially support subdirs and fails with automake
AC_CONFIG_LIBOBJ_DIR([lib])

where I should really have used autoconf comment instead:

dnl define the directory for replacement function since AC_LIBOBJ does not
dnl officially support subdirs and fails with automake
AC_CONFIG_LIBOBJ_DIR([lib])

OTHER TIPS

apt-get install pkg-config

Solve the problem for me.

This often happens because of a different macro expanding in incorrect ways. I'd suggest you two things: use AS_IF rather than if .. then .. else statements, and avoid multiple nested macros.

Just set a result variable to yes or no, then use a single AC_MSG_RESULT; and instead of calling AC_LIBOBJ twice, just call it once checking that variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top