#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgbase=gdb
# gdb-common is a package that contains files common for all cross compiled versions
# of gdb (for arm/avr/...)
pkgname=(gdb gdb-common)
pkgver=13.1
pkgrel=02
pkgdesc='The GNU Debugger'
arch=(x86_64)
url='https://www.gnu.org/software/gdb/'
makedepends=(glibc gcc-libs texinfo python guile ncurses expat xz mpfr 
	boost source-highlight readline)
source=(https://ftp.gnu.org/gnu/gdb/${pkgname}-${pkgver}.tar.xz{,.sig}
        rust.patch::"https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=562403d4f5483e0787219fdb88da72c707c8d7f6")

prepare() {
  cd gdb-$pkgver

  patch -p1 < ../rust.patch
}

build() {
  cd gdb-$pkgver
 
#  patch -Np1 -i ../readline8.patch
 
  mkdir -p build && cd build
  ../configure \
    --prefix=/usr \
    --disable-nls \
    --enable-source-highlight \
    --enable-tui \
    --with-system-readline \
    --with-python=/usr/bin/python \
    --with-system-gdbinit=/etc/gdb/gdbinit
  make

#    --with-guile=guile-2.2 \

}

package_gdb-common() {
  depends=(python guile)

  cd gdb-$pkgver/build
  make -C gdb/data-directory DESTDIR="$pkgdir" install
}

package_gdb() {
  depends=(glibc ncurses libncursesw.so gcc-libs expat xz mpfr source-highlight gdb-common=$pkgver
           readline libreadline.so guile python libelf)
  backup=(etc/gdb/gdbinit)

  cd gdb-$pkgver/build
  make -C gdb DESTDIR="$pkgdir" install
  make -C gdbserver DESTDIR="$pkgdir" install

  # install "custom" system gdbinit
  install -dm 755 "$pkgdir/etc/gdb"
  touch "$pkgdir/etc/gdb/gdbinit"

  # comes from gdb-common
  rm -r "$pkgdir/usr/share/gdb/"
}


#---- license gpg-key sha256sums ----

license=(GPL3)

validpgpkeys=('F40ADB902B24264AA42E50BF92EDB04BFF325CF3') # Joel Brobecker

sha256sums=(115ad5c18d69a6be2ab15882d365dda2a2211c14f480b3502c6eba576e2e95a0  # gdb-13.1.tar.xz
	d14d21a672624767c609582d1c8eee91661e580a2fb08f7c38b35332c6d76dad  # gdb-13.1.tar.xz.sig
	99d8956a5a277398823ae6851855f3f8004072090ed6f89868674170d9e33c13) #rust.patch

##  7e9bce18d314a0b945922730b8b9ff01740ccb99583bcf24a68a5bfa4081b859  gdb-13.1-02-x86_64.pkg.tar.lz
##  67d01217a9b4fb3134681362002de7ce590154fdbd82236470f334074741550f  gdb-common-13.1-02-x86_64.pkg.tar.lz

