From adf76faace83d2b926b9136821daa02a78266b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= Date: Fri, 26 Nov 2021 09:31:35 -0800 Subject: [PATCH] pcre2grep: fix build for Hurd (#52) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since d5a61ee8 (Patch to detect (and ignore) symlink loops in pcre2grep., 2021-08-28), there is optional code that depends on readlink and PATH_MAX but that had only detection added for the first. GNU Hurd doesn't have the later so it fails to build. Improve the detection to include both dependencies in autotools and cmake to fix that. Signed-off-by: Carlo Marcelo Arenas Belón --- CMakeLists.txt | 8 +++++++- configure.ac | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8010497..542fe0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,10 +142,16 @@ CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H) CHECK_SYMBOL_EXISTS(bcopy "strings.h" HAVE_BCOPY) CHECK_SYMBOL_EXISTS(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE) CHECK_SYMBOL_EXISTS(memmove "string.h" HAVE_MEMMOVE) -CHECK_SYMBOL_EXISTS(realpath "stdlib.h" HAVE_REALPATH) CHECK_SYMBOL_EXISTS(secure_getenv "stdlib.h" HAVE_SECURE_GETENV) CHECK_SYMBOL_EXISTS(strerror "string.h" HAVE_STRERROR) +CHECK_C_SOURCE_COMPILES( + "#include + #include + int main(int c, char *v[]) { char buf[PATH_MAX]; realpath(v[1], buf); return 0; }" + HAVE_REALPATH +) + set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") CHECK_C_SOURCE_COMPILES( diff --git a/configure.ac b/configure.ac index 07a0af2..caa4093 100644 --- a/configure.ac +++ b/configure.ac @@ -512,7 +512,20 @@ AC_TYPE_SIZE_T # Checks for library functions. -AC_CHECK_FUNCS(bcopy memfd_create memmove mkostemp realpath secure_getenv strerror) +AC_CHECK_FUNCS(bcopy memfd_create memmove mkostemp secure_getenv strerror) +AC_MSG_CHECKING([for realpath]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +]],[[ +char buffer[PATH_MAX]; +realpath(".", buffer); +]])], +[AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_REALPATH], 1, + [Define to 1 if you have the `realpath' function.]) +], +AC_MSG_RESULT([no])) # Check for the availability of libz (aka zlib)