File autogen-only-deal-with-json-yaksa-if-enabled.patch of Package mvapich3

commit f52bf4f26caeee6452aea2b38c6702543be19ba4
Author: Nicolas Morey <nmorey@suse.com>
Date:   Sat Sep 7 13:09:18 2024 +0200

    autogen: only deal with json/yaksa if enabled
    
    --without-(json|yaksa) is partially ignored as submodule is not
    checked but still configured
    
    Signed-off-by: Nicolas Morey <nmorey@suse.com>

diff --git configure.ac configure.ac
index 51ddb3952c4b..163cb29bcee9 100644
--- configure.ac
+++ configure.ac
@@ -1428,14 +1428,23 @@ AC_SUBST([jsonsrcdir])
 jsonlib=""
 AC_SUBST([jsonlib])
 
-PAC_PUSH_ALL_FLAGS()
-PAC_RESET_ALL_FLAGS()
-PAC_CONFIG_SUBDIR_ARGS([modules/json-c],[--enable-embedded --disable-werror],[],[AC_MSG_ERROR(json-c configure failed)])
-PAC_POP_ALL_FLAGS()
-jsonsrcdir="${main_top_builddir}/modules/json-c"
-jsonlib="${main_top_builddir}/modules/json-c/libjson-c.la"
-PAC_APPEND_FLAG([-I${use_top_srcdir}/modules/json-c],[CPPFLAGS])
-PAC_APPEND_FLAG([-I${main_top_builddir}/modules/json-c],[CPPFLAGS])
+PAC_CHECK_HEADER_LIB([json-c/json.h], [json-c], [json_object_get], [have_json=yes], [have_json=no])
+if test "${have_json}" = "no" ; then
+   AC_MSG_NOTICE([Using an embedded libjson-c])PAC_PUSH_ALL_FLAGS()
+   PAC_RESET_ALL_FLAGS()
+   PAC_CONFIG_SUBDIR_ARGS([modules/json-c],[--enable-embedded --disable-werror],[],
+                          [AC_MSG_ERROR(json-c configure failed)])
+   PAC_POP_ALL_FLAGS()
+   jsonsrcdir="${main_top_builddir}/modules/json-c"
+   jsonlib="${main_top_builddir}/modules/json-c/libjson-c.la"
+   PAC_APPEND_FLAG([-I${use_top_srcdir}/modules/json-c],[CPPFLAGS])
+   PAC_APPEND_FLAG([-I${main_top_builddir}/modules/json-c],[CPPFLAGS])
+else
+   AC_MSG_NOTICE([Using an external libjson-c])
+   PAC_APPEND_FLAG([-I/usr/include/json-c],[CPPFLAGS])
+   PAC_APPEND_FLAG([-ljson-c],[WRAPPER_LIBS])
+fi
+
 
 # ----------------------------------------------------------------------------
 # HWLOC
openSUSE Build Service is sponsored by