# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 46155 2009-01-30 17:25:49Z krischik@macports.org $

PortSystem 1.0

name				free42
version				1.4.44
revision			1
platforms			darwin
categories			emulators
maintainers			krischik@me.com
description			a HP-42s Simulator
long_description	Free42 is a complete re-implementation of the HP-42S	\
					calculator and the HP-82240 printer. Free42 was written \
					from scratch, without using any HP code. You do not		\
					need any ROM images in order to use it, yet it is fully \
					HP-42S compatible.

homepage			http://free42.sourceforge.net/
master_sites		sourceforge

set prog			free42.${version}.tgz
set skin			Free42Skins.zip

distfiles			${prog}	\
					${skin}

extract.only		${prog}

checksums			${prog} sha1 a116ab15c3d7faef0bfd9b1e59426964248b4242	\
					${skin} sha1 db0c327224fa163423003e287bee58e7f906f7b8

depends_lib			port:gtk2					\
					path:${prefix}/bin/zsh:zsh

build.env-append LIBS="-lm -lXm -lXpm -lXp -lXmu -lXt -lX11"

worksrcdir			${name}
use_parallel_build	yes
use_configure		no

post-extract {
    system "unzip -q ${distpath}/${skin} -d ${workpath}/skin"
}

build {
	reinplace "s|CXXFLAGS := |CXXFLAGS := -DNO_SINCOS |g" ${workpath}/free42/gtk/Makefile
	system "
	cd ${workpath}/free42/gtk;
	unset BCD_MATH
	make
	make clean
	make -e BCD_MATH=1"
}

destroot {
	xinstall -m 775 -d ${destroot}${prefix}/share/free42
	xinstall -m 775 -d ${destroot}${applications_dir}

	xinstall -m 444											\
		-W ${workpath}/skin									\
		42ck.gif											\
		42ck.layout											\
		42ct.gif											\
		42ct.layout											\
		Ehrling42sl.gif										\
		Ehrling42sl.layout									\
		Ehrling42sm.gif										\
		Ehrling42sm.layout									\
		HP42S.gif											\
		HP42S.layout										\
		KR.gif												\
		KR.layout											\
		Khor.gif											\
		Khor.layout											\
		"Michaels HP.gif"									\
		"Michaels HP.layout"								\
		Original.gif										\
		Original.layout										\
		README.txt											\
		SemiAuto42.gif										\
		SemiAuto42.layout									\
		SemiAuto42b.gif										\
		SemiAuto42b.layout									\
		SemiReal42.gif										\
		SemiReal42.layout									\
		Standard.gif										\
		Standard.layout										\
		Voyager42.gif										\
		Voyager42.layout									\
		Widgi42.gif											\
		Widgi42.layout										\
		${destroot}${prefix}/share/free42

	xinstall -m 775											\
		-W ${workpath}/free42/gtk							\
		free42bin											\
		free42dec											\
		${destroot}${prefix}/bin

	xinstall -m 755															\
		-W ${filespath}														\
		Free42-Decimal.command.in											\
		${destroot}${applications_dir}/Free42-Decimal.command
	reinplace																\
		s|@PREFIX@|${prefix}|g												\
		${destroot}${applications_dir}/Free42-Decimal.command
	system "SetFile -a E ${destroot}${applications_dir}/Free42-Decimal.command"
	xinstall -m 755															\
		-W ${filespath}														\
		Free42-Binary.command.in											\
		${destroot}${applications_dir}/Free42-Binary.command
	reinplace																\
		s|@PREFIX@|${prefix}|g												\
		${destroot}${applications_dir}/Free42-Binary.command
	system "SetFile -a E ${destroot}${applications_dir}/Free42-Binary.command"
}

############################################################ {{{1 ###########
# vim: set nowrap tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab :
# vim: set textwidth=0 filetype=tcl foldmethod=marker nospell :
