# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 80409 2011-07-12 12:26:17Z jmr@macports.org $

PortSystem      1.0

name            unrar
set my_name     ${name}src
version         4.0.7
categories      archivers
license         Restrictive/Distributable
platforms       darwin freebsd
maintainers     nomaintainer
description     Extract, view & test RAR archives

long_description \
    The unRAR utility is a minor part of the RAR archiver and \
    contains RAR uncompression algorithm. unRAR requires very \
    small volume of memory to operate.

homepage        http://www.rarlab.com/
master_sites    ${homepage}rar/
distname        ${my_name}-${version}

checksums           md5     41b0a9bca945b4ae2608421afd8f606e \
                    sha1    e4c8b0d47278475f3dfb77e8497f5818eca3d4a0 \
                    rmd160  0629f8600e9ddb298f59fc05b9569bd40703acaf

worksrcdir      ${name}

use_configure   no

set CXXFLAGS        ${configure.cxxflags}
set LDFLAGS         ${configure.ldflags}
if {[variant_isset universal]} {
    append CXXFLAGS    " ${configure.universal_cxxflags}"
    append LDFLAGS     " ${configure.universal_ldflags}"
} else {
    append CXXFLAGS    " ${configure.cxx_archflags}"
    append LDFLAGS     " ${configure.cc_archflags}"
}

if {[tbool configure.ccache]} {
    configure.cxx "ccache ${configure.cxx}"
}

build.env-append CXX="[join ${configure.cxx} " "]"
build.env-append CXXFLAGS="${CXXFLAGS}"
build.env-append LDFLAGS="${LDFLAGS}"
build.args      -f makefile.unix

destroot {
	set docdir ${prefix}/share/doc/${name}

	xinstall -d ${destroot}${docdir}
	xinstall ${worksrcpath}/${name} ${destroot}${prefix}/bin
	xinstall -m 0644 -W ${worksrcpath} license.txt readme.txt ${destroot}${docdir}
}

variant universal {}

livecheck.type  regex
livecheck.url   ${homepage}rar_add.htm
livecheck.regex ${my_name}-(\\d+(?:\\.\\d+)*)
