# Template file for 'flightgear'
pkgname=flightgear
version=2020.3.17
revision=3
# XXX: always keep in sync with simgear version!
create_wrksrc=yes
build_style=cmake
build_helper="qemu"
configure_args="-DFG_DATA_DIR:STRING=/usr/share/flightgear/fgdata
 -DOpenGL_GL_PREFERENCE=GLVND
 -DTRANSLATIONS_SRC_DIR=${XBPS_BUILDDIR}/$pkgname-$version/fgdata/Translations
 -DSYSTEM_SQLITE=ON -DSYSTEM_FLITE=ON"
hostmakedepends="gettext pkg-config qt5-tools"
makedepends="MesaLib-devel boost-devel freealut-devel libevent-devel
 libfreeglut-devel libglvnd-devel libgsm-devel glew-devel speex-devel
 sqlite-devel osg-devel plib-devel libcurl-devel simgear-devel flite-devel
 qt5-devel qt5-tools-devel qt5-declarative-devel qt5-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="
 $SOURCEFORGE_SITE/project/flightgear/release-${version%.*}/${pkgname}-${version}.tar.bz2
 $SOURCEFORGE_SITE/project/flightgear/release-${version%.*}/FlightGear-${version}-data.txz"
checksum="6670dedeaca2683aca77f9f06bf9d1d8062ae32a2a5459dddc8aa0989c5f1854
 2a5eba2b9ae67a3691285833a6ce3f6bbdf3f20229f5871d7c940e151d54d8e8"
# the test suite doesn't get built, if enabled it segfaults
make_check=no

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" qt5-host-tools qt5-devel qt5-declarative-devel"
fi

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	makedepends+=" libexecinfo-devel"
	configure_args+=" -DCMAKE_EXE_LINKER_FLAGS=-lexecinfo"
fi

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

post_extract() {
	mv flightgear-$version/* .
}

flightgear-data_package() {
	short_desc+=" - data files"
	pkg_install() {
		vmkdir usr/share/flightgear
		mv fgdata ${PKGDESTDIR}/usr/share/flightgear
		# 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
	}
}
