From 66656f767c39fce474c668c6c53706e292b53057 Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Mon, 28 Oct 2019 09:15:00 +0100
Subject: [PATCH] [configure] automatic uppercasing of configure_pkg arg

---
 share/configure.ac              | 31 ++++++++++++++++---------------
 src/plugins/server/configure.ac |  2 +-
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/share/configure.ac b/share/configure.ac
index 76c6d965782..85a700fb52d 100644
--- a/share/configure.ac
+++ b/share/configure.ac
@@ -212,22 +212,22 @@ m4_define([configure_library],
   ])
 ])
 
-# 1st param: uppercase name of the ocamlfind package
-# 2nd param: actual name of the ocamlfind package (often lowercase)
-# 3rd param: warning to display if problem
+# 1st param: actual name of the ocamlfind package (often lowercase)
+# 2nd param: warning to display if problem
 m4_define([configure_pkg],
 [
-m4_ifdef(HAS_OCAML_$1,,
+define([PKG_UP],[tovarname($1)])
+m4_ifdef([HAS_OCAML_]PKG_UP,,
   [
-  define([VAR],[OCAML_$1])
-  define([require],[$REQUIRE_OCAML_$1])
-  define([use],[$USE_OCAML_$1])
-  define([msg],[$3])
-  define([has],[HAS_OCAML_$1])
+  define([VAR],[[OCAML_]PKG_UP])
+  define([require],[$[REQUIRE_OCAML_]PKG_UP])
+  define([use],[$[USE_OCAML_]PKG_UP])
+  define([msg],[$2])
+  define([has],[[HAS_OCAML_]PKG_UP])
 
    has=
-  AC_MSG_CHECKING(for OCaml package $2)
-  VAR=$(ocamlfind query $2 -format %v 2>/dev/null)
+  AC_MSG_CHECKING(for OCaml package $1)
+  VAR=$(ocamlfind query $1 -format %v 2>/dev/null)
   if test -z "$VAR" ; then
     AC_MSG_RESULT(not found via ocamlfind.)
     has=no
@@ -239,7 +239,7 @@ m4_ifdef(HAS_OCAML_$1,,
   if test -n "require" -o -n "use" -o "$force_check" = "yes"; then
     if test "$has" = "no"; then
       AC_MSG_WARN([msg])
-      reason="$2 missing"
+      reason="$1 missing"
       for p in require; do
         up=`upper "$p"`
         ep=ENABLE_$up
@@ -249,7 +249,7 @@ m4_ifdef(HAS_OCAML_$1,,
           if eval test "\$$fp" = "yes"; then
             AC_MSG_ERROR([$p requested but $reason.])
           fi
-          eval $ep="no\ \(see\ warning\ about\ $2\)"
+          eval $ep="no\ \(see\ warning\ about\ $1\)"
           AC_MSG_WARN([$p disabled because $reason.])
           eval INFO_$up=\", $reason\"
         fi
@@ -259,18 +259,19 @@ m4_ifdef(HAS_OCAML_$1,,
         ep=ENABLE_$up
         eval eep="\$$ep"
         if test "`echo $eep | sed -e 's/ .*//' `" != "no"; then
-          eval $ep="partial\ \(see\ warning\ about\ $2\)"
+          eval $ep="partial\ \(see\ warning\ about\ $1\)"
           AC_MSG_WARN([$p partially enabled because $reason.])
           eval INFO_$up=\", $reason\"
         fi
       done
     else
-        VAR=$1
+        VAR=PKG_UP
     fi
   fi
   m4_divert_pop(frama_c_configure_tool)
   AC_SUBST(VAR)
   AC_SUBST(has)
+  undefine([PKG_UP])
   undefine([VAR])
   undefine([require])
   undefine([use])
diff --git a/src/plugins/server/configure.ac b/src/plugins/server/configure.ac
index e1a06aa1252..47ac79512c1 100644
--- a/src/plugins/server/configure.ac
+++ b/src/plugins/server/configure.ac
@@ -50,7 +50,7 @@ AC_ARG_ENABLE(
 
 if test "$SERVER_ZMQ" = "yes" ;
 then
-        configure_pkg([ZMQ],[zmq],
+        configure_pkg([zmq],
                       [Server support for ZeroMQ disabled (try 'opam install zmq').])
         plugin_use_pkg(server,zmq)
 fi
-- 
GitLab