# Contributor: Sodface <sod@sodface.com>
# Maintainer: Sodface <sod@sodface.com>
pkgname=althttpd
pkgver=202405010759
pkgrel=0
pkgdesc="Small, simple, stand-alone HTTP server"
url="https://sqlite.org/althttpd/doc/trunk/althttpd.md"
arch="all"
license="Public-Domain"
makedepends="openssl-dev>3 sqlite-dev"
options="!check" # no test suite
subpackages="$pkgname-doc $pkgname-openrc $pkgname-utils"
source="
	$pkgname-$pkgver.tar.gz::https://sqlite.org/althttpd/tarball?r=$pkgver
	10-allow-filename-plus-sign.patch
	$pkgname.confd
	$pkgname.initd
	"
builddir="$srcdir"

build() {
	sed -in -e 's/^CFLAGS=/CFLAGS+=/' Makefile
	make althttpsd logtodb
}

package() {
	install -Dm 644 "$srcdir"/althttpd.confd \
		"$pkgdir"/etc/conf.d/althttpd
	install -Dm 755 "$srcdir"/althttpd.initd \
		"$pkgdir"/etc/init.d/althttpd
	install -D althttpsd \
		"$pkgdir"/usr/bin/althttpd
	install -D logtodb \
		"$pkgdir"/usr/bin/logtodb
	install -Dm644 althttpd.md \
		"$pkgdir"/usr/share/doc/$pkgname/althttpd.md
}

utils() {
	pkgdesc="$pkgname utilities"

	amove /usr/bin/logtodb
}

sha512sums="
c99bbd7cd5cb844bffa62d154c91b0275071ed7acc5f9f5021fbdd9e8fc07478dc990a8615644e1d57ab4d39250fd0ac65efdc0f7cfb70fba5a0b2fe9a2e5524  althttpd-202405010759.tar.gz
ece2633a822589f1e49129bf00fb4b066e9d079e3e56f7c78e3bcba02c8aad9ae3ee75f6459360524d7c2a3a7dc7cfea4eb1652b4cbf1aff60d968e1f816b535  10-allow-filename-plus-sign.patch
41f0015f98f108067b42a4a2487c7c89653388a1c3c4a94884fedf5f704f05cdcc189ea81e7a01a8ec8408045b72ee06b6f1063e5b7cd5e67318d42b4c0add89  althttpd.confd
f21867430470b836d97d60215d9dda835125140cced3bb9c856349228572f2c73ac0574d3f705d72938879fc2b5a37855768a5f7de5c29943e3aa6ead5d72d9c  althttpd.initd
"
