### this file is sourced not run
pkgname=librecad
PKGVER=2.2.0.rc3
PKGBUILD=1
PKGARCH=x86_64

# source: JakeSFR
TARBALL=${pkgname}-${PKGVER}.tar.gz
MD5SUM=a66156de31b57d9115daa07b7496b182
SRC_URL=https://github.com/LibreCAD/LibreCAD/archive/refs/tags/2.2.0-rc3.tar.gz
BUNDLE=

SLACKDESC="${pkgname}: ${pkgname} ${PKGVER} (2D CAD program)  
${pkgname}: 
${pkgname}: LibreCAD is a cross-platform 2D CAD program written in C++11
${pkgname}: using the Qt framework. It can read DXF and DWG files
${pkgname}: and can write DXF, PDF and SVG files. The user interface is
${pkgname}: highly customizable, and has dozens of translations.
${pkgname}: 
${pkgname}: https://github.com/LibreCAD/LibreCAD
${pkgname}: 
${pkgname}: 
${pkgname}: 
"

SLACKINSTALL=''
SLACKREQ='qt5-common libboost-common'

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	# qt5
	export PATH="$PATH:/opt/qt5/bin"
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt5/$LIBDIR"
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/qt5/$LIBDIR/pkgconfig"
	export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/qt5/include"
	export QT5_PATH="/opt/qt5/bin"
	export QT5_LD_LIBRARY_PATH="/opt/qt5/$LIBDIR"
	export QT5_PKG_CONFIG_PATH="/opt/qt5/$LIBDIR/pkgconfig"
	export QT5_CPLUS_INCLUDE_PATH="/opt/qt5/include" 
	export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb"	
	export QT5DIR=/opt/qt5
	export BUILDCC=gcc

	cd /tmp/LibreCAD* &&
	qmake &&
	make $MAKEFLAGS &&

	install -m 644 -Dt "/usr/share/pixmaps" librecad/res/main/librecad.png &&
	install -m 644 -Dt "/usr/share/applications" desktop/librecad.desktop &&
	install -m 644 -Dt "/usr/share/man/man1" desktop/librecad.1 &&
	
	cd unix &&
	
	mkdir -p "/opt/librecad" &&
	cp -r -t "/opt/librecad" * &&
	
	#ln -sfT /opt/librecad/librecad /usr/bin/librecad &&
	# have to use a wrapper script, because launching it only via full/relative path
	# makes the plugins visible in menu
	echo -e '#!/bin/sh\nexec /opt/librecad/librecad "$@"' > /usr/bin/librecad &&
	chmod +x /usr/bin/librecad &&
	ln -sfT /opt/librecad/ttf2lff /usr/bin/ttf2lff &&
	
	pkg_build_slackdesc

}
