code:
# Build recipe for libjpeg-turbo.
#
# Copyright (C) 2018, MMPG <mmpg@vp.pl>
# 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=libjpeg-turbo
version=2.1.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://downloads.sourceforge.net/libjpeg-turbo/$tarname

description="
Library for JPEG images.

libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64
processors which uses SIMD instructions (MMX, SSE2, etc.) to accelerate
baseline JPEG compression and decompression.

ibjpeg-turbo is generally 2-4x as fast as the unmodified version of
libjpeg, all else being equal.
"

homepage=https://libjpeg-turbo.org/
license="IJG | BSD, zlib"

docs="ChangeLog.md LICENSE.md README.md README.ijg"
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

    cmake \
     -DCMAKE_C_FLAGS_RELEASE:STRING="$QICFLAGS"       \
     -DCMAKE_EXE_LINKER_FLAGS:STRING="$QILDFLAGS"     \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$QILDFLAGS"  \
     -DCMAKE_INSTALL_PREFIX=/usr                      \
     -DCMAKE_INSTALL_LIBDIR=/usr/lib${libSuffix}      \
     -DCMAKE_INSTALL_MANDIR=$mandir                   \
     -DCMAKE_INSTALL_DOCDIR=$docsdir                  \
     -DCMAKE_BUILD_TYPE=Release                       \
     -DCMAKE_VERBOSE_MAKEFILE=ON                      \
     -G Ninja ..

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

    cd ..

    # 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/libjpeg-turbo/recipe


code:
# Build recipe for libmad.
#
# 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=libmad
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=https://downloads.sourceforge.net/project/mad/libmad/${version}/$tarname

description="
MPEG Audio Decoder.

MAD is a high-quality MPEG audio decoder.  It currently supports MPEG-1
and the MPEG-2 extension to lower sampling frequencies, as well as the
de facto MPEG 2.5 format.  All three audio layers: Layer I, Layer II, and
Layer III (i.e. MP3) are fully implemented.
"

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 .

    # Refresh old source with patches coming from Gentoo (thanks!)
    patch -Np1 -i "${worktree}/patches/libmad/libmad-0.15.1b-cflags.patch"
    patch -Np1 -i "${worktree}/patches/libmad/libmad-0.15.1b-cflags-O2.patch"
    patch -Np1 -i "${worktree}/patches/libmad/libmad-0.15.1b-gcc44-mips-h-constraint-removal.patch"
    patch -Np1 -i "${worktree}/patches/libmad/libmad-0.15.1b-CVE-2017-8372_CVE-2017-8373_CVE-2017-8374.patch"

    sed -e "s@AM_CONFIG_HEADER@AC_CONFIG_HEADERS@g" -i configure.ac
    touch NEWS AUTHORS ChangeLog
    autoreconf -vif

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" 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

    # Provide pkg-config file
    mkdir -p "${destdir}/usr/lib${libSuffix}/pkgconfig"
    cat << "EOF" > "${destdir}/usr/lib${libSuffix}"/pkgconfig/mad.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: mad
Description: MPEG audio decoder
Requires:
Version: 0.15.1b
Libs: -L${libdir} -lmad -lm
Cflags: -I${includedir}
EOF

    # 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"
}

repo_name: dustdfg/dragora

path: recipes/libs/libmad/recipe

license: mit


code:
# Build recipe for libmetalink.
#
# 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=libmetalink
version=0.1.3
release=1

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

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

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

description="
A library to read Metalink XML download description format.

Libmetalink is a library to read Metalink XML download description
format.  It supports Metalink version 3 and Metalink version 4
(RFC 5854).
"

homepage=https://github.com/metalink-dev
license=MIT

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

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

    cd "$srcdir"

    # https://bugs.launchpad.net/libmetalink/+bug/1888672
    patch -Np1 -i "${worktree}/patches/libmetalink/libmetalink-0.1.3-ns_uri.patch"

    # 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 \
     --with-expat \
     --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/libmetalink/recipe


code:
# Build recipe for libnsl.
#
# 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=libnsl
version=2.0.0
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/thkukuk/libnsl/releases/download/v${version}/$tarname

description="
Public client interface library for NIS(YP) and NIS+.

This package contains the libnsl library. This library contains
the public client interface for NIS(YP) and NIS+.

This code was formerly part of glibc, but is now standalone to
be able to link against TI-RPC for IPv6 support.

The NIS(YP) functions are still maintained, the NIS+ part is
deprecated and should not be used anymore.
"

homepage=https://github.com/thkukuk/libnsl
license=LGPLv2.1

# 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 \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    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"
    cp -p $docs "${destdir}/$docsdir"
}

path: recipes/libs/libnsl/recipe


code:
# Build recipe for libogg.
#
# 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=libogg
version=1.3.5
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.osuosl.org/pub/xiph/releases/ogg/$tarname

