diff options
author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2012-05-08 13:56:38 -0700 |
---|---|---|
committer | Chris E Ferron <chris.e.ferron@linux.intel.com> | 2012-05-08 13:56:38 -0700 |
commit | 774bfe88ebce201d29d6cfd2e652743f3ed0280d (patch) | |
tree | fd9f1fcbcf99f2f6c012aa8f903944f44c1467a3 /configure.ac | |
parent | 280022f38cd1c7a73b9706893d9c81d43c8f1041 (diff) |
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 <sergey.senozhatsky@gmail.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 36 |
1 files 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 |