# $Id: Portfile 103250 2013-02-19 11:18:05Z ryandesign@macports.org $

PortSystem			1.0

name				getopt
version				1.1.5
revision            1
categories			sysutils
license				GPL-2+
installs_libs		no
maintainers			nomaintainer
description			Replacement getopt for shell script use
long_description \
	Getopt(1) is a program to help shell scripts parse command-line \
	parameters.  It can do anything that the GNU getopt(3) routines can do. \
	It can cope with spaces and shell metacharacters within arguments. \
	It can parse long parameters. \
	It can shuffle parameters, so you can mix options and other parameters on \
	the command-line. \
	It can be easily identified as an enhanced getopt(1) from within shell \
	scripts. \
	It can report parse errors as coming from the shell script. \
	It is fully compatible with other getopt(1) implementations.

platforms			darwin

homepage			http://software.frodo.looijaard.name/getopt/
master_sites		http://software.frodo.looijaard.name/getopt/files/

checksums           md5     546acfdb67ba16b8658a45ade9a64d5d \
                    sha1    9090eb46ac92f2fd2749ca4121e81aaad40f325d \
                    rmd160  5cdef902ada45ba5e8a66a1357be8189b0cc634f

post-extract {
    # 1.1.5 ships with ELF .o files
    fs-traverse f ${worksrcpath} {
        if {[file isfile ${f}] && [file extension ${f}] == ".o"} {
            delete ${f}
        }
    }
}

patchfiles			patch-Makefile.diff

depends_lib			port:gettext

use_configure		no

variant universal {}

post-patch {
    reinplace -E "/^CFLAGS/s|\$| [get_canonical_archflags cc]|" ${worksrcpath}/Makefile
    reinplace -E "/^LDFLAGS/s|\$| [get_canonical_archflags ld]|" ${worksrcpath}/Makefile
}

build.args			LIBCGETOPT=0 prefix=${prefix} mandir=${prefix}/share/man CC=${configure.cc}

destroot.args		${build.args}
destroot.target		install install_doc

post-destroot {
    set docdir ${prefix}/share/doc/${name}
	xinstall -d ${destroot}${docdir}
	xinstall -m 644 -W ${worksrcpath} COPYING Changelog README TODO \
		${destroot}${docdir}
}

platform darwin 8 powerpc {
    configure.universal_ldflags-append -liconv
}

livecheck.type  regex
livecheck.url   ${homepage}download.php
livecheck.regex ${name}-(\\d+(?:\\.\\d+)*)

