# $Id: Portfile 79231 2011-06-05 22:52:33Z ryandesign@macports.org $

PortSystem			1.0
name				unicodeconverter-java
version				2.0
categories			java textproc unicode
maintainers			nomaintainer
description			Convert various encodings to UTF-8
long_description \
	UnicodeConverter is a Java program that converts text and HTML files in \
	VNI, VISCII, VPS, TCVN, or VIQR/Vietnet format to Unicode UTF-8. The \
	program, executable in both graphic user interface (GUI) and command-line \
	modes, is capable of converting multiple files in a directory, or an \
	entire directory, including its subdirectories. In effect, this enhanced \
	capability enables conversion of an entire website to Unicode UTF-8 \
	format with one single command or a few mouse clicks.

platforms			darwin

homepage			http://unicodeconvert.sourceforge.net/
master_sites		sourceforge:unicodeconvert
distname			UnicodeConverter-${version}
use_zip				yes

worksrcdir			UnicodeConverter

checksums			sha1    606f0cea9bdeb47e65229f34c0c139a9ad72e807 \
					rmd160  d48b4ac4f2e19393e027b302f8eb044c36c13436

depends_lib			bin:java:kaffe

post-patch {
	reinplace "s|^PROGDIR=.*|PROGDIR=\"${prefix}/share/java\"|" \
		${worksrcpath}/Uni
}

use_configure		no

build				{}

destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/java \
		${destroot}${prefix}/share/doc/${name}
	xinstall -m 755 -W ${worksrcpath} Uni ${destroot}${prefix}/bin
	xinstall -m 644 -W ${worksrcpath} UnicodeConverter.jar ${destroot}${prefix}/share/java
	xinstall -m 644 -W ${worksrcpath} readme.html versionchanges.html \
		${destroot}${prefix}/share/doc/${name}
}

platform darwin {
	# Build a nice .app
	post-destroot {
		set ucAppPath ${destroot}${applications_dir}/UnicodeConverter.app
		# Build paths
		xinstall -m 755 -d ${ucAppPath}/Contents/Resources/Java \
			${ucAppPath}/Contents/MacOS
		# Copy basic package information
		xinstall -m 644 -W ${filespath} Info.plist PkgInfo \
			${ucAppPath}/Contents
		# Set version correctly in Info.plist
		reinplace "s|@@VERSION@@|${version}|g" ${ucAppPath}/Contents/Info.plist
		# Copy the jar into the right place
		xinstall -m 644 -W ${worksrcpath} UnicodeConverter.jar \
			${ucAppPath}/Contents/Resources/Java
		# Copy the stub app
		xinstall -m 755 "/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/MacOS/JavaApplicationStub" \
			${ucAppPath}/Contents/MacOS
		# If Jar Bundler is installed, we can grab the generic icon
		set javaGenericIcon "/Developer/Applications/Java Tools/Jar Bundler.app/Contents/Resources/GenericJavaApp.icns"
		if {[file exists ${javaGenericIcon}]} {
			xinstall -m 644 ${javaGenericIcon} ${ucAppPath}/Contents/Resources
		}
	}
}
