DESCRIPTION="Robust, small and high performance http and reverse proxy server"
SUMMARY="nginx [engine x] is an HTTP and reverse proxy server, a mail proxy \
server, and a generic TCP proxy server, originally written by Igor Sysoev. \
For a long time, it has been running on many heavily loaded Russian sites \
including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, nginx \
served or proxied 21.89% busiest sites in June 2015."
HOMEPAGE="http://nginx.org/"
COPYRIGHT="2002-2014 Igor Sysoev
	2011-2014 Nginx, Inc."
# "it's complicated", cf. http://packages.gentoo.org/package/www-servers/nginx
#TODO: sort this out
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="hg+http://hg.nginx.org/nginx#f87afb46ccd2"
#CHECKSUM_SHA256=""
PATCHES="nginx-1.7.4_hg.diff"

ARCHITECTURES="?x86_gcc2 ?x86 ?x86_64"

#FIXME: on ./auto/configure:
#grep: /etc/group: No such file or directory

PROVIDES="
	nginx$secondaryArchSuffix = $portVersion
	cmd:nginx$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
	
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpcre$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc${secondaryArchSuffix}
	cmd:ld${secondaryArchSuffix}
	cmd:make
	cmd:ranlib
	cmd:sed
	cmd:find
	"

GLOBAL_WRITABLE_FILES="
	settings/nginx directory
	"

BUILD()
{
	./auto/configure --prefix=$prefix \
		--sbin-path=$binDir/nginx \
		--doc-prefix=$docDir \
		--conf-path=$settingsDir/nginx/nginx.conf \
		--error-log-path=$localStateDir/log/error.log \
		--http-log-path=$localStateDir/log/access.log \
		--pid-path=$localStateDir/nginx.pid \
		--lock-path=$localStateDir/nginx.lock \
		--with-debug

	make
}

INSTALL()
{
	mkdir -p $binDir
	mkdir -p $docDir
	make install
}
