SUMMARY="A version of Firefox 2 for Haiku"
DESCRIPTION="Bezilla is an open source web browser. \
It achieves balance between ease of use and customization, catering to the \
needs of both casual and power users."
HOMEPAGE="https://github.com/mmadia/bezilla"
SOURCE_URI="git+https://github.com/mmadia/bezilla.git#686254"
REVISION="1"
LICENSE="MPL v1.1"
COPYRIGHT="1998-1999 Netscape Communications Corporation"

ARCHITECTURES="x86_gcc2 x86 ?arm"
SECONDARY_ARCHITECTURES="x86_gcc2 x86 ?arm"

PROVIDES="
	bezilla$secondaryArchSuffix = $portVersion
	cmd:firefox$secondaryArchSuffix = $portVersion
	app:BeZilla$secondaryArchSuffix = $portVersion
	"

REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libidl$secondaryArchSuffix
	devel:libglib$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:m4
	cmd:gawk
	cmd:perl
	cmd:xargs
	cmd:tar
	cmd:zip
	cmd:autoconf_2.13$secondaryArchSuffix
	"

PATCHES="bezilla-2.0.0.22.patchset"

BUILD()
{
	cd mozilla
	autoconf-2.13

	pushd nsprpub
	autoconf-2.13
	popd

	pushd directory/c-sdk
	autoconf-2.13
	popd

	export MOZCONFIG=../supporting-files/mozilla-configs/browser.mozconfig

	runConfigure --omit-dirs 'docDir dataRootDir' configure
	make $jobArgs
}

INSTALL()
{
	cd mozilla
	make install

	mkdir $appsDir

	mv $libDir/firefox-2.0.0.22pre $appsDir/BeZilla
	mv $appsDir/BeZilla/firefox-bin $appsDir/BeZilla/BeZilla

	# creating the lib and add-ons
	mkdir $appsDir/BeZilla/lib
	mkdir $appsDir/BeZilla/add-ons

	# arranging the files in lib and add-ons directories
	cd $appsDir/BeZilla
	mv libnspr4.so libnss3.so libnssutil3.so libplc4.so libplds4.so \
	libsmime3.so libsoftokn3.so libsqlite3.so libssl3.so libxpcom.so \
	libxpcom_compat.so libxpcom_core.so lib

	mv libfreebl3.so libnssckbi.so libnssdbm3.so libxpistub.so add-ons

	cp $sourceDir/supporting-files/persdict.dat $appsDir/BeZilla/defaults/profile
	cp $sourceDir/supporting-files/haiku-widget-theme/browser/classic.jar $appsDir/BeZilla/chrome

	ln -sf ../lib/libsoftokn3.so add-ons

	fixPkgconfig

	packageEntries devel \
		$developDir \
		$dataDir/idl \
		$dataDir/aclocal \
		$binDir/firefox-config

	# TODO: fix $dist_bin/$MOZILLA_BIN in cmd:firefox script

	addAppDeskbarSymlink $appsDir/BeZilla/BeZilla
}

# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	bezilla${secondaryArchSuffix}_devel = $portVersion
	cmd:firefox_config$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	bezilla$secondaryArchSuffix == $portVersion base
	"
