# Description: A library for manipulating block devices
# URL: https://github.com/storaged-project/libblockdev
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: json-glib libbytesize libyaml ndctl volume_key

name=libblockdev
version=3.5.0
release=1
source=(https://github.com/storaged-project/$name/releases/download/$version/$name-$version.tar.gz)

build() {
  cd $name-$version

  find -type f \( -name "Makefile.am" -o -name "configure.ac" \) -print0 \
    | xargs --null sed "s@ -Werror@@" -i
  export CFLAGS="${CFLAGS} -Wno-deprecated-declarations"
  aclocal
  automake

  prt-get isinst btrfs-progs || PKGMK_LIBBLOCKDEV+=' --without-btrfs'
  prt-get isinst cryptsetup || PKGMK_LIBBLOCKDEV+=' --without-crypto'
  prt-get isinst lvm2 || PKGMK_LIBBLOCKDEV+=' --without-dm'
  prt-get isinst libatasmart || PKGMK_LIBBLOCKDEV+=' --without-smart'
  prt-get isinst smartmontools || PKGMK_LIBBLOCKDEV+=' --without-smartmontools'
  prt-get isinst nvme-cli || PKGMK_LIBBLOCKDEV+=' --without-nvme'
  prt-get isinst parted || PKGMK_LIBBLOCKDEV+=' --without-part --without-tools'

  ./configure --prefix=/usr $PKGMK_LIBBLOCKDEV \
    --with-python3 \
    --without-gtk-doc
  make
  make DESTDIR=$PKG install
}
