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

github.setup        zlib-ng zlib-ng 2.3.2
github.tarball_from archive
revision            0

description         \
    zlib replacement with optimizations for \"next generation\" systems.

long_description    \
    {*}${description} \
    Features: \
    - Zlib compatible API with support for dual-linking \
    - Modernized native API based on zlib API for ease of porting \
    - Modern C11 syntax and a clean code layout \
    - Deflate medium and quick algorithms based on Intel\’s zlib fork \
    - Support for CPU intrinsics when available \
    - Unaligned memory read/writes and large bit buffer improvements \
    - Includes improvements from Cloudflare and Intel forks \
    - Configure, CMake, and NMake build system support \
    - Comprehensive set of CMake unit tests \
    - Code sanitizers, fuzzing, and coverage \
    - GitHub Actions continuous integration on Windows, macOS, and Linux \
    - Emulated CI for ARM, AARCH64, PPC, PPC64, RISCV, SPARC64, S390x using \
      qemu

categories          archivers
license             Zlib
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  3d7515e9f8a3aeae08e81cd381a458cc881d8162 \
                    sha256  6a0561b50b8f5f6434a6a9e667a67026f2b2064a1ffa959c6b2dae320161c2a8 \
                    size    2446623

depends_build-append    path:bin/git:git

# zlib-ng downloads own copy of gtest
# We can't use gtest from MacPorts because it's broken
# with shared libs: https://github.com/google/googletest/issues/3442
# It has also been discovered that it cannot be compiled on
# macOS 10.7-10.8 with the newer versions of LLVM
# Enforcing the _DARWIN_C_SOURCE flag fixes this issue
# https://trac.macports.org/ticket/60885
if {${os.platform} eq "darwin" && ${os.major} < 13 && ${os.major} > 10} {
    configure.cxxflags-append \
                    -D_DARWIN_C_SOURCE
}

# uses newer intrinsic functions
# zlib-ng uses the C11 standard, but a C17/C++17
# compiler is required to build the tests
# it also fixed builds with +native variant
compiler.c_standard     2017
compiler.cxx_standard   2017
# fails to build on 10.12 with Xcode Clang
compiler.blacklist-append \
                    {clang < 1000}

variant native description "Enable optimizations only for your CPU" {
    configure.args-append \
                    -DWITH_NATIVE_INSTRUCTIONS=ON
}
