Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
On Sun, 2012-05-06 at 21:24 +0300, Sergey Senozhatsky 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: > > > 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]). On Debian the wide character version of ncurses is named ncursesw so if I use the scripts out of the box the screen looks ugly (M-xM-y). Would it be possible to stop assuming that the lib is named libncurses? /MF ___ Power mailing list Power@bughost.org https://bughost.org/mailman/listinfo/power
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
On (05/06/12 22:25), Magnus Fromreide wrote: > On Sun, 2012-05-06 at 21:24 +0300, Sergey Senozhatsky 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: > > > > > 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]). > > On Debian the wide character version of ncurses is named ncursesw so if > I use the scripts out of the box the screen looks ugly (M-xM-y). > > Would it be possible to stop assuming that the lib is named libncurses? > > /MF > AC_SEARCH_LIBS (function, search-libs, [action-if-found], [action-if-not-found], [other-libraries]) Search for a library defining function if it's not already available. This equates to calling ‘AC_LINK_IFELSE([AC_LANG_CALL([], [function])])’ first with no libraries, then for each library listed in search-libs.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. We can try out AC_SEARCH_LIBS(function, [ncursesw ncurses], ...), so ncursesw will be the first one to check in a list of possible LIBs. Could you please try the following patch? --- configure.ac | 36 +--- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 753a374..462e494 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 @@ -46,33 +47,30 @@ AC_FUNC_REALLOC 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], [ncursesw 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_ERRO
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
On Sun, 2012-05-06 at 23:42 +0300, Sergey Senozhatsky wrote: > On (05/06/12 22:25), Magnus Fromreide wrote: > > On Sun, 2012-05-06 at 21:24 +0300, Sergey Senozhatsky 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: > > > > > > > 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]). > > > > On Debian the wide character version of ncurses is named ncursesw so if > > I use the scripts out of the box the screen looks ugly (M-xM-y). > > > > Would it be possible to stop assuming that the lib is named libncurses? > > > > /MF > > > > AC_SEARCH_LIBS (function, search-libs, [action-if-found], > [action-if-not-found], [other-libraries]) > > Search for a library defining function if it's not already available. > This equates to calling > ‘AC_LINK_IFELSE([AC_LANG_CALL([], [function])])’ first with no libraries, > then for each library > listed in search-libs.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. > > > We can try out AC_SEARCH_LIBS(function, [ncursesw ncurses], ...), so ncursesw > will be the first one to > check in a list of possible LIBs. > > Could you please try the following patch? With the patch csstoh is linked with -lncursesw. That is a god sign. The main program fails to build. gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2-g -O2 -MT tuning/powertop-iw.o -MD -MP -MF tuning/.deps/powertop-iw.Tpo -c -o tuning/powertop-iw.o `test -f 'tuning/iw.c' || echo './'`tuning/iw.c tuning/iw.c: In function ‘nl80211_init’: tuning/iw.c:82:17: warning: assignment makes pointer from integer without a cast [enabled by default] tuning/iw.c:88:2: warning: passing argument 1 of ‘genl_connect’ from incompatible pointer type [enabled by default] /usr/include/netlink/genl/genl.h:23:13: note: expected ‘struct nl_handle *’ but argument is of type ‘struct nl_sock *’ tuning/iw.c:94:2: warning: passing argument 1 of ‘genl_ctrl_alloc_cache’ from incompatible pointer type [enabled by default] /usr/include/netlink/genl/ctrl.h:25:26: note: expected ‘struct nl_handle *’ but argument is of type ‘struct nl_sock *’ tuning/iw.c:94:2: error: too many arguments to function ‘genl_ctrl_alloc_cache’ /usr/include/netlink/genl/ctrl.h:25:26: note: declared here tuning/iw.c: In function ‘__handle_cmd’: tuning/iw.c:242:2: warning: passing argument 1 of ‘nl_send_auto_complete’ from incompatible pointer type [enabled by default] /usr/include/netlink/netlink.h:48:14: note: expected ‘struct nl_handle *’ but argument is of type ‘struct nl_sock *’ tuning/iw.c:253:3: warning: passing argument 1 of ‘nl_recvmsgs’ from incompatible pointer type [enabled by default] /usr/include/netlink/netlink.h:58:14: note: expected ‘struct nl_handle *’ but argument is of type ‘struct nl_sock *’ make[3]: *** [tuning/powertop-iw.o] Error 1 /MF > > --- > > configure.ac | 36 +--- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 753a374..462e494 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 > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC > 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], [ncursesw 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
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
On (05/07/12 00:47), Magnus Fromreide wrote: > On Sun, 2012-05-06 at 23:42 +0300, Sergey Senozhatsky wrote: > > On (05/06/12 22:25), Magnus Fromreide wrote: > > > On Sun, 2012-05-06 at 21:24 +0300, Sergey Senozhatsky 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: > > > > > > > > > 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]). > > > > > > On Debian the wide character version of ncurses is named ncursesw so if > > > I use the scripts out of the box the screen looks ugly (M-xM-y). > > > > > > Would it be possible to stop assuming that the lib is named libncurses? > > > > > > /MF > > > > > > > AC_SEARCH_LIBS (function, search-libs, [action-if-found], > > [action-if-not-found], [other-libraries]) > > > > Search for a library defining function if it's not already available. > > This equates to calling > > ‘AC_LINK_IFELSE([AC_LANG_CALL([], [function])])’ first with no > > libraries, then for each library > > listed in search-libs.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. > > > > > > We can try out AC_SEARCH_LIBS(function, [ncursesw ncurses], ...), so > > ncursesw will be the first one to > > check in a list of possible LIBs. > > > > Could you please try the following patch? > > With the patch csstoh is linked with -lncursesw. That is a god sign. > > The main program fails to build. > That's weird. What version of libnl you are using? Could you please provide Makefile and config.h files? -ss > gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2-g -O2 -MT > tuning/powertop-iw.o -MD -MP -MF tuning/.deps/powertop-iw.Tpo -c -o > tuning/powertop-iw.o `test -f 'tuning/iw.c' || echo './'`tuning/iw.c > tuning/iw.c: In function ‘nl80211_init’: > tuning/iw.c:82:17: warning: assignment makes pointer from integer without a > cast [enabled by default] > tuning/iw.c:88:2: warning: passing argument 1 of ‘genl_connect’ from > incompatible pointer type [enabled by default] > /usr/include/netlink/genl/genl.h:23:13: note: expected ‘struct nl_handle *’ > but argument is of type ‘struct nl_sock *’ > tuning/iw.c:94:2: warning: passing argument 1 of ‘genl_ctrl_alloc_cache’ from > incompatible pointer type [enabled by default] > /usr/include/netlink/genl/ctrl.h:25:26: note: expected ‘struct nl_handle *’ > but argument is of type ‘struct nl_sock *’ > tuning/iw.c:94:2: error: too many arguments to function > ‘genl_ctrl_alloc_cache’ > /usr/include/netlink/genl/ctrl.h:25:26: note: declared here > tuning/iw.c: In function ‘__handle_cmd’: > tuning/iw.c:242:2: warning: passing argument 1 of ‘nl_send_auto_complete’ > from incompatible pointer type [enabled by default] > /usr/include/netlink/netlink.h:48:14: note: expected ‘struct nl_handle *’ but > argument is of type ‘struct nl_sock *’ > tuning/iw.c:253:3: warning: passing argument 1 of ‘nl_recvmsgs’ from > incompatible pointer type [enabled by default] > /usr/include/netlink/netlink.h:58:14: note: expected ‘struct nl_handle *’ but > argument is of type ‘struct nl_sock *’ > make[3]: *** [tuning/powertop-iw.o] Error 1 > > /MF > > > > > --- > > > > configure.ac | 36 +--- > > 1 file changed, 17 insertions(+), 19 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index 753a374..462e494 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 > > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC > > 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], [ncursesw ncurses], [], AC_MSG_ERROR([ncurses is > > required but was not found]), []) > > + > > PKG_CHECK_MODULES([PCIUTILS], [libpci],[],[ > > - AC_CHECK_LIB([libpci], [main],[AC_SUBST(PCIUTILS
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
> 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 > >> 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 > > --- > > 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],[Defin
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
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 > > > > --- > > > > 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
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
> 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. > LIBS might be enough, Im not contending I know what is optimal here, I was more making an inquiry. Im going to play with this a bit as well. -C > 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 >> > >> > --- >> > >> > 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_LIB
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
> On (05/07/12 00:47), Magnus Fromreide wrote: >> On Sun, 2012-05-06 at 23:42 +0300, Sergey Senozhatsky wrote: >> > On (05/06/12 22:25), Magnus Fromreide wrote: >> > > On Sun, 2012-05-06 at 21:24 +0300, Sergey Senozhatsky 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: >> > > > >> > > > > 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]). >> > > >> > > On Debian the wide character version of ncurses is named ncursesw so >> if >> > > I use the scripts out of the box the screen looks ugly (M-xM-y). >> > > >> > > Would it be possible to stop assuming that the lib is named >> libncurses? >> > > >> > > /MF >> > > >> > >> > AC_SEARCH_LIBS (function, search-libs, [action-if-found], >> [action-if-not-found], [other-libraries]) >> > >> > Search for a library defining function if it's not already >> available. This equates to calling >> > âAC_LINK_IFELSE([AC_LANG_CALL([], [function])])â first with no >> libraries, then for each library >> > listed in search-libs.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. >> > >> > >> > We can try out AC_SEARCH_LIBS(function, [ncursesw ncurses], ...), so >> ncursesw will be the first one to >> > check in a list of possible LIBs. >> > >> > Could you please try the following patch? >> >> With the patch csstoh is linked with -lncursesw. That is a god sign. >> >> The main program fails to build. >> > > That's weird. What version of libnl you are using? > Could you please provide Makefile and config.h files? > > -ss So i just got the patch applied clean, and I see the same thing. Looks like HAVE_LIBNL20 is getting set to 1, even if you have ver < 2. I have a spotty internet connection, so my work is going slow. Must be something simple in the configure.ac for libnl checking. -C > > >> gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2-g -O2 -MT >> tuning/powertop-iw.o -MD -MP -MF tuning/.deps/powertop-iw.Tpo -c -o >> tuning/powertop-iw.o `test -f 'tuning/iw.c' || echo './'`tuning/iw.c >> tuning/iw.c: In function ânl80211_initâ: >> tuning/iw.c:82:17: warning: assignment makes pointer from integer >> without a cast [enabled by default] >> tuning/iw.c:88:2: warning: passing argument 1 of âgenl_connectâ from >> incompatible pointer type [enabled by default] >> /usr/include/netlink/genl/genl.h:23:13: note: expected âstruct >> nl_handle *â but argument is of type âstruct nl_sock *â >> tuning/iw.c:94:2: warning: passing argument 1 of >> âgenl_ctrl_alloc_cacheâ from incompatible pointer type [enabled by >> default] >> /usr/include/netlink/genl/ctrl.h:25:26: note: expected âstruct >> nl_handle *â but argument is of type âstruct nl_sock *â >> tuning/iw.c:94:2: error: too many arguments to function >> âgenl_ctrl_alloc_cacheâ >> /usr/include/netlink/genl/ctrl.h:25:26: note: declared here >> tuning/iw.c: In function â__handle_cmdâ: >> tuning/iw.c:242:2: warning: passing argument 1 of >> ânl_send_auto_completeâ from incompatible pointer type [enabled by >> default] >> /usr/include/netlink/netlink.h:48:14: note: expected âstruct nl_handle >> *â but argument is of type âstruct nl_sock *â >> tuning/iw.c:253:3: warning: passing argument 1 of ânl_recvmsgsâ from >> incompatible pointer type [enabled by default] >> /usr/include/netlink/netlink.h:58:14: note: expected âstruct nl_handle >> *â but argument is of type âstruct nl_sock *â >> make[3]: *** [tuning/powertop-iw.o] Error 1 >> >> /MF >> >> > >> > --- >> > >> > configure.ac | 36 +--- >> > 1 file changed, 17 insertions(+), 19 deletions(-) >> > >> > diff --git a/configure.ac b/configure.ac >> > index 753a374..462e494 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 >> > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC >> > 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],
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check
On (05/07/12 14:26), Chris Ferron wrote: > So i just got the patch applied clean, and I see the same thing. > Looks like HAVE_LIBNL20 is getting set to 1, even if you have ver < 2. > I have a spotty internet connection, so my work is going slow. > Must be something simple in the configure.ac for libnl checking. > -C > I think the error is in has_libnl_ver checks. Probably the right ones are: if (test "$has_libnl_ver" -eq 0); then AC_MSG_ERROR(libnl is required but not found) fi if (test "$has_libnl_ver" -gt 1); then AC_DEFINE([HAVE_LIBNL20], [1], [Define if you have libnl-2.0 or higher]) fi ___ Power mailing list Power@bughost.org https://bughost.org/mailman/listinfo/power
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check (v3)
On Tue, 2012-05-08 at 00:52 +0300, Sergey Senozhatsky wrote: > Fix libnl-3 detection and rework libnl configure check (v3) Thanks - with this it works for me as well. Sorry for not having answered earlier. ___ Power mailing list Power@bughost.org https://bughost.org/mailman/listinfo/power
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check (v3)
That seems to work on most my systems. I do get an error with slightly older automake. how about this for a fix? error to fix is configure.ac:19: warning: macro `AM_PROG_AR' not found in library autoreconf: running: /usr/bin/autoconf configure.ac:19: error: possibly undefined macro: AM_PROG_AR If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. autoreconf: /usr/bin/autoconf failed with exit status: 1 diff --git a/configure.ac b/configure.ac index d7820d5..2be64b2 100644 --- a/configure.ac +++ b/configure.ac @@ -9,14 +9,12 @@ AC_CONFIG_FILES([Makefile src/Makefile pevent/Makefile po/Make AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) -#AC_SUBST(LIBTOOL_DEPS) -#AC_LTDL_DLLIB GETTEXT_PACKAGE=powertop AC_SUBST(GETTEXT_PACKAGE) AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.18]) -AM_PROG_AR +m4_pattern_allow([AM_PROG_AR], [AM_PROG_AR]) # Checks for programs. AC_PROG_CPP AC_PROG_CXX > > Fix libnl-3 detection and rework libnl configure check (v3) > > Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the end of > AC_CHECK_LIB docs: > >> 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]). > > > > Thanks to Magnus Fromreide and to Chris Ferron. > Signed-off-by: Sergey Senozhatsky > > --- > > configure.ac | 36 +--- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 753a374..d7820d5 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 > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC > 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], [ncursesw 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" -eq 0); then > AC_MSG_ERROR(libnl is required but not found) > fi > +if (test "$has_libnl_ver" -gt 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
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check (v3)
On (05/08/12 14:05), Chris Ferron wrote: > > That seems to work on most my systems. > I do get an error with slightly older automake. > how about this for a fix? > error to fix is > > > configure.ac:19: warning: macro `AM_PROG_AR' not found in library > autoreconf: running: /usr/bin/autoconf > configure.ac:19: error: possibly undefined macro: AM_PROG_AR > If this token and others are legitimate, please use m4_pattern_allow. > See the Autoconf documentation. > autoreconf: /usr/bin/autoconf failed with exit status: 1 > > > I've installed debian on qemu VM, and - Yes, m4_pattern_allow did the trick for debian. However, it didn't work for my Arch Linux: 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' autoreconf: automake failed with exit status: 1 -ss > > diff --git a/configure.ac b/configure.ac > index d7820d5..2be64b2 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -9,14 +9,12 @@ AC_CONFIG_FILES([Makefile src/Makefile pevent/Makefile > po/Make > AC_CONFIG_SRCDIR([src/main.cpp]) > AC_CONFIG_MACRO_DIR([m4]) > AC_CONFIG_HEADERS([config.h]) > -#AC_SUBST(LIBTOOL_DEPS) > -#AC_LTDL_DLLIB > GETTEXT_PACKAGE=powertop > AC_SUBST(GETTEXT_PACKAGE) > AM_GNU_GETTEXT([external]) > AM_GNU_GETTEXT_VERSION([0.18]) > -AM_PROG_AR > +m4_pattern_allow([AM_PROG_AR], [AM_PROG_AR]) > # Checks for programs. > AC_PROG_CPP > AC_PROG_CXX > > > > > > > Fix libnl-3 detection and rework libnl configure check (v3) > > > > Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the end of > > AC_CHECK_LIB docs: > > > >> 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]). > > > > > > > > Thanks to Magnus Fromreide and to Chris Ferron. > > Signed-off-by: Sergey Senozhatsky > > > > --- > > > > configure.ac | 36 +--- > > 1 file changed, 17 insertions(+), 19 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index 753a374..d7820d5 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 > > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC > > 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], [ncursesw 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], [ > > +
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check (v3)
On (05/08/12 14:05), Chris Ferron wrote: > > That seems to work on most my systems. > I do get an error with slightly older automake. > how about this for a fix? > error to fix is > > > configure.ac:19: warning: macro `AM_PROG_AR' not found in library > autoreconf: running: /usr/bin/autoconf > configure.ac:19: error: possibly undefined macro: AM_PROG_AR > If this token and others are legitimate, please use m4_pattern_allow. > See the Autoconf documentation. > autoreconf: /usr/bin/autoconf failed with exit status: 1 > > > > -AM_PROG_AR +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) seems to work for me. Sergey > diff --git a/configure.ac b/configure.ac > index d7820d5..2be64b2 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -9,14 +9,12 @@ AC_CONFIG_FILES([Makefile src/Makefile pevent/Makefile > po/Make > AC_CONFIG_SRCDIR([src/main.cpp]) > AC_CONFIG_MACRO_DIR([m4]) > AC_CONFIG_HEADERS([config.h]) > -#AC_SUBST(LIBTOOL_DEPS) > -#AC_LTDL_DLLIB > GETTEXT_PACKAGE=powertop > AC_SUBST(GETTEXT_PACKAGE) > AM_GNU_GETTEXT([external]) > AM_GNU_GETTEXT_VERSION([0.18]) > -AM_PROG_AR > +m4_pattern_allow([AM_PROG_AR], [AM_PROG_AR]) > # Checks for programs. > AC_PROG_CPP > AC_PROG_CXX > > > > > > > Fix libnl-3 detection and rework libnl configure check (v3) > > > > Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the end of > > AC_CHECK_LIB docs: > > > >> 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]). > > > > > > > > Thanks to Magnus Fromreide and to Chris Ferron. > > Signed-off-by: Sergey Senozhatsky > > > > --- > > > > configure.ac | 36 +--- > > 1 file changed, 17 insertions(+), 19 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index 753a374..d7820d5 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 > > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC > > 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], [ncursesw 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" -eq 0); then > > AC_MSG_ERROR(libnl is required but not found) > > fi > > +if (test "$has_libnl_ver" -gt 1); then > > + AC_DEFINE([HAVE_LIBNL2
Re: [PATCH] configure: fix libnl-3 detection and rework libnl configure check (v3)
> On (05/08/12 14:05), Chris Ferron wrote: >> >> That seems to work on most my systems. >> I do get an error with slightly older automake. >> how about this for a fix? >> error to fix is >> >> >> configure.ac:19: warning: macro `AM_PROG_AR' not found in library >> autoreconf: running: /usr/bin/autoconf >> configure.ac:19: error: possibly undefined macro: AM_PROG_AR >> If this token and others are legitimate, please use >> m4_pattern_allow. >> See the Autoconf documentation. >> autoreconf: /usr/bin/autoconf failed with exit status: 1 >> >> >> >> > > > -AM_PROG_AR > +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) > seems to work on fedora, and arch for me. > > seems to work for me. > > > Sergey > > > >> diff --git a/configure.ac b/configure.ac >> index d7820d5..2be64b2 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -9,14 +9,12 @@ AC_CONFIG_FILES([Makefile src/Makefile pevent/Makefile >> po/Make >> AC_CONFIG_SRCDIR([src/main.cpp]) >> AC_CONFIG_MACRO_DIR([m4]) >> AC_CONFIG_HEADERS([config.h]) >> -#AC_SUBST(LIBTOOL_DEPS) >> -#AC_LTDL_DLLIB >> GETTEXT_PACKAGE=powertop >> AC_SUBST(GETTEXT_PACKAGE) >> AM_GNU_GETTEXT([external]) >> AM_GNU_GETTEXT_VERSION([0.18]) >> -AM_PROG_AR >> +m4_pattern_allow([AM_PROG_AR], [AM_PROG_AR]) >> # Checks for programs. >> AC_PROG_CPP >> AC_PROG_CXX >> >> >> >> > >> > Fix libnl-3 detection and rework libnl configure check (v3) >> > >> > Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the >> end of >> > AC_CHECK_LIB docs: >> > >> >> 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]). >> > >> > >> > >> > Thanks to Magnus Fromreide and to Chris Ferron. >> > Signed-off-by: Sergey Senozhatsky >> > >> > --- >> > >> > configure.ac | 36 +--- >> > 1 file changed, 17 insertions(+), 19 deletions(-) >> > >> > diff --git a/configure.ac b/configure.ac >> > index 753a374..d7820d5 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 >> > @@ -46,33 +47,30 @@ AC_FUNC_REALLOC >> > 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], [ncursesw 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}"