# Packager = Tuxcore <dev@tuxcore.org> 
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=15.2
pkgrel=3
pkgdesc='The GNU Debugger'
arch=(x86_64)
url='https://www.gnu.org/software/gdb/'
license=(GPL-3.0-or-later LGPL-3.0-or-later)
makedepends=(
  bash
  boost
  expat
  gcc-libs
  glibc
  gmp
  guile
  mpfr
  ncurses
  python
  readline
  source-highlight
  texinfo
  xxhash
  xz
  zstd
)
source=(https://ftp.gnu.org/gnu/gdb/${pkgname}-${pkgver}.tar.xz{,.sig})
sha1sums=('f06b8694d2019e03f55560059aac4a5b70a32677'
          'SKIP')
b2sums=('073668c21b41f12bf40160c6d3df808056453cc9df3b5b86374abe38e955d208f86467458b7e64b3c3e93d70b7f87425619778173fdb375256cd85be15419f14'
        'SKIP')
validpgpkeys=('F40ADB902B24264AA42E50BF92EDB04BFF325CF3') # Joel Brobecker

build() {
  cd gdb-$pkgver

  mkdir -p build && cd build
  ../configure \
    --prefix=/usr \
    --disable-nls \
    --enable-source-highlight \
    --enable-tui \
    --enable-targets=all \
    --enable-languages=all \
    --enable-multilib \
    --enable-interwork \
    --with-system-readline \
    --with-python=/usr/bin/python \
    --with-system-gdbinit=/etc/gdb/gdbinit
  make
}

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

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

package_gdb() {
  depends=(
    bash
    expat
    gcc-libs
    gdb-common=$pkgver
    glibc
    gmp
    guile
    libelf
    liblzma.so
    libmpfr.so
    libncursesw.so
    libreadline.so
    libxxhash.so
    libzstd.so
    mpfr
    ncurses
    python
    readline
    source-highlight
    xxhash
    xz
    zstd
  )
  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/"
}

# vim: ts=2 sw=2 et:
