On (05/07/12 11:55), Chris Ferron wrote:
> > Fix libnl-3 detection and rework libnl configure check.
> >
> > Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the end of
> > AC_CHECK_LIB docs:
> Ok that makes since. Thanks.
> Won't I still need the AC_SETST to set the *_LIBS? The reason I did this
> in the first place, is so I could use *_LIBS in the Makefile.am regardless
> of if there was a package config or not. Some distros (rare) don't have
> package configs. Im not an autoconf expert so maybe my solution is not
> correct?
> -Chris
> 

There were no science behind decision to remove AC_SUBST.

        AC_SEARCH_LIBS (function, search-libs, [action-if-found], 
[action-if-not-found], [other-libraries])

        |
        | Prepend -llibrary to LIBS for the first library found to contain 
function, and run action-if-found.
        | If the function is not found, run action-if-not-found. 
        |

I thought that LIBS is enough and *_LIBS are just a sub-sets of LIBS.

I left a room for AC_SUBST libnl, we can extend has_libnl_ver checks (e.g.):

 if (test "${has_libnl_ver}" > "1"); then
         AC_DEFINE([HAVE_LIBNL20],[1],[Define if you have libnl-2.0 or higher])
 fi
 if (test "${has_libnl_ver}" = "2"); then
         AC_SUBST(...  -lnl-2 ...)
 fi
 if (test "${has_libnl_ver}" > "2"); then
         AC_SUBST(... -lnl-3 -lnl-genl ...)
 fi


>
> Some distros (rare) don't have package configs.
>

I'll bring them back then.


Will resend as soon as fix problem with Debian.


        -ss