description="
File structure for the Ogg bitstream format.

The libogg package contains the Ogg file structure.  This is useful for
creating (encoding) or playing (decoding) a single physical bit stream.
"

homepage=https://www.xiph.org/ogg/
license="BSD-license inplementation of the public domain Ogg bitstream format"

# Source documentation
docs="AUTHORS CHANGES 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 .

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" 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/libogg/recipe


code:
# Build recipe for libpipeline.
#
# 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=libpipeline
version=1.5.5
release=1

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

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

# Remote source(s)
fetch=https://download.savannah.gnu.org/releases/libpipeline/$tarname

description="
Pipeline manipulation library.

Libpipeline is a C library for setting up and running pipelines of
processes, without needing to involve shell command-line parsing
which is often error-prone and insecure.
"

homepage=https://libpipeline.nongnu.org
license=GPLv3+

# Source documentation
docs="COPYING 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} \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-threads=posix \
     --enable-socketpair-pipe \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    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

    # 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/libpipeline/recipe


code:
# Build recipe for libpng.
#
# Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2017-2019 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=libpng
version=1.6.37
release=1

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

description="
The main PNG library.

libpng is the official PNG reference library.  It supports almost
all PNG features, is extensible, and has been extensively tested
for over 20 years.
"

homepage=https://www.libpng.org/pub/png/libpng.html
license="libpng license"

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

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

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

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

    cd "$srcdir"

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

    # Include animated PNG functionality in libpng
    patch -p1 < "${worktree}/patches/libpng/libpng-1.6.37-apng.patch"

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" LIBS='-lpthread' \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --infodir=$infodir \
    --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/libpng/recipe


code:
# Build recipe for libpsl.
#
# 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=libpsl
version=0.21.1
release=1

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

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

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

description="
A C library to handle the Public Suffix List.

A Public Suffix List is a collection of Top Level Domains (TLDs) suffixes.
TLDs include Global Top Level Domains (gTLDs) like .com and .net; Country
Top Level Domains (ccTLDs) like .de and .cn; and Brand Top Level Domains
like .apple and .google. Brand TLDs allows users to register their own top
level domain that exist at the same level as ICANN's gTLDs.

Brand TLDs are sometimes referred to as Vanity Domains.
"

homepage=https://github.com/rockdaboot/libpsl
license=MIT

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

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

    cd "$srcdir"

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

    # https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat
    #
    # Follow the example of Slackware, by installing the public list instead of
    # creating a separate package so that the build can proceed, which after all
    # will be overwritten.  We also follow the Fedora example for the
    # configuration of this package.  Thank you.  :-)
    if test ! -r /usr/share/publicsuffix/public_suffix_list.dat
    then
        mkdir -p /usr/share/publicsuffix
        install -p -m 644 -o root -g root \
         "${worktree}"/archive/libpsl/public_suffix_list.dat \
         /usr/share/publicsuffix/
        (
            cd /usr/share/publicsuffix && \
            ln -sf public_suffix_list.dat effective_tld_names.dat
        )
        install -p -m 644 -o root -g root \
         list/tests/tests.txt /usr/share/publicsuffix/test_psl.txt
    fi

    # Force to make use of Python v3
    # (Thanks to "Beyond Linux From Scratch")
    sed -i 's/env python/&3/' src/psl-make-dafsa

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --disable-doc \
     --enable-man \
     --enable-builtin=libicu \
     --enable-runtime=libidn2 \
     --with-psl-distfile=/usr/share/publicsuffix/public_suffix_list.dafsa \
     --with-psl-file=/usr/share/publicsuffix/effective_tld_names.dat \
     --with-psl-testfile=/usr/share/publicsuffix/test_psl.txt \
     --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 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/libpsl/recipe


code:
# Build recipe for librsvg.
#
# Copyright (C) 2018, MMPG <mmpg@vp.pl>
# 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=librsvg
version=2.40.21
release=1

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

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

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

description="
A high performance SVG rendering library.

The librsvg package contains librsvg libraries and tools used to
manipulate, convert and view Scalable Vector Graphic images.
"

homepage=https://wiki.gnome.org/Projects/LibRsvg
license="GPLv2+, LGPLv2+"

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

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

    cd "$srcdir"

    # Apply patches from Debian (Thanks!)
    patch -Np1 -i "${worktree}/patches/librsvg/10_rsvg-gz.patch"
    patch -Np1 -i "${worktree}/patches/librsvg/remove-tests.patch"
    patch -Np1 -i "${worktree}/patches/librsvg/hide-private-symbol.patch"

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
    LDFLAGS="$QILDFLAGS -Wl,--no-keep-memory,-z,defs -Wl,-O1 -Wl,--as-needed" \
    $configure_args \
    --mandir=$mandir \
    --libdir=/usr/lib${libSuffix} \
    --enable-static=no \
    --enable-shared=yes \
    --enable-pixbuf-loader \
    --enable-introspection \
    --enable-vala \
    --disable-rpath \
    --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} V=1 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/librsvg/recipe


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

