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.10.1.tar.gz"
CHECKSUM_MD5="b9b2fdb957f50ada62d73f43ee75d044"
REVISION="6"
ARCHITECTURES="x86_gcc2 x86 x86_64"

PATCHES="perl-5.10.1.patch"

PROVIDES="
	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:libnetcfg = $portVersion compat >= 5
	cmd:perl = $portVersion compat >= 5
	cmd:perl5.10.1 = $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:s2p = $portVersion compat >= 5
	cmd:shasum = $portVersion compat >= 5
	cmd:splain = $portVersion compat >= 5
	cmd:xsubpp = $portVersion compat >= 5
	lib:libperl = $portVersion compat >= 5
	"
REQUIRES="
	haiku >= $haikuVersion
	"
BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	haiku_devel >= $haikuVersion
	cmd:gcc
	cmd:ld
	cmd:make
	cmd:sed
	"

GLOBAL_WRITABLE_FILES="
	non-packaged/lib/perl5/site_perl/5.10.1/BePC-haiku directory
	"

BUILD_PACKAGE_ACTIVATION_PHASE=INSTALL

BUILD()
{
	./Configure \
		-Dprefix=$prefix \
		-Dprivlib=$prefix/lib/perl5/core_perl/$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_LIB_DIRECTORY) $(finddir B_COMMON_LIB_DIRECTORY) $(finddir B_SYSTEM_LIB_DIRECTORY)" \
		-Dusrinc="$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/headers/posix" \
		-Dlocinc="$(finddir B_USER_CONFIG_DIRECTORY)/develop/headers $(finddir B_COMMON_DEVELOP_DIRECTORY)/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" -de

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

	make $jobArgs
}

INSTALL()
{
	eval $(./miniperl "-I$relativeLibDir" -V:archname)
	make install
	cd "$binDir"
	chmod a+x perl psed pstruct perlthanks
	cd "$libDir"
	ln -sf perl5/core_perl/5.10.1/$archname/CORE/libperl.so .

	# The "site-perl" stuff is automatically created, when necessary, so we can
	# as well remove it.
	rm -r $prefix/non-packaged
}
