# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer:
pkgname=flightgear
pkgver=2017.3.1
pkgrel=1
pkgdesc="Sophisticated flight simulator"
url="http://flightgear.org"
arch="!aarch64"
license="GPL"
makedepends="$depends_dev boost-dev cmake curl-dev dbus-dev eudev-dev
	freeglut-dev glew-dev libx11-dev libxi-dev libxmu-dev mesa-dev
	openal-soft-dev openscenegraph-dev plib qt5-qtbase-dev
	qt5-qtdeclarative-dev simgear zlib-dev"
install=
subpackages="$pkgname-doc"
source="http://downloads.sourceforge.net/project/$pkgname/release-${pkgver%.[1-9]*}/$pkgname-$pkgver.tar.bz2
	musl-fixes.patch
	fix-link_with_x11.patch
	"
builddir="$srcdir"/$pkgname-$pkgver

build() {
	cd "$builddir"
	mkdir _build.tmp && cd _build.tmp
	cmake \
		-D CMAKE_BUILD_TYPE="Release" \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D CMAKE_INSTALL_SYSCONFDIR=/etc/$pkgname \
		-D FG_DATA_DIR=/var/lib/$pkgname \
		-D SimGear_DIR=/usr/lib/cmake/SimGear \
		.. || return 1
}

package() {
	cd "$builddir/_build.tmp"
	make DESTDIR="$pkgdir" install || return 1

	# remove the 2 lines below (and this) if there is no init.d script
	# install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	# install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="e91268b4fc6a5b04761cf64e003e9962e5a66a91c0f089a1de220ef7cc438250dbd93ed99773c09f19255604c4cc5a0b65b80fe19e663fa0eae8107374527b4b  flightgear-2017.3.1.tar.bz2
3350de9e465dc4f865d2a94d96b2f79b4c98c994fc4713cfa296c20ed12129f310779171b89639f69d1e4f5f0103fca6cc01df5a9e25d77f93a0b4e76f6b973a  musl-fixes.patch
49d359d213870ad71a3403e93951574b334d8281fbe9553fe259d65e1b0a8659c127cde11ffdf2ba3351c2af2dabe60657dab6dab3ff0c9fecad4a398fd6f2eb  fix-link_with_x11.patch"
