-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the autoconf code for finding libtirpc and do not assume the headers are in /usr/include/tirpc. Also remove this assumption from the `rpc/xdr.h` header in libspl and use the same `#include_next` mechanism that is used for other libspl headers. Include pkg.m4 from pkg-config in config/ for PKG_CHECK_MODULES(), the file license allows this. Include ax_save_flags.m4 and ax_restore_flags.m4 from autoconf-archive, the file licenses are compatible. Use the 2012 versions so as not rely on a more recent autoconf feature AS_VAR_COPY(), which breaks some build slaves. Add new macro library `config/find_system_library.m4` which defines the FIND_SYSTEM_LIBRARY() macro which is a convenience wrapper over using PKG_CHECK_MODULES() with a fallback to standard library locations and some sanity checks. The parameters are: ``` FIND_SYSTEM_LIBRARY(VARIABLE-PREFIX, MODULE, HEADER, HEADER-PREFIXES, LIBRARY, FUNCTIONS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) ``` `HEADER-PREFIXES` and `FUNCTIONS` are comma-separated m4 lists. For libtirpc we are using: ``` FIND_SYSTEM_LIBRARY(LIBTIRPC, [libtirpc], [rpc/xdr.h], [tirpc], [tirpc], [xdrmem_create], [], [...]) ``` The headers are first checked for without the prefixes and then with. This system works with pkg-config and falls back on checking standard header/library locations, it can be easily overridden by the user by setting the `PREFIX_CFLAGS` and `PREFIX_LIBS` variables which are automatically added to the `./configure --help` output. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rafael Kitover <rkitover@gmail.com> Closes #7422 Closes #8313
- Loading branch information
1 parent
0409679
commit 762f9ef
Showing
9 changed files
with
437 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# =========================================================================== | ||
# http://www.gnu.org/software/autoconf-archive/ax_restore_flags.html | ||
# =========================================================================== | ||
# | ||
# SYNOPSIS | ||
# | ||
# AX_RESTORE_FLAGS() | ||
# | ||
# DESCRIPTION | ||
# | ||
# Restore common compilation flags from temporary variables | ||
# | ||
# LICENSE | ||
# | ||
# Copyright (c) 2009 Filippo Giunchedi <filippo@esaurito.net> | ||
# | ||
# Copying and distribution of this file, with or without modification, are | ||
# permitted in any medium without royalty provided the copyright notice | ||
# and this notice are preserved. This file is offered as-is, without any | ||
# warranty. | ||
|
||
#serial 3 | ||
|
||
AC_DEFUN([AX_RESTORE_FLAGS], [ | ||
CPPFLAGS="${CPPFLAGS_save}" | ||
CFLAGS="${CFLAGS_save}" | ||
CXXFLAGS="${CXXFLAGS_save}" | ||
OBJCFLAGS="${OBJCFLAGS_save}" | ||
LDFLAGS="${LDFLAGS_save}" | ||
LIBS="${LIBS_save}" | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# =========================================================================== | ||
# http://www.gnu.org/software/autoconf-archive/ax_save_flags.html | ||
# =========================================================================== | ||
# | ||
# SYNOPSIS | ||
# | ||
# AX_SAVE_FLAGS() | ||
# | ||
# DESCRIPTION | ||
# | ||
# Save common compilation flags into temporary variables | ||
# | ||
# LICENSE | ||
# | ||
# Copyright (c) 2009 Filippo Giunchedi <filippo@esaurito.net> | ||
# | ||
# Copying and distribution of this file, with or without modification, are | ||
# permitted in any medium without royalty provided the copyright notice | ||
# and this notice are preserved. This file is offered as-is, without any | ||
# warranty. | ||
|
||
#serial 3 | ||
|
||
AC_DEFUN([AX_SAVE_FLAGS], [ | ||
CPPFLAGS_save="${CPPFLAGS}" | ||
CFLAGS_save="${CFLAGS}" | ||
CXXFLAGS_save="${CXXFLAGS}" | ||
OBJCFLAGS_save="${OBJCFLAGS}" | ||
LDFLAGS_save="${LDFLAGS}" | ||
LIBS_save="${LIBS}" | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# find_system_lib.m4 - Macros to search for a system library. -*- Autoconf -*- | ||
|
||
dnl requires pkg.m4 from pkg-config | ||
dnl requires ax_save_flags.m4 from autoconf-archive | ||
dnl requires ax_restore_flags.m4 from autoconf-archive | ||
|
||
dnl FIND_SYSTEM_LIBRARY(VARIABLE-PREFIX, MODULE, HEADER, HEADER-PREFIXES, LIBRARY, FUNCTIONS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) | ||
|
||
AC_DEFUN([FIND_SYSTEM_LIBRARY], [ | ||
AC_REQUIRE([PKG_PROG_PKG_CONFIG]) | ||
_library_found= | ||
PKG_CHECK_MODULES([$1], [$2], [_library_found=1], [ | ||
AS_IF([test -f /usr/include/[$3]], [ | ||
AC_SUBST([$1][_CFLAGS], []) | ||
AC_SUBST([$1][_LIBS], ["-l[$5]]") | ||
_library_found=1 | ||
],[ AS_IF([test -f /usr/local/include/[$3]], [ | ||
AC_SUBST([$1][_CFLAGS], ["-I/usr/local/include"]) | ||
AC_SUBST([$1][_LIBS], ["-L/usr/local -l[$5]]") | ||
_library_found=1 | ||
],[dnl ELSE | ||
m4_foreach([prefix], [$4], [ | ||
AS_IF([test "x$_library_found" != "x1"], [ | ||
AS_IF([test -f [/usr/include/]prefix[/][$3]], [ | ||
AC_SUBST([$1][_CFLAGS], ["[-I/usr/include/]prefix["]]) | ||
AC_SUBST([$1][_LIBS], ["-l[$5]]") | ||
_library_found=1 | ||
],[ AS_IF([test -f [/usr/local/include/]prefix[/][$3]], [ | ||
AC_SUBST([$1][_CFLAGS], ["[-I/usr/local/include/]prefix["]]) | ||
AC_SUBST([$1][_LIBS], ["-L/usr/local -l[$5]"]) | ||
_library_found=1 | ||
])]) | ||
]) | ||
]) | ||
])]) | ||
AS_IF([test -z "$_library_found"], [ | ||
AC_MSG_WARN([cannot find [$2] via pkg-config or in the standard locations]) | ||
]) | ||
]) | ||
dnl do some further sanity checks | ||
AS_IF([test -n "$_library_found"], [ | ||
AX_SAVE_FLAGS | ||
CPPFLAGS="$CPPFLAGS $(echo $[$1][_CFLAGS] | sed 's/-include */-include-/g; s/^/ /; s/ [^-][^ ]*//g; s/ -[^Ii][^ ]*//g; s/-include-/-include /g; s/^ //;')" | ||
CFLAGS="$CFLAGS $[$1][_CFLAGS]" | ||
LDFLAGS="$LDFLAGS $[$1][_LIBS]" | ||
AC_CHECK_HEADER([$3], [], [ | ||
AC_MSG_WARN([header [$3] for library [$2] is not usable]) | ||
_library_found= | ||
]) | ||
m4_foreach([func], [$6], [ | ||
AC_CHECK_LIB([$5], func, [], [ | ||
AC_MSG_WARN([cannot find ]func[ in library [$5]]) | ||
_library_found= | ||
]) | ||
]) | ||
AX_RESTORE_FLAGS | ||
]) | ||
AS_IF([test -n "$_library_found"], [ | ||
:;$7 | ||
],[dnl ELSE | ||
:;$8 | ||
]) | ||
]) |
Oops, something went wrong.