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

PortSystem          1.0
PortGroup           github 1.0

github.setup        SRI-CSL yices2 2.6.5 Yices-
name                yices
revision            0
categories          math
license             GPL-3
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         The Yices SMT Solver
long_description    {*}${description}
homepage            https://yices.csl.sri.com
checksums           rmd160  dd62264f3cead2dbd21b356100e34409e7e1ae2a \
                    sha256  46a93225c1e14ee105e573bb5aae69c8d75b5c65d71e4491fac98203cb0182f3 \
                    size    10389496
github.tarball_from archive

# ./api/yices_api_lock_free.h:34: error: previous declaration of ‘lp_algebraic_number_t’ was here
compiler.blacklist-append \
                    *gcc-4.* {clang < 421}

use_autoconf        yes

depends_build-append \
                    port:gperf
depends_lib-append  port:gmp

# Static GMP does not link correctly even on x86: https://github.com/macports/macports-ports/pull/17078#issuecomment-1366078584
post-patch {
    reinplace "s|obj static-obj lib static-lib bin static-bin|obj lib bin|" ${worksrcpath}/Makefile.build
}

if {${build_arch} in [list i386 ppc]} {
    # ld: absolute addressing (perhaps -mdynamic-no-pic) used in ___gmpn_modexact_1c_odd
    # from /opt/local/lib/libgmp.a(mode1o.o) not allowed in slidable image.
    # Use '-read_only_relocs suppress' to enable text relocs.
    configure.ldflags-append \
                    -read_only_relocs suppress
    build.args-append \
                    OPTION=32bit
} elseif {${build_arch} eq "ppc64"} {
    # On 10.6+ x86_64 is the default.
    build.args-append \
                    OPTION=64bit
}

platform darwin powerpc {
    patch.pre_args-replace  -p0 -p1
    # Fix for Rosetta:
    if {${os.major} == 10} {
        patchfiles-append \
                    0002-Rosetta-hack.patch
        configure.args-append \
                    --build=powerpc-apple-darwin${os.major}
        build.args-replace \
                    OPTION=32bit \
                    OPTION=Rosetta
    }

    notes "
    Presently PowerPC is not supported with the upstream.
    The build is experimental. Larger part of tests fail at the moment.
    "
}

universal_variant   no

pre-destroot {
    system -W ${worksrcpath} "make dist"
}

destroot.target     install-darwin

test.run            yes
test.target         check
