# $Id: Portfile,v 1.7 2006/06/13 20:10:36 takanori Exp $

PortSystem        1.0
name              FDclone
version           2.08d
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 bafdb09d7945c902d323f148059cff79 \
		  sha1 9439b6a36767ca95a93d399d79019786ffef6f35 \
		  rmd160 9dca54b2f462c1e731baa0454783c2b8dfd8b6d3

set editor ""
set pager ""

worksrcdir        FD-${version}
patchfiles	  nojmaninstall.patch
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 {set editor emacs}
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 {}
