# Template file for 'Aegisub'
pkgname=Aegisub
version=3.2.2
revision=3
build_style=gnu-configure
configure_args="--disable-update-checker --with-alsa --with-ffms2
 --with-wx-config=wx-config-gtk3 $(vopt_with fftw fftw3) $(vopt_with openal)
 $(vopt_with portaudio)"
hostmakedepends="automake gettext-devel intltool libtool LuaJIT pkg-config"
makedepends="alsa-lib-devel boost-devel libcurl-devel fontconfig-devel
 freetype-devel hunspell-devel icu-devel libass-devel libffms2-devel LuaJIT-devel
 MesaLib-devel wxWidgets-gtk3-devel $(vopt_if fftw fftw-devel)
 $(vopt_if openal libopenal-devel) $(vopt_if portaudio portaudio-devel)"
short_desc="Tool for creating and modifying subtitles"
maintainer="Rasmus Thomsen <rasmus.thomsen@protonmail.com>"
license="BSD-3-Clause, MIT"
homepage="http://www.aegisub.org"
distfiles="https://github.com/Aegisub/Aegisub/archive/v${version}.tar.gz"
checksum=62757dd491455268a240f983b59734a801cc2e899039a7493deeaf5e24a61dcd

build_options="fftw openal portaudio"
build_options_default="fftw"

desc_option_fftw="Enable support for rendering of audio waveforms/spectrum"
desc_option_openal="Enable support for openal"
desc_option_portaudio="Enable support for portaudio"

LDFLAGS+=" -pthread"

case "$XBPS_TARGET_MACHINE" in
	*musl) broken="segfaults on startup";;
	armv7l*|armv6l*) broken="error: invalid conversion from 'const char**' to 'char**' [-fpermissive]"
esac

post_extract() {
	# Fix shebang to use system luajit instead of vendored minilua
	sed -e \
		"s:../vendor/luajit/src/host/minilua:/usr/bin/luajit:" \
		-i tools/respack.lua
}

pre_configure() {
	# Aegisub fails to start on Wayland, so we have to force GDK to start it
	# with the x11 backend
	sed "s/Exec=@AEGISUB_COMMAND@ %f/Exec=env GDK_BACKEND=x11 @AEGISUB_COMMAND@ %f/" -i \
		packages/desktop/aegisub.desktop.template.in

	autoreconf -fi
}

post_install() {
	vlicense LICENCE
}
