SUMMARY="Larry Wall's Practical Extraction and Report Language"
DESCRIPTION="
Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix \
scripting language to make report processing easier.

Perl borrows features from other programming languages including C, shell \
scripting (sh), AWK, and sed. The language provides powerful text processing \
facilities without the arbitrary data-length limits of many contemporary Unix \
tools, facilitating easy manipulation of text files.

In addition to CGI, Perl is used for graphics programming, system \
administration, network programming, finance, bioinformatics, and other \
applications. Perl is nicknamed 'the Swiss Army chainsaw of scripting \
languages' because of its flexibility and power, and possibly also because of \
its perceived 'ugliness'.
"
HOMEPAGE="http://www.perl.org/"
COPYRIGHT="1993-2009 Larry Wall and others"
LICENSE="GNU GPL v1
	Artistic (Perl)"
SRC_URI="http://www.cpan.org/src/perl-5.18.2.tar.gz"
CHECKSUM_SHA256="7cbed5ef11900e8f68041215eea0de5e443d53393f84c41d5c9c69c150a4982f"
REVISION="2"
ARCHITECTURES="x86_gcc2 x86 x86_64 arm"

PATCHES="perl-5.18.1.patchset"

PROVIDES="
	# assume that any perl commands are backwards compatible to version 5.
	perl = $portVersion compat >= 5
	cmd:a2p = $portVersion compat >= 5
	cmd:c2ph = $portVersion compat >= 5
	cmd:config_data = $portVersion compat >= 5
	cmd:corelist = $portVersion compat >= 5
	cmd:cpan = $portVersion compat >= 5
	cmd:cpan2dist = $portVersion compat >= 5
	cmd:cpanp = $portVersion compat >= 5
	cmd:cpanp_run_perl = $portVersion compat >= 5
	cmd:dprofpp = $portVersion compat >= 5
	cmd:enc2xs = $portVersion compat >= 5
	cmd:find2perl = $portVersion compat >= 5
	cmd:h2ph = $portVersion compat >= 5
	cmd:h2xs = $portVersion compat >= 5
	cmd:instmodsh = $portVersion compat >= 5
	cmd:json_pp = $portVersion compat >= 5
	cmd:libnetcfg = $portVersion compat >= 5
	cmd:perl = $portVersion compat >= 5
	cmd:perl$portVersion = $portVersion compat >= 5
	cmd:perlbug = $portVersion compat >= 5
	cmd:perldoc = $portVersion compat >= 5
	cmd:perlivp = $portVersion compat >= 5
	cmd:perlthanks = $portVersion compat >= 5
	cmd:piconv = $portVersion compat >= 5
	cmd:pl2pm = $portVersion compat >= 5
	cmd:pod2html = $portVersion compat >= 5
	cmd:pod2latex = $portVersion compat >= 5
	cmd:pod2man = $portVersion compat >= 5
	cmd:pod2text = $portVersion compat >= 5
	cmd:pod2usage = $portVersion compat >= 5
	cmd:podchecker = $portVersion compat >= 5
	cmd:podselect = $portVersion compat >= 5
	cmd:prove = $portVersion compat >= 5
	cmd:psed = $portVersion compat >= 5
	cmd:pstruct = $portVersion compat >= 5
	cmd:ptar = $portVersion compat >= 5
	cmd:ptardiff = $portVersion compat >= 5
	cmd:ptargrep = $portVersion compat >= 5
	cmd:s2p = $portVersion compat >= 5
	cmd:shasum = $portVersion compat >= 5
	cmd:splain = $portVersion compat >= 5
	cmd:xsubpp = $portVersion compat >= 5
	cmd:zipdetails = $portVersion compat >= 5
	# vendor_perl refers to the path to packaged perl modules, which includes
	# the full perl version, so it isn't backwards compatible to anything else.
	vendor_perl = $portVersion
	# It is unclear which kind of backwards compatibility libperl.so 
	# implements, so we assume none.
	lib:libperl = $portVersion
	"
REQUIRES="
	haiku >= $haikuVersion
	"
BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	haiku_devel >= $haikuVersion
	cmd:awk
	cmd:gcc
	cmd:ld
	cmd:make
	cmd:sed
	"

perlArchName="$(uname -m)-haiku"

GLOBAL_WRITABLE_FILES="
	non-packaged/lib/perl5/site_perl/$portVersion/sitecustomize.pl keep-old
	non-packaged/lib/perl5/site_perl/$portVersion/$perlArchName directory keep-old
	"

BUILD_PACKAGE_ACTIVATION_PHASE=INSTALL

BUILD()
{
	./Configure \
		-Dprefix=$prefix \
		-Dprivlib=$prefix/lib/perl5/$portVersion \
		-Dsiteprefix=$prefix/non-packaged \
		-Dsitelib=$prefix/non-packaged/lib/perl5/site_perl/$portVersion \
		-Dvendorprefix=$prefix \
		-Dvendorlib=$prefix/lib/perl5/vendor_perl/$portVersion \
		-Dcf_email=zooey@hirschkaefer.de \
		-Uusenm -Duseshrplib -Uusemymalloc \
		-Dlibpth="$(finddir B_USER_DEVELOP_DIRECTORY)/lib $(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib" \
		-Dusrinc="$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/headers/posix" \
		-Dlocinc="$(finddir B_USER_CONFIG_DIRECTORY)/develop/headers $(finddir B_SYSTEM_DEVELOP_DIRECTORY)/headers" \
		-Dlibc="'$(finddir B_SYSTEM_LIB_DIRECTORY)/libroot.so'" \
		-Dlibs=-lnetwork -Dcc=gcc -Dld=gcc \
		-Ud_link -Ddont_use_nlink -Ud_syserrlst \
		-Dldlibpthname=LIBRARY_PATH -Dstartperl="#! perl" \
		-Dccdlflags="-Wl,-rpath=$libDir/perl5/$portVersion/$perlArchName/CORE" \
		-Dusesitecustomize \
		-de

	# force-remove path from sed
	sed -i -e 's/LOC_SED\s*"\/bin\/sed/LOC_SED "sed/' config.h

	make $jobArgs
}

INSTALL()
{
	make install
	chmod a+x $binDir/{perl,psed,pstruct,perlthanks}

	# copy script into site_perl that takes care of massaging @INC into what we need.
	cp sitecustomize.pl $prefix/non-packaged/lib/perl5/site_perl/$portVersion/
}

TEST()
{
	make test
}
