diff --git a/mail/dovecot/dovecot.conf b/mail/dovecot/dovecot.conf index d6340214b..bc6fa8bb3 100644 --- a/mail/dovecot/dovecot.conf +++ b/mail/dovecot/dovecot.conf @@ -15,16 +15,27 @@ # install development headers by default var_append confopt ' ' "--enable-header-install" -# LDAP support -if pkginstalled openldap ; then - pkgprefix -t openldap - var_append extraconfopt ' ' "--with-ldap" -fi +# package/option mappings for auto-configuration +pkg_dovecot_options="openldap:ldap postgresql:pgsql" -# generic SQL support -var_append extraconfopt ' ' "--with-sql=plugin" - -# postgresql support -if pkginstalled -f postgresql; then - var_append extraconfopt ' ' "--with-pgsql" -fi +# automatic feature selection according to the package/option mappings +pkg_dovecot_autoconfig() { + local args="$@" + for x in $args; do + local package="${x%:*}" + local option="${x#*:}" + [ ! -z "$option" ] || option="$package" + if pkginstalled -f "$package"; then + pkgprefix -t "$package" + var_append extraconfopt ' ' "--with-$option" + case $package in + *sql*) enable_sql=true ;; + esac + fi + done + # generic SQL support/build drivers as plugins + if $enable_sql; then + var_append extraconfopt ' ' "--with-sql=plugin" + fi +} +pkg_dovecot_autoconfig "$pkg_dovecot_options"