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

PortSystem              1.0
PortGroup               legacysupport 1.1
PortGroup               openssl 1.0

legacysupport.newest_darwin_requires_legacy 19

if {[string match *clang* ${configure.compiler}]} {
    legacysupport.use_mp_libcxx yes
}

name                    cone
version                 2.2
revision                0
categories              mail
license                 GPL-3
maintainers             nomaintainer
description             Text-based mail client
long_description        {*}${description}, based, in part, on Courier libraries.

homepage                https://www.courier-mta.org/${name}/index.html
master_sites            sourceforge:project/courier/${name}/${version}
use_bzip2               yes

checksums               rmd160  a395797bf73195806d17e6a76824d57d11a156d9 \
                        sha256  7725afc88ea3cfc180d3297f83425938a3f22ad252c8db35a5b1e509ecdac6bb \
                        size    4341100

# https://github.com/svarshavchik/courier/issues/79
patchfiles-append       patch-maildircache.h.diff

# https://github.com/iains/gcc-14-branch/issues/26
if {${configure.cxx_stdlib} ne "libc++"} {
    patchfiles-append   patch-cone.sh.diff
}

depends_build-append    port:gettext \
                        path:bin/perl:perl5 \
                        path:bin/pkg-config:pkgconfig

depends_lib-append      port:aspell \
                        port:courier-sox \
                        port:courier-unicode \
                        port:gettext-runtime \
                        port:gnupg2 \
                        port:kerberos5 \
                        port:libiconv \
                        port:libidn2 \
                        port:libxml2 \
                        port:ncurses \
                        path:lib/libldap.dylib:openldap

configure.args-append   --with-notice=unicode

compiler.cxx_standard   2017
configure.cxxflags-append \
                        -std=gnu++17
compiler.blacklist-append \
                        {clang < 1300} {macports-clang-1[0-7]}

if {[string match *clang* ${configure.compiler}]} {
    compiler.whitelist  macports-clang-21 macports-clang-20 macports-clang-19
}

# https://github.com/svarshavchik/courier/issues/72
configure.cppflags-append \
                        -D_XOPEN_SOURCE_EXTENDED=1

# Undefined symbols for architecture x86_64: "_libiconv"
configure.ldflags-append \
                        -liconv
