# $Id: Portfile,v 1.5 2005/10/19 08:10:14 blb Exp $

PortSystem			1.0
name				lsof
version				4.70
categories			sysutils
maintainers			blb@opendarwin.org
description			LiSt Open Files
long_description \
	lsof stands for LiSt Open Files, and it does just that.  It lists \
	information about files that are open by the processes running on a \
	UNIX system.

use_bzip2			yes
distname			${name}_${portversion}

master_sites		ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ \
					ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/ \
					ftp://ftp.tau.ac.il/pub/unix/admin/ \
					ftp://ftp.ayamura.org/pub/lsof/ \
					ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/ \
					ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/ \
					ftp://ftp.kaizo.org/pub/lsof/ \
					ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/ \
					ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/ \
					ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/ \
					ftp://sunsite.ualberta.ca/pub/Mirror/lsof/ \
					ftp://the.wiretapped.net/pub/security/host-security/lsof/

platforms			darwin sunos
checksums			md5 605c0aa8591adaf05c47bf1b846c6703

post-extract {
	cd ${workpath}/${distname}
	system "tar xf ${distname}_src.tar"
}

worksrcdir			${distname}/${distname}_src

configure.cmd		./Configure
configure.pre_args	-n

post-configure {
	reinplace "s|/\\*.*#define.*HASSECURITY.*1.*\\*/|#define HASSECURITY 1|" \
		${worksrcpath}/machine.h
}

pre-destroot {
	if { $env(USER) != "root" } {
		ui_msg "------------------------------------------------------------"
		ui_msg "Note that you are not installing as root, so lsof will not"
		ui_msg "end up with proper permissions, and probably not work"
		ui_msg "properly"
		ui_msg "------------------------------------------------------------"
	}
}

variant darwin {
	pre-configure {
		cd ${workpath}
		system "${extract.cmd} -dc ${filespath}/macosx_kernel_headers.tar.bz2 \
			${extract.post_args}"
	}
	configure.args-append	darwin
	destroot {
		xinstall -m 2755 -g kmem ${worksrcpath}/lsof ${destroot}/${prefix}/bin
		xinstall -m 444 ${worksrcpath}/lsof.8 \
			${destroot}/${prefix}/share/man/man8
	}
}

platform darwin 6 {
	configure.env-append	DARWIN_XNUDIR=${workpath}/krnhead_lsof/6.x
}

platform darwin 7 {
	configure.env-append	DARWIN_XNUDIR=${workpath}/krnhead_lsof/7.0-2
}

variant sunos {
	configure.args-append	solaris
	# The man page should be done in a generic, global destroot, but
	# destroot-append doesn't seem to allow adding commands to the 
	# destroot phase
	destroot {
		xinstall -m 2755 -g sys ${worksrcpath}/lsof ${destroot}/${prefix}/bin
		xinstall -m 444 ${worksrcpath}/lsof.8 \
			${destroot}/${prefix}/share/man/man8
	}
}

