Build: Allow arbitrary *_PC settings in EDITME
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 23 May 2020 19:19:10 +0000 (21:19 +0200)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 23 May 2020 19:38:42 +0000 (21:38 +0200)
src/scripts/Configure-Makefile

index 61368ecb3ac2e7377383efdbb8eaffe0295e3aa8..4dd7c9bf96130eb1b7500fb1f1413d626dbcbcf2 100755 (executable)
@@ -112,14 +112,16 @@ for f in OS/Makefile-Default \
          $mfb
 do   if test -r ../$f
      then   echo "# From $f"
-            sed "/^#/d;/^[$st]*\$/d;s/[$st]*\$//" ../$f || exit 1
+            # remove comments, leading/trailing spaces, spaces around assignment ops
+            # (There should be not need to check for [$st]* anymore in
+            # the following lines
+            sed "/^#/d;/^[$st]*\$/d;s/[$st]*\$//;s/[$st]*\\(\\+\\?=\\)[$st]*/\\1/" ../$f || exit 1
             echo "# End of $f"
             echo ""
      fi
 done \
      | sed 's/^TMPDIR=/EXIM_&/' \
-     >> $mft || exit 1
-
+     > $mft || exit 1
 # handle PKG_CONFIG_PATH because we need it in our env, and we want to handle
 # wildcards; note that this logic means all setting _appends_ values, never
 # replacing; if that's a problem, we can revisit.
@@ -147,12 +149,16 @@ rm -f ./$mftepcp ./$mftepcp2
 
 # handle pkg-config
 # beware portability of extended regexps with sed.
-egrep "^[$st]*(AUTH|LOOKUP)_[A-Z0-9_]*[$st]*=[$st]*" $mft | \
-  sed "s/[$st]*=/='/" | \
-  sed "s/\$/'/" > $mftt
-egrep "^[$st]*((USE_(OPENSSL|GNUTLS)_PC)|SUPPORT_TLS|USE_GNUTLS|PCRE_CONFIG|AVOID_GNUTLS_PKCS11)[$st]*=[$st]*" $mft | \
-  sed "s/[$st]*=/='/" | \
-  sed "s/\$/'/" >> $mftt
+{
+    egrep "^(AUTH|LOOKUP)_[A-Z0-9_]=" $mft
+    egrep "^(USE_GNUTLS|PCRE_CONFIG|AVOID_GNUTLS_PKCS11)=" $mft
+    egrep "^[A-Z][A-Z0-9_]+_PC=" $mft \
+    | while IFS== read name value; do
+        egrep "^${name%_PC}=" $mft && echo "$name=$value"
+    done
+} | sed "s/[$st]*=/='/" \
+  | sed "s/\$/'/" \
+  | sort | uniq > $mftt
 if test -s $mftt
 then
   (
@@ -225,7 +231,8 @@ then
             echo "CFLAGS += $cflags"
             echo "AUTH_LIBS += $libs"
           else
-            echo >&2 "Don't know how to handle pkg-config for $var"
+            echo "CFLAGS += $cflags"
+           echo "LIBS += $libs"
           fi
         fi
         ;;