code:
# Build recipe for kmod.
#
# Copyright (c) 2017-2019 Matias Fonzo, <selk@dragora.org>.
# Copyright (c) 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=kmod
version=29
release=1

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/linux/utils/kernel/kmod/$tarname

description="
Linux kernel module handling.

kmod is a set of tools to handle common tasks with Linux kernel modules
like insert, remove, list, check properties, resolve dependencies and
aliases.
"

homepage=https://git.kernel.org/?p=utils/kernel/kmod/kmod.git
license=LGPLv2.1

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

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

    cd "$srcdir"

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

    # Add support for Kernel modules compressed with LZIP
    patch -p1 < "${worktree}/patches/kmod/kmod-29_lzip-0.diff"

    autoreconf -vif

    # --enable-static is not supported by kmod

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     lzlib_LIBS="-llz" lzlib_CFLAGS="-llz" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-static \
     --enable-shared \
     --enable-tools \
     --with-rootlibdir=/usr/lib${libSuffix} \
     --with-openssl \
     --with-zlib \
     --with-lzlib \
     --without-xz \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Make symlinks for compatibility

    mkdir -p "${destdir}/usr/sbin"
    for target in depmod insmod lsmod modinfo modprobe rmmod
    do
        ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
    done

    # For user invocation
    ( cd "${destdir}/usr/bin" && ln -sf ../bin/kmod lsmod )

    # Prepare directories / files for modprobe

    mkdir -p "${destdir}/usr/lib${libSuffix}/modprobe.d" \
             "${destdir}/etc/modprobe.d"

    for file in "${worktree}"/archive/kmod/etc/modprobe.d/*
    do
        cp -p $file "${destdir}/etc/modprobe.d/"
        chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
    done

    # To manage (dot) new files
    touch "${destdir}/etc/modprobe.d/.graft-config"

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/kernel/kmod/recipe


code:
# Build recipe for alsa-lib.
#
# Copyright (c) 2017-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=alsa-lib
version=1.2.6.1
release=1

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

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

# Remote source(s)
fetch=ftp://ftp.alsa-project.org/pub/lib/$tarname

description="
The ALSA library.

The alsa-lib package contains the ALSA library.  This is used by
programs (including ALSA utilities) requiring access to the ALSA
sound interface.
"

homepage=https://alsa-project.org
license=LGPLv2.1

# Source documentation
docs="COPYING ChangeLog MEMORY-LEAK NOTES TODO version doc/asoundrc.txt"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --without-versioned \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

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

repo_name: dustdfg/dragora

path: recipes/libs/alsa-lib/recipe

license: mit


code:
# Build recipe for alsa-plugins.
#
# Copyright (c) 2017-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=alsa-plugins
version=1.2.6
release=1

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

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

# Remote source(s)
fetch=ftp://ftp.alsa-project.org/pub/plugins/$tarname

description="
Plugins for ALSA.

The alsa-plugins package contains plugins for
various audio libraries and sound servers.
"

homepage=https://alsa-project.org
license="LGPLv2.1, GPLv2+"

# Source documentation
docs="COPYING* version"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

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

path: recipes/libs/alsa-plugins/recipe


code:
# Build recipe for audiofile.
#
# Copyright (c) 2020 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=audiofile
version=0.3.6
release=1

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

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

# Remote source(s)
fetch=https://audiofile.68k.org/$tarname

description="
Audio file library.

The Audio File Library is a C-based library for reading and writing
audio files in many common formats.

The Audio File Library provides a uniform API which abstracts away
details of file formats and data formats. The same calls for opening
a file, accessing and manipulating audio metadata (e.g. sample rate,
sample format, textual information, MIDI parameters), and reading and
writing sample data will work with any supported audio file format.

The Audio File Library lets you work with audio data in whatever
format is most convenient for you.
"

homepage=https://audiofile.68k.org
license="LGPLv2.1, GPLv2+"

# Source documentation
docs="ACKNOWLEDGEMENTS AUTHORS COPYING* ChangeLog NEWS NOTES README TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    # Update for hosts based on musl
    cp -f "${worktree}/archive/common/config.guess" config.guess
    cp -f "${worktree}/archive/common/config.sub" config.sub

    # Apply patches from Debian to refresh this old source
    while read -r line
    do
        patch -Np1 -i "${worktree}/patches/audiofile/${line}"
    done < "${worktree}/patches/audiofile/series"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/audiofile/recipe


code:
# Build recipe for barelibs (dragora).
#
# Copyright (c) 2021 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=barelibs
version=dragora
pkgversion=20211101
release=1

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

description="
Set of various libraries that will be required by many programs.

This package is composed of many (shared) libraries from different
packages, which will be used by many programs.  That is, in case you
have not installed or do not have installed the package containing the
required library; once the package containing the library included here
is installed, your part will be replaced by the installed package.
"

homepage=https://www.dragora.org
license=Custom

build()
{
    rm -rf "$destdir"
    mkdir -p "$destdir"

    cd "$destdir"

    # Read list of file names declared on the 'tracked-names' list.
    #
    # This list is intended to be general, and is based on the
    # "Slackware Linux" list(s), which is now a big distribution.
    # It makes sense, since we do not want to be missing a shared
    # library necessary for the execution of some program within
    # the system.  Thanks.  :^)
    #
    while read -r name
    do
        for file in $(find /usr/lib${libSuffix} -name "${name}*")
        do
            # We are looking for a file, not for a directory
            if test -d "$file"
            then
                continue;
            fi
            # Ignore libtool, static libraries and other extensions
            case "${file##*.}" in
            a | la | pc | spec )
                continue;;
            esac
            if test ! -e "$file"
            then
                printf '%s\n' "" \
                 "WARNING: \`${file##*/}' is not found on the distro installation." \
                 "    This means that the package providing the *shared library* may" \
                 "    not yet be available for the distro, so it will be ignored" \
                 "    for inclusion in the creation of this package." 1>&2
                continue;
            fi

            # Get the real location and real directory of the file

            real_location="$(readlink -- "$file")"
            real_directory="$(dirname -- "$real_location")"

            destination="${real_directory##*@}"
            destination="${destination#*/}"

            # Create directory in destination if needed
            if test ! -d "${destdir}/${destination}"
            then
                mkdir -v -p "${destdir}/${destination}"
            fi

            # Now copy the file as it is (without traverse the path)
            cp -v -p -P "$real_location" "${destdir}/${destination}"

            unset -v real_location real_directory destination
        done
    done < "${worktree}"/archive/barelibs/tracked-names

    # Do not include the following (non-essential) libraries

    rm -f \
     "${destdir}/usr/lib${libSuffix}"/libdbus-?-tqt* \
     "${destdir}/usr/lib${libSuffix}"/libdbus-tqt*
}