> >
> >> AC_CHECK_LIB requires some care in usage, and should be avoided in some
> >> common cases. Many standard functions
> >> like gethostbyname appear in the standard C library on some hosts, and
> >> in special libraries like nsl on other
> >> hosts. On some hosts the special libraries contain variant
> >> implementations that you may not want to use.
> >> These days it is normally better to use AC_SEARCH_LIBS([gethostbyname],
> >> [nsl]) instead of AC_CHECK_LIB([nsl], [gethostbyname]).
> >
> > The following autoreconf warnings were also fixed:
> >
> > configure.ac:60: the top level
> > configure.ac:60: warning: AC_LANG_CALL: no function given
> > ../../lib/autoconf/lang.m4:272: AC_LANG_CALL is expanded from...
> > ../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
> > ../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
> > ../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
> > ../../lib/m4sugar/m4sh.m4:639: AS_IF is expanded from...
> > ../../lib/autoconf/general.m4:2031: AC_CACHE_VAL is expanded from...
> > ../../lib/autoconf/general.m4:2052: AC_CACHE_CHECK is expanded from...
> > ../../lib/autoconf/libs.m4:99: AC_CHECK_LIB is expanded from...
> > ../../lib/m4sugar/m4sh.m4:639: AS_IF is expanded from...
> > ../../lib/autoconf/libs.m4:99: AC_CHECK_LIB is expanded from...
> >
> > automake: warnings are treated as errors
> > /usr/share/automake-1.12/am/ltlibrary.am: warning: 'libparseevent.la':
> > linking libtool libraries using a non-POSIX
> > /usr/share/automake-1.12/am/ltlibrary.am: archiver requires 'AM_PROG_AR'
> > in 'configure.ac'
> > pevent/Makefile.am:1:   while processing Libtool library
> > 'libparseevent.la'
> >
> > Signed-off-by: Sergey Senozhatsky <sergey.senozhat...@gmail.com>
> >
> > ---
> >
> >  configure.ac |   33 ++++++++++++++++-----------------
> >  1 file changed, 16 insertions(+), 17 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 753a374..64076ec 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -16,6 +16,7 @@ AC_SUBST(GETTEXT_PACKAGE)
> >  AM_GNU_GETTEXT([external])
> >  AM_GNU_GETTEXT_VERSION([0.18])
> >
> > +AM_PROG_AR
> >  # Checks for programs.
> >  AC_PROG_CPP
> >  AC_PROG_CXX
> > @@ -47,32 +48,30 @@ AC_FUNC_STRTOD
> >  AC_CHECK_FUNCS([fdatasync getpagesize gettimeofday memmove memset mkdir
> > munmap pow realpath regcomp select setlocale socket sqrt strcasecmp
> > strchr strdup strerror strncasecmp strstr strtoul strtoull])
> >
> >  PKG_CHECK_MODULES([NCURSES], [ncurses],[],[
> > -   AC_CHECK_LIB([ncurses], [main],[AC_SUBST(NCURSES_LIBS, "-lncurses","
> > ")],AC_MSG_ERROR([ncurses is required but was not found]))
> > +   AC_SEARCH_LIBS([delwin], [ncurses], [], AC_MSG_ERROR([ncurses is
> > required but was not found]), [])
> >  ])
> >  PKG_CHECK_MODULES([PCIUTILS], [libpci],[],[
> > -   AC_CHECK_LIB([libpci], [main],[AC_SUBST(PCIUTILS_LIBS, "-lpci","
> > ")],AC_MSG_ERROR([libpci is required but was not found]))
> > +   AC_SEARCH_LIBS([pci_get_dev], [pci], [], AC_MSG_ERROR([libpci is
> > required but was not found]), [])
> >  ])
> >  PKG_CHECK_MODULES([LIBZ], [zlib],[],[
> > -   AC_CHECK_LIB([zlib], [main],[AC_SUBST(LIBZ_LIBS, "-lz","
> > ")],AC_MSG_ERROR([zlib is required but was not found]))
> > +   AC_SEARCH_LIBS([deflate], [z], [], AC_MSG_ERROR([zlib is required but
> > was not found]), [])
> >  ])
> >
> > -has_libnl=no
> > -PKG_CHECK_MODULES([LIBNL], [libnl-1], [has_libnl=yes],[
> > -   AC_CHECK_LIB([libnl], [main],[has_libnl=yes AC_SUBST(LIBNL_LIBS,
> > "-lnl","Update LIBNL_LIBS based on AC_CHECK_LIB")],[
> > -           PKG_CHECK_MODULES([LIBNL], [libnl-2.0 libnl-3.0 libnl-genl-3.0],
> > [has_libnl=yes AC_DEFINE([HAVE_LIBNL20],[1],[Define if you have libnl-2.0
> > or higher])],[
> > -                   AC_CHECK_LIB([libnl>= 2.0 libnl-genl], 
> > [main],[has_libnl=yes
> > AC_SUBST(LIBNL_LIBS, "-lnl","Update LIBNL_LIBS based on AC_CHECK_LIB")
> > AC_DEFINE([HAVE_LIBNL20],[1],[Define if you have libnl-2.0 or
> > higher])],[dummy=no])
> > -           ])
> > -   ])
> > +has_libnl_ver=0
> > +PKG_CHECK_MODULES([LIBNL], [libnl-1], [has_libnl_ver=1], [
> > +   AC_SEARCH_LIBS([nl_socket_alloc], [nl], [has_libnl_ver=2], [
> > +                PKG_CHECK_MODULES([LIBNL], [libnl-3.0 libnl-genl-3.0],
> > [has_libnl_ver=3],
> > +                                  [AC_SEARCH_LIBS([nl_socket_alloc], [nl-3 
> > nl-genl-3],
> > [has_libnl_ver=3], [], [])])
> > +   ], [])
> >  ])
> > -if (test "${has_libnl}" = "no"); then
> > +if (test "${has_libnl_ver}" = "0"); then
> >     AC_MSG_ERROR(libnl is required but not found)
> >  fi
> > +if (test "${has_libnl_ver}" > "1"); then
> > +   AC_DEFINE([HAVE_LIBNL20],[1],[Define if you have libnl-2.0 or higher])
> > +fi
> >
> > -AC_CHECK_LIB([pthread], [pthread_create],[AC_SUBST(PTHREAD_LIBS,
> > "-lpthread"," ")] , AC_MSG_ERROR([libpthread is required but was not
> > found]))
> > -
> > -# FIXME: Replace `main' with a function in `-lresolv':
> > -AC_CHECK_LIB([resolv], [main],[AC_SUBST(RESOLV_LIBS, "-lresolv"," ")],
> > AC_MSG_ERROR([libresolv is required but was not found]))
> > -
> > -
> > +AC_SEARCH_LIBS([pthread_create], [pthread], [], AC_MSG_ERROR([libpthread
> > is required but was not found]), [])
> > +AC_SEARCH_LIBS([inet_aton], [resolv], [], AC_MSG_ERROR([libresolv is
> > required but was not found]), [])
> >
> >  AC_OUTPUT
> >
> >
> 

_______________________________________________
Power mailing list
Power@bughost.org
https://bughost.org/mailman/listinfo/power

Reply via email to