APKBUILD 3.17 KB
Newer Older
1
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
Natanael Copa's avatar
Natanael Copa committed
2
pkgname=binutils
3 4
pkgver=2.32
pkgrel=0
Natanael Copa's avatar
Natanael Copa committed
5
pkgdesc="Tools necessary to build programs"
6
url="https://www.gnu.org/software/binutils/"
7 8 9
makedepends_build="bison flex texinfo"
makedepends_host="zlib-dev"
makedepends="$makedepends_build $makedepends_host"
10
arch="all"
11
license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
12
subpackages="$pkgname-dev $pkgname-doc $pkgname-gold"
13
source="https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.bz2
14
	binutils-ld-fix-static-linking.patch
15
	gold-mips.patch
16
	"
17
builddir="$srcdir/$pkgname-$pkgver"
Natanael Copa's avatar
Natanael Copa committed
18

19 20 21 22 23 24
if [ "$CHOST" != "$CTARGET" ]; then
	pkgname="$pkgname-$CTARGET_ARCH"
	subpackages=""
	sonameprefix="$pkgname:"
fi

25
# secfixes:
26 27 28 29 30
#   2.32-r0:
#   - CVE-2018-19931
#   - CVE-2018-19932
#   - CVE-2018-20002
#   - CVE-2018-20712
31 32 33
#   2.28-r1:
#   - CVE-2017-7614

Natanael Copa's avatar
Natanael Copa committed
34
build() {
35
	local _sysroot=/
36
	local _cross_configure="--enable-install-libiberty --enable-shared"
37
	local _arch_configure=""
38 39 40 41 42 43

	if [ "$CHOST" != "$CTARGET" ]; then
		_sysroot="$CBUILDROOT"
		_cross_configure="--disable-install-libiberty"
	fi

44
	if [ "$CTARGET_ARCH" = "x86_64" ]; then
45 46 47
		_arch_configure="--enable-targets=x86_64-pep"
	fi

48 49 50 51 52
	case "$CTARGET_ARCH" in
	mips*)  _hash_style_configure="--enable-default-hash-style=sysv" ;;
	*)      _hash_style_configure="--enable-default-hash-style=gnu"	;;
	esac

53
	cd "$builddir"
54 55 56
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
57 58
		--target=$CTARGET \
		--with-build-sysroot="$CBUILDROOT" \
59
		--with-sysroot=$_sysroot \
60
		--prefix=/usr \
61 62
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
63
		--disable-multilib \
64 65
		--enable-ld=default \
		--enable-gold=yes \
Natanael Copa's avatar
Natanael Copa committed
66
		--enable-64-bit-bfd \
67
		--enable-plugins \
68
		--enable-relro \
69
		--enable-deterministic-archives \
70
		$_cross_configure \
71
		$_arch_configure \
72
		$_hash_style_configure \
73
		--with-pic \
Natanael Copa's avatar
Natanael Copa committed
74
		--disable-werror \
75
		--disable-nls \
Natanael Copa's avatar
Natanael Copa committed
76
		--with-mmap \
77 78
		--with-system-zlib
	make
79 80 81
}

package() {
82
	cd "$builddir"
83
	make install DESTDIR="$pkgdir"
84 85 86 87
	if [ -d "$pkgdir"/usr/lib64 ]; then
		mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/
		rmdir "$pkgdir"/usr/lib64
	fi
88 89 90 91
	if [ "$CHOST" != "$CTARGET" ]; then
		# creating cross tools: remove any files that would conflict
		# with the native tools, or other cross tools
		rm -r "$pkgdir"/usr/share
92
		rm -f "$pkgdir"/usr/lib/libiberty.a
93
	fi
Natanael Copa's avatar
Natanael Copa committed
94
}
95 96

libs() {
97 98 99
	pkgdesc="Runtime libraries from binutils - libbfd and libopcodes"

	mkdir -p "$subpkgdir"/usr/lib
100
	mv "$pkgdir"/usr/lib/lib*.so "$subpkgdir"/usr/lib/
101 102 103 104 105 106 107 108 109 110 111
}

gold() {
	pkgdesc="GNU binutils - gold linker"

	if [ -e "$pkgdir"/usr/bin/ld.gold ]; then
		mkdir -p "$subpkgdir"/usr/bin
		mv "$pkgdir"/usr/bin/ld.gold "$subpkgdir"/usr/bin
	fi
	mkdir -p "$subpkgdir"/usr/$CTARGET/bin
	mv "$pkgdir"/usr/$CTARGET/bin/ld.gold "$subpkgdir"/usr/$CTARGET/bin/ld.gold
112 113
}

114
sha512sums="99ec7ed2b5ebfd3ac16cecb1567ec4a72f81ac30717002d601708f7547b2f8122ffcce076c986f22894aede33c54c73012210a4e973ba9b6e2d87a242a2bee12  binutils-2.32.tar.bz2
115
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49  binutils-ld-fix-static-linking.patch
116
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f  gold-mips.patch"