# Exit immediately on any error
set -e

program=libsigsegv
version=2.14
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/libsigsegv/$tarname

description="
A library for handling page faults.

GNU libsigsegv is a library for handling page faults in user mode.
A page fault occurs when a program tries to access to a region of
memory that is currently not available.
"

hompage=https://www.gnu.org/software/libsigsegv/
license=GPLv2+

# Source documentation
docs="AUTHORS ChangeLog 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} \
     --enable-static=yes \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

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

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

path: recipes/libs/libsigsegv/recipe


code:
# Build recipe for libssh2.
#
# 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=libssh2
version=1.10.0
release=1

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

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

# Remote source(s)
fetch=https://www.libssh2.org/download/$tarname

description="
A SSH library.

The libssh2 package is a client-side C library implementing
the SSH2 protocol.
"

homepage=https://www.libssh2.org
license=BSD

# Source documentation
docs="COPYING ChangeLog NEWS README RELEASE-NOTES"
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 \
     --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"
}


code:
# Build recipe for libtasn1.
#
# Copyright (c) 2018-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=libtasn1
version=4.18.0
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/libtasn1/$tarname

description="
A highly portable C library that encodes or decodes an ASN.1 schema.

Libtasn1 is the ASN.1 library used by GnuTLS, p11-kit and some other
packages.  It was originally written by Fabio Fiorina, and now
maintained as a GNU package.  The goal of this implementation is to
be highly portable, and only require an ANSI C99 platform.
"

homepage=https://www.gnu.org/software/libtasn1
license="GPLv3+, LGPLv2+"

# Source documentation
docs="AUTHORS CONTRIBUTING.md COPYING ChangeLog NEWS README.md 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 \
     --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"
}


code:
# Build recipe for libthai.
#
# 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=libthai
version=0.1.29
release=1

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

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

# Remote source(s)
fetch=https://linux.thai.net/pub/thailinux/software/libthai/$tarname

description="
A library that includes a set of Thai language support routines.

libthai is a set of Thai language support routines aimed to ease
developers tasks to incorporate Thai language support in their
applications.
"

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

# Copy documentation
docs="AUTHORS COPYING ChangeLog NEWS README* 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 \
     --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

    # 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/libthai/recipe


code:
# Build recipe for libtirpc.
#
# 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=libtirpc
version=1.3.2
release=1

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

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

# Remote source(s)
fetch=https://sourceforge.net/projects/libtirpc/files/libtirpc/${version}/$tarname

description="
Transport-Independent RPC library.

This package contains SunLib's implementation of transport-independent
RPC (TI-RPC) documentation.  This library forms a piece of the base of
Open Network Computing (ONC), and is derived directly from the Solaris
2.3 source.

TI-RPC is an enhanced version of TS-RPC that requires the UNIX System V
Transport Layer Interface (TLI) or an equivalent X/Open Transport Interface
(XTI).  TI-RPC is on-the-wire compatible with the TS-RPC, which is supported
by almost 70 vendors on all major operating systems.  TS-RPC source code
(RPCSRC 4.0) remains available from several internet sites.

This release was a native source release, compatible for building on
Solaris 2.3.  It had been ported from FreeBSD 5.2.1 to GNU/Linux in 2004.
"

homepage=https://sourceforge.net/projects/libtirpc/
license="BSD 3-clause"

docs="AUTHORS COPYING ChangeLog NEWS README THANKS TODO 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 \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-gssapi \
     --disable-symvers \
     --build="$(gcc -dumpmachine)"

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

    # To manage .new files via graft(1)
    touch "${destdir}/etc/.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"
}

path: recipes/libs/libtirpc/recipe


code:
# Build recipe for libuargp.
#
# 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=libuargp
version=20210611_1f92296
release=1

# 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="
A library providing the functionality of the argp module from Gnulib.

libuargp is a library providing the command-line parsing functionality
of the argp module of the GNU Portability Library (Gnulib).
"

homepage=https://github.com/xhebox/libuargp/
license=LGPLv2.1

# 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 .

    make -j${jobs} prefix=/usr libdir=/usr/lib${libSuffix} \
     CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS -fPIC -Wall" LDFLAGS="$QILDFLAGS" \
     DESTDIR="$destdir" install

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

path: recipes/libs/libuargp/recipe


code:
# Build recipe for libunistring.
#
# 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=libunistring
version=1.0
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/libunistring/$tarname

description="
A library that provides functions for manipulating Unicode strings.

