# $Id: Portfile,v 1.3 2005/10/19 08:10:12 blb Exp $

PortSystem			1.0
name				unicodeconverter-java
version				1.1
categories			java textproc unicode
maintainers			blb@opendarwin.org
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			md5 4ed03336f2916de652137d8a14251e89

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} Uni.jar ${destroot}/${prefix}/share/java
	xinstall -m 644 -W ${worksrcpath} readme.html versionchanges.html \
		${destroot}/${prefix}/share/doc/${name}
	# Build a nice .app
	if {[variant_isset darwin]} {
		set ucAppPath ${destroot}/Applications/DarwinPorts/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} Uni.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
		}
	}
}

# So it gets set, when applicable
variant darwin {
}

