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

checksums           rmd160  17d22bc99e0eee2dc8b77083f16634a634057927 \
                    sha256  ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450 \
                    size    26765692

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.

platforms           darwin
categories          devel
license             GPL-3+
maintainers         {@catap korins.ky:kirill} \
                    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

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

# 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 "Having ${name} installed will cause some other ports to\
fail to build. Consider uninstalling ${name}."
