# -*- 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
PortGroup           legacysupport 1.1

name                google-glog
github.setup        google glog 0.6.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            3
checksums           rmd160  f59cdbebd81c3c8881e3775ccec9336968648387 \
                    sha256  8eb8a80e63839beb9587bbd7deb95ba263bc112f55db9042c6cd8c77f69a2a1f \
                    size    193314

categories          devel
maintainers         nomaintainer

description         Logging library for C++
long_description    The glog library implements application-level logging. \
                    This library provides logging APIs based on C++-style \
                    streams and various helper macros.

license             BSD

# See: https://github.com/google/glog/pull/239
patchfiles-append   patch-pkg_file.diff

# Needed for clock_gettime()
legacysupport.newest_darwin_requires_legacy \
                    15

compiler.cxx_standard \
                    1998

# https://trac.macports.org/ticket/65645
# #pragma GCC diagnostic inside functions available from gcc-4.6.
compiler.blacklist-append \
                    {*gcc-4.[0-5]} {clang < 421}

configure.args-append \
                    -DWITH_GFLAGS=OFF \
                    -DBUILD_SHARED_LIBS=ON \
                    -DWITH_GTEST=OFF

platform darwin {
    set port_cxxflags "${configure.cxxflags}"

    # Needed to support building dependents. See: https://kumasento.github.io/2020-06-12-glog-gflags-and-c-abi/
    if {${os.major} < 16} {
        set port_cxxflags "${port_cxxflags} -D_GLIBCXX_USE_CXX11_ABI=0"
    }

    configure.args-append \
        -DCMAKE_CXX_FLAGS="${port_cxxflags}"
}

# Undefined symbols:
# "___atomic_load_8", referenced from: _main in logging_unittest.cc.o
# "___atomic_store_8", referenced from: _main in logging_unittest.cc.o
if {[string match *gcc* ${configure.compiler}]} {
    configure.ldflags-append \
                    -latomic
}

variant gflags description {Includes gflags command line control of logging} {
    configure.args-replace \
                    -DWITH_GFLAGS=OFF -DWITH_GFLAGS=ON
    depends_lib-append \
                    port:gflags
}

default_variants +gflags

post-destroot {
    set dest_doc ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${dest_doc}
    xinstall -m 0644 -W ${worksrcpath} \
        AUTHORS COPYING ChangeLog README.rst \
        ${dest_doc}
}

github.livecheck.regex {([0-9.]+)}
