Index: server/mail/postfix.xml
===================================================================
--- server/mail/postfix.xml	(revision 39eac9218c50cc94001177acf68bc1e99a02145b)
+++ server/mail/postfix.xml	(revision 69e865058015c07128d88473c77e7f35efb34327)
@@ -10,6 +10,6 @@
   <!ENTITY postfix-download-http "https://ghostarchive.org/postfix/postfix-release/official/postfix-&postfix-version;.tar.gz">
   <!ENTITY postfix-download-ftp  " ">
-  <!ENTITY postfix-md5sum        "ae12d4dfc965a74a691a22ace14e7207">
-  <!ENTITY postfix-size          "4.6 MB">
+  <!ENTITY postfix-md5sum        "3eda9b945ed6cdf11ef58a731c574a04">
+  <!ENTITY postfix-size          "4.7 MB">
   <!ENTITY postfix-buildsize     "208 MB">
   <!ENTITY postfix-time          "0.1 SBU (Using parallelism=4)">
@@ -173,4 +173,21 @@
       </para>
 
+      <para>
+        Initialize the <envar>CCARGS</envar> and <envar>AUXLIBS</envar>
+        according to the note above:
+      </para>
+
+<screen><userinput>CCARGS="-DNO_NIS -DNO_DB"
+AUXLIBS=""</userinput></screen>
+
+      <para>
+        Next, the <envar>CCARGS</envar> and the <envar>AUXLIBS</envar>
+        variables are filled with settings depending on the actual
+        system configuration. If an optional package is installed but
+        should <emphasis>not</emphasis> be included in the
+        <application>Postfix</application> build, simply skip the
+        corresponding <code>if [ ... ]; then</code> scriptlets.
+      </para>
+
       <sect4>
         <title>Cyrus-SASL</title>
@@ -181,7 +198,8 @@
         </para>
 
-<screen><literal>CCARGS="-DNO_NIS -DNO_DB \
-        -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl"
-AUXLIBS='-lsasl2'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/libsasl2.so ]; then
+  CCARGS="$CCARGS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl"
+  AUXLIBS="$AUXLIBS -lsasl2"
+fi</userinput></screen>
       </sect4>
 
@@ -193,6 +211,8 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DHAS_LMDB'
-AUXLIBS_LMDB='-llmdb'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/liblmdb.so ]; then
+  CCARGS="$CCARGS -DHAS_LMDB"
+  AUXLIBS="$AUXLIBS -llmdb"
+fi</userinput></screen>
       </sect4>
 
@@ -205,6 +225,8 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DHAS_LDAP'
-AUXLIBS_LDAP='-lldap -llber'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/libldap.so -a -r /usr/lib/liblber.so ]; then
+  CCARGS="$CCARGS -DHAS_LDAP"
+  AUXLIBS="$AUXLIBS -lldap -llber"
+fi</userinput></screen>
 
       </sect4>
@@ -218,6 +240,8 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DHAS_SQLITE'
-AUXLIBS_SQLITE='-lsqlite3 -lpthread'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/libsqlite3.so ]; then
+  CCARGS="$CCARGS -DHAS_SQLITE"
+  AUXLIBS="$AUXLIBS -lsqlite3 -lpthread"
+fi</userinput></screen>
 
       </sect4>
@@ -231,6 +255,8 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DHAS_MYSQL -I/usr/include/mysql'
-AUXLIBS_MYSQL='-lmysqlclient -lz -lm'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/libmysqlclient.so ]; then
+  CCARGS="$CCARGS -DHAS_MYSQL -I/usr/include/mysql"
+  AUXLIBS="$AUXLIBS -lmysqlclient -lz -lm"
+fi</userinput></screen>
 
       </sect4>
@@ -244,6 +270,8 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DHAS_PGSQL -I/usr/include/postgresql'
-AUXLIBS_PGSQL='-lpq -lz -lm'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/libpq.so ]; then
+  CCARGS="$CCARGS -DHAS_PGSQL -I/usr/include/postgresql"
+  AUXLIBS="$AUXLIBS -lpq -lz -lm"
+fi</userinput></screen>
 
       </sect4>
@@ -258,6 +286,8 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DHAS_CDB'
-AUXLIBS_CDB='<replaceable>&lt;/path/to/CDB&gt;</replaceable>/libcdb.a'</literal></screen>
+<screen><literal>if [ -r <replaceable>&lt;/path/to/CDB&gt;</replaceable>/libcdb.a ]; then
+  CCARGS="$CCARGS -DHAS_CDB"
+  AUXLIBS="$AUXLIBS <replaceable>&lt;/path/to/CDB&gt;</replaceable>/libcdb.a"
+fi</literal></screen>
 
       </sect4>
@@ -271,6 +301,13 @@
         </para>
 
-<screen><literal>CCARGS='-DNO_NIS -DNO_DB -DUSE_TLS -I/usr/include/openssl/'
-AUXLIBS='-lssl -lcrypto'</literal></screen>
+<screen><userinput>if [ -r /usr/lib/libssl.so -a -r /usr/lib/libcrypto.so ]; then
+  CCARGS="$CCARGS -DUSE_TLS -I/usr/include/openssl/"
+  AUXLIBS="$AUXLIBS -lssl -lcrypto"
+fi</userinput></screen>
+        <para>
+          <application>OpenSSL</application> is installed by LFS so it
+          should be always there. The <code>if ... then</code> is here
+          just for consistency.
+        </para>
       </sect4>
 
@@ -281,17 +318,12 @@
 
       <para>
-        Adjust the following according to your needs. For example,
-	if you have <application>Cyrus SASL</application> and
-	<application>LMDB</application>,
-        install <application>Postfix</application> by running the following
-        commands:
-      </para>
-
-<screen><userinput>make CCARGS="-DNO_NIS -DNO_DB -DUSE_TLS -I/usr/include/openssl/    \
-             -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  \
-             -DHAS_LMDB"                                           \
-     AUXLIBS="-lssl -lcrypto -lsasl2"                              \
-     AUXLIBS_LMDB="-llmdb"                                         \
-     makefiles &amp;&amp;
+        There might be duplicate settings in <envar>AUXLIBS</envar>
+        like <code>-lm</code> when both, <application>MariaDB</application>
+        and <application>PostgreSQL</application> are used. They do
+        not harm. Install <application>Postfix</application> by
+        running the following commands:
+      </para>
+
+<screen><userinput>make CCARGS="$CCARGS" AUXLIBS="$AUXLIBS" makefiles &amp;&amp;
 make</userinput></screen>
 
