# $Id: Portfile 117900 2014-03-16 20:01:41Z larryv@macports.org $

PortSystem      1.0

name            libtool
version         2.4.2
revision        3
categories      devel sysutils
# Scripts are GPL-2+, libltdl is LGPL-2+, but all parts that tend to be
# distributed with dependents have a licensing exception that allows
# distrbution under the same terms as the rest of the program.
license         libtool
maintainers     larryv
description     GNU Libtool - 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        http://www.gnu.org/software/libtool/
platforms       darwin freebsd
master_sites    gnu

checksums           md5     d2f3b7d4627e69e13514a40e72a24d50 \
                    sha1    22b71a8b5ce3ad86e1094e7285981cae10e6ff88 \
                    rmd160  b7153f3f1e1c50d8c04787cafccd4e19af62ec7d

depends_build   port:automake port:autoconf

if {${os.platform} ne "darwin"} {
    depends_lib port:grep \
                port:gsed
}

#worksrcdir      [strsed $distname {s/[a-z]*$//}]

configure.args  F77=no \
                FC=no \
                GCJ=no \
                --program-prefix=g

# Patch to allow -stdlib=* for the linker
# See ticket 32982.
# committed upstream -> remove for libtool 2.4.3
patchfiles      ltmain.m4sh-allow-clang-stdlib.diff

use_parallel_build  yes

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

platform darwin {
    configure.env-append GREP=/usr/bin/grep \
                         SED=/usr/bin/sed
    post-destroot {
        foreach {neededfile} "${prefix}/lib/libltdl.dylib" {
            if {![file exists ${destroot}${neededfile}]} {
                ui_error "${neededfile} is not in the destroot. Please clean ${name} and try again."
                return -code error "missing ${neededfile} in destroot"
            }
        }
    }
}

livecheck.type  regex
livecheck.url   http://ftp.gnu.org/gnu/${name}/?C=M&O=D
livecheck.regex ${name}-(\\d+(?:\\.\\d+)*\[a-z\]?)
