# Template file for 'gpsbabel'
pkgname=gpsbabel
version=1.7.0
revision=1
build_style=gnu-configure
build_helper=qmake
makedepends="qt5-devel qt5-webkit-devel libusb-compat-devel"
depends="desktop-file-utils"
short_desc="Converts waypoints, tracks, and routes between popular GPS formats"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://www.gpsbabel.org/"
distfiles="https://github.com/gpsbabel/${pkgname}/archive/${pkgname}_${version//./_}.tar.gz"
checksum=30b186631fb43db576b8177385ed5c31a5a15c02a6bc07bae1e0d7af9058a797

replaces="gpsbabel-gui>=0"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" qt5-devel qt5-webkit-devel"
	configure_args+=" ac_cv_prog_QMAKE=${XBPS_WRAPPERDIR}/qmake"
fi

do_build() {
	sed -i 's|langPath_ = QApplication::applicationDirPath();|langPath_ = "/usr/share/gpsbabel";|' gui/mainwindow.cc

	make ${makejobs}
	cd gui
	qmake-qt5
	lrelease-qt5 *.ts
	sed -i Makefile \
		-e"s;^\(CFLAGS.*=.*\);& $CFLAGS;" \
		-e"s;^\(CXXFLAGS.*=.*\);& $CXXFLAGS;" \
		-e"s;^\(LFLAGS.*=.*\);& $LDFLAGS;"
	make ${makejobs}
}

do_install() {
	make install DESTDIR=${DESTDIR}
	vbin gui/objects/gpsbabelfe
	vinstall gui/gpsbabel.desktop 644 usr/share/applications
	vinstall gui/images/appicon.png 644 usr/share/pixmaps gpsbabel.png
	vmkdir usr/share/gpsbabel/translations
	mv gui/*.qm ${DESTDIR}/usr/share/gpsbabel/translations
}
