pkgname=eigen
pkgver=3.4.0
pkgdesc='Lightweight C++ template library for vector and matrix math, a.k.a. linear algebra (legacy version)'
arch=(any)
homepage='https://eigen.tuxfamily.org'
license=(MPL-2.0 Apache-2.0
         BSD-3-Clause Minpack
         'LGPL-2.1-only OR LGPL-2.1-or-later')
makedepends=(cmake)
sources=("${pkgname}-${pkgver}.tar.bz2"
  "eigen-3.4.0-cxxstandard.patch"
)
urls=("https://gitlab.com/lib${pkgname}/${pkgname}/-/archive/${pkgver}/${sources[0]}"
  "eigen-3.4.0-cxxstandard.patch"
)
md5sums=("132dde48fe2b563211675626d29f1707"
  "baa6b8689c99421cd928271aa1e5bb9e"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  patch -p1 -i ${filedir}/${sources[1]}

  sed \
  -e "/add_subdirectory(bench\/spbench/s/^/#DONOTCOMPILE /g" \
  -e "/add_subdirectory(demos/s/^/#DONOTCOMPILE /g" \
  -i CMakeLists.txt

  # no test
  sed \
  -e "/add_subdirectory(test/s/^/#DONOTCOMPILE /g" \
  -e "/add_subdirectory(scripts/s/^/#DONOTCOMPILE /g" \
  -e "/add_subdirectory(failtest/s/^/#DONOTCOMPILE /g" \
  -e "/add_subdirectory(blas/s/^/#DONOTCOMPILE /g" \
  -e "/add_subdirectory(lapack/s/^/#DONOTCOMPILE /g" \
  -i CMakeLists.txt
}

src_build() {
	local mycmakeargs=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DBUILD_SHARED_LIBS=yes
    -DBUILD_TESTING=OFF
    -DEIGEN_BUILD_DOC=OFF
    -DEIGEN_BUILD_PKGCONFIG=yes
  )

	cmake -B build "${mycmakeargs[@]}"

  cmake --build build
}

src_install() {
  DESTDIR="$pkgdir" cmake --install build

  # install custom licenses
  install -Dm644 COPYING.* -t "$pkgdir/usr/share/licenses/${pkgname}3"
}

# vim:ft=sh syn=sh et sw=2:
