0
votes

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.

3
Why would you name it .sh? That's arbitrary and misleading, since configure.ac is not a valid shell script. The problem is that you are telling autoconf what your miss-named configure.ac is, but not telling the same information to aclocal. - DanielKO
Not configure.ac should be named configure.sh, but the result: instead of a configure script I want/need a configure.sh script. And the result of autoconf (the configure script itself) is a valid shell script. But as I wrote, the problem starts earlier, when running autoreconf -fi for example. - dev-zero
Sorry, I misread your description. Why can't you call aclocal/autoconf/automake by hand? I believe you have to tell autoconf the explicit name of the output with "-o", because automake will track its dependency (configure.ac) and re-generate it when needed. Can't you simply make configure.sh invoke configure? - DanielKO
Ok, I updated the description. The point of my question is: I would like to know why this error happens. Even putting AC_LIBOBJ([something]) on a separate line somewhere before yields that error and I do not understand why. - dev-zero

3 Answers

7
votes
apt-get install pkg-config

Solve the problem for me.

1
votes

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])
0
votes

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.