Text files are nowadays usually encoded in Unicode, and may consist of
very different scripts from Latin letters to Chinese Hanzi, with many
kinds of special characters accents, right-to-left writing marks,
hyphens, Roman numbers, and much more.  But the POSIX platform APIs for
text do not contain adequate functions for dealing with particular
properties of many Unicode characters.  In fact, the POSIX APIs for
text have several assumptions at their base which don't hold for
Unicode text.

This library provides functions for manipulating Unicode strings and
for manipulating C strings according to the Unicode standard.
"

homepage=https://www.gnu.org/software/libunistring/
license="GPLv3+, LGPLv3+"

# Source documentation
docs="AUTHORS BUGS COPYING* 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 \
     --enable-threads=posix \
     --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/libunistring/recipe


code:
# Build recipe for userspace-rcu (liburcu).
#
# 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=userspace-rcu
pkgname=liburcu
version=0.13.1
release=3

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

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

# Remote source(s)
fetch=https://lttng.org/files/urcu/$tarname

description="
Userspace RCU (read-copy-update) library.

The liburcu package provides a set of userspace RCU (read-copy-update)
libraries.  These data synchronization libraries provide read-side access
which scales linearly with the number of cores.  It does so by allowing
multiples copies of a given data structure to live at the same time, and
by monitoring the data structure accesses to detect grace periods after
which memory reclamation is possible.
"

homepage=https://liburcu.org
license=LGPLv2.1

# Source documentation
docs="ChangeLog LICENSE README* *.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} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} V=1 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"
    cp -p $docs "${destdir}/$docsdir"
}

path: recipes/libs/liburcu/recipe


code:
# Build recipe for libusb-compat.
#
# 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=libusb-compat
version=0.1.7
release=1

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

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

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

description="
USB access library (libusb-1.0 compat wrapper).

A compatibility layer allowing applications written for libusb-0.1 to work
with libusb-1.0. libusb-compat-0.1 attempts to look, feel, smell and walk
like libusb-0.1.
"

homepage=https://github.com/libusb/libusb-compat-0.1
license=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} \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=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"
}

path: recipes/libs/libusb-compat/recipe


code:
# Build recipe for libusb.
#
# 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=libusb
version=1.0.24
release=1

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

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

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

description="
C API for USB device access.

The libusb package contains a library used by some applications for
USB device access.
"

homepage=https://libusb.info/
license=LGPLv2.1

# Source documentation
docs="AUTHORS COPYING 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 \
     --enable-static \
     --enable-udev \
     --enable-system-log \
     --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/libusb/recipe


code:
# Build recipe for libuv.
#
# 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=libuv
version=v1.44.1
pkgversion="${version#v*}"
release=1

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

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

# Remote source(s)
fetch=https://dist.libuv.org/dist/${version}/$tarname

homepage=https://www.libuv.org
license=MIT

description="
An asynchronous I/O library.

libuv is a multi-platform support library with a focus on asynchronous
I/O.  See $homepage for more information.
"

# Source documentation
docs="AUTHORS CONTRIBUTING.md LICENSE* MAINTAINERS.md README.md"
docsdir="${docdir}/${program}-${pkgversion}"

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-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    #make -C docs man;	# It needs "Sphinx"
    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/libuv/recipe


code:
# Build recipe for libvorbis.
#
# 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=libvorbis
version=1.3.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://ftp.osuosl.org/pub/xiph/releases/vorbis/$tarname

description="
The Ogg vorbis library.

The libvorbis package contains a general purpose audio and music
encoding format.  This is useful for creating (encoding) and
playing (decoding) sound in an open (patent free) format.
"

homepage=https://www.xiph.org/ogg/
license="BSD-3 clause"

# Source documentation
docs="AUTHORS CHANGES COPYING"
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-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/libvorbis/recipe


code:
# Build recipe for libxml2.
#
# Copyright (C) 2018, MMPG <mmpg@vp.pl>
# 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=libxml2
version=2.9.12
release=2

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

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

# Remote source(s)
fetch=http://xmlsoft.org/sources/$tarname

description="
A XML C parser library and toolkit.

XML itself is a meta language to design markup languages.  HTML is the
most well-known markup language.  Though the library is written in C,
a variety of language bindings make it available in other environments.
"

homepage=https://xmlsoft.org
license=MIT

docs="AUTHORS ChangeLog Copyright NEWS README TODO"
docsdir="${docdir}/${program}-${version}"

# The source has a custom directory
srcdir="${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 \
     --with-python=/usr/bin/python3 \
     --with-history \
     --with-icu \
     --with-lzma \
     --with-iso8859x \
     --without-legacy \
     --build="$(gcc -dumpmachine)" \
     ac_cv_path_XSLTPROC=/usr/bin/xsltproc

    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"
}


code:
# Build recipe for libxslt.
#
# Copyright (C) 2018-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=libxslt
version=1.1.34
release=4

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

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

