Discussion:
[PATCH] configure: fix libnl-3 detection and rework libnl configure check
Sergey Senozhatsky
2012-05-06 18:24:52 UTC
Permalink
Fix libnl-3 detection and rework libnl configure check.
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.senozhatsky-***@public.gmane.org>

---

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
Magnus Fromreide
2012-05-06 20:25:37 UTC
Permalink
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
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
Sergey Senozhatsky
2012-05-06 20:42:43 UTC
Permalink
Post by Magnus Fromreide
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
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_ERROR([libresolv is required but was not found]), [])

AC_OUTPUT
Magnus Fromreide
2012-05-06 22:47:48 UTC
Permalink
Post by Sergey Senozhatsky
Post by Magnus Fromreide
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
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
Post by Sergey Senozhatsky
---
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]))
-
-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
Sergey Senozhatsky
2012-05-07 07:11:57 UTC
Permalink
Post by Magnus Fromreide
Post by Sergey Senozhatsky
Post by Magnus Fromreide
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
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
Post by Magnus Fromreide
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: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: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
Post by Sergey Senozhatsky
---
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]))
-
-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
Chris Ferron
2012-05-07 21:26:15 UTC
Permalink
Post by Sergey Senozhatsky
Post by Sergey Senozhatsky
Post by Magnus Fromreide
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at
AC_CHECK_LIB requires some care in usage, and should be avoided
in some common cases. Many standard functions
Post by Sergey Senozhatsky
Post by Magnus Fromreide
Post by Sergey Senozhatsky
like gethostbyname appear in the standard C library on some
hosts, and in special libraries like nsl on other
Post by Sergey Senozhatsky
Post by Magnus Fromreide
Post by Sergey Senozhatsky
hosts. On some hosts the special libraries contain variant
implementations that you may not want to use.
Post by Sergey Senozhatsky
Post by Magnus Fromreide
Post by Sergey Senozhatsky
These days it is normally better to use
AC_SEARCH_LIBS([gethostbyname], [nsl]) instead of
AC_CHECK_LIB([nsl], [gethostbyname]).
Post by Sergey Senozhatsky
Post by Magnus Fromreide
On Debian the wide character version of ncurses is named ncursesw so
if
Post by Sergey Senozhatsky
Post by Magnus Fromreide
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?
Post by Sergey Senozhatsky
Post by Magnus Fromreide
/MF
AC_SEARCH_LIBS (function, search-libs, [action-if-found],
[action-if-not-found], [other-libraries])
Post by Sergey Senozhatsky
Search for a library defining function if it's not already
available. This equates to calling
Post by Sergey Senozhatsky
‘AC_LINK_IFELSE([AC_LANG_CALL([], [function])])’ first with no
libraries, then for each library
Post by Sergey Senozhatsky
listed in search-libs.Prepend -llibrary to LIBS for the first
library found to contain function,
Post by Sergey Senozhatsky
and run action-if-found. If the function is not found, run
action-if-not-found.
Post by Sergey Senozhatsky
We can try out AC_SEARCH_LIBS(function, [ncursesw ncurses], ...), so
ncursesw will be the first one to
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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: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: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
Post by Sergey Senozhatsky
---
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])
Post by Sergey Senozhatsky
-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]))
Post by Sergey Senozhatsky
-])
+AC_SEARCH_LIBS([delwin], [ncursesw ncurses], [],
AC_MSG_ERROR([ncurses is required but was not found]), [])
Post by Sergey Senozhatsky
+
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]))
Post by Sergey Senozhatsky
+ AC_SEARCH_LIBS([pci_get_dev], [pci], [], AC_MSG_ERROR([libpci is
required but was not found]), [])
Post by Sergey Senozhatsky
])
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]))
Post by Sergey Senozhatsky
+ AC_SEARCH_LIBS([deflate], [z], [], AC_MSG_ERROR([zlib is required
but was not found]), [])
Post by Sergey Senozhatsky
])
-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")],[
Post by Sergey Senozhatsky
- 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])],[
Post by Sergey Senozhatsky
- 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])
Post by Sergey Senozhatsky
- ])
- ])
+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],
Post by Sergey Senozhatsky
+ [AC_SEARCH_LIBS([nl_socket_alloc], [nl-3 nl-genl-3],
[has_libnl_ver=3], [], [])])
Post by Sergey Senozhatsky
+ ], [])
])
-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])
Post by Sergey Senozhatsky
+fi
-AC_CHECK_LIB([pthread], [pthread_create],[AC_SUBST(PTHREAD_LIBS,
"-lpthread"," ")] , AC_MSG_ERROR([libpthread is required but was not
found]))
Post by Sergey Senozhatsky
-
-AC_CHECK_LIB([resolv], [main],[AC_SUBST(RESOLV_LIBS, "-lresolv","
")], AC_MSG_ERROR([libresolv is required but was not found]))
Post by Sergey Senozhatsky
-
-
+AC_SEARCH_LIBS([pthread_create], [pthread], [],
AC_MSG_ERROR([libpthread is required but was not found]), [])
Post by Sergey Senozhatsky
+AC_SEARCH_LIBS([inet_aton], [resolv], [], AC_MSG_ERROR([libresolv is
required but was not found]), [])
Post by Sergey Senozhatsky
AC_OUTPUT
Sergey Senozhatsky
2012-05-07 21:45:26 UTC
Permalink
Post by Chris Ferron
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
Sergey Senozhatsky
2012-05-07 21:52:47 UTC
Permalink
Fix libnl-3 detection and rework libnl configure check (v3)
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 <sergey.senozhatsky-***@public.gmane.org>

---

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 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
Magnus Fromreide
2012-05-07 22:06:29 UTC
Permalink
Post by Sergey Senozhatsky
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.
Chris Ferron
2012-05-08 21:05:42 UTC
Permalink
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
Post by Sergey Senozhatsky
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 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.
---
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]))
-
-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
Sergey Senozhatsky
2012-05-08 22:11:51 UTC
Permalink
Post by Chris Ferron
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
Post by Chris Ferron
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
Post by Sergey Senozhatsky
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 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.
---
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]))
-
-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
Chris Ferron
2012-05-08 23:17:51 UTC
Permalink
Post by Sergey Senozhatsky
Post by Chris Ferron
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.
automake: warnings are treated as errors
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
wow :(
m4_pattern_allow([AM_PROG_AR]) is not working for automake-1.12?????
Thanks for checking. I just got an arch system to play with, so I will
poke at it some more.

sorry for the continued delay in response, I am at a conference this week.
-Chris
Post by Sergey Senozhatsky
-ss
Post by Chris Ferron
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
AC_CHECK_LIB requires some care in usage, and should be avoided in
some
Post by Sergey Senozhatsky
common cases. Many standard functions
like gethostbyname appear in the standard C library on some hosts,
and
Post by Sergey Senozhatsky
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],
Post by Sergey Senozhatsky
[nsl]) instead of AC_CHECK_LIB([nsl], [gethostbyname]).
Thanks to Magnus Fromreide and to Chris Ferron.
---
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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])
Post by Sergey Senozhatsky
+fi
-AC_CHECK_LIB([pthread], [pthread_create],[AC_SUBST(PTHREAD_LIBS,
"-lpthread"," ")] , AC_MSG_ERROR([libpthread is required but was not
found]))
-
-AC_CHECK_LIB([resolv], [main],[AC_SUBST(RESOLV_LIBS, "-lresolv","
")],
Post by Sergey Senozhatsky
AC_MSG_ERROR([libresolv is required but was not found]))
-
-
+AC_SEARCH_LIBS([pthread_create], [pthread], [],
AC_MSG_ERROR([libpthread
Post by Sergey Senozhatsky
is required but was not found]), [])
+AC_SEARCH_LIBS([inet_aton], [resolv], [], AC_MSG_ERROR([libresolv is
required but was not found]), [])
AC_OUTPUT
Sergey Senozhatsky
2012-05-08 22:17:35 UTC
Permalink
Post by Chris Ferron
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
Post by Chris Ferron
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
Post by Sergey Senozhatsky
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 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.
---
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]))
-
-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
Chris Ferron
2012-05-08 23:21:42 UTC
Permalink
Post by Chris Ferron
Post by Chris Ferron
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.
Post by Chris Ferron
seems to work for me.
Sergey
Post by Chris Ferron
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
AC_CHECK_LIB requires some care in usage, and should be avoided in
some
Post by Sergey Senozhatsky
common cases. Many standard functions
like gethostbyname appear in the standard C library on some hosts,
and
Post by Sergey Senozhatsky
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],
Post by Sergey Senozhatsky
[nsl]) instead of AC_CHECK_LIB([nsl], [gethostbyname]).
Thanks to Magnus Fromreide and to Chris Ferron.
---
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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])
Post by Sergey Senozhatsky
+fi
-AC_CHECK_LIB([pthread], [pthread_create],[AC_SUBST(PTHREAD_LIBS,
"-lpthread"," ")] , AC_MSG_ERROR([libpthread is required but was not
found]))
-
-AC_CHECK_LIB([resolv], [main],[AC_SUBST(RESOLV_LIBS, "-lresolv","
")],
Post by Sergey Senozhatsky
AC_MSG_ERROR([libresolv is required but was not found]))
-
-
+AC_SEARCH_LIBS([pthread_create], [pthread], [],
AC_MSG_ERROR([libpthread
Post by Sergey Senozhatsky
is required but was not found]), [])
+AC_SEARCH_LIBS([inet_aton], [resolv], [], AC_MSG_ERROR([libresolv is
required but was not found]), [])
AC_OUTPUT
Chris Ferron
2012-05-07 18:55:23 UTC
Permalink
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the end of
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
Post by Sergey Senozhatsky
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]).
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
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'
---
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]))
-
-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
Sergey Senozhatsky
2012-05-07 20:03:02 UTC
Permalink
Post by Chris Ferron
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the end of
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
Post by Chris Ferron
Some distros (rare) don't have package configs.
I'll bring them back then.


