# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           clang_dependency 1.0
PortGroup           muniversal 1.0

name                icu58
categories          devel textproc
platforms           darwin
maintainers         nomaintainer
license             Permissive
description         International Components for Unicode -- Legacy Version
long_description    {*}${description}. This port is the last version of icu that builds with\
                    c++03. It should be used only for bootstrapping or for software\
                    that is not compatible with c++11.

homepage            http://site.icu-project.org/

version             58.3
revision            1
checksums           rmd160  0b1ad8ea9bccd5d0f96a89bd0cdc12b5751ed46e \
                    sha256  2680f3c547cd26cba1d7ebd819cd336ff92cf444a270e195fd3b10bfdf22276c \
                    size    22626103

master_sites        https://github.com/unicode-org/icu/releases/download/release-[string map {. -} ${version}]/
distname            icu4c-[string map {. _} ${version}]-src
extract.suffix      .tgz

patchfiles-append   CVE-2017-7867-CVE-2017-7868.patch \
                    patch-bootstrap_config-mh-darwin.diff

if {${build_arch} eq "ppc" || ${build_arch} eq "ppc64"} {
    # (#59514)
    post-extract {
        xinstall -d -m 0755 ${worksrcpath}/data/out
    }
}

configure.python    /usr/bin/python2.7

worksrcdir          icu/source

# prevent ICU from finding installed icu when upgrading (#11981).
configure.cppflags
configure.ldflags

configure.pre_args  --prefix=${prefix}/libexec/${name}
configure.args      --disable-layoutex \
                    --disable-samples \
                    --enable-static

configure.universal_args-delete --disable-dependency-tracking

configure.cmd       ./runConfigureICU MacOSX

# ICU detects cross compiling by trying to run binaries.
merger_must_run_binaries yes

build.type          gnu
build.args          VERBOSE=1

post-build {
    if {[variant_exists universal] && [variant_isset universal]} {
        set dirs {}
        foreach arch ${universal_archs_to_use} {
            lappend dirs ${worksrcpath}-${arch}
        }
    } else {
        set dirs ${worksrcpath}
    }
    foreach dir ${dirs} {
        # Remove architecture-specific differences to allow merging.
        reinplace {s| -DSIZEOF_VOID_P=[48]||g}              ${dir}/config/Makefile.inc \
                                                            ${dir}/config/icu-config
        reinplace -E {s| -arch +[^ ]+||g}                   ${dir}/config/pkgdata.inc
        reinplace {s|host=\".*\"|host=\"\"|g}               ${dir}/config/icu-config
        reinplace {s|host_alias=\".*\"|host_alias=\"\"|g}   ${dir}/config/icu-config
        reinplace {s|host_cpu=\".*\"|host_cpu=\"\"|g}       ${dir}/config/icu-config
    }
}

platform darwin 8 {
    patchfiles-append patch-bootstrap_common-putil.cpp.diff
}

test.run        yes
test.target     check
test.args       VERBOSE=1

livecheck.type  none
