# $Id: Portfile 67842 2010-05-19 15:23:11Z dluke@macports.org $

PortSystem 1.0
PortGroup muniversal 1.0

name			clamav
version		 	0.96.1
categories	  	sysutils
maintainers	 	geeklair.net:dluke
description	 	clamav antivirus software

long_description	Clam AntiVirus is a GPL anti-virus toolkit for UNIX. The \
			main purpose of this software is the integration with mail \
			servers (attachment scanning).
		
license			GPL	
homepage		http://www.clamav.net
master_sites		sourceforge
checksums	md5	38e7870db6e9ad0e569518499a6f3651 \
		sha1	cdb24490f402748cbfb57cc87592fe77b470e0a5 \
		rmd160	f0708b921c8b01a4309fe741ec141ab8cbdf2351

platforms	   	darwin
configure.args  	--mandir=${prefix}/share/man \
			--with-zlib=${prefix}

use_parallel_build	yes

depends_lib		port:libiconv port:zlib port:bzip2 port:ncurses

set merger_dont_diff	${prefix}/bin/clamav-config

platform darwin 7 {
			patchfiles-append patch-clamdtop.c.diff
			#workaround gcc bug 28045 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28045
			configure.cflags {-O0}
			}

platform darwin 8 {
			configure.cflags {-O0}
		}

post-destroot {
			file rename "${destroot}${prefix}/etc/freshclam.conf" "${destroot}${prefix}/etc/example-freshclam.conf"
			file rename "${destroot}${prefix}/etc/clamd.conf" "${destroot}${prefix}/etc/example-clamd.conf"
			
			#muniversal should allow this to be hooked in some way that's less gross
			#this code copied from nspr's portfile
			if {[variant_isset universal]} {
				copy ${destroot}${prefix}/bin/${build_arch}-clamav-config ${destroot}${prefix}/bin/bak-config
				foreach file [glob ${destroot}${prefix}/bin/*clamav-config] {
					delete $file
					}
				move ${destroot}${prefix}/bin/bak-config ${destroot}${prefix}/bin/clamav-config
				reinplace "s|-arch ${build_arch}||g" ${destroot}${prefix}/bin/clamav-config
				reinplace "s|-L\$\{exec_prefix\}/lib/${build_arch}||g" ${destroot}${prefix}/bin/clamav-config
				}
			}

variant clamav_milter description {build with libmilter support} {
			depends_lib-append port:libmilter
			configure.args-append --enable-milter
			post-destroot {
				file rename "${destroot}${prefix}/etc/clamav-milter.conf" "${destroot}${prefix}/etc/example-clamav-milter.conf"
				}
			}

livecheck.type		regex
livecheck.url		http://sourceforge.net/projects/clamav/files
livecheck.regex		${name}-(\\d+.\\d+.\\d+)${extract.suffix}
