SUMMARY="Professional Pascal compiler"
DESCRIPTION="Free Pascal is a 32, 64 and 16 bit professional Pascal compiler. \
It can target many processor architectures: Intel x86 (including 8086), AMD64\
/x86-64, PowerPC, PowerPC64, SPARC, ARM, AArch64, MIPS and the JVM. \
Supported operating systems include Linux, FreeBSD, Haiku, Mac OS X/iOS/\
iPhoneSimulator/Darwin, DOS (16 and 32 bit), Win32, Win64, WinCE, OS/2, \
MorphOS, Nintendo GBA, Nintendo DS, Nintendo Wii, Android, AIX and AROS. \
Additionally, support for the Motorola 68k architecture is available in the \
development versions."
HOMEPAGE="https://freepascal.org/"
COPYRIGHT="1993-2015 Florian Klaempfl and others"
LICENSE="
	GNU LGPL v3
	GNU GPL v3"
REVISION="3"
SOURCE_URI="https://sourceforge.net/projects/freepascal/files/Haiku/$portVersion/fpc-$portVersion.i386-haiku.tar"
CHECKSUM_SHA256="c5d618fcb11275f0b7b2b0a18319dea46b97401d1cb17eab21fae5e6334579ca"
SOURCE_DIR="fpc-$portVersion.i386-haiku"

ARCHITECTURES="x86_gcc2"
DISABLE_SOURCE_PACKAGE="YES"

POST_INSTALL_SCRIPTS="
	boot/post-install/createcfg.sh
"

PROVIDES="
	fpc_bin = $portVersion
	cmd:bin2obj = $portVersion
	cmd:chmcmd = $portVersion
	cmd:chmls = $portVersion
	cmd:cvsco.tdf = $portVersion
	cmd:cvsdiff.tdf = $portVersion
	cmd:cvsup.tdf = $portVersion
	cmd:data2inc = $portVersion
	cmd:delp = $portVersion
	cmd:fd2pascal = $portVersion
	cmd:fp = $portVersion
	cmd:fp.ans = $portVersion
	cmd:fpc = $portVersion
	cmd:fpcjres = $portVersion
	cmd:fpclasschart = $portVersion
	cmd:fpcmake = $portVersion
	cmd:fpcmkcfg = $portVersion
	cmd:fpcres = $portVersion
	cmd:fpcsubst = $portVersion
	cmd:fpdoc = $portVersion
	cmd:fppkg = $portVersion
	cmd:fprcp = $portVersion
	cmd:gplprog.pt = $portVersion
	cmd:gplunit.pt = $portVersion
	cmd:grep.tdf = $portVersion
	cmd:h2pas = $portVersion
	cmd:h2paspp = $portVersion
	cmd:instantfpc = $portVersion
	cmd:makeskel = $portVersion
	cmd:makeskel.rsj = $portVersion
	cmd:mkarmins = $portVersion
	cmd:mkinsadd = $portVersion
	cmd:mkx86ins = $portVersion
	cmd:pas2fpm = $portVersion
	cmd:pas2jni = $portVersion
	cmd:pas2ut = $portVersion
	cmd:plex = $portVersion
	cmd:postw32 = $portVersion
	cmd:ppc386 = $portVersion
	cmd:ppdep = $portVersion
	cmd:ppudump = $portVersion
	cmd:ppufiles = $portVersion
	cmd:ppumove = $portVersion
	cmd:program.pt = $portVersion
	cmd:ptop = $portVersion
	cmd:ptop.rsj = $portVersion
	cmd:pyacc = $portVersion
	cmd:rmcvsdir = $portVersion
	cmd:rstconv = $portVersion
	cmd:tpgrep.tdf = $portVersion
	cmd:unit.pt = $portVersion
	cmd:unitdiff = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncurses >= 6.0
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel >= r1~alpha4_pm_hrev51411
	"
BUILD_PREREQUIRES="
	binutils
	cmd:tar
	"

BUILD()
{
	true
}

INSTALL()
{
	for f in `tar tf binary.i386-haiku.tar`; do
		tar -xOf binary.i386-haiku.tar $f | tar -C $prefix -xzf -
	done
	mkdir -p $docDir/examples
	ln -s ../lib/fpc/$portVersion/ppc386 ../../packaging/fpc_bin/bin/ppc386
	mkdir -p ../../packaging/fpc_bin/lib/fpc/etc
	rm -dR $prefix/{doc,share}

	# create post script
	mkdir -p $prefix/boot/post-install
	echo "#!/bin/sh" > $postInstallDir/createcfg.sh
	echo "/boot/system/lib/fpc/$portVersion/samplecfg /boot/system/lib/fpc/$portVersion /etc
" >$postInstallDir/createcfg.sh
	chmod 755 $postInstallDir/createcfg.sh
}