path: recipes/libs/barelibs/recipe


code:
# Build recipe for D-Bus GLib.
#
# Copyright (C) 2018, MMPG <mmpg@vp.pl>
# Copyright (c) 2018, 2020-2021 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=dbus-glib
version=0.112
release=1

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

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

# Remote source(s)
fetch=https://dbus.freedesktop.org/releases/dbus-glib/$tarname

description="
Glib bindings for D-Bus.

The dbus-glib package contains GLib interfaces to the D-Bus API.
"

homepage=https://www.freedesktop.org/wiki/Software/dbus/
license="AFLv2.1 | GPLv2+"

# Source documentation
docs="AUTHORS COPYING NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-bash-completion \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} V=1 \
     completiondir=/usr/share/bash-completion/completions \
     DESTDIR="$destdir" \
     install-strip

    (
        cd "${destdir}/usr/share/bash-completion/completions"
        mv -f dbus-bash-completion.sh dbus-glib
    )

    # Compress manpages
    lzip -9 "${destdir}/${mandir}/"/man?/*.?

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

path: recipes/libs/dbus-glib/recipe


code:
# Recipe file for expat.
#
# Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2017-2019, 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=expat
version=2.4.2
release=1

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

description="
A stream-oriented XML parser library written in C.

Expat excels with files too large to fit RAM, and where
performance and flexibility are crucial.
"

homepage=https://libexpat.github.io/
license=MIT

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

# Remote source(s)
fetch=https://downloads.sourceforge.net/project/expat/expat/${version}/$tarname

# Source documentation
docs="AUTHORS COPYING Changes README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress manual pages
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 {} +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

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

path: recipes/libs/expat/recipe


code:
# Build recipe for fftw.
#
# Copyright (c) 2021 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=fftw
version=3.3.10
release=1

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

description="
A fast C library for computing the discrete Fourier transform.

FFTW is a C subroutine library for computing the discrete Fourier
transform (DFT) in one or more dimensions, of arbitrary input size,
and of both real and complex data (as well as of even/odd data, i.e.
the discrete cosine/sine transforms or DCT/DST).
"

homepage=https://fftw.org
license=GPLv2+

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

# Remote source(s)
fetch=http://www.fftw.org/$tarname

# Source documentation
docs="AUTHORS CONVENTIONS COPYING COPYRIGHT NEWS README* TODO"
docsdir="${docdir}/${program}-${version}"

_configure_argv()
{
    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
    LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --infodir=$infodir \
    --mandir=$mandir \
    --docdir=$docsdir \
    --enable-static=no \
    --enable-shared=yes \
    --build="$(gcc -dumpmachine)" "$@"
}

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

    cd "$srcdir"

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

    # Set custom build options per architecture
    case $arch in
    i?86 | amd64 | x32 )
        _build_simd="--enable-sse2 --enable-avx"
        ;;
    esac

    # Build with double precision arithmetic support

    _configure_argv $_build_simd
    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Build with single precision support

    make clean
    _configure_argv $_build_simd --enable-threads --enable-float
    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    unset -v _build_simd

    # Build with long double support

    make clean
    _configure_argv --enable-threads --enable-long-double
    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Build with quad precision support

    make clean
    _configure_argv --enable-threads --enable-quad-precision
    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    unset -f _configure_argv

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress manual pages
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 {} +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

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

path: recipes/libs/fftw/recipe


code:
# Build recipe for fuse (version 2).
#
# Copyright (c) 2019-2020 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=fuse
version=2.9.9
release=3

# Set custom package name
pkgname=fuse2

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

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

# Remote source(s)
fetch=https://github.com/libfuse/libfuse/releases/download/fuse-${version}/$tarname

description="
Filesystem in userspace (release 2).

FUSE (Filesystem in Userspace) is a simple interface for userspace
programs to export a virtual filesystem to the Linux kernel.  FUSE
also aims to provide a secure method for non privileged users to
create and mount their own filesystem implementations.
"

homepage=https://github.com/libfuse/libfuse/
license="GPLv2+, LGPLv2.1"

# Source documentation
docs="AUTHORS COPYING* ChangeLog NEWS README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    MOUNT_FUSE_PATH=/usr/sbin INIT_D_PATH=/etc/rc.d \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-lib \
     --enable-util \
     --disable-static \
     --disable-example \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Replace rc script with a better one from Dragora!
    rm -f "${destdir}/etc/rc.d/fuse"
    cp -p "${worktree}/archive/fuse/rc.fuse" "${destdir}/etc/rc.d/"
    chmod 755 "${destdir}/etc/rc.d/rc.fuse"

    touch "${destdir}/etc/rc.d/.graft-config"

    # Rules for FUSE are already managed by eudev
    rm -rf "${destdir}/etc/udev" "${destdir}/dev"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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


code:
# Build recipe for gettext.
#
# Copyright (c) 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=gettext
version=0.21
release=1

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/gettext/$tarname

description="
Utilities for internationalization and localization.

The GNU gettext package contains utilities for internationalization
and localization.  These allow programs to be compiled with NLS
(Native Language Support), enabling them to output messages in the
user's native language.
"

homepage=https://www.gnu.org/software/gettext
license=GPLv3+

# Source documentation
docs="AUTHORS COPYING ChangeLog HACKING NEWS README THANKS"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --htmldir=${docsdir}/html \
     --enable-shared=yes \
     --enable-static=no \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress examples
    (
        cd "${destdir}$docsdir" && \
         tarlz --solid -9 -cpf examples.tar.lz examples/ && \
          rm -rf examples/
    )

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/gettext/recipe


code:
libs/pcre
python/python3


code:
if test -d "${rootdir}/lib/gio/modules"
then
    echo "Updating GIO module(s) cache: gio-querymodules lib/gio/modules ..."
    chroot "$rootdir" /usr/bin/gio-querymodules lib/gio/modules 2> /dev/null
fi

echo "Updating GLIB schemas: glib-compile-schemas usr/local/share/glib* usr/share/glib*"
for directory in usr/local/share/glib* usr/share/glib*
do
    test -d "${rootdir}/$directory" || continue;
    chroot "$rootdir" /usr/bin/glib-compile-schemas "${directory}"/schemas 2> /dev/null
done
unset -v directory


code:
# Build recipe for glib (release 2, pass 1).
#
# Copyright (c) 2020-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=glib
version=2.70.2
release=1

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

# Set a custom name for this package
pkgname=glib2-pass1

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

# Remote source(s)
fetch="https://download.gnome.org/sources/glib/${version%.*}/$tarname"

description="
General purpose library of C routines.

GLib is the low-level core library that forms the basis for projects
such as GTK+ and GNOME.  It provides data structure handling for C,
portability wrappers, and interfaces for such runtime functionality
as an event loop, threads, dynamic loading, and an object system.
"

homepage=https://wiki.gnome.org/Projects/GLib
license=LGPLv2.1

# Source documentation
docs="AUTHORS COPYING HACKING NEWS README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

    # Apply patch from "Beyond Linux From Scratch" to support 'GLIB_LOG_LEVEL'
    # which enables several warnings levels (Thank you!)
    patch -Np1 -i "${worktree}/patches/glib2/glib-2.70.2-skip_warnings-1.patch"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     -Diconv=auto \
     -Dxattr=true \
     -Dlibmount=enabled \
     -Dman=false \
     -Dgtk_doc=false \
     -Dfam=false \
     -Dselinux=disabled \
     ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    cd ..

    # Delete generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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


code:
# Build recipe for glib (release 2).
#
# Copyright (c) 2017-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=glib
version=2.70.2
release=1

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

# Set a custom name for this package
pkgname=glib2

# The installation of this package replaces to
replace=glib2-pass1

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

# Remote source(s)
fetch="https://download.gnome.org/sources/glib/${version%.*}/$tarname"

description="
General purpose library of C routines.

GLib is the low-level core library that forms the basis for projects
such as GTK+ and GNOME.  It provides data structure handling for C,
portability wrappers, and interfaces for such runtime functionality
as an event loop, threads, dynamic loading, and an object system.
"

homepage=https://wiki.gnome.org/Projects/GLib
license=LGPLv2.1

# Source documentation
docs="AUTHORS COPYING HACKING NEWS README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

    # Apply patch from "Beyond Linux From Scratch" to support 'GLIB_LOG_LEVEL'
    # which enables several warnings levels (Thank you!)
    patch -Np1 -i "${worktree}/patches/glib2/glib-2.70.2-skip_warnings-1.patch"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     -Diconv=auto \
     -Dxattr=true \
     -Dlibmount=enabled \
     -Dman=true \
     -Dgtk_doc=false \
     -Dfam=false \
     -Dselinux=disabled \
     ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    cd ..

    # Delete generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"

    # Include profile file
    mkdir -p "${destdir}/etc/profile.d"
    cp -p "${worktree}/archive/glib2/etc/profile.d/glib2.sh" \
           "${destdir}/etc/profile.d/"
    chmod 644 "${destdir}/etc/profile.d/glib2.sh"

    # To handle config file(s)
    touch "${destdir}/etc/profile.d/.graft-config"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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


code:
# Build recipe for gmp.
#
# Copyright (c) 2015-2017 Matias Fonzo, <selk@dragora.org>.
# Copyright (c) 2019-2021 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=gmp
version=6.2.1
release=1

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

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

# Remote source(s)
fetch=ftp://ftp.gnu.org/gnu/gmp/$tarname

description="
GNU multiple precision arithmetic library.

GMP is a free library for arbitrary precision arithmetic, operating
on signed integers, rational numbers, and floating-point numbers.
There is no practical limit to the precision except the ones implied
by the available memory in the machine GMP runs on.

GMP has a rich set of functions, and the functions have a regular
interface.
"

homepage=https://gmplib.org
license="GPLv2+, GPLv3+, LGPLv3+"

# Source documentation
docs="AUTHORS COPYING* ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --docdir=$docsdir \
     --enable-cxx \
     --enable-static \
     --enable-shared \
     --without-readline \
     --build="$(gcc -dumpmachine)"

    make -j${jobs}
    make -j${jobs} check
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

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

path: recipes/libs/gmp/recipe


code:
# Build recipe for hwdata.
#
# Copyright (c) 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=hwdata
version=0.355
arch=noarch
release=1

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

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

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

description="
Hardware identification and configuration data.

hwdata contains various hardware identification and configuration data,
such as the pci.ids and usb.ids databases.
"

homepage=https://github.com/vcrhonek/hwdata
license="GPLv2+ | XFree86 1.0 license"

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

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

    cd "$srcdir"

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

    ./configure $configure_args --libdir=/usr/lib${libSuffix}
    make -j${jobs} install DESTDIR="$destdir"

    # Make symlinks of the database for programs looking at /usr/share/
    (
        cd "${destdir}/usr/share" || exit 1
        for file in hwdata/*
        do
            ln -sf "$file" .
        done
    )

    # Information already provided by the eudev package
    rm -rf "${destdir}/usr/lib${libSuffix}/modprobe.d"
    rmdir "${destdir}/usr/lib${libSuffix}"

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

path: recipes/libs/hwdata/recipe


code:
# Build recipe for icu.
#
# Copyright (c) 2019-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=icu4c
version=70_1
release=1

# Set custom name and custom version for the package
pkgname=icu
pkgversion="$(echo $version | tr _ .)"

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

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

# Remote source(s)
fetch="https://github.com/unicode-org/icu/releases/download/release-$(printf $version | tr _ -)/$tarname"

description="
International Components for Unicode.

The International Components for Unicode (icu) package is a mature,
widely used set of C/C++ libraries providing Unicode and
Globalization support for software applications. ICU is widely
portable and gives applications the same results on all platforms.
"

homepage=https://site.icu-project.org
license="ICU License"

# Source documentation
docs="LICENSE icu4c.css license.html readme.html"
docsdir="${docdir}/${program}-${version}"

# The source has a custom source directory
srcdir=icu

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

    cd "${srcdir}"/source

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

    ./configure CC=gcc CXX=g++ \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-icu-config \
     --disable-tests \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Copy documentation

    cd ../

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

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi
}

path: recipes/libs/icu/recipe


code:
# Build recipe for inih.
#
# Copyright (c) 2021 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=inih
version=r53
release=1

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

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

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

description="
A simple .ini file parser written in C.

inih (INI Not Invented Here) is a simple .INI file parser written in C.
It's only a couple of pages of code, and it was designed to be small and
simple, so it's good for embedded systems.  It's also more or less
compatible with Python's ConfigParser style of .INI files, including
RFC 822-style multi-line syntax and name: value entries.
"

homepage=https://github.com/benhoyt/inih/
license="New BSD License"

# Source documentation
docs=README.md
docsdir="${docdir}/${program}-${version}"

# Limit parallel jobs for this build
jobs=1

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir -p BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" \
    CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    cd ..

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

path: recipes/libs/inih/recipe


code:
# Build recipe for isl.
#
# Copyright (c) 2016-2021 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=isl
version=0.24
release=2

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

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

# Remote source(s)
fetch=https://libisl.sourceforge.io/$tarname

description="
A library of integers.

ISL is a library for manipulating sets and relations of integer points
bounded by linear constraints.  Supported operations on sets include
intersection, union, set difference, emptiness check, convex hull,
(integer) affine hull, integer projection, and computing the
lexicographic minimum using parametric integer programming.

It also includes an ILP solver based on generalized basis reduction.
"

homepage=https://freshmeat.net/projects/isl
license=MIT

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

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

    cd "$srcdir"

    # Update for hosts based on musl
    cp -f "${worktree}/archive/common/config.guess" config.guess
    cp -f "${worktree}/archive/common/config.sub" config.sub

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --enable-static \
     --enable-shared \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Move misplaced file(s) for GDB
    mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
    mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
       "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"

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

path: recipes/libs/isl/recipe


code:
# Build recipe for json-c.
#
# Copyright (c) 2022 DustDFG, <dfgdust@gmail.com>.
#
# 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=json-c
version=0.16-20220414
release=1

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

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

# Remote source(s)
fetch=https://github.com/json-c/json-c/archive/refs/tags/$tarname

description="
The C library for parsing and manipulating strings in json format.

JSON-C implements a reference counting object model that allows you to easily
construct JSON objects in C, output them as JSON formatted strings and parse
JSON formatted strings back into the C representation of JSON objects. It aims
to conform to RFC 7159.
"

homepage=https://github.com/json-c/json-c
license=MIT

# Source documentation
docs="COPYING README.md"
docsdir="${docdir}/${program}-${version}"

# The source has a custom directory name
srcdir=${program}-json-c-${version}

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_C_FLAGS="$QICFLAGS"                                           \
     -DCMAKE_SHARED_LINKER_FLAGS="$QILDFLAGS"                              \
     -DCMAKE_STATIC_LINKER_FLAGS="$QILDFLAGS"                              \
     -DCMAKE_INSTALL_PREFIX=/usr                                           \
     -DCMAKE_INSTALL_LIBDIR=lib${libSuffix}                                \
     -DCMAKE_INSTALL_MANDIR=$mandir                                        \
     -DCMAKE_INSTALL_DOCDIR=$docsdir                                       \
     -DBUILD_SHARED_LIBS=ON                                                \
     -DBUILD_STATIC_LIBS=ON                                                \
     -DBUILD_TESTING=OFF                                                   \
     -DENABLE_THREADING=OFF                                                \
     -G Ninja ..

	#TODO: build docs when Dragora will have doxygen

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ../

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

path: recipes/libs/json-c/recipe


code:
# Build recipe for libaal.
#
# Copyright (c) 2020 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=libaal
version=1.0.7
release=1

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

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

# Remote source(s)
fetch=https://downloads.sourceforge.net/reiser4/$tarname

description="
Abstraction library for ReiserFS utilities.

This is a library that provides application abstraction mechanism.
It include device abstraction, libc independence code, etc.
"

homepage=https://www.namesys.com
license=GPLv2

# Source documentation
docs="AUTHORS BUGS COPYING CREDITS NEWS README THANKS TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --enable-shared=no \
     --enable-static=yes \
     --enable-libminimal=yes \
     --enable-memory-manager=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1 CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS"
    make -j${jobs} DESTDIR="$destdir" install-strip

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

path: recipes/libs/libaal/recipe


code:
# Build recipe for libaio.
#
# Copyright (c) 2018-2020 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=libaio
version=0.3.112
release=3

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

tarname=${program}_${version}.orig.tar.xz

# Remote source(s)
fetch=https://ftp.debian.org/debian/pool/main/liba/libaio/$tarname

description="
Kernel Asynchronous I/O (AIO) support for GNU/Linux.

AIO enables even a single application thread to overlap I/O operations
with other processing, by providing an interface for submitting one or
more I/O requests in one system call (io_submit()) without waiting for
completion, and a separate interface (io_getevents()) to reap
completed I/O operations associated with a given completion group.
"

homepage=https://lse.sourceforge.net/io/aio.html
license=LGPLv2+

# Source documentation
docs="COPYING ChangeLog TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # Apply patches from Debian, upstream to refresh this source
    while read -r line
    do
        case $line in
        *.patch)
            patch -Np1 -i "${worktree}/patches/libaio/${line}"
            ;;
        esac
    done < "${worktree}/patches/libaio/series"

    make CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS -fno-stack-protector" LDFLAGS="$QILDFLAGS" \
         prefix="${destdir}/usr" \
         libdir="${destdir}/usr/lib${libSuffix}" \
         install

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

path: recipes/libs/libaio/recipe


code:
# Build recipe for libao.
#
# Copyright (c) 2020-2021 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=libao
version=20190728_cafce90
release=2

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
Audio output portability library.

The libao package contains a cross-platform audio library.
This is useful to output audio on a wide variety of platforms.
"

homepage=https://xiph.org/ao
license=GPLv2+

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

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

    cd "$srcdir"

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

    sh ./autogen.sh
    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=no \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libao/recipe


code:
# Build recipe for libarchive.
#
# Copyright (c) 2018-2019, 2021 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=libarchive
version=3.5.2
release=1

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

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

# Remote source(s)
fetch=https://libarchive.org/downloads/$tarname

description="
Multi-format archive and compression library.

The libarchive project develops a portable, efficient C library that
can read and write streaming archives in a variety of formats.

It also includes implementations of the common tar, cpio, and zcat
command-line tools that use the libarchive library.
"

homepage=http:/libarchive.org
license=BSD

# Source documentation
docs="COPYING NEWS README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # Configure to make use of Expat and Nettle (instead of *ssl)

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --without-xml2 \
     --without-openssl \
     --with-nettle \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    rmdir "${destdir}/usr/bin" 2> /dev/null || true;

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libarchive/recipe


code:
# Build recipe for libatomic_ops.
#
# Copyright (c) 2018-2019, 2021 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=libatomic_ops
version=7.6.12
release=1

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

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

# Remote source(s)
fetch=https://github.com/ivmai/libatomic_ops/releases/download/v${version}/$tarname

description="
Implementations for atomic memory.

libatomic_ops provides implementations for atomic memory update
operations on a number of architectures.  This allows direct use of
these in reasonably portable code.  Unlike earlier similar packages,
this one explicitly considers memory barrier semantics, and allows
the construction of code that involves minimum overhead across a
variety of architectures.
"

homepage=https://github.com/ivmai/libatomic_ops
license=GPLv2+

# Source documentation
docs="AUTHORS ChangeLog";	# To complement installed documentation.
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

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


code:
# Build recipe for libburn.
#
# Copyright (c) 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=libburn
version=1.5.4
release=1

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

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

# Remote source(s)
fetch=http://files.libburnia-project.org/releases/$tarname

description="
Library to read/write optical discs.

libburn is a library for writing preformatted data onto optical media:
CD, DVD and BD (Blu-Ray).
"

homepage=https://dev.lovelyhq.com/libburnia
license=GPLv2+

# Source documentation
docs="AUTHORS CONTRIBUTORS COPYING COPYRIGHT ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=no \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    lzip -9 "${destdir}${mandir}"/man?/*

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

path: recipes/libs/libburn/recipe


code:
# Build recipe for libcap-ng.
#
# Copyright (c) 2018-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=libcap-ng
version=0.8.2
release=2

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

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

# Remote source(s)
fetch=https://people.redhat.com/sgrubb/libcap-ng/$tarname

description="
An alternate POSIX capabilities library.

The libcap-ng library is intended to make programming with POSIX
capabilities much easier than the traditional libcap library.

It includes utilities that can analyse all currently running
applications and print out any capabilities and whether or not it has
an open ended bounding set. An open bounding set without the securebits
\"NOROOT\" flag will allow full capabilities escalation for apps
retaining UID 0 simply by calling execve.
"

homepage=https://people.redhat.com/sgrubb/libcap-ng/
license="GPLv2+, LGPLv2.1"

# Source documentation
docs="AUTHORS COPYING* ChangeLog NEWS README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=yes \
     --enable-shared=yes \
     --with-python=no \
     --with-python3 \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libcap-ng/recipe


code:
# Build recipe for libcap.
#
# Copyright (c) 2016-2019, 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=libcap
version=2.62
release=1

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/$tarname

description="
Library with capabilities for POSIX.1e.

The libcap package implements the user-space interfaces to the
POSIX 1003.1e capabilities available in Linux kernels.

These capabilities are a partitioning of the all powerful root
privilege into a set of distinct privileges.
"

homepage=https://sites.google.com/site/fullycapable
license=GPLv2+

# Source documentation
docs="CHANGELOG License README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    make DEBUG="" COPTS="$QICFLAGS" LDFLAGS="$QILDFLAGS"

    make install RAISE_SETFCAP=no \
                 DESTDIR="$destdir" \
                 LIBDIR=/usr/lib${libSuffix} \
                 SBINDIR=/usr/sbin \
                 PKGCONFIGDIR=/usr/lib${libSuffix}/pkgconfig

    # Fix permissions
    chmod 755 "${destdir}/usr/lib${libSuffix}/libcap.so"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libcap/recipe


code:
# Build recipe for libdatrie.
#
# Copyright (C) 2019, 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=libdatrie
version=0.2.13
release=2

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

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

# Remote source(s)
fetch=https://github.com/tlwg/libdatrie/releases/download/v${version}/$tarname

description="
A double-Array Trie library.

libdatrie is an implementation of double-array structure for
representing trie, as proposed by Junichi Aoe.  Trie is a
kind of digital search tree, an efficient indexing method with
O(1) time complexity for searching. Comparably as efficient as
hashing, trie also provides flexibility on incremental matching
and key spelling manipulation.  This makes it ideal for
lexical analyzers, as well as spelling dictionaries.

See the details of the implementation at:
https://linux.thai.net/~thep/datrie/datrie.html

Historically, this was first implemented as C++ classes in a
library called midatrie, but later simplified and rewritten
from scratch in C.
"

homepage=https://linux.thai.net/projects/datrie
license=LGPLv2.1

# Copy documentation
docs="AUTHORS COPYING ChangeLog NEWS README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Build and install the trietool utility
    ( cd tools/ && make install DESTDIR="$destdir" install-strip )

    # Copy the rest of the documentation
    mkdir -p "${destdir}/$docsdir"
    cp -p -f $docs "${destdir}/$docsdir"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi
}

path: recipes/libs/libdatrie/recipe


code:
# Build recipe for libedit.
#
# Copyright (c) 2016-2019, 2021 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=libedit
version=20210910-3.1
release=1

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

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

# Remote source(s)
fetch=https://thrysoee.dk/editline/$tarname

description="
A command line editor library.

This is a port of the NetBSD Editline library (libedit).
This Berkeley-style licensed command line editor library
provides generic line editing, history, and tokenization
functions, similar to those found in GNU Readline.
"

homepage=https://thrysoee.dk/editline
license=BSD

# Source documentation
docs="COPYING ChangeLog THANKS"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static \
     --enable-shared \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # This is provided by the readline package
    rm -f "${destdir}/${mandir}/man3/history.3"

    # Compress and link man pages (if needed)
    if [ -d "${destdir}/$mandir" ] ; then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libedit/recipe


code:
# Build recipe for liepoxy.
#
# Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2018, 2020-2021 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=libepoxy
version=1.5.9
release=1

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

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

# Remote source(s)
fetch=https://github.com/anholt/libepoxy/releases/download/${version}/$tarname

description="
A library for handling OpenGL function pointer management.

It hides the complexity of dlopen(), dlsym(), glXGetProcAddress(),
eglGetProcAddress(), etc. from the app developer, with very little
knowledge needed on their part.  They get to read GL specs and write
code using undecorated function names like glCompileShader().
"

homepage=https://github.com/anholt/libepoxy
license=MIT

# Source documentation
docs="COPYING README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     -Dglx=yes \
     -Degl=yes \
     -Dx11=true \
     ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    cd ..

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

path: recipes/libs/libepoxy/recipe


code:
# Build recipe for libetpan.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
# Copyright (c) 2018-2019, 2021 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=libetpan
version=1.9.4
release=1

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

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

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

description="
A library that will handle all kind of mailbox access.

The purpose of this mail library is to provide a portable, efficient
framework for different kinds of mail access: IMAP, SMTP, POP and NNTP.

It provides an API for C language.
"

homepage=https://www.etpan.org/libetpan.html
license="3-clause BSD"

# Source documentation
docs="AUTHORS COPYRIGHT NEWS README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # TODO: SASL support for build against `--with-sasl'.

    sh ./autogen.sh CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-db \
     --enable-ipv6 \
     --with-zlib \
     --with-sasl=no \
     --with-openssl=no --with-gnutls=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libetpan/recipe


code:
# Build recipe for libevent.
#
# Copyright 2018 Mateus P. Rodrigues <mprodrigues@dragora.org>.
# Copyright 2018-2019, 2021 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=libevent
version=2.1.12-stable
pkgversion=$(echo $version | cut -f 1 -d -)
release=1

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

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

# Remote source(s)
fetch=https://github.com/libevent/libevent/releases/download/release-${version}/$tarname

description="
An event notification library.

The libevent API provides a mechanism to execute a callback function
when a specific event occurs on a file descriptor or after a timeout
has been reached.  Furthermore, libevent also support callbacks due
to signals or regular timeouts.
"

homepage=https://libevent.org/
license="3-clause BSD"

# Source documentation
docs="ChangeLog* LICENSE"
docsdir="${docdir}/${program}-${pkgversion}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --enable-gcc-hardening \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

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

path: recipes/libs/libevent/recipe


code:
# Build recipe for libffcall.
#
# Copyright (c) 2017 MMPG, <mmpg@vp.pl>.
# Copyright (c) 2017-2019, 2021 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=libffcall
version=2.4
release=1

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/pub/gnu/libffcall/$tarname

description="
Foreign function call libraries.

GNU libffcall is a collection of four libraries which can be used to
build foreign function call interfaces in embedded interpreters:

* avcall
Calling C functions with variable arguments.

* vacall
C functions accepting variable argument prototypes.

* trampoline
Closures as first-class C functions.

* callback
Closures with variable arguments as first-class C functions
(a reentrant combination of vacall and trampoline).
"

homepage=https://www.gnu.org/software/libffcall/
license=GPLv3+

# Source doucmentation
docs="COPYING ChangeLog DEPENDENCIES NEWS README VERSION"
docsdir="${docdir}/${program}-${version}"

# Set paralell jobs to 1 for a sucessful compilation
jobs=1

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --htmldir=${docsdir}/html \
     --enable-static=yes \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs}
    make -k check
    make -j${jobs} DESTDIR="$destdir" install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation

    mkdir -p "${destdir}/$docsdir"

    # Move wrong HTML directory
    mv "${destdir}/usr/share/html" "${destdir}/$docsdir"

    cp -p $docs "${destdir}/$docsdir"
}

path: recipes/libs/libffcall/recipe


code:
# Build recipe for libffi.
#
# Copyright (c) 2017, 2021 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=libffi
version=3.4.2
release=1

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

description="
A high level programming interface to various calling conventions.

The libffi library provides a portable, high level programming
interface to various calling conventions.  This allows a programmer to
call any function specified by a call interface description at run time.
"

homepage=https://sourceware.org/libffi/
license=BSD

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

# Remote source(s)
fetch=https://github.com/libffi/libffi/releases/download/v${version}/$tarname

# Source documentation
docs="ChangeLog LICENSE* README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress manual pages
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 {} +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

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

path: recipes/libs/libffi/recipe


code:
# Build recipe for libid3tag.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
# Copyright (c) 2018 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=libid3tag
version=0.15.1b
release=1

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

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

# Remote source(s)
fetch=ftp://ftp.mars.org/pub/mpeg/$tarname

description="
ID3 tag manipulation library.

libid3tag is a library for reading and (eventually) writing ID3 tags,
both ID3v1 and the various versions of ID3v2.
"

homepage=https://www.underbit.com/products/mad/
license=GPLv2+

# Source documentation
docs="CHANGES COPYING COPYRIGHT CREDITS README TODO VERSION"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # Update for hosts based on musl
    cp -f "${worktree}/archive/common/config.guess" config.guess
    cp -f "${worktree}/archive/common/config.sub" config.sub

    # Apply fixes since this release is from 2004 (Thanks to Fedora and Debian)
    patch -p0 < "${worktree}/patches/libid3tag/libid3tag-0.15.1b-fix_overflow.patch"
    patch -p1 < "${worktree}/patches/libid3tag/libid3tag-0.15.1b-id3v1-zero-padding.patch"
    patch -p1 < "${worktree}/patches/libid3tag/libid3tag-0.15.1b-handle-unknown-encoding.patch"
    patch -p0 < "${worktree}/patches/libid3tag/libid3tag-0.15.1b-id3v2-endless-loop.patch"
    patch -p1 < "${worktree}/patches/libid3tag/libid3tag-0.15.1b-gperf-size_t.patch"

    touch NEWS AUTHORS ChangeLog

    # Force these files to be regenerated from the .gperf sources
    rm -f compat.c frametype.c

    autoreconf -vif

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --enable-static=no \
    --enable-shared=yes \
    --disable-debugging \
    --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    strip --strip-unneeded "${destdir}/usr/lib${libSuffix}/"libid3tag.so.0.?.0

    # Write missing .pc for pkgconf
    mkdir -p "${destdir}/usr/lib${libSuffix}/pkgconfig"
    cat << EOF > "${destdir}/usr/lib${libSuffix}/pkgconfig/id3tag.pc"
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib${libSuffix}
includedir=\${prefix}/include

Name: id3tag
Description: ID3 tag manipulation library
Version: ${version}
Requires:
Libs: -L\${libdir} -lid3tag -lz
Cflags: -I\${includedir}

EOF

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


code:
# Build recipe for libidn.
#
# Copyright (c) 2021 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=libidn
version=1.38
release=1

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/libidn/$tarname

description="
An implementation of IDNA2003.

Libidn is a package for internationalized string handling based on the
Stringprep, Punycode, IDNA2003 and TLD specifications.
"

homepage=https://www.gnu.org/software/libidn/
license="GPLv2+, LGPLv2+"

# Source documentation
docs="AUTHORS COPYING* ChangeLog FAQ HACKING NEWS README THANKS"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --disable-doc \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Delete generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"
    rmdir "${destdir}/usr/lib${libSuffix}/" 2> /dev/null || true

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libidn/recipe


code:
# Build recipe for libidn2.
#
# Copyright (c) 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=libidn2
version=2.3.2
release=1

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/libidn/$tarname

description="
An implementation of IDNA2008.

Libidn2 is a free software implementation of IDNA2008, Punycode and TR46.
Its purpose is to encode and decode internationalized domain names.
"

homepage=https://www.gnu.org/software/libidn/
license="GPLv2+, LGPLv3+"

# Source documentation
docs="AUTHORS CONTRIBUTING.md COPYING* ChangeLog NEWS README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --disable-doc \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Delete generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"
    rmdir "${destdir}/usr/lib${libSuffix}/" 2> /dev/null || true

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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


code:
# Build recipe for libisoburn.
#
# Copyright (c) 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=libisoburn
version=1.5.4
release=1

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

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

# Remote source(s)
fetch=http://files.libburnia-project.org/releases/$tarname

description="
Multi-session filesystem extension to libisofs, libburn.

libisoburn is a frontend for libraries libburn and libisofs which
enables creation and expansion of ISO-9660 filesystems on all
CD/DVD/BD media supported by libburn.  This includes media like
DVD+RW, which do not support multi-session management on media
level and even plain disk files or block devices.
"

homepage=https://dev.lovelyhq.com/libburnia
license=GPLv2+

# Source documentation
docs="AUTHORS CONTRIBUTORS COPYING COPYRIGHT ChangeLog NEWS README TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=no \
     --enable-pkg-check-modules \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress info documents (if needed)
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/libs/libisoburn/recipe


code:
# Build recipe for libisofs.
#
# Copyright (c) 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=libisofs
version=1.5.4
release=1

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

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

# Remote source(s)
fetch=http://files.libburnia-project.org/releases/$tarname

description="
ISO9660 filesystem creation library.

libisofs is a library to create an ISO-9660 filesystem with
extensions like RockRidge or Joliet.
"

homepage=https://dev.lovelyhq.com/libburnia
license=GPLv2+

# Source documentation
docs="AUTHORS COPYING COPYRIGHT ChangeLog NEWS README TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=no \
     --enable-ldconfig-at-install=no \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

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

path: recipes/libs/libisofs/recipe