summaryrefslogtreecommitdiff
path: root/main/gdb/APKBUILD
blob: d4a6cd1e12e7be7b109f7086258399a77bd10032 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gdb
pkgver=14.1
pkgrel=0
pkgdesc="The GNU Debugger"
url="https://www.gnu.org/software/gdb/"
arch="all"
license="GPL-3.0-or-later AND LGPL-3.0-or-later"
makedepends="
	autoconf
	automake
	expat-dev
	gmp-dev
	libtool
	linux-headers
	mpfr-dev
	ncurses-dev
	perl
	python3-dev
	readline-dev
	texinfo
	zlib-dev
	zstd-dev
	"
options="!check"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-multiarch"
source="https://ftp.gnu.org/gnu/gdb/gdb-$pkgver.tar.xz
	gcore-sh.patch
	s390x-use-elf-gdb_fpregset_t.patch
	ppc-musl.patch
	ppc-ptregs.patch
	musl-signals.patch
	"

prepare() {
	default_prepare
	mkdir -p "$builddir"/vanilla "$builddir"/multiarch
}

build() {
	local _config="
		--build=$CBUILD
		--host=$CHOST
		--prefix=/usr
		--target=$CTARGET
		--with-build-sysroot=$CBUILDROOT
		--with-python=/usr/bin/python3
		--disable-nls
		--disable-werror
		--mandir=/usr/share/man
		--infodir=/usr/share/info"

	export CFLAGS="$CFLAGS -O2 -g1"
	export CXXFLAGS="$CXXFLAGS -O2 -g1"

	# use system readline if not cross compiling
	[ "$CBUILD" = "$CHOST" ] && _config="$_config --with-system-readline"

	# use system zlib if not cross compiling
	[ "$CBUILD" = "$CHOST" ] && _config="$_config --with-system-zlib"

	# avoid generation of mangled and non-mangled objects on ppc64
	[ "$CARCH" = ppc64le ] && _config="$_config --enable-build-with-cxx=no"

	cd "$builddir"/vanilla
	../configure $_config
	make

	# XXX: As of GDB 12.1, --enable-targets=all is broken on 32-bit targets.
	#
	# See: https://sourceware.org/pipermail/gdb-patches/2022-May/189227.html
	cd "$builddir"/multiarch
	case "$CARCH" in
	arm*|x86) ../configure $_config \
		--disable-sim \
		--enable-64-bit-bfd \
		--enable-targets=all ;;
	*) ../configure $_config --enable-targets=all ;;
	esac
	make
}

package() {
	# backtracing/debugging pretty much anything is going to need libc debug symbols
	# not everything, but the common case needs this, and it's a small dep in comparison
	depends="musl-dbg"

	cd "$builddir"/vanilla
	make DESTDIR="$pkgdir" install

	# resolve conflict with binutils-doc
	rm -f "$pkgdir"/usr/share/info/bfd.info
	rm -f "$pkgdir"/usr/share/info/ctf-spec.info
	rm -f "$pkgdir"/usr/share/info/dir

	# those are provided by binutils
	rm -rf "$pkgdir"/usr/include
	rm -rf "$pkgdir"/usr/lib

	# resolve conflict with binutils-doc
	rm "$pkgdir"/usr/share/info/sframe-spec.info

	# install gdb-multiarch here for default dbg() split function to work
	install -Dm755 "$builddir"/multiarch/gdb/gdb \
		"$pkgdir"/usr/bin/gdb-multiarch
}

multiarch() {
	depends="$pkgname"
	pkgdesc="The GNU Debugger for all supported architectures"

	amove usr/bin/gdb-multiarch
}

sha512sums="
575e198105076fc4a88f68591aa114ab9c1196e84386a3f7b9b58fe5f30cdeed33f6a5f957b68f08c47284ec922bb60c964627e238471419673fd913575ce427  gdb-14.1.tar.xz
68f893e72742eac7e41fd7c3e688b8cccc79327f0422b03319302a1a9d24513e77d698bc6ff16f67236b521df321b9ff0ca2ee342c11f12933c492c5c530ec9b  gcore-sh.patch
70e7d04e4d72461436da503b5bfa370c5779e03245c521f30e9779d5ff37dbb2d708b05f2afb27f43ad9defc44df4bd979d72f777e744851fdbf156295e1cc9f  s390x-use-elf-gdb_fpregset_t.patch
04911f87904b62dd7662435f9182b20485afb29ddb3d6398a9d31fef13495f7b70639c77fdae3a40e2775e270d7cd40d0cfd7ddf832372b506808d33c8301e01  ppc-musl.patch
ab554899bbb2aa98261fd1b6beb4a71ed7c713a714bddd3fa7ec875258e39bd5474dc96a11accb4dadd316f3834f215e8395d3b373bf3affd122dc5b4a8fe710  ppc-ptregs.patch
58aacc7cdc119eab729a3c5a5521f6a0db41c6a5bc2d09d6e32cbdd071d85dd1a31b5e6559616f8da1237c5b79ad9e04aab485211e957b4d1ca752c0c5ad660b  musl-signals.patch
"