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_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