Will resend as soon as fix problem with Debian.


-ss
Post by Chris Ferron
Post by Sergey Senozhatsky
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]).
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
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'
---
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]))
-
-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
Chris Ferron
2012-05-07 21:02:37 UTC
Permalink
Post by Sergey Senozhatsky
Post by Sergey Senozhatsky
Post by Sergey Senozhatsky
Fix libnl-3 detection and rework libnl configure check.
Patch replaces AC_CHECK_LIB with AC_SEARCH_LIBS, as proposed at the
end of
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
Some distros (rare) don't have package configs.
I'll bring them back then.
Will resend as soon as fix problem with Debian.
-ss
Post by Sergey Senozhatsky
Post by Sergey Senozhatsky
AC_CHECK_LIB requires some care in usage, and should be avoided in
some
Post by Sergey Senozhatsky
common cases. Many standard functions
like gethostbyname appear in the standard C library on some hosts,
and
Post by Sergey Senozhatsky
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],
Post by Sergey Senozhatsky
[nsl]) instead of AC_CHECK_LIB([nsl], [gethostbyname]).
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...
Post by Sergey Senozhatsky
../../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
linking libtool libraries using a non-POSIX
/usr/share/automake-1.12/am/ltlibrary.am: archiver requires
'AM_PROG_AR'
Post by Sergey Senozhatsky
in 'configure.ac'
pevent/Makefile.am:1: while processing Libtool library
'libparseevent.la'
---
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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
Post by Sergey Senozhatsky
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])
Post by Sergey Senozhatsky
+fi
-AC_CHECK_LIB([pthread], [pthread_create],[AC_SUBST(PTHREAD_LIBS,
"-lpthread"," ")] , AC_MSG_ERROR([libpthread is required but was not
found]))
-
-AC_CHECK_LIB([resolv], [main],[AC_SUBST(RESOLV_LIBS, "-lresolv","
")],
Post by Sergey Senozhatsky
AC_MSG_ERROR([libresolv is required but was not found]))
-
-
+AC_SEARCH_LIBS([pthread_create], [pthread], [],
AC_MSG_ERROR([libpthread
Post by Sergey Senozhatsky
is required but was not found]), [])
+AC_SEARCH_LIBS([inet_aton], [resolv], [], AC_MSG_ERROR([libresolv is
required but was not found]), [])
AC_OUTPUT
Loading...