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

commit 3c1a93f03031b238eab968773d1e571fd2e1da5a
Author: Nicolas Morey <nmorey@suse.com>
Date:   Tue Jul 25 16:02:22 2023 +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 9563ad2034dc..860617dabbc6 100644
--- configure.ac
+++ configure.ac
@@ -1060,18 +1060,26 @@ AC_SUBST([jsonsrcdir])
 jsonlib=""
 AC_SUBST([jsonlib])
 
-jsonlib="modules/json-c/libjson-c.la"
-if test -e "${use_top_srcdir}/modules/PREBUILT" -a -e "$jsonlib"; then
-    jsonsrcdir=""
+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])
+   jsonlib="modules/json-c/libjson-c.la"
+   if test -e "${use_top_srcdir}/modules/PREBUILT" -a -e "$jsonlib"; then
+       jsonsrcdir=""
+    else
+	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"
+	fi
+	PAC_APPEND_FLAG([-I${use_top_srcdir}/modules/json-c],[CPPFLAGS])
+	PAC_APPEND_FLAG([-I${main_top_builddir}/modules/json-c],[CPPFLAGS])
 else
-    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"
-fi
-PAC_APPEND_FLAG([-I${use_top_srcdir}/modules/json-c],[CPPFLAGS])
-PAC_APPEND_FLAG([-I${main_top_builddir}/modules/json-c],[CPPFLAGS])
+    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 / NETLOC
openSUSE Build Service is sponsored by