PKG_CHECK_MODULES for msgpack and jansson
authorAlan Modra <amodra@gmail.com>
Mon, 26 Sep 2022 04:42:05 +0000 (14:12 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 26 Sep 2022 04:53:29 +0000 (14:23 +0930)
Using AS_IF rather than shell "if" is recommended for conditionals
that contain non-trivial autoconf macros, because autoconf will emit
any AC_REQUIREd autoconf macro expansions outside of the conditional.
This makes them available elsewhere in the configure script.

binutils/
* configure.ac (msgpack): Use "AS_IF" rather than "if".
* configure: Regenerate.
ld/
* configure.ac (jansson): Use "AS_IF" rather than "if".
* configure: Regenerate.

binutils/configure
binutils/configure.ac
ld/configure
ld/configure.ac

index 1c518227f57ff8b8a389b15788cf86085eeb3e0d..4c0c391e9d5113c37028f83b361968ab5af08061 100755 (executable)
@@ -13507,8 +13507,7 @@ else
 fi
 
 
-
-if test "$with_msgpack" != no; then
+if test "$with_msgpack" != no; then :
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msgpack" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$MSGPACK_PKG_ERRORS" >&5
 
-
-      if test "$with_msgpack" = yes; then
-       as_fn_error $? "--with-msgpack was given, but msgpack is missing or unusable." "$LINENO" 5
-      fi
-
+       if test "$with_msgpack" = yes; then :
+  as_fn_error $? "--with-msgpack was given, but msgpack is missing or unusable." "$LINENO" 5
+fi
 elif test $pkg_failed = untried; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-
-      if test "$with_msgpack" = yes; then
-       as_fn_error $? "--with-msgpack was given, but msgpack is missing or unusable." "$LINENO" 5
-      fi
-
+       if test "$with_msgpack" = yes; then :
+  as_fn_error $? "--with-msgpack was given, but msgpack is missing or unusable." "$LINENO" 5
+fi
 else
        MSGPACK_CFLAGS=$pkg_cv_MSGPACK_CFLAGS
        MSGPACK_LIBS=$pkg_cv_MSGPACK_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-
 $as_echo "#define HAVE_MSGPACK 1" >>confdefs.h
 
-
 fi
 fi
 
index ec002d3f88fd35165fbd58f81fff9913e2aaf0ba..0798d84f4d14041db8becd1a0a8feba888564d51 100644 (file)
@@ -278,16 +278,11 @@ AC_ARG_WITH([msgpack],
            [],
            [with_msgpack=auto])
 
-
-if test "$with_msgpack" != no; then
-  PKG_CHECK_MODULES(MSGPACK, msgpack, [
-    AC_DEFINE([HAVE_MSGPACK], [1], [Define to 1 if msgpack is available.])
-  ], [
-      if test "$with_msgpack" = yes; then
-       AC_MSG_ERROR([--with-msgpack was given, but msgpack is missing or unusable.])
-      fi
-  ])
-fi
+AS_IF([test "$with_msgpack" != no],
+  [PKG_CHECK_MODULES(MSGPACK, msgpack,
+    [AC_DEFINE([HAVE_MSGPACK], [1], [Define to 1 if msgpack is available.])],
+    [AS_IF([test "$with_msgpack" = yes],
+      [AC_MSG_ERROR([--with-msgpack was given, but msgpack is missing or unusable.])])])])
 
 # target-specific stuff:
 
index a1a07005400bff2e003eda0ee9506a7b7a58cf84..4efe3ef5dfc024d04642da01b4aa0ac3f1b5b54f 100755 (executable)
@@ -15585,7 +15585,6 @@ else
 fi
 
 
-if test "x$enable_jansson" != "xno"; then
 
 
 
@@ -15706,8 +15705,7 @@ $as_echo "no" >&6; }
                PKG_CONFIG=""
        fi
 fi
-  if test -n "$PKG_CONFIG"; then :
-
+if test "x$enable_jansson" != "xno"; then :
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jansson" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$JANSSON_PKG_ERRORS" >&5
 
-
-         as_fn_error $? "Cannot find jansson library" "$LINENO" 5
-
+       as_fn_error $? "Cannot find jansson library" "$LINENO" 5
 elif test $pkg_failed = untried; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-
-         as_fn_error $? "Cannot find jansson library" "$LINENO" 5
-
+       as_fn_error $? "Cannot find jansson library" "$LINENO" 5
 else
        JANSSON_CFLAGS=$pkg_cv_JANSSON_CFLAGS
        JANSSON_LIBS=$pkg_cv_JANSSON_LIBS
@@ -15814,11 +15808,6 @@ $as_echo "#define HAVE_JANSSON 1" >>confdefs.h
 
 fi
 
-else
-
-      as_fn_error $? "Cannot find pkg-config" "$LINENO" 5
-
-fi
 fi
 
 
index eb55904c090ee8c1cb10b0d502a2d8561740a30e..8a8bfc9a14e7536b367f862f8ed7f8f28c581326 100644 (file)
@@ -296,24 +296,15 @@ AC_ARG_ENABLE([jansson],
   [enable_jansson=$enableval],
   [enable_jansson="no"])
 
-if test "x$enable_jansson" != "xno"; then
-  PKG_PROG_PKG_CONFIG
-  AS_IF([test -n "$PKG_CONFIG"],
+AS_IF([test "x$enable_jansson" != "xno"],
+  [PKG_CHECK_MODULES(JANSSON, [jansson],
     [
-      PKG_CHECK_MODULES(JANSSON, [jansson],
-       [
-         AC_DEFINE(HAVE_JANSSON, 1, [The jansson library is to be used])
-         AC_SUBST([JANSSON_CFLAGS])
-         AC_SUBST([JANSSON_LIBS])
-       ],
-       [
-         AC_MSG_ERROR([Cannot find jansson library])
-       ])
+      AC_DEFINE(HAVE_JANSSON, 1, [The jansson library is to be used])
+      AC_SUBST([JANSSON_CFLAGS])
+      AC_SUBST([JANSSON_LIBS])
     ],
-    [
-      AC_MSG_ERROR([Cannot find pkg-config])
-    ])
-fi
+    [AC_MSG_ERROR([Cannot find jansson library])])
+  ])
 
 AM_BINUTILS_WARNINGS