# $Id: Portfile 60745 2009-11-21 20:41:34Z landonf@macports.org $

PortSystem 1.0
name			nsis
version			2.45
categories		devel win32
platforms		darwin
maintainers		landonf openmaintainer
homepage		http://nsis.sourceforge.net/
description		NSIS is a tool for creating win32 installers.
long_description	NSIS (Nullsoft Scriptable Install System) is a tool \
			that allows programmers to create software installers \
			for Windows. It is released under an open source \
			license and is completely free for any use.

master_sites		sourceforge

distfiles		nsis-${version}-src.tar.bz2 \
			nsis-${version}.zip
checksums		nsis-${version}-src.tar.bz2 \
				md5     91a167a19c75f8dd52654e4cdc2ae0d4 \
                    		sha1    ce02adf68dbedc798615ffb212d27a9b03d5defb \
                    		rmd160  c5b1abdac37892b3f49455fa42d44c030dc451b7 \
			nsis-${version}.zip \
            		        md5     8fb39ec61b003653968c0f1c6b6dc73f \
                    		sha1    d956939a4aa0cc78c72a93f236b121c40e0c4bc9 \
                    		rmd160  327d0ed9ebdfab44ecaf71c7b4a83c8b874f7519

worksrcdir		nsis-${version}-src
use_bzip2		yes

depends_build		port:scons port:i386-mingw32-gcc

extract.only		nsis-${version}-src.tar.bz2

post-extract {
	system "cd ${workpath} && unzip ${distpath}/nsis-${version}.zip"
}

use_configure		no

# nsis can only ever be built 32-bit, but relies on libiconv. Since the dependency is limited to only iconv,
# we will rely on the base system 32-bit libiconv installation. Should MacPorts switch to 32-bit/64-bit universal
# builds by default, this decision should be revisited.
set scons.args		"PREFIX=\"${prefix}\" PREFIX_DEST=\"${destroot}\" SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all"
# APPEND_CPPPATH=\"${prefix}/include\" APPEND_LIBPATH=\"${prefix}/lib\"

build {
	system "cd ${worksrcpath} && scons ${scons.args}"
}

destroot {
	system "cd ${worksrcpath} && scons ${scons.args} install"
	foreach dir {Bin Docs Include Plugins Contrib Examples Menu Stubs} {
		file delete -force ${destpath}${prefix}/share/nsis/${dir}
		file copy -force ${workpath}/nsis-${version}/${dir} ${destpath}${prefix}/share/nsis
	}
	system "chmod -R go-w '${destpath}${prefix}/share/nsis'"
}
