# Description: Postfix Mail Transport Agent (MTA) PostgreSQL database support
# URL: http://www.postfix.org/
# Maintainer: Matt Housh, jaeger at crux dot ninja
# Depends on: postfix postgresql

name=postfix-pgsql
version=3.11.3
release=1
source=(http://ftp.porcupine.org/mirrors/postfix-release/official/postfix-${version}.tar.gz)

build() {
    cd postfix-$version

    make tidy
    make makefiles \
        DEBUG="" \
        OPT="${CFLAGS}" \
        pie=yes \
        shared=yes \
        dynamicmaps=yes \
        CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DUSE_TLS -I/usr/include/sasl" \
        AUXLIBS="-lsasl2 -lssl -lcrypto" \
        CCARGS+="-DHAS_PGSQL -I /usr/include/postgresql" \
        AUXLIBS_PGSQL="-lpq"
    make

    install -D -m 0755 lib/postfix-pgsql.so \
        ${PKG}/usr/lib/postfix/postfix-pgsql.so

    install -d -m 0755 ${PKG}/etc/postfix/dynamicmaps.cf.d
    echo -e "pgsql\tpostfix-pgsql.so\tdict_pgsql_open" > \
        ${PKG}/etc/postfix/dynamicmaps.cf.d/pgsql.cf
}

# vim: set ts=4 et:
