# -*- 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.45.1
revision            0

checksums           rmd160  65f4fb2a4726a4bf598db81101fb565747386a18 \
                    sha256  5fe101e6fe9d18fdec95962d81ed670fdee5f37e3f48f0bef87bddf862513aa5 \
                    size    27962312

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         nomaintainer
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}."
