Build: cleanup Configure-Makefile
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 23 May 2020 19:04:49 +0000 (21:04 +0200)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 23 May 2020 19:38:43 +0000 (21:38 +0200)
src/scripts/Configure-Makefile

index 4dd7c9bf96130eb1b7500fb1f1413d626dbcbcf2..3f1dcbac681e12069dfc854b16a46b389a17595f 100755 (executable)
@@ -91,7 +91,6 @@ look_mf_post=${look_mf}.postdynamic
 # the OSTYPE and ARCHTYPE variables.
 
 rm -f $mft $mftt $mftepcp $mftepcp2 $look_mf-t
-(echo "OSTYPE=$ostype"; echo "ARCHTYPE=$archtype"; echo "") > $mft || exit 1
 
 # Now concatenate the files to the temporary file. Copy the files using sed to
 # remove comments, blank lines, and trailing white space.
@@ -103,6 +102,11 @@ rm -f $mft $mftt $mftepcp $mftepcp2 $look_mf-t
 
 st='    '
 
+{
+echo "OSTYPE=$ostype"
+echo "ARCHTYPE=$archtype"
+echo ""
+
 for f in OS/Makefile-Default \
          OS/Makefile-$ostype \
          Local/Makefile \
@@ -115,18 +119,21 @@ do   if test -r ../$f
             # 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
+            sed -e "/^#/d" \
+               -e "/^[$st]*\$/d" \
+               -e "s/[$st]*\$//" \
+               -e "s/[$st]*\\(\\+\\?=\\)[$st]*/\\1/" \
+               ../$f || exit 1
             echo "# End of $f"
             echo ""
      fi
-done \
-     | sed 's/^TMPDIR=/EXIM_&/' \
-     > $mft || exit 1
+done | sed 's/^TMPDIR=/EXIM_&/'
+} > $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.
-sed -n "s/^[$st]*PKG_CONFIG_PATH[$st]*[+]*=[$st]*//p" $mft | \
-  sed "s/[$st]*\$//" >> $mftepcp
+sed -n "s/^PKG_CONFIG_PATH[$st]*[+]*=[$st]*//p" $mft > $mftepcp
 if test -s ./$mftepcp
 then
   # expand any wildcards and strip spaces, to make it a real PATH-like variable
@@ -153,11 +160,10 @@ rm -f ./$mftepcp ./$mftepcp2
     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
+    | while IFS== read name value; do  # find the BASE for BASE_PC
         egrep "^${name%_PC}=" $mft && echo "$name=$value"
     done
-} | sed "s/[$st]*=/='/" \
-  | sed "s/\$/'/" \
+} | sed "s/=\\(.*\\)/='\\1'/" \
   | sort | uniq > $mftt
 if test -s $mftt
 then