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

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

github.setup        macports macports-legacy-support 1.5.2 v
revision            0
github.tarball_from archive
checksums           rmd160  58a9837f78a72cb2204d674cc41e028b10bff71b \
                    sha256  16da882281d26d8ddfb434acfde0828fc3e4119aab332445f65688ae879e9962 \
                    size    228427

# Primary release version
set release_ver     ${github.version}

# Binary compatibility version
set compat_ver      1.0.0

subport ${name} {
    conflicts           ${name}-devel
    set so_curversion   ${release_ver}
}

subport ${name}-devel {
    conflicts           ${name}
    github.setup        macports macports-legacy-support \
                        d7744801e5d53b6134443968e96401d5e8ab5900
    github.tarball_from archive
    version             20260910
    revision            0
    livecheck.type      none
    checksums           rmd160  2c6d5813f0b63bf650769d370f94963e6ca23461 \
                        sha256  8381bf91ab5221650d284bc2c11f9bcd1320e3536cc23eb76afa57739e21dd6a \
                        size    317452
    set v_split         [split ${release_ver} .]
    set so_curversion   [lindex ${v_split} 0].[lindex ${v_split} 1].99
}

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

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

# Simple make-based setup, with natural universal support
use_configure       no
universal_variant   yes

# Set up the needed portion of the standard environment, plus our ARCHS
foreach phase {build destroot} {
    ${phase}.env-append    ARCHS=${archs} \
                           CC=${configure.cc} \
                           CXX=${configure.cxx} \
                           PREFIX=${prefix}

    # For some reason, omitting the unnecessary LDFLAGS definition causes
    # a benign discrepancy in some otherwise reproducible builds on 11.x.
    # For maximum consistency of installed content, we keep this for the
    # release version for now.  This can be removed as of the next release.
    #
    if {${subport} eq ${name}} {
        ${phase}.env-append    LDFLAGS=${configure.ldflags}
    }
}

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

# Set test target for optional universal handling and testing all libs
# For some reason, setting test.target doesn't work.
test.pre_args       test_all_unv

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

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

    # Avoid troublesome Xcode 2.5 linker on 10.4
    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
    "
}
