# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=gettext
pkgver=0.22.5
pkgrel=2
pkgdesc="GNU internationalization library"
url="https://www.gnu.org/software/gettext/"
arch=(x86_64)
license=(
  GFDL-1.2-only
  GPL-2.0-only
  GPL-2.0-or-later
  LGPL-2.0-only
)
depends=(
  acl
  gcc-libs
  libunistring
  libxml2
  sh
)
makedepends=(
  emacs
)
optdepends=('git: for autopoint infrastructure updates')
options=(!docs)
source=(https://ftp.gnu.org/pub/gnu/gettext/$pkgname-$pkgver.tar.gz{,.sig}
        gettext-0.22-disable-libtextstyle.patch)
b2sums=('39bc18de7b8836c63dec0b006555eec0bb82e7bbf210ea774f47d9933c98dad9a719c9cd2eff46ec3bacc8be633167a4fa8d84bb0132cdadbb86d182235b63b7'
        'SKIP'
        '8512f87c7c8fc6bedf2992a5da8b34ee847dd61af4f55407ff9e02b965afcbea508b1dd87cd2e31c689166ee8ded824f54a95089978274753a6730a8a1d39164')
validpgpkeys=('462225C3B46F34879FC8496CD605848ED7E69871'  # Daiki Ueno
              '68D94D8AAEEAD48AE7DC5B904F494A942E4616C2'
              '9001B85AF9E1B83DF1BDA942F5BE8B267C6A406D') # Bruno Haible (Open Source Development)

prepare() {
  cd ${pkgname}-${pkgver}
  # Do not build libtextstyle, as it depends on libcroco
  # which is now unmaintained and has known security bugs.
  # patch from Fedora	
  patch -p1 -i $srcdir/gettext-0.22-disable-libtextstyle.patch
  autoreconf -f
  automake
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --enable-csharp \
    --enable-nls \
    --with-xz \
    --without-included-gettext
  sed -e 's/ -shared / -Wl,-O1,--as-needed\0/g' \
      -i gettext-{tools,runtime,runtime/libasprintf}/libtool
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="$pkgdir" install
}
