Ticket #49109: qca.diff

File qca.diff, 14.4 KB (added by RJVB (René Bertin), 8 years ago)

This diff makes qca compatible with concurrent qt4-mac, upgrades it to the current version (which requires making qca-ossl a subport) and also introduces a qca-qt5 subport

  • Portfile

    old new  
    11# -*- 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
    2 # $Id: Portfile 154192 2016-10-24 00:00:00Z michaelld@macports.org $
     2# $Id: Portfile 128101 2014-11-13 09:19:56Z ryandesign@macports.org $
    33
    44PortSystem          1.0
    5 PortGroup           cmake 1.0
    6 PortGroup           active_variants 1.1
    75
    86name                qca
    9 version             2.1.0
    10 revision            3
    11 set branch          [join [lrange [split ${version} .] 0 1] .]
     7
     8# Qt version handling logic
     9global Qt_Major
     10subport ${name}-qt5 {}
     11if {[string match "${name}-qt5*" ${subport}]} {
     12    version         2.1.0.3
     13    PortGroup       qt5 1.0
     14    set Qt_Major    5
     15    master_sites    http://download.kde.org/stable/qca-qt5/${version}/src
     16    checksums       rmd160  cc4040d013170ca5f21fbcefd0607daa8191d333 \
     17                    sha256  ab0170696a8ff87588d38a72d36d0b4b42db9080c991d1a40ceb3f8311d289f9
     18    use_xz          yes
     19    distname        "qca-qt5-${version}"
     20    livecheck.regex "qca-qt5-(\\d+(?:\\.\\d+)*)"
     21} else {
     22    version         2.1.0
     23    revision        4
     24    set branch      [join [lrange [split ${version} .] 0 0] .]
     25    PortGroup       qt4 1.0
     26    set Qt_Major    4
     27    master_sites    http://delta.affinix.com/download/qca/${branch}.0/
     28    checksums       md5     c2b00c732036244701bae4853a2101cf \
     29                    sha1    2b582b3ccc7e6098cd14d6f52a829ae1539e9cc8 \
     30                    rmd160  30358bbd182cfeb9eaa696b5b39fa9e6d1f99b4c
     31    livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)"
     32}
     33PortGroup           cmake 1.1
     34cmake.out_of_source yes
     35
    1236categories          devel crypto security
    13 maintainers         nomaintainer
     37maintainers         gmail.com:rjvbertin openmaintainer
    1438license             LGPL-2.1
    15 
    16 description "Qt Cryptographic Architecture"
     39description         Qt Cryptographic Architecture
    1740long_description \
    18     "Qt Cryptographic Architecture provides an easy API for the following \
    19      features: SSL/TLS, X509, SASL, RSA, Hashing (SHA1, MD5), Ciphers \
    20      (BlowFish, 3DES, AES).  Functionality is supplied via plugins."
     41    Qt Cryptographic Architecture provides an easy API for the following \
     42    features: SSL/TLS, X509, SASL, RSA, Hashing (SHA1, MD5), Ciphers \
     43    (BlowFish, 3DES, AES).  Functionality is supplied via plugins.
    2144
    2245platforms           darwin
    2346
    2447homepage            http://delta.affinix.com/qca/
    25 master_sites        http://delta.affinix.com/download/qca/2.0/
    26 
    27 checksums           rmd160 30358bbd182cfeb9eaa696b5b39fa9e6d1f99b4c \
    28                     sha256 226dcd76138c3738cdc15863607a96b3758a4c3efd3c47295939bcea4e7a9284
    29 
    30 # do VPATH (out of source tree) build
    31 
    32 cmake.out_of_source yes
    33 
    34 if {${name} eq ${subport}} {
    35 
    36     # temporary patch to add including QIODevice to qca_basic.h
    37 
    38     patchfiles-append patch-include_QtCrypto_qca_basic.h.diff
    39 
    40     # fix install directories for certs and cmake files
    41 
    42     patchfiles-append patch-CMakeLists.txt.diff
    43 
    44     # remove unnecessary Carbon #include, which fails on 10.8
    45 
    46     patchfiles-append patch-src_qac_systemstore_mac.cpp.diff
    47 
    48 } else {
    49     # fix top-level CMakeLists.txt to build just plugins
    50     patchfiles-append patch-CMakeLists.txt_plugins.diff
    51 }
    52 
    53 # Qt variants
    54 
    55 variant qt4 conflicts qt5 description "Build with qt4" {}
    56 
    57 variant qt5 conflicts qt4 description "Build with qt5" {}
    58 
    59 if {![variant_isset qt4] && ![variant_isset qt5]} {
    60     default_variants +qt4
    61 }
    62 
    63 # make sure -qt4 wasn't specified alone
    64 
    65 if {![variant_isset qt4] && ![variant_isset qt5]} {
    66     ui_error "\n\nYou must select either the +qt4 or +qt5 variant to build ${subport}\n"
    67     return -code error "Invalid variant selection"
    68 }
    69 
    70 if {${name} eq ${subport}} {
    71     if {[variant_isset qt4]} {
    72         PortGroup qt4 1.0
    73         configure.args-append -DQT4_BUILD=ON
    74     } else {
    75         PortGroup qt5 1.0
    76     }
    77 } else {
    78     # require qca to also have the selected Qt variant
    79     if {[variant_isset qt4]} {
    80         PortGroup qt4 1.0
    81         require_active_variants port:qca qt4
    82         configure.args-append -DQT4_BUILD=ON
    83     } else {
    84         PortGroup qt5 1.0
    85         require_active_variants port:qca qt5
    86     }
    87 }
    88 
    89 variant examples description {Include examples in install} {}
    9048
    91 # set install directory for mkspec files
    92 
    93 configure.args-append \
    94     -DQCA_FEATURE_INSTALL_DIR=${qt_mkspecs_dir}
    95 
    96 # specify various configure options
    97 
    98 configure.args-append \
    99     -DQCA_INSTALL_IN_QT_PREFIX=NO \
    100     -DQCA_PLUGINS_INSTALL_DIR=${prefix}/share/${name}/plugins
    101 
    102 if {${name} eq ${subport}} {
    103 
    104     # build as a framework
     49depends_lib-append  port:botan \
     50                    port:libgcrypt \
     51                    port:nss
     52
     53# # check for standard port:qt4-mac and/or port:qt5 instead of port:qt5-kde
     54# if {![file exists ${prefix}/lib/pkgconfig/QtCore.pc] && ![info exists qt5.using_kde] && !${qt5.using_kde}} {
     55# }
     56
     57# remove unnecessary Carbon #include, which fails on 10.8
     58patchfiles-append   patch-src_qac_systemstore_mac.cpp.diff
     59
     60patchfiles-append   patch-qca-ossl.diff
     61
     62# 1) it seems that configure.pre_args --prefix=${qt_dir} has the desired effect, but
     63# I don't know to what extent that uses an undocumented cmake feature, so use
     64# the exhaustive list of install variables.
     65# 2) the QCA plugins have been rolled into the main source tarball and are built by default
     66# when their dependencies are available. Allow this for all plugins that were not already
     67# available through an individual port; no reason to impose new dependencies on our dependents.
     68configure.args          -DCMAKE_INSTALL_PREFIX:PATH=${qt_dir} \
     69                        -DQCA_PLUGINS_INSTALL_DIR:PATH=${qt_plugins_dir} \
     70                        -DQCA_LIBRARY_INSTALL_DIR:PATH=${qt_libs_dir} \
     71                        -DQCA_BINARY_INSTALL_DIR:PATH=${qt_bins_dir} \
     72                        -DQCA_FEATURE_INSTALL_DIR:PATH=${qt_mkspecs_dir}/features \
     73                        -DQCA_INCLUDE_INSTALL_DIR:PATH=${qt_includes_dir} \
     74                        -DQCA_PRIVATE_INCLUDE_INSTALL_DIR:PATH=${qt_includes_dir} \
     75                        -DQCA_DOC_INSTALL_DIR:PATH=${qt_docs_dir} \
     76                        -DQCA_MAN_INSTALL_DIR:PATH=${prefix}/share/man \
     77                        -DPKGCONFIG_INSTALL_PREFIX:PATH=${qt_pkg_config_dir} \
     78                        -DOSX_FRAMEWORK:BOOL=OFF \
     79                        -DBUILD_PLUGINS:STRING="botan\;gcrypt\;logger\;nss\;softstore"
    10580
     81if {${Qt_Major} eq "4"} {
    10682    configure.args-append \
    107         -DOSX_FRAMEWORK=YES
    108 
    109     # specify various configure options
    110 
     83                        -DQT4_BUILD:BOOL=ON
     84} elseif {${Qt_Major} eq "5"} {
     85    patchfiles-append   patch-qca210-qt550.diff \
     86                        patch-qca210-qt56x.diff
    11187    configure.args-append \
    112         -DBUILD_PLUGINS=NO \
    113         -DQCA_MAN_INSTALL_DIR=${prefix}/share/man \
    114         -DQCA_LIBRARY_INSTALL_DIR=${frameworks_dir} \
    115         -DCMAKE_MODULES_DIR=${prefix}/share/cmake \
    116         -DPKGCONFIG_INSTALL_PREFIX=${prefix}/lib/pkgconfig \
    117         -DQCA_DOC_INSTALL_DIR=${prefix}/share/${name}/doc
    118 
     88                        -DQCA_SUFFIX:STRING="qt5"
    11989}
    12090
    12191# allow ccache, if specified by the user
    122 
    12392pre-build {
    12493    if {[tbool configure.ccache]} {
    12594        build.post_args "CCACHE=ccache"
     
    12796}
    12897
    12998post-destroot {
    130 
    131     if {${name} eq ${subport}} {
    132 
     99    if {${subport} eq ${name} || ${subport} eq "${subport}-qt5"} {
    133100        # install docs
    134 
    135         xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
     101        xinstall -d -m 755 ${destroot}${prefix}/share/doc/${subport}
    136102        xinstall -m 644 -W ${worksrcpath} COPYING README TODO \
    137             ${destroot}${prefix}/share/doc/${name}
    138 
    139         # get qca's version numbers
    140 
    141         set qca_vers [split ${version} "."]
    142         set qca_major [lindex ${qca_vers} 0]
    143         set qca_minor [lindex ${qca_vers} 1]
    144         set qca_patch [lindex ${qca_vers} 2]
    145 
    146         # link includes and libraries for each actual installed framework
    147 
    148         set tf_full ${frameworks_dir}/qca.framework/Versions/${version}
    149 
    150         # link headers into ${prefix}/include, removing
    151         # directories if they are already there first
    152 
    153         set dr_inc_file ${destroot}${prefix}/include
    154         ln -s ${tf_full}/Headers ${dr_inc_file}/qca
    155         ln -s ${tf_full}/Headers ${dr_inc_file}/QtCrypto
    156 
    157         # link libraries into ${dr_libs_dir}, all 4 number variants
     103            ${destroot}${prefix}/share/doc/${subport}
     104    }
    158105
    159         set dr_libs_dir ${destroot}${prefix}/lib
    160         ln -s ${tf_full}/qca ${dr_libs_dir}/libqca.dylib
    161         ln -s ${tf_full}/qca ${dr_libs_dir}/libqca.${qca_major}.dylib
    162         ln -s ${tf_full}/qca ${dr_libs_dir}/libqca.${qca_major}.${qca_minor}.dylib
    163         ln -s ${tf_full}/qca ${dr_libs_dir}/libqca.${qca_major}.${qca_minor}.${qca_patch}.dylib
     106    if {${subport} eq "${name}"} {
     107        # install cmake file (taken from port 'kdelibs4'). To use this
     108        # file, include '-DCMAKE_MODULE_PATH=...' in configure.args during
     109        # the initial 'configure' stage (which uses CMake), to the full
     110        # path of where the CMake files are installed.
     111        # note that QCA 2.1+ also installs .cmake files in ${qt_libs_dir}/cmake/Qca; I don't
     112        # see a reason to move those so I'm leaving them there.
     113        xinstall -d -m 755 ${destroot}${qt_cmake_module_dir}
     114        xinstall -m 644 -W ${filespath} FindQCA2.cmake \
     115            ${destroot}${qt_cmake_module_dir}
    164116
    165         if {[variant_isset examples]} {
    166             xinstall -d -m 755 ${destroot}${prefix}/share/examples/${name}
    167             eval file copy [glob ${worksrcpath}/examples/*] \
    168                 ${destroot}${prefix}/share/examples/${name}
    169         }
    170117    }
    171118}
    172119
    173 array set bindings {
    174     botan       {port:botan       botan}
    175     cyrus-sasl  {port:cyrus-sasl2 cyrus-sasl}
    176     gcrypt      {port:libgcrypt   gcrypt}
    177     gnupg       {port:gnupg       gnupg}
    178     logger      {""               logger}
    179     nss         {port:nss         nss}
    180     ossl        {path:lib/libssl.dylib:openssl ossl}
    181     softstore   {""               softstore}
    182 }
    183 #    pkcs11      {port:pkcs11      pkcs11}
    184 array set prettynames {
    185     botan Botan cyrus-sasl Cyrus-SASL gcrypt GCrypt
    186     gnupg GnuPG logger Logger nss NSS
    187     ossl OpenSSL pkcs11 pkcs11 softstore SoftStore
    188 }
    189 
    190 options qca.plugin
    191 default qca.plugin ""
    192 
    193 foreach plugin [lsort [array names bindings]] {
    194     set arg      [lindex $bindings($plugin) 1]
    195     set arg_name [lindex [split ${arg} =] 0]
    196     subport qca-${plugin} {
    197         if {[lindex $bindings($plugin) 0] ne ""} {
    198             depends_lib-append [lindex $bindings($plugin) 0]
    199         }
    200         configure.args-append  -DWITH_${arg}_PLUGIN=ON
    201         qca.plugin             ${arg_name}
    202     }
    203     if {${qca.plugin} != ${arg_name}} {
    204         configure.args-append -DWITH_${arg_name}_PLUGIN=OFF
    205     }
     120# NB: it doesn't seem possible to build this way with the new cmake-based approach
     121variant debug description \
     122{Build both release and debug library} {
     123    ui_msg "this variant is obsolete; use configure.optflags=\"-g\""
     124    PortGroup   obsolete 1.0
    206125}
    207 if {${qca.plugin} ne ""} {
    208     description $prettynames(${qca.plugin}) plugin for ${name}
    209     long_description \
    210         Qt Cryptographic Architecture. This is the \
    211         $prettynames(${qca.plugin}) plugin.
    212     depends_lib-append port:qca
    213     livecheck.type none
    214 } else {
    215     livecheck.type  regex
    216     livecheck.url   ${homepage}
    217     livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
     126
     127# avoid installing the examples into Qt's binary tree
     128variant examples description \
     129{Include examples in install} {
     130    post-destroot {
     131        xinstall -d -m 755 ${destroot}${prefix}/share/${subport}/examples/
     132        eval file copy [glob ${worksrcpath}/examples/*] \
     133            ${destroot}${prefix}/share/${subport}/examples/
     134    }
    218135}
    219136
     137# NB: I haven't yet tested universal variants; those may require the muniversal portgroup
     138# variant universal {
     139#     # Add the universal flag understood by qmake
     140#     configure.universal_args-append --universal
     141# }
     142
    220143subport qca-tls {
     144    replaced_by qca-ossl
    221145    PortGroup obsolete 1.0
    222146    long_description "This port is obsolete."
    223147}
     148
     149### The ossl, cyrus-sasl and gnupg plugins that used to be standalone ports.
     150### It makes more sense IMHO to implement them as subports. The other plugins
     151### are built together with the main port; I don't see a reason to introduce
     152### new subports for components that used to be built along with the main ports,
     153### only to impose new dependencies on the ports that require qca.
     154# Qt4 receives no suffix:
     155set qt.versions     {"" "-qt5"}
     156foreach qv ${qt.versions} {
     157    subport ${name}${qv}-ossl {
     158        license                 LGPL-2.1+
     159        depends_lib-append      port:${name}${qv} port:openssl
     160        configure.args-delete   -DBUILD_PLUGINS:STRING="botan\;gcrypt\;logger\;nss\;softstore"
     161        configure.args-append   -DBUILD_PLUGINS:STRING="ossl"
     162        build.dir               ${workpath}/build/plugins/qca-ossl
     163    }
     164    subport ${name}${qv}-cyrus-sasl {
     165        license                 LGPL-2.1+
     166        depends_lib-append      port:${name}${qv} port:cyrus-sasl2
     167        configure.args-delete   -DBUILD_PLUGINS:STRING="botan\;gcrypt\;logger\;nss\;softstore"
     168        configure.args-append   -DBUILD_PLUGINS:STRING="cyrus-sasl"
     169        build.dir               ${workpath}/build/plugins/qca-cyrus-sasl
     170    }
     171    subport ${name}${qv}-gnupg {
     172        license                 LGPL-2.1+
     173        depends_lib-append      port:${name}${qv}
     174        configure.args-delete   -DBUILD_PLUGINS:STRING="botan\;gcrypt\;logger\;nss\;softstore"
     175        configure.args-append   -DBUILD_PLUGINS:STRING="gnupg"
     176        build.dir               ${workpath}/build/plugins/qca-gnupg
     177    }
     178    foreach virtual {"botan" "gcrypt" "logger" "nss" "softstore"} {
     179        subport ${name}${qv}-${virtual} {
     180            archive_sites
     181            distfiles
     182            depends_lib         port:${name}${qv}
     183            use_configure       no
     184            supported_archs     noarch
     185            patchfiles
     186            build {}
     187            destroot {
     188                set stubdir ${destroot}${prefix}/share/doc/${subport}
     189                xinstall -d -m 755 ${stubdir}
     190                system "touch ${stubdir}/this.is.a.stubport"
     191            }
     192        }
     193    }
     194}
     195
     196livecheck.type  regex
     197livecheck.url   ${master_sites}