# Remote source(s)
fetch=http://xmlsoft.org/sources/$tarname

description="
XSLT support for libxml2.

The libxslt package contains XSLT libraries.  These are useful for
extending libxml2 libraries in order to support XSLT files.
"

homepage=https://xmlsoft.org
license=MIT

docs="AUTHORS ChangeLog Copyright NEWS README TODO"
docsdir="${docdir}/${program}-${version}"

# The source has a custom directory
srcdir="${program}-${version%-*}"

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

    cd "$srcdir"

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

    # This increases the recursion limit.  This is
    # needed by some packages for their documentation
    sed -e 's/3000/5000/' \
        -i libxslt/transform.c doc/xsltproc.1 doc/xsltproc.xml

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --with-python=/usr/bin/python3 \
     --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/libxslt/recipe


code:
# Build recipe for libyaml (yaml).
#
# 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=yaml
pkgname=libyaml
version=0.2.5
release=1

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

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

# Remote source(s)
fetch=https://pyyaml.org/download/libyaml/$tarname

description="
Libyaml is a YAML parser and emitter library.

The libyaml package contains a C library for parsing and emitting YAML
(YAML Ain't Markup Language) code.
"

homepage=https://pyyaml.org/wiki/LibYAML
license=Custom

# Source documentation
docs="Changes 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} \
     --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"
}

path: recipes/libs/libyaml/recipe


code:
# Build recipe for lzlib.
#
# 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=lzlib
version=1.13
release=1

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

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

# Remote source(s)
fetch=https://download.savannah.gnu.org/releases/lzip/lzlib/$tarname

homepage=https://lzip.nongnu.org/lzlib.html
license=GPLv2+

description="
A data compression library for the lzip format.

Lzlib is a data compression library providing in-memory LZMA
compression and decompression functions, including integrity checking
of the decompressed data.  The compressed data format used by the
library is the lzip format.  Lzlib is written in C.

For more information, visit: $homepage
"

# 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="-Wall -W $QICFLAGS -O3" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-shared \
     --disable-ldconfig \
     --build="$(gcc -dumpmachine)"

    make -j${jobs}
    make -j${jobs} DESTDIR="$destdir" install
    make -j${jobs} DESTDIR="$destdir" install-bin;	# Install "minilzip".

    # Compress texinfo documents

    rm -f "${destdir}/${infodir}/dir";			# Redundancy.
    lzip -9 "${destdir}/${infodir}/lzlib.info"

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

path: recipes/libs/lzlib/recipe


code:
# Build recipe for lzo.
#
# 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=lzo
version=2.10
release=1

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

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

# Remote source(s)
fetch=https://www.oberhumer.com/opensource/lzo/download/$tarname

homepage=https://www.oberhumer.com/opensource/lzo/

description="
A real-time data compression library.

LZO is a portable lossless data compression library written in ANSI C.
Offers pretty fast compression and *extremely* fast decompression.

For more details, visit: $homepage
"

license=GPLv2+

# Source directory for document installation
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 \
     --mandir=$mandir \
     --enable-static \
     --enable-shared \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} check && make -j${jobs} test
    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
}

path: recipes/libs/lzo/recipe


code:
# Build recipe for mpc.
#
# Copyright (c) 2015-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=mpc
version=1.2.1
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.gnu.org/gnu/mpc/$tarname

description="
Library for the arithmetic of complex numbers.

The MPC package contains a library for the arithmetic of complex
numbers with arbitrarily high precision and correct rounding of
the result.
"

homepage=https://www.multiprecision.org
license=LGPLv3+

# Source documentation
docs="AUTHORS COPYING* 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} \
     --infodir=$infodir \
     --with-gmp=/usr \
     --enable-static \
     --enable-shared \
     --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/mpc/recipe


code:
# Build recipe for mpfr.
#
# Copyright (c) 2015-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=mpfr
version=4.1.0
release=2

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

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

# Remote source(s)
fetch=https://www.mpfr.org/mpfr-current/$tarname

description="
Library for multiple-precision floating point.

The MPFR library is a C library for multiple-precision
floating-point computations with correct rounding.
"

homepage=https://www.mpfr.org
license="GPLv3+, LGPLv3+"

