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

name                binutils
version             2.47
revision            0

checksums           rmd160  525e5d29ed49a1d6ca9c54b728171d5ccac72d97 \
                    sha256  154ab23b60070e8f27013c22977f1129425d67d1e8acd6e13010e617811e4cff \
                    size    29034716

description         FSF Binutils for native development.
long_description    Free Software Foundation development toolchain ("binutils") \
                    for native development. Tools are prefixed with g to avoid \
                    conflicts with original tools.

categories          devel
license             GPL-3+
maintainers         @wu21-web openmaintainer
homepage            https://www.gnu.org/software/binutils/binutils.html
master_sites        gnu:binutils
use_xz              yes

depends_build-append \
                    port:gettext

# Enforce systems nm on 10.10 and earlier,
# See: https://trac.macports.org/ticket/65621
if {${os.platform} eq "darwin" && ${os.major} <= 14} {
    build.env-append \
                    NM=/usr/bin/nm
    build.args-append \
                    lt_cv_path_NM=/usr/bin/nm
}

depends_lib-append  port:gettext-runtime \
                    port:libiconv \
                    port:zlib \
                    port:zstd

# bfd.c: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘bfd_error_type’
compiler.thread_local_storage yes

# --enable-shared leads to Undefined symbols, avoid it
# See: https://sourceware.org/bugzilla/show_bug.cgi?id=31056
configure.args      --infodir='${prefix}/share/info' \
                    --mandir='${prefix}/share/man' \
                    --disable-silent-rules \
                    --disable-werror \
                    --program-prefix=g \
                    --enable-install-libbfd \
                    --enable-install-libiberty \
                    --with-system-zlib

# The Makefile runs configure again in subdirectories.
# It correctly passes along most configure variables (CFLAGS, LDFLAGS, ...),
#    but seems to neglect CPPFLAGS.
build.env-append    CPPFLAGS=-I${prefix}/include

# Binutils violates the mtree layout by creating ${prefix}/<arch>/
destroot.violate_mtree  yes

# We don't want the etc module.
# But leave texi2pod.pl untouched for processing man pages
post-extract {
    move ${worksrcpath}/etc/texi2pod.pl ${worksrcpath}
    delete {*}[glob ${worksrcpath}/etc/*]
    move ${worksrcpath}/texi2pod.pl ${worksrcpath}/etc/texi2pod.pl
}

universal_variant   no

notes "Some of the utilities that ${name} installs can cause some\
other ports to fail to build, due to subtle differences with system\
tools sharing their names. Consider using trace mode if such build\
failures happen to you, or, if that is impossible, consider\
uninstalling ${name}."
