# Build recipe for ncompress.
#
# Copyright (c) 2023 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Exit immediately on any error
set -e

program=ncompress
version=5.0
release=1

# Define a category for the output of the package name
pkgcategory=compressors

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=https://github.com/vapier/ncompress/archive/v${version}/$tarname

description="
A fast, simple LZW file compressor.

Compress is a fast, simple LZW file compressor.  Compress does not have the
highest compression rate, but it is one of the fastest programs to compress
data.  Compress is the defacto standard in the UNIX community for compressing
files.

The ncompress code is, and will continue to be, released into the public
domain as the original authors intended.
"

homepage=https://vapier.github.io/ncompress/
license="Public Domain"

# Source documentation
docs="Acknowleds Changes LICENSE.txt LZW.INFO README.md UNLICENSE"
docsdir="${docdir}/${program}-${version}"

build()
{
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    make -j${jobs} V=1 CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS"

    install -m755 compress -D "${destdir}/usr/bin/compress"
    ln -sf compress "${destdir}/usr/bin/uncompress"

    install -m644 compress.1 -D "${destdir}/${mandir}/man1/compress.1"
    install -m644 uncompress.1 -D "${destdir}/${mandir}/man1/uncompress.1"
    lzip -9 "${destdir}/${mandir}"/man1/*.1

    # Copy documentation
    mkdir -p "${destdir}/$docsdir"
    cp -p $docs "${destdir}/$docsdir"
}

