# $Id: Portfile,v 1.11 2006/08/09 04:28:55 takanori Exp $

PortSystem        1.0
name              FDclone
version           2.08f
revision	  2
categories        sysutils
maintainers       takanori@opendarwin.org
description       File & Directory Maintenance Tool
long_description  ${description}
homepage          http://hp.vector.co.jp/authors/VA012337/soft/fd/index.html
master_sites      http://hp.vector.co.jp/authors/VA012337/soft/fd/ \
		  ftp://ftp.unixusers.net/src/fdclone/
platforms         darwin
distfiles         FD-${version}.tar.gz
checksums	  md5 2cd69c228060b6fa48cca7484d430195 \
		  sha1 dbf9efb257d19ee99ac650002831b61228283742 \
		  rmd160 96a15d679ed2d8804413c58909707b7c3119cba2
depends_lib	  lib:libncurses:ncurses

set editor ""
set pager ""

worksrcdir        FD-${version}
patchfiles	  nojmaninstall.patch patch-log.c patch-kanji.c
post-patch	  {
		  reinplace "s|\$(TOPDIR)/man|\$(TOPDIR)/share/man|g" ${worksrcpath}/Makefile.in

		  if {[variant_isset nojpnmes]} {
		     system "echo \"#define _NOJPNMES\" >> ${worksrcpath}/config.hin"
		  }

		  if {${editor} != ""} { reinplace "s|\"vi\"|\"${editor}\"|g" ${worksrcpath}/fd.h }
		  if {${pager} != ""} { reinplace "s|\"more%K\"|\"${pager}\"|g" ${worksrcpath}/fd.h }

		  if {[variant_isset autosort]} {
		     reinplace "s|SORTTYPE\t0|SORTTYPE\t1|" ${worksrcpath}/fd.h
		     reinplace "s|DISPLAYMODE\t0|DISPLAYMODE\t3|" ${worksrcpath}/fd.h
		     reinplace "s|SORTTREE\t0|SORTTREE\t1|" ${worksrcpath}/fd.h
		  }
}
configure	  {}
build.args	  CONFDIR=${prefix}/etc PREFIX=${prefix}
destroot.args	  BUILD=${destroot} PREFIX=${prefix}

post-destroot   {
		xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}

		foreach f {FAQ* HISTORY* Install* LICENSES* README* TECHKNOW* ToAdmin*} {
			eval xinstall -m 644 [glob ${worksrcpath}/${f}] ${destroot}${prefix}/share/doc/${name}
		}
}

variant nojpnmes {}
variant emacs conflicts vim {set editor emacs}
variant vim conflicts emacs {set editor vim}
variant lv conflicts less jless {set pager lv}
variant less conflicts lv jless {set pager less}
variant jless conflicts lv less {set pager jless}
variant autosort {}

livecheck.check	regex
livecheck.url	${homepage}
livecheck.regex	FD-(\[0-9.a-z\]+)\\\.tar
