# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=cfitsio
pkgver=4.4.1
pkgrel=0
pkgdesc="Library reading and writing data files in Flexible Image Transport System data format"
url="https://heasarc.gsfc.nasa.gov/fitsio/"
arch="all"
license="CFITSIO"
makedepends="
	bzip2-dev
	curl-dev
	gfortran
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	"
source="https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-$pkgver.tar.gz
	10-OFF_T.patch
	add-loongarch64.patch
	"

build() {
	export CFLAGS="$CFLAGS -D_DEFAULT_SOURCE"
	./configure \
		--prefix=/usr \
		--with-bzip2 \
		--enable-reentrant \
		--enable-sse2 \
		--enable-hera
	make shared
	make utils
}

package() {
	make DESTDIR="$pkgdir" install

	# delete test/demo programs
	rm "$pkgdir"/usr/bin/testprog
	rm "$pkgdir"/usr/bin/cookbook

	# avoid conflicts with smem
	rm "$pkgdir"/usr/bin/smem
}

check() {
	LD_LIBRARY_PATH=. ./testprog > testprog.lis
	[ -z "$(diff testprog.lis testprog.out)" ]
	[ -z "$(cmp testprog.fit testprog.std)" ]
}

sha512sums="
a49e4e09a2e5f6e0ae823a68f02b3f6285cf3e0af66c9a1f8dadcd2867fa83c17fd27e446e8e5af9374ff2dc7b7a18334663ce977a1691c4ed4ced14d33232b7  cfitsio-4.4.1.tar.gz
4a1cf7cf6f7dbd44c91d8f0b7de5792b83786ffcb3e18188e1ed82c00fda420613e7442b7497d3867bcd6695438ce660ebf7563a60dfc4f48a3807712a69f7ec  10-OFF_T.patch
a74c929ab3fdb57af9f6efaf987ffe6fb1e70eeca9fdc3706a71ef26e9bb58e8d7cedee3eac4aa24c713e10b85de0feb6de79e6a0777d61045627c6f7ce2d7ce  add-loongarch64.patch
"
