pkg_name=xz
version=5.8.3
revision=1
build_style=gnu-configure
short_desc="XZ/LZMA compression utilities"
home_page="https://tukaani.org/xz/"
license="GPL-2.0-or-later"
dist_files="https://excellmedia.dl.sourceforge.net/project/lzmautils/xz-${version}.tar.gz"
checksum="80056b186e5fc54d4653c1163bc317ee690bf7fcfec890f2d29710319fe13816ca"
use_flags="-nls -doc static"

configure_args="$(use_enable doc) $(use_enable nls)"

post_install() {
    use static || return 0
    # relink the command line tools without shared liblzma so they keep
    # working if /usr/lib is fucked
    ( cd src
      rm -f xz/xz lzmainfo/lzmainfo xzdec/lzmadec xzdec/xzdec
      for d in xz lzmainfo xzdec; do
        $make_cmd LDFLAGS="$LDFLAGS -all-static" -C "$d"
      done )
    for b in src/xz/xz src/lzmainfo/lzmainfo src/xzdec/lzmadec src/xzdec/xzdec; do
        bbin "$b"
    done
}
