# -*- 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 86121 2011-10-19 14:56:10Z michaelld@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0

name                qca-ossl
version             2.0.0-beta3
revision            4
categories          devel crypto security
maintainers         michaelld openmaintainer
description         Qt Cryptographic Architecture - openssl 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 OpenSSL related ciphers.

platforms           darwin

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

checksums           md5 bdc62c01321385c7da8d27b3902910ce \
                    sha1 dd925e8732ff76f24f9f90f4094abaf2f0ac27bf \
                    rmd160 c979c3c3427eb45e8866e28746f83966e8bcf3c2

depends_lib-append  port:qca \
                    port:openssl

# Without the patch to "qca-ossl.cpp", if MD2 isn't part of OpenSSL
# (which it is not by default as of at least version 0.9.7) then
# compiling will error out.  Upstream has already fixed this issue for
# this port; just waiting for a new release.
patchfiles-append   patch-qca-ossl.cpp.diff

# (2) Use QCA's 'crypto.prf' file to correctly include its libraries
# (no matter how QCA is installed), instead of forcing patching of
# multiple files.  Correct compiling for universal or set of arches.
patchfiles-append   patch-configure.diff

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

# QCA's configure does not handle this flag,
# but does not generate an error either.
configure.universal_args-delete --disable-dependency-tracking
configure.args-delete  --disable-dependency-tracking

post-patch {
    # set arch type(s)
    reinplace "s|@ARCHES@|${qt_arch_types}|g" \
        ${worksrcpath}/configure
}

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
}
