### this file is sourced not run
PKGVER=0.16
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=gatling-$PKGVER.tar.xz
MD5SUM=3b703d93996cb7da3edea1306b68b386
SRC_URL=https://www.fefe.de/gatling/$TARBALL
BUNDLE=

LIBOWFAT_TARBALL=libowfat-0.33.tar.xz
LIBOWFAT_MD5SUM=9a921504a478f3134873df8060cc0932
LIBOWFAT_URL=https://www.fefe.de/libowfat/$LIBOWFAT_TARBALL

SLACKREQ='openssl' # we could have used mbedtls - but let's stick with openssl for now
SLACKDESC="gatling: gatling $PKGVER (Small, high performance webserver)
gatling: 
gatling: From the author of dietlibc, gatling is an easy-to-use 
gatling: high-performance webserver supporting HTTP, FTP, SMB, virtual 
gatling: domains, CGI, FCGI, IPv6, FTP uploads, HTTPS, .htaccess, etc
gatling: 
gatling: https://www.fefe.de/gatling/
gatling: 
gatling: 
gatling: 
gatling: 
"

USE_MBEDTLS=

### default pkg_download
### prepare
pkg_prepare() {
	if pkg_check $SRC_DIR $TARBALL $MD5SUM; then
		SRC_URL=$LIBOWFAT_URL &&
		pkg_check $SRC_DIR $LIBOWFAT_TARBALL $LIBOWFAT_MD5SUM &&
		tar -xf $SRC_DIR/$TARBALL -C tmp &&
		tar -xf $SRC_DIR/$LIBOWFAT_TARBALL -C tmp &&

		true
	else
		return 1
	fi
}

### default pkg_package
### build
pkg_build() {
	cd /tmp

	# prepare libowfat
	mv libowfat* libowfat &&
	cd libowfat && make   &&

	# build - only binaries we want
	cd /tmp/gatling* &&
	make gatling dl getlinks bench &&
	if [ $USE_MBEDTLS ]; then
		make ptlsgatling ptlsdl   &&
		mv ptlsgatling tlsgatling &&
		mmv ptlsdl tlsdl
	else
		make tlsgatling tlsdl
	fi &&
	
	# install binaries
	install -m755 gatling tlsgatling /usr/bin    &&
	install -m755 bench /usr/bin/gatling-bench   &&
	install -dm755 /usr/libexec/gatling          &&
	install -m755 dl tlsdl getlinks /usr/libexec/gatling &&

	# install manpage
	install -dm755 /usr/share/man/man1          &&
	install -m644 gatling.1 /usr/share/man/man1 &&
	install -m644 bench.1 /usr/share/man/man1/gatling-bench.1 &&

	# install extra docs
	install -dm755 /usr/share/doc/gatling       &&
	install -m644 README.{antidos,cgi,ftp,htaccess,http,httpbench,php,prefetch,proxy,redirect,tls} \
		/usr/share/doc/gatling &&
	
	pkg_build_slackdesc
}


