# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: judd <jvinet@zeroflux.org>

# NOTE: requires rebuilt with each new gcc version

pkgname=lib32-libltdl
pkgver=2.4.7
pkgrel=3
_gccver=12.1.0
pkgdesc='A generic library support script (32-bit)'
arch=(x86_64)
url='https://www.gnu.org/software/libtool'
license=(GPL)
depends=(sh tar lib32-glibc libtool)
makedepends=("gcc>=$_gccver" git help2man)
checkdepends=()
provides=("lib32-libtool=$pkgver")
conflicts=(lib32-libtool)
replaces=(lib32-libtool)
_commit=6d7ce133ce54898cf28abd89d167cccfbc3c9b2b
source=(git+https://git.savannah.gnu.org/git/libtool.git#commit=$_commit
        git+https://git.savannah.gnu.org/git/gnulib.git
        gnulib-bootstrap::git+https://github.com/gnulib-modules/bootstrap.git
        no_hostname.patch)
sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            '693aabb24a6e7ce21fe0b5d14394e19edcb8476663b5afa4463f9fa0df24d946')

pkgver() {
  cd libtool
  git describe --tags | sed 's/-/+/g;s/^v//'
}

prepare() {
  cd libtool

  patch -Np1 -i ${srcdir}/no_hostname.patch

  git submodule init
  git config --local submodule.gnulib.url "$srcdir/gnulib"
  git config --local submodule.gl-mod/bootstrap.url "$srcdir/gnulib-bootstrap"
  git -c protocol.file.allow=always submodule update

  ./bootstrap
}

build() {
  export CC="gcc -m32" CXX="g++ -m32"

  cd libtool
  ./configure --prefix=/usr lt_cv_sys_lib_dlsearch_path_spec="/usr/lib /usr/lib32" --libdir=/usr/lib32
  make
}

package() {
  cd libtool
  make DESTDIR="$pkgdir" install-libLTLIBRARIES
}
