# Template file for 'flightgear'
pkgname=flightgear
version=3.4.0
revision=3
build_style=cmake
configure_args="-DFG_DATA_DIR:STRING=/usr/share/flightgear/fgdata"
hostmakedepends="cmake fltk pkg-config"
makedepends="MesaLib-devel boost-devel freealut-devel glu-devel libfreeglut-devel fltk-devel
 libopenal-devel libgsm-devel speex-devel sqlite-devel osg-devel plib-devel simgear
 $(vopt_if qt qt5-devel)"
depends="flightgear-data>=${version}"
short_desc="Sophisticated flight wimulator"
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
license="GPL-3"
homepage="http://www.flightgear.org/"
distfiles="
 http://ftp.igh.cnrs.fr/pub/flightgear/ftp/Source/flightgear-${version}.tar.bz2
 http://ftp.igh.cnrs.fr/pub/flightgear/ftp/Shared/FlightGear-data-${version}.tar.bz2"
checksum="
 b5645d05b50728a89f091292bc557f440d8f8719dd9cebf7f5bf3fa8ea795780
 8cefa7c323d974d8e51fd23c97ae79dc731e65b81e1729cb1bc9bc1f99df128b"

build_options="qt"
if [ "$CROSS_BUILD" ]; then
	configure_args+=" -DSIMGEAR_COMPILE_TEST_EXITCODE=0"
else
	build_options_default="qt"
fi

post_install() {
	vinstall package/flightgear.desktop 644 usr/share/applications
	vinstall package/flightgear.ico 644 usr/share/icons
	vinstall ${FILESDIR}/flightgear.png 644 usr/share/pixmaps
	vinstall scripts/completion/fg-completion.bash 644 usr/share/bash-completion/completions/fgfs
	sed -i ${DESTDIR}/usr/share/applications/flightgear.desktop \
		-e "s;Exec=.*;Exec=fgfs --fg-root=/usr/share/flightgear/fgdata;"
}

flightgear-data_package() {
	short_desc+=" - data files"
	noarch=yes
	pkg_install() {
		vmkdir usr/share/flightgear
		mv ${XBPS_BUILDDIR}/fgdata ${PKGDESTDIR}/usr/share/flightgear
	}
}
