From 5ccb1b703b63fb4ae0c2e59385acd6ad190fcb9f Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Tue, 3 Oct 2017 09:17:24 +0200
Subject: [PATCH] plumedcheck: autoconf

While doing plumedcheck, verify that autoconf has been applied correctly
---
 src/maketools/plumedcheck | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/maketools/plumedcheck b/src/maketools/plumedcheck
index 0fcec6571..864804dae 100755
--- a/src/maketools/plumedcheck
+++ b/src/maketools/plumedcheck
@@ -67,6 +67,7 @@ BEGIN{
   pre=""
   opt_global_check=0
   astyle="astyle"
+  autoconf="autoconf"
   for(i=1;i<ARGC;i++){
     opt=pre ARGV[i]
     pre=""
@@ -84,6 +85,9 @@ BEGIN{
         astyle_options=opt;
         break;
         break;
+      case /--autoconf=.*/:
+        sub("^--autoconf=","",opt);
+        autoconf=opt;
       case /-.*/:
         print "Unknown option " opt; exit(1)
       default:
@@ -209,6 +213,23 @@ BEGINFILE{
     system("rm " tempfile)
   }
 
+# check if configure.ac is consistent with configure
+  if(filetype=="autoconf"){
+    tempfile = tmpdir "/configure"
+    configurefile = FILENAME
+    sub("\\.ac","",configurefile)
+    system("autoconf " FILENAME " > " tempfile)
+    s=system("diff -q " configurefile " " tempfile ">/dev/null 2>/dev/null")
+# check if autoconf has been applied correctly
+# DOC: :autoconf:
+# DOC: In our git repository we distribute both `./configure` and `./configure.ac` files.
+# DOC: When you modify the latter, the former should be regenerated using `autoconf` and
+# DOC: committed to git. This error indicates that the `./configure.ac` and `./configure` files
+# DOC: in the repository are not consistent.
+    if(s!=0) error("autoconf","autoconf not satisfied")
+    system("rm " tempfile)
+  }
+
 }
 
 # line by line analysis
-- 
GitLab