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

name                libtool
version             2.5.4
categories          devel sysutils
platforms           darwin freebsd
# Scripts are GPL-2+, libltdl is LGPL-2+, but all parts that tend to be
# distributed with dependents have a licensing exception that allows
# distribution under the same terms as the rest of the program.
license             libtool
maintainers         {larryv @larryv} {michaelld @michaelld}

description         The GNU Portable Library Tool
long_description    GNU libtool is a generic library support script. \
                    Libtool hides the complexity of using shared \
                    libraries behind a consistent, portable interface.
homepage            https://www.gnu.org/software/libtool

master_sites        gnu
use_xz              yes
checksums           rmd160 8dcde730274c8ac3d0bce43f58bb9ba18d0b9a1e \
                    sha256 f81f5860666b0bc7d84baddefa60d1cb9fa6fceb2398cc3baca6afaa60266675 \
                    size   1056924

# hardcode the M4 executable, similar to other executables such as SED, GREP, LN ...
patchfiles          hardcode-m4.patch

post-patch {
    # Stop build from trying to regenerate these after patching.
    touch ${worksrcpath}/doc/libtool.1 ${worksrcpath}/doc/libtoolize.1
    touch ${worksrcpath}/aclocal.m4 ${worksrcpath}/libltdl/aclocal.m4
    touch ${worksrcpath}/Makefile.in ${worksrcpath}/libltdl/Makefile.in
    touch ${worksrcpath}/config-h.in ${worksrcpath}/libltdl/config-h.in
    touch ${worksrcpath}/configure ${worksrcpath}/libltdl/configure
}

# m4 1.4.2 which comes with Mac OS X 10.4 is too old:
# https://trac.macports.org/ticket/47545
# And m4 wasn't included in the Xcode 15.3 version of the command line tools:
# https://trac.macports.org/ticket/69467#comment:6
depends_lib-append      port:m4
configure.env           M4=${prefix}/bin/gm4

# Don't let configure detect MacPorts' grep or gsed (#19237).
if {${os.platform} eq "darwin"} {
    configure.env-append    GREP=/usr/bin/grep SED=/usr/bin/sed
} else {
    depends_lib-append      port:grep port:gsed port:help2man
}

# Don't look for broken compilers (#23684, #32321).
configure.env-append    GCJ=no
configure.fc            no
configure.f77           no

configure.args          --disable-silent-rules --program-prefix=g

post-destroot {
    set gnubin ${prefix}/libexec/gnubin
    xinstall -d ${destroot}${gnubin}
    ln -s ../../bin/glibtool ${destroot}${gnubin}/libtool
    ln -s ../../bin/glibtoolize ${destroot}${gnubin}/libtoolize

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
            AUTHORS COPYING ChangeLog NEWS README THANKS TODO \
            ${destroot}${docdir}
}

test.run            yes
test.target         check
