# Maintainer: Martchus <martchus@gmx.net>

# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
# you also find the URL of a binary repository.

_reponame=qtutilities
_pkgname=qtutilities
_android_arch=arm64-v8a
_pkg_arch=aarch64
_android_platform=22
_prefix=/opt/android-libs/$_pkg_arch

pkgname=android-$_pkg_arch-$_pkgname
pkgver=6.0.6
pkgrel=1
arch=('any')
pkgdesc="Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models (Android, $_pkg_arch)"
license=('GPL')
depends=("android-$_pkg_arch-c++utilities" "android-$_pkg_arch-qt5")
optdepends=("$_pkgname-doc: API documentation")
makedepends=('cmake' 'ninja' 'android-ndk' 'android-sdk')
conflicts=("android-$_pkgname-$_android_arch")
replaces=("android-$_pkgname-$_android_arch")
url="https://github.com/Martchus/${_reponame}"
source=("${_pkgname}-${pkgver}.tar.gz::https://github.com/Martchus/${_reponame}/archive/v${pkgver}.tar.gz")
sha256sums=('6e853502cc3a636d82e64f23e96050f8357f2937bca35ef3359c2ec75e8fedf3')
options=(!buildflags staticlibs !strip !emptydirs)

prepare() {
  cd "$srcdir/${PROJECT_DIR_NAME:-$_reponame-$pkgver}"
}

build() {
  cd "$srcdir/${PROJECT_DIR_NAME:-$_reponame-$pkgver}"
  cmake \
    -G Ninja \
    -DCMAKE_SYSTEM_NAME=Android \
    -DCMAKE_SYSTEM_VERSION=$_android_platform \
    -DCMAKE_ANDROID_ARCH_ABI=$_android_arch \
    -DCMAKE_ANDROID_NDK=/opt/android-ndk \
    -DCMAKE_ANDROID_SDK=/opt/android-sdk \
    -DCMAKE_ANDROID_STL_TYPE=c++_shared \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="$_prefix" \
    -DCMAKE_FIND_ROOT_PATH="/opt/android-ndk/sysroot;$_prefix" \
    -DBUILD_SHARED_LIBS:BOOL=ON \
    -DNO_DOXYGEN=ON \
    -DWIDGETS_GUI=OFF \
    -DQUICK_GUI=ON \
    .
  ninja
}

package() {
  cd "$srcdir/${PROJECT_DIR_NAME:-$_reponame-$pkgver}"
  DESTDIR="${pkgdir}" ninja install
}
