# -*- 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           github 1.0
PortGroup           makefile 1.0

name                legacy-support
categories          devel

maintainers         {mascguy @mascguy} \
                    {fwright.net:fw @fhgwright} \
                    openmaintainer
license             MIT BSD APSL-2

description         Installs wrapper headers and a runtime library to add \
                    missing functionality to legacy OSX versions.
long_description    {*}${description}

# Introduced to roll back to 1.0.13 release due to issues with 1.1.0.
# Must now stay.
epoch               1

# Primary release version
set release_ver     1.5.0

# Binary compatibility version
set compat_ver      1.0.0

subport ${name} {
    PortGroup           muniversal 1.1

    conflicts           ${name}-devel
    github.setup        macports macports-legacy-support ${release_ver} v
    # Change github.tarball_from to 'releases' or 'archive' next update
    # N.B.: That's a nice theory, but neither choice works correctly
    github.tarball_from tarball
    revision            0
    checksums           rmd160  02d6f192a75ffacda4530d82464240f404cc224c \
                        sha256  18f4df8850aebe64f66ed80eae14b50cc87cbe1d1dabfbdd432ff0aaf87b44f4 \
                        size    214986
}

subport ${name}-devel {
    conflicts           ${name}
    github.setup        macports macports-legacy-support \
                        17cb4f9a1e313356db8acd1b3f8ae317ddacaf11
    # Change github.tarball_from to 'releases' or 'archive' next update
    # N.B.: That's a nice theory, but neither choice works correctly
    github.tarball_from tarball
    version             20250728
    revision            0
    livecheck.type      none
    checksums           rmd160  80bea072afe759d0aa13bed02205e7165e116b51 \
                        sha256  aa9f267e7d25a10ea359e571a1fb180440f8d81aca1f250b95df42a4b1a65ddc \
                        size    227836
    set v_split         [split ${release_ver} .]
    set release_ver     [lindex ${v_split} 0].[lindex ${v_split} 1].99

    # Set up proper arch list for build and test
    if {![variant_isset universal]} {
        set archs       ${configure.build_arch}
    } else {
        set archs       ${configure.universal_archs}
    }

    # Let the Makefile handle the archs setup
    configure.cc_archflags
    configure.cxx_archflags
    configure.ld_archflags
    configure.universal_cflags
    configure.universal_cxxflags
    configure.universal_ldflags

    # Pass the arch list to the Makefile
    build.env-append        ARCHS=${archs}
    destroot.env-append     ARCHS=${archs}
    test.env-append         ARCHS=${archs}

    # Set test target for optional universal handling
    # For some reason, setting test.target doesn't work.
    test.pre_args       test_unv

    # Enable parallel tests
    default test.jobs   ${build.jobs}
    test.post_args      -j${test.jobs}
}

# The makefile PG brings in the unnecessary compiler_wrapper PG.
# Disable it to reduce logfile clutter and obfuscation.
#
compwrap.compilers_to_wrap

# This port doesn't use C++ at all, except for three obsolete tests that
# are now manual-only.  Disabling cxx_stdlib avoids unnessary compiler
# constraints on some platforms.
#
configure.cxx_stdlib

build.env-append    SOCURVERSION=${release_ver} \
                    SOCOMPATVERSION=${compat_ver}

# Include Tiger-specific additions
platform darwin 8 {
    build.target-append     tiger-bins
    destroot.target-append  install-tiger

    # The 10.4 compiler selection logic fails to correctly substitute
    # apple-gcc42 for the Xcode compiler when building +universal for
    # "ppc ppc64", and blacklisting seems to just result in a different
    # bad choice.
    # In this particular circumstance, just setting configure.compiler
    # directly isn't unreasonable.
    #
    configure.compiler      apple-gcc-4.2
}

# Include Leopard-specific additions
platform darwin 9 {
    build.target-append     leopard-bins
    destroot.target-append  install-leopard
}

test.env            {*}${build.env}
test.run            yes
test.target         test

if {![file exists ${prefix}/libexec/mpstats]} {
    notes "
    To help make sure your system continues to be well-represented by\
    MacPorts, especially if your system is not one of the latest macOS\
    releases, please consider installing mpstats.  It will periodically\
    send an anonymous synopsis of your OS settings and installed ports.\
    The information provided by this is useful to help determine how\
    resources are allocated.

    You can install mpstats like this:    sudo port install mpstats
    "
}
