#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=cmake
pkgver=3.26.3
pkgrel=01
pkgdesc='A cross-platform open-source make system w/o zstd or qt-gui '
url="https://www.cmake.org/"
depends=('curl' 'libarchive' 'hicolor-icon-theme' 'jsoncpp' 'libuv' 'rhash')
makedepends=('python-sphinx' 'emacs-git' python-sphinx-autoapi) # without autoapi build fails at sphinx html documents
optdepends=('qt6-base: cmake-gui')
source=("https://www.cmake.org/files/v${pkgver%.*}/${pkgname}-${pkgver}.tar.gz")

build() {
  cd ${pkgname}-${pkgver}
  ./bootstrap --prefix=/usr \
    --mandir=/share/man \
    --docdir=/share/doc/cmake \
    --datadir=/share/cmake \
    --system-liblzma \
    --no-system-zstd \
    --no-qt-gui \
    --system-libs \
    --parallel=$(/usr/bin/getconf _NPROCESSORS_ONLN)
  make
}

#    --sphinx-man \  I removed this to avoid error at sphinx html docs
#  export CXXFLAGS+=" ${CPPFLAGS}"  # used in the past
#    --qt-gui \  # qt6-base dependency is needed for the gui
#     --sphinx-html \  Build stops unable to find sphinx module to build html docs
#  it still fails and there are no valid options for --no-sphinx-html ..

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  rm -r "$pkgdir"/usr/share/doc/cmake/html/_sources
  emacs -batch -f batch-byte-compile "${pkgdir}"/usr/share/emacs/site-lisp/cmake-mode.el
  install -Dm644 Copyright.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('custom')

sha256sums=(bbd8d39217509d163cb544a40d6428ac666ddc83e22905d3e52c925781f0f659) #  cmake-3.26.3.tar.gz
 
##  1cf0b1cf05abed2f2c17e16213bea4b298830184900c56b35e3b88fb0de3815c  cmake-3.26.3-01-x86_64.pkg.tar.lz
