app=gdb
version=8.3.1
build=2sml
homepage="https://www.gnu.org/software/gdb/"
download="https://ftp.gnu.org/gnu/gdb/gdb-$version.tar.xz"
desc="GNU symbolic debugger"
requires="gcc-libs netbsd-curses expat xz python3 gmp mpfr"
noautoconfsite=1

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z* 
  cd $app-$version 
  fixbuilddirpermissions

  applypatch $srcdir/100-musl_fix.patch
  applypatch $srcdir/110-shared_libgcc.patch
  applypatch $srcdir/120-sigprocmask-invalid-call.patch
  applypatch $srcdir/130-uclibc-fix.patch

  ./configure \
    --prefix="" \
    --sysconfdir=/etc \
    --disable-werror \
    --with-system-readline \
    --with-system-zlib \
    --disable-sim \
    --with-python=/bin/python3

  make
  make install DESTDIR=$pkg 

  cp COPYING* $pkgdocs/

  mkfinalpkg
}

sha512sums="
9053a2dc6b9eb921907afbc4cecc75d635aa76df5e8c4f0e5824ccf57cb206b299c19b127fff000b65c334826ff8304a54ff6098428365a8e997cca886c39e9a  gdb-8.3.1.tar.xz
8f266317da5ac6c0288d5254d836fb2166b78ba98714de011977a2546e1b695d28b1f5114c3faddedc113b729aac8ef0b5cafd651a5de53322be42f22e8b696f  001-gdb-pr14523-mips-signal-number.patch
a47debfd5285d9d2cbea42be9ca856c0ee44fa14b1e8a6c590908d5939c932d0f1898888ac337a27f57a49e01a884d0258c155425c0c64d9483879bc35295eda  010-aarch64-headers.patch
6b881ab5ba9807c967b74b5fc049412c1fa281926d433ee32ed04ccb205f41e94983af5242cbe04ba5a922aa38af23bd48fc4670cc2d6bf79c2cd89912d39967  100-musl_fix.patch
394f215e929bc2ea936276f8084cfb686c8d3f67cfee76ba62857a1b909a0ddf2a722dcdee2c695da0bd43e09e508db08f8eaad040062dc37364170bcfe38c16  110-shared_libgcc.patch
3aa7ff65e2d8440d2dff50fe3e8ffe7dc46f5f84c74104b99a0de52d081ecaccfaa2ffae41505103820e7da3618724fb4e9bd3a3030ab5dd406a726201f5dcaa  120-sigprocmask-invalid-call.patch
ce5e845697618c9219b7461830e9a77c95130613199911eda14ee2ce0be3bbf1154b72a73807f3614041e5ee1e6570ffb33ffc71556059f45018267f2ab9476b  130-uclibc-fix.patch
"
