# Build recipe for tree.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
# Copyright (c) 2018, 2021-2022 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=tree
version=2.0.1
release=1

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

tarname=${program}-${version}.tgz

# Remote source(s)
fetch=http://mama.indstate.edu/users/ice/tree/src/"$tarname"

description="
Tree is a recursive directory listing command.

Tree produces a depth indented listing of files, which is colorized 
ala dircolors if the LS_COLORS environment variable is set and output 
is to tty. Tree has been ported and reported to work under the 
following operating systems: Linux, FreeBSD, OS X, Solaris, 
HP/UX, Cygwin, HP Nonstop and OS/2. 
"

homepage=https://mama.indstate.edu/users/ice/tree/
license=GPLv2+

# Source documentation
docs="CHANGES LICENSE README TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"
   
    make -j${jobs} \
     CPPFLAGS="$QICPPFLAGS" \
     CFLAGS="$QICFLAGS -O3 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" \
     LDFLAGS="$QILDFLAGS -static" \
     PREFIX="${destdir}/usr" \
     MANDIR="${destdir}/${mandir}" install

    lzip -9 "${destdir}/${mandir}/man1/tree.1"

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