# Source documentation
docs="AUTHORS BUGS COPYING* ChangeLog NEWS PATCHES 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 .

    # Apply patches from upstream

    for file in "${worktree}"/patches/mpfr/*
    do
        if test -f "$file"
        then
            rm -f PATCHES
            patch -p1 < "$file"
        fi
    done

    # Avoid texinfo usage, we do not provide it on the early process
    touch doc/mpfr.info

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

    make -j${jobs} MAKEINFO="true"
    make -j${jobs} check
    make -j${jobs} MAKEINFO="true" 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}"/* || true
    fi

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

path: recipes/libs/mpfr/recipe


code:
# Build recipe for mtdev.
#
# Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2021 Matias A. 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=mtdev
version=1.1.6
release=1

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

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

# Remote source(s)
fetch=https://bitmath.org/code/mtdev/$tarname

description="
Multitouch Protocol Translation Library.

The mtdev is a stand-alone library which transforms all variants of
kernel MT events to the slotted type B protocol.  The events put into
mtdev may be from any MT device, specifically type A without contact
tracking, type A with contact tracking, or type B with contact
tracking.  See the kernel documentation for further details.
"

homepage=https://bitmath.org/code/mtdev/
license=MIT

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

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

    cd "$srcdir"

    # Update for several hosts (including Musl)
    cp -f "${worktree}/archive/common/config.guess" config-aux/config.guess
    cp -f "${worktree}/archive/common/config.sub" config-aux/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} \
     --docdir=$docsdir \
     --infodir=$infodir \
     --mandir=$mandir \
     --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/mtdev/recipe


code:
# Build recipe for musl-compat.
#
# 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=musl-compat
version=20210503_77a1509
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="
Extra utilities and headers to complement Musl.

A set of headers and small utilities for use on musl libc systems,
for providing some minimal glibc compatibility.

The code is derived from software contributed to The NetBSD Foundation,
mostly rewritten to be used in musl-compatible systems by Timo Teras.

The implementation of the iconv utility was written by Rich Felker.
"

homepage=https://dev.midipix.org/compat/musl-compat
license="GPLv2+, MIT | BSD"

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

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

    cd "$srcdir"

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

    make -j${jobs} V=1 \
     prefix=/usr CFLAGS="$QICFLAGS" DESTDIR="$destdir" install

    # This should be part of usr/sbin
    rm -f "${destdir}/usr/bin/ldconfig"

    strip --strip-unneeded "${destdir}"/usr/bin/* || true

    # Write a better version of dummy "ldconfig"
    mkdir -p "${destdir}"/usr/sbin
    cat << EOF > "${destdir}"/usr/sbin/ldconfig
#! /bin/sh -

true

EOF
    chmod 755 "${destdir}"/usr/sbin/ldconfig

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

path: recipes/libs/musl-compat/recipe


code:
# Build recipe for musl-fts.
#
# 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=musl-fts
version=1.2.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://github.com/void-linux/musl-fts/archive/v${version}/$tarname

description="
Implementation of fts(3) functions for musl libc.

The musl-fts package implements the fts(3) functions
fts_open, fts_read, fts_children, fts_set and fts_close,
which are missing in musl libc.

It uses the NetBSD implementation of fts(3) to build a static
library /usr/lib/libfts.a and the /usr/include/fts.h header file.
"

homepage=https://github.com/pullmoll/musl-fts
license="BSD 3-clause"

# 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 .

    sh ./bootstrap.sh

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

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

    install -p -m 0644 fts.3 -D "${destdir}/${mandir}/man3/fts.3"
    lzip -9 "${destdir}/${mandir}/man3/fts.3"

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

path: recipes/libs/musl-fts/recipe


code:
# Build recipe for musl-obstack.
#
# 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=musl-obstack
version=1.2.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://github.com/void-linux/musl-obstack/archive/v${version}/$tarname

description="
Implementation of obstack functions for musl libc.

The musl-obstack package is a copy + paste of the \`obstack\`
functions and macros found in GNU gcc \`libiberty\` library
for use with Musl libc.
"

homepage=https://github.com/pullmoll/musl-obstack/
license=GPLv2+

# 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 .

    sh ./bootstrap.sh

   ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS -fPIC" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --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/musl-obstack/recipe


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

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

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

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

description="
A powerful standard C/POSIX library (version $version).

Musl is a new standard library to power a new generation of Linux-based
devices.  Musl is lightweight, fast, simple, free, and strives to be
correct in the sense of standards-conformance and safety.
"

homepage=https://www.musl-libc.org
license="MIT Expat variant"

# Source documentation
docs="COPYRIGHT README VERSION WHATSNEW"
docsdir="${docdir}/${program}"

# Limit package name to the program name
full_pkgname="${program}@${pkgcategory}"

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

    cd "$srcdir"

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

    patch -Np0 -i "${worktree}/patches/musl/musl-utmp_path.diff"
    #patch -Np1 -i "${worktree}/patches/musl/branch-updates.diff"

    # Do not use the compiler runtime library from the temporary system,
    # the toolchain must be adjusted until the native GCC take place
    if cc -print-libgcc-file-name | grep -q '^/tools'
    then
        patch -Np1 -i "${worktree}/patches/musl/musl-nolibcc_stage1.diff"
    fi

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --syslibdir=/lib \
     --enable-shared \
     --enable-static \
     --enable-optimize

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

    # Provide minimal libssp_nonshared.a

    cc -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
       -o __stack_chk_fail_local.o
    ar rc libssp_nonshared.a __stack_chk_fail_local.o
    ranlib libssp_nonshared.a
    cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
    strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"

    # To print shared library dependencies
    mkdir -p "${destdir}/usr/bin"
    ln -sf /usr/lib${libSuffix}/libc.so "${destdir}/usr/bin/ldd"

    # Create dynamic linker runtime file taking -$(ARCH) as reference
    for file in "${destdir}"/lib/ld-musl-*.so.1
    do
        ld_path="${file##*/}"			# Basename
        ld_path="${ld_path%%.so.1}.path"	# Get the rid of .so.1
        export ld_path
        break;
    done
    unset -v file

    if test -n "$ld_path"
    then
        mkdir -p "${destdir}/etc"

        if test -n "$libSuffix"
        then
            cat << EOF > "${destdir}"/etc/$ld_path
