1From 9d14fad412a497fe83cfc6ab594ddc612512f02a Mon Sep 17 00:00:00 2001
2From: Matt Weber <matthew.weber@rockwellcollins.com>
3Date: Thu, 4 Jun 2020 20:34:11 -0500
4Subject: [PATCH] autoconf variable cache option for getcwd test
5
6The cached variable allows cross compiled builds to successfully set the
7desired default for this value without invoking a test.
8
9Fixes:
10https://issues.apache.org/jira/browse/SANTUARIO-549
11
12Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
13---
14 configure.ac | 20 ++++++++++++--------
15 1 file changed, 12 insertions(+), 8 deletions(-)
16
17diff --git a/configure.ac b/configure.ac
18index b43d7a5..c3d4489 100644
19--- a/configure.ac
20+++ b/configure.ac
21@@ -74,14 +74,18 @@ AC_CHECK_FUNCS([strcasecmp])
22
23 # Check whether getcwd can dynamically allocate memory.
24 AC_MSG_CHECKING([whether getcwd(NULL, 0) works])
25-AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>
26-     #include <unistd.h>],
27-[char *cwd = getcwd(NULL, 0);
28-return (cwd != NULL) ? EXIT_SUCCESS : EXIT_FAILURE;])],
29-     [AC_MSG_RESULT(yes)
30-      AC_DEFINE([XSEC_HAVE_GETCWD_DYN], [1],
31-         [Define to 1 if getcwd(NULL, 0) works])],
32-     [AC_MSG_RESULT(no)])
33+AC_CACHE_VAL([xml_cv_func_getcwd_null],
34+[AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
35+     #include <unistd.h>
36+     char *cwd = getcwd(NULL, 0);
37+     return (cwd != NULL) ? EXIT_SUCCESS : EXIT_FAILURE;]])],
38+  [xml_cv_func_getcwd_null=yes],
39+  [xml_cv_func_getcwd_null=no])])
40+AC_MSG_RESULT([$xml_cv_func_getcwd_null])
41+if test $xml_cv_func_getcwd_null = yes; then
42+AC_DEFINE([XSEC_HAVE_GETCWD_DYN], [1],
43+  [Define to 1 if getcwd(NULL, 0) works])
44+fi
45
46 AC_LANG(C++)
47
48--
492.17.1
50
51