#Packager: Dimitris Tzemos <djemos~at~gmail~dot~com>

pkgname=unifdef
pkgver=2.12
pkgrel=1dj
source=("https://dotat.at/prog/unifdef/$pkgname-$pkgver.tar.xz" "unifdef-2.12-c23.patch" 
"unifdef-2.12-fortify.patch"
"unifdef-2.12-tests.patch ") 
url=https://dotat.at/prog/unifdef/
docs=("COPYING" "README" "Changelog.gz")

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"unifdef (selectively processes C conditional compilation)"
"The unifdef utility selectively processes conditional C preprocessor"
"#if and #ifdef directives. It removes from a file both the directives"
"and the additional text that they delimit, while otherwise leaving"
"the file alone."
)


build() {
	cd $startdir/src/$pkgname-$pkgver
	patch -p1 < $startdir/src/unifdef-2.12-c23.patch || return 1
	patch -p1 < $startdir/src/unifdef-2.12-fortify.patch || return 1
	patch -p1 < $startdir/src/unifdef-2.12-tests.patch || return 1

	make DESTDIR=$startdir/pkg|| return 1
	
	mkdir -p $startdir/pkg/usr/bin $startdir/pkg/usr/man/man1
	# Test suite fails 1 of the 90 tests. The test itself is
	# broken: it expects to be run as a non-root user.
	[ "${TESTSUITE:-no}" = "yes" ] && rm -f tests/outeperm.* && make test

	# manual install = less code than hacking 'make install'
	install -s -m0755 $pkgname $startdir/pkg/usr/bin
	install -m0755 ${pkgname}all.sh $startdir/pkg/usr/bin/${pkgname}all
	gzip -9c < $pkgname.1 > $startdir/pkg/usr/man/man1/$pkgname.1.gz
	ln -s $pkgname.1.gz $startdir/pkg/usr/man/man1/${pkgname}all.1.gz

	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
	gzip -9 Changelog # it's bloody enormous
	cp -a COPYING README Changelog.gz $startdir/pkg/usr/doc/$pkgname-$pkgver

} 
