build: use pkg-config for i18n
[exim.git] / src / scripts / drivers-Makefile
index 0c3da19cbe9a19e255a29154f585f1cd9188a244..4b2bf245b6c87f2498dcffd94ef4b4441f6af21c 100755 (executable)
@@ -3,10 +3,10 @@
 # Copyright (c) The Exim Maintainers 1995 - 2024
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-set -e
 class=${CLASS:?}
 classdef=${CLASSDEF:?}
 drnames="${DRNAMES:?}"
+egrep="${EGREP:?}"
 
 # We turn the configure-built build-$foo/$class/Makefile.predynamic into Makefile.
 # This is used for router and transport drivers, called from scripts/Configure-Makefile.
@@ -96,19 +96,30 @@ fi
 # command-line, not just check the Makefile.
 
 want_dynamic() {
-  local dyn_name="$1"
+  local dyn_name="${1#_}"
   local re="(${classdef}|EXPERIMENTAL)_${dyn_name}[ $tab]*=[ $tab]*2"
-  env | grep -E -q "^$re"
+  env | ${egrep} -q "^$re"
   if [ $? -eq 0 ]; then return 0; fi
-  grep -E -q "^[ $tab]*$re" "$defs_source"
+  ${egrep} -q "^[ $tab]*$re" "$defs_source"
+}
+
+want_not_disabled() {
+  local want_name="${1#_}"
+  [ "$want_name" = "$1" ] && return 1;
+  local re="DISABLED_${want_name}[ $tab]*=[ $tab]*."
+  env | ${egrep} -q "^$re"
+  [ $? -ne 0 ] && return 0
+  ${egrep} -q "^[ $tab]*$re" "$defs_source"
+  [ $? -ne 0 ] && return 0
+  return 1
 }
 
 want_at_all() {
   local want_name="$1"
   local re="(${classdef}|EXPERIMENTAL)_${want_name}[ $tab]*=[ $tab]*."
-  env | grep -E -q "^$re"
+  env | ${egrep} -q "^$re"
   if [ $? -eq 0 ]; then return 0; fi
-  grep -E -q "^[ $tab]*$re" "$defs_source"
+  ${egrep} -q "^[ $tab]*$re" "$defs_source"
 }
 
 # The values of these variables will be emitted into the Makefile.
@@ -136,19 +147,21 @@ emit_module_rule() {
       echo >&2 "Missing CFLAGS_DYNAMIC prevents building dynamic $name"
       exit 1
     fi
-    MODS="${MODS} ${mod_name}.so"
-#    pkgconf=$(grep "^${classdef}_${name}_PC" "$defs_source")
-#    if [ $? -eq 0 ]; then
-#      pkgconf=$(echo $pkgconf | sed 's/^.*= *//')
-#      echo "${classdef}_${mod_name}_INCLUDE = $(pkg-config --cflags $pkgconf)"
-#      echo "${classdef}_${mod_name}_LIBS = $(pkg-config --libs $pkgconf)"
-#    else
-#      grep "^${classdef}_${name}_" "$defs_source"
-#      echo "${classdef}_${mod_name}_INCLUDE = \$(${classdef}_${name}_INCLUDE)"
-#      echo "${classdef}_${mod_name}_LIBS = \$(${classdef}_${name}_LIBS)"
-#    fi
-  elif want_at_all "$name"
-  then
+    MODS="${MODS} ${mod_name#_}.so"
+    grep "^${classdef}_${name}_PC" "$defs_source" 1>&2
+    pkgconf=$(grep "^${classdef}_${name}_PC" "$defs_source")
+    if [ $? -eq 0 ]; then
+      pkgconf=$(echo $pkgconf | sed 's/^.*= *//')
+      echo "${classdef}_${mod_name#_}_INCLUDE = $(pkg-config --cflags $pkgconf)"
+      echo "${classdef}_${mod_name#_}_LIBS = $(pkg-config --libs $pkgconf)"
+    else
+      grep "^${classdef}_${name}_" "$defs_source"
+      echo "${classdef}_${mod_name#_}_INCLUDE = \$(${classdef}_${name}_INCLUDE)"
+      echo "${classdef}_${mod_name#_}_LIBS = \$(${classdef}_${name}_LIBS)"
+    fi
+  elif want_not_disabled "$name"; then
+    OBJ="${OBJ} ${mod_name#_}.o"
+  elif want_at_all "$name"; then
     OBJ="${OBJ} ${mod_name}.o"
   fi
 }