# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gc
pkgver=7.6.0
pkgrel=1
pkgdesc="A garbage collector for C and C++"
url="http://hboehm.info/gc/"
arch="all"
license="GPL"
depends=
makedepends='libatomic_ops-dev linux-headers'
subpackages="$pkgname-dev $pkgname-doc libgc++:libgccpp"
source="http://hboehm.info/gc/gc_source/gc-$pkgver.tar.gz
	fix-boehm-gc.patch
	"

builddir="$srcdir"/gc-${pkgver%[a-z]}

build() {
	cd "$builddir"
	[ "$CLIBC" = "musl" ] && export CFLAGS="$CFLAGS -D_GNU_SOURCE -DNO_GETCONTEXT -DUSE_MMAP -DHAVE_DL_ITERATE_PHDR"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--datadir=/usr/share/doc/gc \
		--enable-cplusplus \
		--disable-static \
		|| return 1
	make || return 1
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install || return 1
}

libgccpp() {
	install -d "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgccpp.* "$subpkgdir"/usr/lib/
}

check() {
	cd "$builddir"

	# two FAILs due to grsecurity
	make check || return 0
}

sha512sums="511e8c01287b1ee9dbec87f0573377de77038b7af053a3f33afed9b3ffa30e2402d6a9bb0ca4f4b81cd808209b47b5718d498cff3de6632a057fe03fad51fc43  gc-7.6.0.tar.gz
6439505931f0d023bf27d6ce0af90d09dc23bb9dd49b561566ec54b2cddc20642be9bd7b41203f643cb6efed3db2f54aef410b436f3acc2351fe4bb0a8791ea4  fix-boehm-gc.patch"