/lib
/lib${libSuffix}
/usr/local/lib
/usr/local/lib${libSuffix}
/usr/lib
/usr/lib${libSuffix}
/usr/$(gcc -dumpmachine)/lib
/opt/trinity/lib
/opt/trinity/lib${libSuffix}
/opt/trinity/lib/trinity
/opt/trinity/lib${libSuffix}/trinity
EOF
        else
            cat << EOF > "${destdir}"/etc/$ld_path
/lib
/usr/local/lib
/usr/lib
/usr/$(gcc -dumpmachine)/lib
/opt/trinity/lib
/opt/trinity/lib/trinity
EOF
        fi

        chmod 644 "${destdir}"/etc/$ld_path
        touch "${destdir}/etc/.graft-config"
    else
        echo "WARNING: \$ld_path is empty." 1>&2
    fi

    # Add to the post-install script a symlink for compatibility,
    # as some 'configure' scripts still have the Glibc name "ld.so.conf".

    mkdir -p "${destdir}/var/lib/qi"
    cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"

# Adjust the toolchain only once (as needed)
if test -x /tools/bin/adjust-toolchain
then
    /tools/bin/adjust-toolchain && chmod 644 /tools/bin/adjust-toolchain
fi

# A symlink for compatibility
if test ! -e "\${rootdir}/etc/ld.so.conf"
then
    ( cd -- "\${rootdir}/etc" && ln -sf $ld_path ld.so.conf )
fi

EOF

    unset -v ld_path

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

path: recipes/libs/musl/recipe


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

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

tarname=${program}-${version}.tgz
termcap_file=termcap-20210816.src.gz

# Remote source(s)
fetch="
  https://invisible-mirror.net/archives/ncurses/current/$tarname
  https://invisible-mirror.net/archives/ncurses/current/$termcap_file
"

description="
Emulation library of Curses.

The Ncurses (new curses) library is a free software emulation of
curses in System V Release 4.0.  The ncurses code was developed
under GNU/Linux.  It has been in use for some time with OpenBSD
as the system curses library, and on FreeBSD and NetBSD as an
external package.

The distribution includes the library and support utilities,
including a terminfo compiler \"tic\", a decompiler \"infocmp\",
clear, tput, tset, and a termcap conversion tool \"captoinfo\".
"

homepage=https://www.gnu.org/software/ncurses
license=Custom

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

_DEFAULT_NCURSES_BUILD_OPTIONS="
  --libdir=/usr/lib${libSuffix} \
  --mandir=$mandir \
  --enable-overwrite \
  --enable-symlinks \
  --enable-pc-files \
  --enable-xmc-glitch \
  --enable-colorfgbg \
  --enable-hard-tabs \
  --disable-stripping \
  --with-pkg-config-libdir=/usr/lib${libSuffix}/pkgconfig \
  --with-manpage-format=normal \
  --with-shared \
  --with-termlib=tinfo \
  --with-ticlib=tic \
  --with-gpm \
  --without-tests \
  --without-debug \
  --without-profile \
  --build="$(gcc -dumpmachine)"
