# Template file for 'gzdoom'
pkgname=gzdoom
version=4.12.2
revision=2
archs="x86_64* aarch64*"
build_style=cmake
configure_args="-DINSTALL_PK3_PATH=share/gzdoom -DDYN_GTK=OFF -DDYN_OPENAL=OFF"
hostmakedepends="pkg-config"
makedepends="SDL2-devel gtk+3-devel libgomp-devel ZMusic-devel libopenal-devel libvpx-devel libwebp-devel"
short_desc="Advanced Doom source port with OpenGL support"
maintainer="Érico Nogueira <ericonr@disroot.org>"
license="GPL-3.0-or-later"
homepage="https://www.zdoom.org"
# WARNING: watch out for new submodules
distfiles="https://github.com/ZDoom/gzdoom/archive/g${version}.tar.gz
 https://github.com/ZDoom/gzdoom/releases/download/g${version}/gzdoom_${version}_amd64.deb"
checksum="864c5a1ec976dd6068f9cd93f92c5404c662824996101f1411ddb25a54afc732
 c173bcbf8a3e6a4885b6f5d75173160af3a2344c290bc342a3542dcc0a283475"
skip_extraction="${pkgname}_${version}_amd64.deb"
nocross=yes

CXXFLAGS=-std=gnu++11

if [ "$XBPS_TARGET_LIBC" = musl ]; then
	CFLAGS+=" -DZ7_AFFINITY_DISABLE"
	CXXFLAGS+=" -DZ7_AFFINITY_DISABLE"
	makedepends+=" musl-fts-devel libexecinfo-devel"
fi

post_extract() {
	vsrcextract --strip-components=4 \
		${pkgname}_${version}_amd64.deb \
		./usr/share/{pixmaps/gzdoom.png,applications/gzdoom.desktop}
	: >tools/updaterevision/UpdateRevision.cmake
	sed "
		s/@Tag@/${version}/;
		s/@Hash@/v${version}/;
		s/@Timestamp@/<unknown>/;
	" tools/updaterevision/gitinfo.h.in >src/gitinfo.h
}

post_install() {
	vmkdir usr/share/licenses
	mv ${PKGDESTDIR}/usr/share/{doc/gzdoom/licenses,licenses/${pkgname}}
	vinstall gzdoom.desktop 644 usr/share/applications
	vinstall gzdoom.png 644 usr/share/pixmaps
	vinstall soundfont/gzdoom.sf2 644 usr/share/gzdoom/soundfonts
}
