# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 84512 2011-09-27 14:19:06Z snc@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0

name                qca-gnupg
version             2.0.0-beta3
revision            1
categories          devel crypto security
maintainers         michaelld openmaintainer
description         Qt Cryptographic Architecture - gnupg plugin
long_description \
    This library provides an easy API for the following features: SSL/TLS, \
    X509, SASL, RSA, Hashing (SHA1, MD5), Ciphers (BlowFish, 3DES, AES), \
    Functionality is supplied via plugins. \
    \
    This plugin provides support for gnupg.

platforms           darwin

homepage            http://delta.affinix.com/qca/
master_sites        http://delta.affinix.com/download/qca/2.0/plugins/
use_bzip2           yes

checksums           md5 9b4d020efd835a52d98b2ced9ae79c4b \
                    sha1 77e3874b9ed427e281b23b9bf41ecc95e74f7053 \
                    rmd160 2531d81179e0b78cc3689c7891b4c6c60d56a422

depends_lib-append  port:qca

# The patch to "configure" uses QCA's 'crypto.prf' file to correctly
# include its libraries (no matter how QCA is installed), instead of
# forcing patching of multiple files.
patchfiles          patch-configure.diff

# qca-gnupg does not use --prefix
configure.pre_args
configure.args       --verbose             \
                     --qtdir=${qt_dir}

post-destroot {
    # fix library path of installed library/ies
    foreach fixfile [exec find ${destroot}${qt_dir} -name "*.dylib" | \
                         sed -e "s@${destroot}@@g"] {
        system "install_name_tool -id ${fixfile} ${destroot}${fixfile}"
    }
}

variant debug description \
{Build both release and debug library} \
{
    configure.args-delete --release
    configure.args-append --debug-and-release
}

variant universal {
    configure.universal_args-append --universal
}

variant gnupg1 description {GnuPG version 1 runtime use} {
	depends_run-append port:gnupg
}

variant gnupg2 description {GnuPG version 2 runtime use} {
	depends_run-append port:gnupg2
}

# check for setting the default variant
if {![variant_isset gnupg1] &&
    ![variant_isset gnupg2]} {
    default_variants +gnupg2
}

# make sure -gnupg2 isn't set alone
if {![variant_isset gnupg1] &&
    ![variant_isset gnupg2]} {
    return -code error \
"\n\nThe variant -gnupg2 will not work alone.
Please select one of +gnupg1 or +gnupg2 as a variant.\n"
}
