# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=make
pkgver=4.2.1
pkgrel=0
pkgdesc="GNU make utility to maintain groups of programs"
url="https://www.gnu.org/software/make"
arch="all"
license="GPL-3.0-or-later"
depends=""
subpackages="$pkgname-doc"
source="ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.bz2
	fix-atexit-exit.patch
	"

_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
	cd "$_builddir"
	update_config_sub || return 1
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-nls \
		|| return 1
	make || return 1

	[ "$CBUILD" != "$CHOST" ] || make check || return 1
	return 0
}

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

md5sums="15b012617e7c44c0ed482721629577ac  make-4.2.1.tar.bz2
842902e4a28f29e953f022f80b3ce57c  fix-atexit-exit.patch"
sha256sums="d6e262bf3601b42d2b1e4ef8310029e1dcf20083c5446b4b7aa67081fdffc589  make-4.2.1.tar.bz2
ecf0edef6b8cf173d2f792c61f5a3e6f289d789e9b9ce5ff9186c6c17022bd87  fix-atexit-exit.patch"
sha512sums="9cf00869a2f938492554f71d8cb288b5b009b3bd0489ef164f2c8f6532fc37db5c7e20af1dea288536e7c9710ee0bc6e1ddcdfc4928a8540e6e43661741825b8  make-4.2.1.tar.bz2
a1639d9caf84a24a9f161a30d8b5dcd079b13faf2a5e3d514ff39fa11b13e796c7ff34c46ac2b56656d52129b4d3627c6102b129a4ab011f065076d872ef3992  fix-atexit-exit.patch"
