Avoid 'configure' error: cannot run test program while cross compiling
The SVN_LIB_MACHO_ITERATE macro contains an AC_RUN_IFELSE test that
will raise the following build failure when cross-compiling:
checking for Mach-O dynamic module iteration functions... configure: error: in `/home/fabrice/buildroot/output/build/subversion-1.14.0':
configure: error: cannot run test program while cross compiling
To avoid this build failure, set the action-if-cross-compiling of
AC_RUN_IFELSE to a pessimistic value (no). Moreover, encapsulate this
call with AC_CACHE_CHECK as suggested by Thomas Petazzoni to allow the
user to override this value when cross-compiling for macosx target.
See discussion "build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE"
started 2020/08/30, archived at (3 mail threads):
https://lists.apache.org/thread.html/r932d960924ac514c003d22f499a8f1317a6005b5084d2be6141730e1%40%3Cdev.subversion.apache.org%3E
https://lists.apache.org/thread.html/rbf56391984e7f8abc11ca78d48e09dd18d57d66390e6f5a63b046fa5%40%3Cdev.subversion.apache.org%3E
https://lists.apache.org/thread.html/r935bf45f5a70d8d6247e1cf6323a4c9a6383b9cbd96d424768dce1f5%40%3Cdev.subversion.apache.org%3E
build/ac-macros/macosx.m4
* (SVN_LIB_MACHO_ITERATE): Wrap AC_RUN_IFELSE with AC_CACHE_CHECK. New
variable 'ac_cv_mach_o_dynamic_module_iteration_works' allows
cache check.
Patch by: Fabrice Fontaine
Inspired by: Thomas Petazzoni
(See https://git.buildroot.net/buildroot/tree/package/subversion/0002-workaround-ac-run-ifelse.patch?h=2020.08-rc3)
Review by: hartmannathan
danielsh (earlier versions of the patch)
Tested by: hartmannathan (native macosx build)
git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1881534 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build/ac-macros/macosx.m4 b/build/ac-macros/macosx.m4
index 92fa58e..4116a30 100644
--- a/build/ac-macros/macosx.m4
+++ b/build/ac-macros/macosx.m4
@@ -20,28 +20,31 @@
dnl Mac OS X specific checks
dnl SVN_LIB_MACHO_ITERATE
-dnl Check for _dyld_image_name and _dyld_image_header availability
-AC_DEFUN(SVN_LIB_MACHO_ITERATE,
-[
- AC_MSG_CHECKING([for Mach-O dynamic module iteration functions])
- AC_RUN_IFELSE([AC_LANG_PROGRAM([[
- #include <mach-o/dyld.h>
- #include <mach-o/loader.h>
- ]],[[
- const struct mach_header *header = _dyld_get_image_header(0);
- const char *name = _dyld_get_image_name(0);
- if (name && header) return 0;
- return 1;
- ]])],[
- AC_DEFINE([SVN_HAVE_MACHO_ITERATE], [1],
- [Is Mach-O low-level _dyld API available?])
- AC_MSG_RESULT([yes])
- ],[
- AC_MSG_RESULT([no])
- ])
-])
-
-dnl SVN_LIB_MACOS_PLIST
+dnl Check for _dyld_image_name and _dyld_image_header availability
+AC_DEFUN(SVN_LIB_MACHO_ITERATE,
+[
+ AC_CACHE_CHECK([for Mach-O dynamic module iteration functions],
+ [ac_cv_mach_o_dynamic_module_iteration_works], [
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+ #include <mach-o/dyld.h>
+ #include <mach-o/loader.h>
+ ]],[[
+ const struct mach_header *header = _dyld_get_image_header(0);
+ const char *name = _dyld_get_image_name(0);
+ if (name && header) return 0;
+ return 1;
+ ]])],
+ [ac_cv_mach_o_dynamic_module_iteration_works=yes],
+ [ac_cv_mach_o_dynamic_module_iteration_works=no],
+ [ac_cv_mach_o_dynamic_module_iteration_works=no])
+ ])
+ if test "$ac_cv_mach_o_dynamic_module_iteration_works" = yes; then
+ AC_DEFINE([SVN_HAVE_MACHO_ITERATE], [1],
+ [Is Mach-O low-level _dyld API available?])
+ fi
+])
+
+dnl SVN_LIB_MACOS_PLIST
dnl Assign variables for Mac OS property list support
AC_DEFUN(SVN_LIB_MACOS_PLIST,
[