# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=ctags
pkgver=6.1.20240901.0
_realver="p$pkgver"
pkgrel=0
pkgdesc="Generator of tags for all types of C/C++ languages"
url="https://ctags.io/"
arch="all"
license="GPL-2.0-or-later"
checkdepends="diffutils python3"
makedepends="autoconf automake pkgconf py3-docutils yaml-dev jansson-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/universal-ctags/ctags/archive/$_realver.tar.gz"
builddir="$srcdir"/$pkgname-$_realver

# secfixes:
#   5.8-r5:
#     - CVE-2014-7204

prepare() {
	default_prepare
	./autogen.sh

	# Fail, likely due to compatibility issues with musl's iconv.
	# Alternative solution: Build ctags with --disable-iconv.
	rm -r Tmain/input-encoding-option.d \
		Tmain/output-encoding-option.d
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-external-sort \
		--enable-json \
		--enable-yaml
	make
}

check() {
	make check
}

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

sha512sums="
e8281a3791a040237b8504885a9f18d9f25975bebb50a9342a0979b928d897c1d22fa0ec742ce21919e473c0cb333e13a5d44d9b379761b07d09b11425a2006b  ctags-6.1.20240901.0.tar.gz
"