"

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

    cd "$srcdir"

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

    unset -v TERMINFO;	# Just in case.

    ./configure CPPFLAGS="$QICPPFLAGS -D_GNU_SOURCE" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args --includedir=/usr/include/ncurses \
      $_DEFAULT_NCURSES_BUILD_OPTIONS \
       --with-manpages --enable-widec --with-normal

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

    unset -v _DEFAULT_NCURSES_BUILD_OPTIONS

    # Provide non-widec compatibility

    for name in form panel menu
    do
        rm -f "${destdir}/usr/lib${libSuffix}/lib${name}.so" \
              "${destdir}/usr/lib${libSuffix}/lib${name}.a"

        echo "INPUT(-l${name}w)" > \
         "${destdir}/usr/lib${libSuffix}/lib${name}.so"
        echo "INPUT(-l${name}w)" > \
         "${destdir}/usr/lib${libSuffix}/lib${name}.a"

        (
            cd "${destdir}/usr/lib${libSuffix}/pkgconfig" && \
             ln -sf ${name}w.pc ${name}.pc
        )
    done
    unset -v name

    # Do not leave behind this symbolic link for pkgconfig
    ln -sf ncursesw.pc "${destdir}/usr/lib${libSuffix}/pkgconfig/ncurses.pc"

    # Make symlinks for compatibility
    (
        cd "${destdir}/usr/include" || exit 1
        ln -sf ncurses ncursesw
        for header in ncurses/*
        do
            ln -sf $header .
        done
    )

    # Insert termcap file provided by "Thomas E. Dickey"
    mkdir -p "${destdir}/etc"
    zcat "${tardir}/$termcap_file" > "${destdir}/etc/termcap"
    chmod 644 "${destdir}/etc/termcap"
    unset -v termcap_file

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

    # Make sure to link against -ltinfo
    (
        major_version=$(echo $version | cut -f 1 -d .)

        cd "${destdir}/usr/lib${libSuffix}" || exit 1
        rm -f libncursesw.so libncurses.so libncurses.a libtermcap.so libtermcap.a

        echo "INPUT(libncursesw.so.${major_version} -ltinfo)" > libncurses.so
        echo "INPUT(libncursesw.a -ltinfo)" > libncurses.a

        echo "INPUT(libncursesw.so.${major_version} -ltinfo)" > libncursesw.so

        echo "INPUT(-ltinfo)" > libtermcap.so
        echo "INPUT(-ltinfo)" > libtermcap.a
    )

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip --force -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/ncurses/recipe


code:
# Build recipe for nettle.
#
# 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=nettle
version=3.7.3
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/nettle/"$tarname"

description="
A low-level cryptographic library.

Nettle is a cryptographic library that is designed to fit easily in
more or less any context: in crypto toolkits for object-oriented
languages (C++, Python, Pike, ...), in applications like LSH or
GnuPG, or even in kernel space.
"

homepage=https://www.lysator.liu.se/~nisse/nettle/
license="GPLv2+, GPLv3+, LPGLv3+"

# Source documentation
docs="AUTHORS CONTRIBUTING.md COPYING* ChangeLog NEWS README nettle.html"
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 \
     --build="$(gcc -dumpmachine)"

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

    # Fix library permissions
    chmod 755 \
     "${destdir}/usr/lib${libSuffix}"/libhogweed.so.?.? \
     "${destdir}/usr/lib${libSuffix}"/libnettle.so.?.?

    # 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/nettle/recipe


code:
# Build recipe for npth.
#
# 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=npth
version=1.6
release=1

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

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

# Remote source(s)
fetch=https://www.gnupg.org/ftp/gcrypt/npth/$tarname

description="
A new portable thread library.

The npth package contains a very portable POSIX/ANSI-C based library
for Unix platforms which provides non-preemptive priority-based
scheduling for multiple threads of execution (multithreading) inside
event-driven applications.  All threads run in the same address space
of the server application, but each thread has its own individual
program-counter, run-time stack, signal mask and errno variable.
"

homepage=https://www.gnupg.org
license=LGPLv2+

# Source documentation
docs="AUTHORS COPYING.LIB ChangeLog NEWS README 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 \
     --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 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/npth/recipe


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

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

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

# Remote source(s)
fetch=https://sourceforge.net/projects/pcre/files/pcre/${version}/$tarname

description="
Perl-compatible regular expressions.

The PCRE library is a set of functions that implement regular
expression pattern matching using the same syntax and semantics
as Perl, with just a few differences.
"

homepage=https://www.pcre.org
license=BSD

# Source 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" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-jit \
     --enable-unicode-properties \
     --enable-pcretest-libreadline \
     --enable-pcregrep-libz \
     --enable-pcregrep-libbz2 \
     --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
}

path: recipes/libs/pcre/recipe


code:
# Build recipe for pcre2.
#
# 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=pcre2
version=10.39
release=1

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

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

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

description="
Perl-compatible regular expressions (version 2).

The PCRE2 library is a set of C functions that implement regular
expression pattern matching using the same syntax and semantics as
Perl 5.  PCRE2 has its own native API, as well as a set of wrapper
functions that correspond to the POSIX regular expression API.
The PCRE2 library is free, even for building proprietary software.
It comes in three forms, for processing 8-bit, 16-bit, or 32-bit code
units, in either literal or UTF encoding.
"

homepage=https://www.pcre.org
license=BSD

# Source 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} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-jit \
     --enable-pcre2-16 \
     --enable-pcre2-32 \
     --enable-pcre2grep-libz \
     --enable-pcre2grep-libbz2 \
     --enable-pcre2test-libreadline \
     --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
}