# -*- 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$

PortSystem          1.0
PortGroup           muniversal 1.0

name                openssl
epoch               1
version             1.0.2j

# Please revbump these ports when updating OpenSSL.
#  - freeradius (#43461)
#  - tor, tor-devel (#44256)

categories          devel security
platforms           darwin
license             OpenSSL SSLeay
maintainers         larryv cal openmaintainer

description         OpenSSL SSL/TLS cryptography library
long_description    The OpenSSL Project is a collaborative effort to \
                    develop a robust, commercial-grade, full-featured, \
                    and Open Source toolkit implementing the Secure \
                    Sockets Layer (SSL v2/v3) and Transport Layer \
                    Security (TLS v1) protocols as well as \
                    a full-strength general purpose cryptography \
                    library.
homepage            https://www.openssl.org

conflicts           libressl libressl-devel

depends_lib         port:zlib

# See https://www.openssl.org/source/mirror.html
master_sites        ${homepage}/source \
                    ftp://gd.tuwien.ac.at/infosys/security/openssl/source/ \
                    http://openssl.skazkaforyou.com/source/ \
                    http://mirror.switch.ch/ftp/mirror/openssl/source/ \
                    ftp://ftp.fi.muni.cz/pub/openssl/source/ \
                    ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
                    http://artfiles.org/openssl.org/source/ \
                    ftp://ftp.linux.hr/pub/openssl/source/ \
                    ftp://guest.kuria.katowice.pl/pub/openssl/source/

checksums           sha1    bdfbdb416942f666865fa48fe13c2d0e588df54f \
                    rmd160  d5be416caf523f3496323dbd05547144348e7854 \
                    sha256  e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431

patchfiles          install-headers-HFS+.patch \
                    parallel-building.patch \
                    remove-duplicate-bn_print-doc.patch

configure.ccache    no
configure.perl      /usr/bin/perl
configure.cmd       ./Configure
configure.args     -L${prefix}/lib \
                    no-krb5 \
                  --openssldir=${prefix}/etc/openssl \
                    shared \
                    zlib
# Use SDK if necessary.
if {${configure.sdkroot} ne ""} {
    configure.args-append   '-isysroot ${configure.sdkroot}' \
                            -Wl,-syslibroot,${configure.sdkroot}
}

set merger_arch_compiler no
array set merger_configure_args {
    ppc     darwin-ppc-cc
    i386    darwin-i386-cc
    ppc64   darwin64-ppc-cc
    x86_64  darwin64-x86_64-cc
}
platform darwin {
    # Don't use i386 assembly on Tiger (#38015, #43303).
    if {${os.major} <= 8} {
        append merger_configure_args(i386) { no-asm}
    }
    # Don't use x86-64 assembly on Tiger or Leopard.
    if {${os.major} <= 9} {
        append merger_configure_args(x86_64) { no-asm}
    }
}
# Don't pass --host to configure.
array set merger_host {ppc {} i386 {} ppc64 {} x86_64 {}}

if {![variant_isset universal]
        && [info exists merger_configure_args(${configure.build_arch})]} {
    configure.args-append $merger_configure_args(${configure.build_arch})
}
configure.universal_args-delete --disable-dependency-tracking

# Parallel builds don't quite work (#46719).
use_parallel_build  no

test.run            yes

if {[variant_isset universal]} {
    pre-destroot {
        global merger_dont_diff
        if {[llength ${universal_archs_to_use}] > 2} {
            lappend merger_dont_diff ${prefix}/include/openssl/opensslconf.h
        }
    }
}

destroot.args       MANDIR=${prefix}/share/man MANSUFFIX=ssl
destroot.destdir    INSTALL_PREFIX=${destroot}

variant rfc3779 description {enable RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers} {
    configure.args-append   enable-rfc3779
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}-(\[0-9.\]+\[a-z\]?)\\.tar\\.gz