# -*- 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
# $Id: Portfile 108363 2013-07-21 07:51:52Z aschenke@macports.org $

PortSystem       1.0

name		     latexdiff
version		     1.0.3
categories	     tex
maintainers	     aschenke
license             GPL-2
platforms	     darwin
supported_archs	 noarch
description	     determine and mark up significant differences between latex files
long_description latexdiff is a Perl script, which compares two latex files \
                 and marks up significant differences between them (i.e. a \
                 diff for latex files). Various options are available for \
                 visual markup using standard latex packages such as \
                 color.sty. Changes not directly affecting visible text, for \
                 example in formatting commands, are still marked in the latex \
                 source.
homepage         http://latexdiff.berlios.de
master_sites     http://download.berlios.de/${name}

checksums        rmd160  1b1d5b7688787753939f640c9d64de8d569b659a \
                 sha256  6bc83859e209c81c8aee2f8e102c9e50c377ffcf83b3bfbdbceaf790bc3e0d3b

depends_run      path:bin/perl5.12:perl5.12 \
				 port:p5.12-algorithm-diff

configure {
	 	reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5.12|g" \
 		${worksrcpath}/latexdiff-so ${worksrcpath}/latexdiff-vc \
 		${worksrcpath}/latexdiff-fast ${worksrcpath}/latexdiff \
 		${worksrcpath}/latexrevise 
}

build            { }

destroot.destdir INSTALLPATH=${destroot}${prefix} \
                 INSTALLMANPATH=${destroot}${prefix}/share/man

destroot {
	# install scripts
	xinstall -m 755 ${worksrcpath}/latexdiff ${destroot}${prefix}/bin
	xinstall -m 755 ${worksrcpath}/latexdiff-fast ${destroot}${prefix}/bin
	xinstall -m 755 ${worksrcpath}/latexdiff-so ${destroot}${prefix}/bin
	xinstall -m 755 ${worksrcpath}/latexdiff-vc ${destroot}${prefix}/bin
	xinstall -m 755 ${worksrcpath}/latexrevise ${destroot}${prefix}/bin

	# install man pages
	xinstall -m 644 ${worksrcpath}/latexdiff.1 ${destroot}${prefix}/share/man/man1
	xinstall -m 644 ${worksrcpath}/latexdiff-vc.1 ${destroot}${prefix}/share/man/man1
	xinstall -m 644 ${worksrcpath}/latexrevise.1 ${destroot}${prefix}/share/man/man1

	# install docs
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 ${worksrcpath}/doc/latexdiff-man.pdf ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 ${worksrcpath}/doc/latexdiff-man.tex ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 ${worksrcpath}/doc/example-diff.tex ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 ${worksrcpath}/COPYING ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}
	
	# install examples
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}/example
	xinstall -m 644 ${worksrcpath}/example/example-draft.tex ${destroot}${prefix}/share/doc/${name}/example
	xinstall -m 644 ${worksrcpath}/example/example-rev.tex ${destroot}${prefix}/share/doc/${name}/example
}

pre-activate {
    # texlive-bin-extra used to contain latexdiff, but doesn't
    # anymore. If the old version is installed, deactivate it to avoid
    # a conflict.
    if {[file exists $prefix/bin/latexdiff]
        && ![catch {set vers [lindex [registry_active texlive-bin-extra] 0]}]
        && [vercmp [lindex $vers 1] 19536] < 0} {
        registry_deactivate_composite texlive-bin-extra "" [list ports_nodepcheck 1]
    }
}

livecheck.type   regex
livecheck.url    https://developer.berlios.de/project/showfiles.php?group_id=13015
livecheck.regex  [suffix ${name}-(\[0-9.\]+)]
