SUMMARY="Erlang/OTP"
DESCRIPTION="
Erlang is a programming language used to
build massively scalable soft real-time systems with
requirements on high availability. Some of its uses
are in telecoms, banking, e-commerce, computer
telephony and instant messaging. Erlang's runtime
system has built-in support for concurrency, distribution and fault tolerance." 
HOMEPAGE="http://www.erlang.org" 
SRC_URI="http://www.erlang.org/download/otp_src_R16B03.tar.gz"
CHECKSUM_SHA256="6133b3410681a5c934e54c76eee1825f96dead8d6a12c31a64f6e160daf0bb06"
ARCHITECTURES="x86_gcc2 x86"
LICENSE="EPL"
REVISION="1"
COPYRIGHT="1997-2013 Ericsson AB"
SOURCE_DIR="otp_src_R16B03"
PATCHES="erlang_R16B03_haiku.patch"

PROVIDES="
	erl = $portVersion
	cmd:erl = $portVersion
	cmd:ct_run = $portVersion
	cmd:dialyzer = $portVersion
	cmd:epmd = $portVersion
	cmd:erlc = $portVersion
	cmd:escript = $portVersion
	cmd:run_erl = $portVersion
	cmd:to_erl = $portVersion
	cmd:typer = $portVersion
	"

REQUIRES="
	haiku >= $haikuVersion
	cmd:libtool
	cmd:perl
	cmd:gcc
	"

BUILD_PREREQUIRES="
	haiku_devel >= $haikuVersion
	cmd:perl
	cmd:make
	cmd:gcc
	cmd:tar
	cmd:uname
	devel:libncurses
	devel:libssl
	devel:libcrypto
	"
ERLANG_CFLAGS="-DETHR_X86_OUT_OF_ORDER -DHAVE_NET_IF_DL_H -DETHR_HAVE_ETHREAD_DEFINES -DETHR_PTHREADS -DETHR_SIZEOF_PTR=4 -DHAVE_CONFIG_H -I../i586-pc-haiku -I../../i586-pc-haiku -I../include/internal -I../../include/internal -I../../emulator/sys/unix -I../../include/i586-pc-haiku -I../../emulator/beam -I../../../erts/include/internal/i586-pc-haiku -I../../../erts/i586-pc-haiku -Imisc -I../include -Iepmd -Iconnect -I../../../erts/emulator/beam -I../../../erts/include/i586-pc-haiku -I../../../../erts/emulator/beam -I../../../../erts/include/i586-pc-haiku -I../../../../erts/i586-pc-haiku"

BUILD()
{
	rm -rf `finddir B_SYSTEM_SETTINGS_DIRECTORY`/network
	mkdir -p `finddir B_SYSTEM_SETTINGS_DIRECTORY`/network
	touch `finddir B_SYSTEM_SETTINGS_DIRECTORY`/network/hostname
	runConfigure --omit-dirs "docDir dataRootDir" configure --prefix="$prefix" --disable-ipv6 --disable-hipe LDFLAGS="-lnetwork"
	echo "#undef ERTS_SMP" >> erts/i586-pc-haiku/config.h
	echo "#undef USE_THREADS" >> erts/i586-pc-haiku/config.h
	echo "Skip" > lib/megaco/SKIP
	HOME=/boot/home make CFLAGS="$ERLANG_CFLAGS"
}

INSTALL()
{
	HOME=/boot/home make CFLAGS="$ERLANG_CFLAGS" install
}