# Template file for 'flightgear'
pkgname=flightgear
version=2024.1.3
revision=1
build_style=cmake
build_helper="qemu"
configure_args="-DFG_DATA_DIR:STRING=/usr/share/flightgear/fgdata
 -DSYSTEM_SQLITE=ON -DSYSTEM_FLITE=ON"
hostmakedepends="gettext pkg-config qt6-base qt6-declarative-host-tools qt6-tools"
makedepends="MesaLib-devel boost-headers freealut-devel libevent-devel
 libfreeglut-devel libgsm-devel glew-devel speex-devel
 sqlite-devel osg-devel plib-devel libcurl-devel simgear-devel flite-devel
 qt6-base-devel qt6-tools-devel qt6-declarative-devel qt6-svg-devel"
depends="flightgear-data>=${version}"
short_desc="Sophisticated flight simulator"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://www.flightgear.org/"
changelog="https://wiki.flightgear.org/Changelog_2020.3"
distfiles="
 https://gitlab.com/flightgear/flightgear/-/archive/${version}/flightgear-${version}.tar.bz2
 https://gitlab.com/flightgear/fgdata/-/archive/${version}/fgdata-${version}.tar.bz2"
checksum="9131c5b3441804b31e213477ed07f8bcba9df9382acc5e9ce07b33ebc14a800a
 31a6b34b540c41133e6e5458dcd1158759ebae6b5a4b6ee5a8e2219716023130"
# the test suite doesn't get built, if enabled it segfaults
make_check=no

skip_extraction="fgdata-${version}.tar.bz2"

CXXFLAGS=" -D_LARGE_FILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"

post_extract() {
	mkdir -p fgdata
	vsrcextract -C fgdata $skip_extraction
}

pre_configure() {
	configure_args+=" -DTRANSLATIONS_SRC_DIR=$wrksrc/fgdata/Translations"
}

flightgear-data_package() {
	short_desc+=" - data files"
	pkg_install() {
		vmkdir usr/share/flightgear
		mv fgdata ${PKGDESTDIR}/usr/share/flightgear/fgdata
		# python 2 build scripts
		rm "${PKGDESTDIR}"/usr/share/flightgear/fgdata/Aircraft/c172p/Models/Interior/Panel/Instruments/asi/asi.py \
			"${PKGDESTDIR}"/usr/share/flightgear/fgdata/Docs/compile_docs.py
	}
}
