code:
# Build recipe for alsa-topology-conf.
#
# 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=alsa-topology-conf
version=1.2.5.1
arch=noarch
release=1

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

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

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

description="
ALSA topology configuration files.

This is required for the correct functioning of ALSA.
"

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

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

    mkdir -p "${destdir}/usr/share/alsa"
    cp -RpP 'topology' "${destdir}/usr/share/alsa"

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

path: recipes/data/alsa-topology-conf/recipe


code:
# Build recipe for alsa-ucm-conf.
#
# 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=alsa-ucm-conf
version=1.2.6.3
arch=noarch
release=1

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

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

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

description="
ALSA use case manager configuration.

This is required for the correct functioning of ALSA.
"

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

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

    mkdir -p "${destdir}/usr/share/alsa"
    cp -RpP 'ucm' "${destdir}/usr/share/alsa"
    cp -RpP 'ucm2' "${destdir}/usr/share/alsa"

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

repo_name: dustdfg/dragora

path: recipes/data/alsa-ucm-conf/recipe

license: mit


code:
chmod 640 etc/gshadow etc/shadow
chown root:shadow etc/gshadow etc/shadow

if test -f etc/os-release.new
then
    mv -f etc/os-release.new etc/os-release
fi

path: recipes/data/etc/post-install


code:
# Build recipe for /etc.
#
# 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=etc
version=dragora
pkgversion=20210307
arch=noarch
release=1

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

description="
Essential configuration files.

It contains the essential configuration files for the system.
"

homepage=https://www.dragora.org
license="Apache License version 2"

build()
{
    mkdir -p "${destdir}/etc"
    cp -RPp "${worktree}"/archive/etc/* "${destdir}/etc/"

    # ** This is provided by the bootscripts package **
    rm -rf "${destdir}/etc/rc.d/" \
           "${destdir}/etc/rc.conf" \
           "${destdir}/etc/inittab"

    touch "${destdir}/etc/.graft-config" \
          "${destdir}/etc/skel/.graft-config" \
          "${destdir}/etc/sysctl.d/.graft-config"
}

path: recipes/data/etc/recipe


code:
# Ownerships and permissions

chown root:games  usr/games usr/share/games usr/local/games var/games
chown root:log    var/log
chown root:mail   var/mail
chown root:lp     var/spool/lpd
chown root:news   var/spool/news

chmod 775         var/log
chmod 2775        var/mail
chmod 1777        var/tmp

# Force symlink creation for "/var/run -> /run" and "/var/lock -> /run/lock"
(
    cd var || exit 1
    rm -rf run lock
    ln -sf /run/lock .
    ln -sf /run .
)

chmod 555         proc sys
chmod 750         root
chmod 1777        tmp run/lock
chmod 775         usr/games usr/share/games usr/local/games var/games

# Create character special files, if needed
test -c dev/console || mknod -m 600 dev/console c 5 1
test -c dev/null || mknod -m 666 dev/null c 1 3

# Create shm directory if does not exist
test -e dev/shm || mkdir -p dev/shm

# Create file records for logins and logouts
touch \
 var/log/btmp var/log/lastlog var/log/faillog var/log/wtmp var/run/utmp

chgrp utmp  var/log/lastlog var/run/utmp
chmod 664   var/log/lastlog var/run/utmp
chmod 600   var/log/btmp

# Make symlinks at 'rootdir'

for link_name in bin sbin
do
    if test ! -L $link_name
    then
        rm -f $link_name
        ln -s -f usr/${link_name} $link_name
    fi
done
unset link_name

(
    cd opt || exit 1
    ln -sf ../etc/opt etc
)
(
    cd usr || exit 1
    ln -sf share/doc   doc
    ln -sf share/info  info
    ln -sf share/man   man
)
(
    cd usr/local || exit 1
    ln -sf share/doc   doc
    ln -sf share/info  info
    ln -sf share/man   man
)
(
    cd var/spool || exit 1
    ln -sf ../mail mail
)

# Offer a compatible "X11R6 symlink"
test -L usr/X11R6 || ( cd usr && ln -sf . X11R6 )

libSuffix=X

if test "$libSuffix" != X
then
     rmdir lib usr/lib usr/local/lib 2> /dev/null

     # Make default library path using 'libSuffix', linking
     # canonical path "lib" to the library suffix directory
     for directory in usr usr/local
     do
         (
             cd "$directory" || exit 1
             test -d lib${libSuffix} || mkdir -p lib${libSuffix}
             if test ! -L lib
             then
                 rm -f lib
                 ln -s -f lib${libSuffix} lib
             fi
         )
     done
     unset directory
     # This is for the 'rootdir'
     (
         cd . || exit 1
         if test ! -L lib${libSuffix}
         then
             rm -f lib${libSuffix}
             ln -s -f usr/lib${libSuffix} lib${libSuffix}
         fi
         if test ! -L lib
         then
             rm -f lib
             ln -s -f lib${libSuffix} lib
         fi
     )
else
    # Make canonical paths for usr/lib, usr/local/lib, with a
    # symlink of "/lib -> usr/lib" if 'libSuffix' is empty
    for directory in usr/lib usr/local/lib
    do
        test -e $directory || mkdir -p $directory
    done
    unset directory
    if test ! -L lib || test ! -e lib
    then
        rm -f lib
        ln -s -f usr/lib lib
    fi
fi

# Re-create pkgconfig directory
test -e usr/lib/pkgconfig || mkdir -p usr/lib/pkgconfig
test -e usr/local/lib/pkgconfig || mkdir -p usr/local/lib/pkgconfig

for directory in usr/share usr/local/share
do
    ( cd $directory && ln -sf ../lib/pkgconfig . )
done
unset directory


code:
# Build recipe for hierarchyfs.
#
# 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=hierarchyfs
version=dragora
pkgversion=3.0
release=11

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

description="
Skeleton bases of Dragora GNU/Linux-Libre.

It contains the main hierarchy of directories, symlinks,
ownerships, and permissions for compose the basic structure
of the file system.
"

homepage=https://www.dragora.org
license=GPLv3+

build()
{
    mkdir -p "$destdir"
    cd "$destdir"

    # Directories

    mkdir -p \
     usr/bin                   \
     boot                      \
     dev                       \
     etc                       \
     home                      \
     lost+found                \
     media                     \
     mnt                       \
     opt                       \
     proc                      \
     root                      \
     run                       \
     run/lock                  \
     usr/sbin                  \
     srv                       \
     sys                       \
     tmp                       \
     usr                       \
     var                       \
     dev/pts                   \
     etc/X11                   \
     etc/opt                   \
     etc/skel                  \
     etc/xdg                   \
     media/cdrecorder          \
     media/cdrom               \
     media/floppy              \
     media/zip                 \
     usr/bin                   \
     usr/games                 \
     usr/include               \
     usr/libexec               \
     usr/local/bin             \
     usr/local/etc             \
     usr/local/games           \
     usr/local/include         \
     usr/local/libexec         \
     usr/local/sbin            \
     usr/local/share/doc       \
     usr/local/share/info      \
     usr/local/share/man/man1  \
     usr/local/share/man/man2  \
     usr/local/share/man/man3  \
     usr/local/share/man/man4  \
     usr/local/share/man/man5  \
     usr/local/share/man/man6  \
     usr/local/share/man/man7  \
     usr/local/share/man/man8  \
     usr/local/src             \
     usr/pkg                   \
     usr/share/doc             \
     usr/share/games           \
     usr/share/info            \
     usr/share/man/man1        \
     usr/share/man/man2        \
     usr/share/man/man3        \
     usr/share/man/man4        \
     usr/share/man/man5        \
     usr/share/man/man6        \
     usr/share/man/man7        \
     usr/share/man/man8        \
     usr/src                   \
     var/cache/man             \
     var/games                 \
     var/lib                   \
     var/local                 \
     var/log                   \
     var/mail                  \
     var/opt                   \
     var/spool/lpd             \
     var/spool/news            \
     var/tmp

    # Copy local files

    cp -p "${worktree}/archive/hierarchyfs/README.media" \
          "media/README"
    cp -p "${worktree}/archive/hierarchyfs/README.mnt" \
          "mnt/README"

    chmod 644 "media/README" "mnt/README"

    # Copy files for the already created root account
    cp -p "${worktree}"/archive/etc/skel/.*rc      \
          "${worktree}"/archive/etc/skel/.profile  \
          "${destdir}/root/"

    touch \
     "media/.graft-config" "mnt/.graft-config" "root/.graft-config"

    # Manually include the post-install file for the package

    mkdir -p "${destdir}/var/lib/qi"

    cp -p "${CWD}/post-install.multidir" "${destdir}/var/lib/qi/${full_pkgname}.sh"
    chmod 644 "${destdir}/var/lib/qi/${full_pkgname}.sh"

    # Handle lib<equal> for the multi directory support

    # Guess the suffix to compose the corresponding library directory
    if test -f /tools/etc/stage1_is-multi-directory
    then
        libSuffix="$(cat /tools/etc/stage1_is-multi-directory)"
    fi

    if test -n "$libSuffix"
    then
        echo "libSuffix detected."
        echo "Changing value for post-install '${libSuffix}'"

        sed -i s"/^libSuffix=X/libSuffix=${libSuffix}/" \
         "${destdir}/var/lib/qi/${full_pkgname}.sh"
    fi
}

path: recipes/data/hierarchyfs/recipe


code:
# Build recipe for iana-etc.
#
# Copyright (c) 2017, 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=iana-etc
version=2.30
update_version=20211229
arch=noarch
release=1

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

# Define custom package version
pkgversion=${version}_${update_version}

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

# Remote source(s)
fetch="
  http://sethwklein.net/$tarname
  https://github.com/Mic92/iana-etc/releases/download/${version}/$tarname
"

description="
Provides /etc/services and /etc/protocols files.

The iana-etc package provides the Unix/Linux /etc/services and
/etc/protocols files.  Using data from the Internet Assigned
Numbers Authority <https://www.iana.org>.
"

homepage=https://www.iana.org/protocols
license=OSLv3.0

# Source documentation
docs="COPYING CREDITS NEWS README VERSION"
docsdir="${docdir}/${program}-${pkgversion}"

build()
{
    unpack "${tardir}/$tarname"
    unpack "${tardir}/${program}-${update_version}.tar.gz"

    cd "$srcdir"

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

    make all && make DESTDIR="$destdir" install

    # Update files from 'update_version' iana's variant
    cp -f -p "${TMPDIR}/${program}-${update_version}"/protocols \
     "${destdir}/etc"
    cp -f -p "${TMPDIR}/${program}-${update_version}"/services \
     "${destdir}/etc"

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

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

    # Do not keep the update version source, unless --keep is passed in Qi
    if test -z "$keep_srcdir"
    then
        rm -rf -- "${TMPDIR}/${program}-${update_version}"
    fi
    unset -v update_version
}

path: recipes/data/iana-etc/recipe


code:
# Build recipe for iso-codes.
#
# 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=iso-codes
version=4.6.0
arch=noarch
release=1

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

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

# Remote source(s)
fetch=http://anduin.linuxfromscratch.org/BLFS/iso-codes/$tarname

description="
ISO country, language, script and currency codes and translations.

This package provides lists of various ISO standards (e.g. country,
language, language scripts, and currency names) in one place, rather
than repeated in many programs throughout the system.
"

homepage=https://salsa.debian.org/iso-codes-team/iso-codes
license=GPLv2+

docs="COPYING ChangeLog.md README.md TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --build="$(gcc -dumpmachine)"

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

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

path: recipes/data/iso-codes/recipe


code:
# Build recipe for the berkeley-db.
#
# 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=db
version=6.2.38
release=1

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

pkgname=berkeley-db

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
 https://download.oracle.com/berkeley-db/$tarname
"

description="
Berkeley database library.

Berkeley DB is a programmatic toolkit that provides embedded database
support for client/server applications.
"

homepage=https://www.oracle.com/database/berkeley-db/index.html
license=Custom

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

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

    cd "$srcdir"

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

    cd build_unix
    ../dist/configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --enable-compat185 \
     --enable-dbm \
     --enable-cxx \
     --enable-stl \
     --build="$(gcc -dumpmachine)"

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

    # Huge size for the package
    rm -rf "${destdir}/usr/docs"

    # Strip remaining binaries and libraries
    find "$destdir" -type f | xargs file | \
     awk '/ELF/ && /executable/ || /shared object/' | \
      cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

    find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
     cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true

    cd ..

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

path: recipes/db/berkeley-db/recipe


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

# Exit immediately on any error
set -e

program=gdbm
version=1.23
release=1

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

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

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

description="
The GNU database library.

GNU dbm is a set of database routines that use extendible hashing
and works similar to the standard UNIX dbm routines.
"

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

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS NOTE-WARNING 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 \
     --enable-static=yes \
     --enable-shared=yes \
     --with-readline=yes \
     --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/db/gdbm/recipe


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

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

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

# Remote source(s)
fetch=https://sqlite.org/2020/$tarname

description="
SQlite is a C-language library that implements a SQL database engine.

The sqlite package is a software library that implements a
self-contained, serverless, zero-configuration, transactional
SQL database engine.
"

homepage=https://www.sqlite.org
license="Public Domain"

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

# The source has a custom source directory
srcdir=${program}-autoconf-${version}

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

    cd "$srcdir"

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

    ./configure LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)" \
     --enable-fts5 \
      CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS \
       -DSQLITE_ENABLE_FTS3=1             \
       -DSQLITE_ENABLE_FTS4=1             \
       -DSQLITE_ENABLE_COLUMN_METADATA=1  \
       -DSQLITE_ENABLE_UNLOCK_NOTIFY=1    \
       -DSQLITE_ENABLE_DBSTAT_VTAB=1      \
       -DSQLITE_SECURE_DELETE=1           \
       -DSQLITE_ENABLE_FTS3_TOKENIZER=1"

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

    # Build TCL extension (TEA)

    cd tea

    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args --libdir=/usr/lib${libSuffix}

    make -j${jobs} && make -j${jobs} DESTDIR="$destdir" 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/db/sqlite/recipe


code:
# Copy/update time zone database to the /etc hierarchy

cp -Rpf "${packagedir}/${name}"/etc/zoneinfo* etc/

# Delete unneeded .nograft files under etc
find etc/zoneinfo* -type f -name '.nograft' -exec rm -f {} +

# Set default zone info file, default points to 'UTC'

if test -r etc/zoneinfo/UTC
then
    if test -L etc/localtime && test ! -e etc/localtime
    then
        echo "etc/localtime is a dangling symlink, trying to recreate it" 1>&2
        ln -sf zoneinfo/UTC etc/localtime
    elif test ! -e etc/localtime
    then
        ln -s zoneinfo/UTC etc/localtime
    fi
fi

if test ! -e etc/localtime
then
    echo "Setting default time zone to UTC (etc/localtime -> zoneinfo/UTC) ..."
    ln -sf zoneinfo/UTC etc/localtime
fi

# Re-create symlink for "zoneinfo-posix" directory

(
    rm -f etc/zoneinfo-posix
    cd etc && ln -sf zoneinfo zoneinfo-posix
)

# Make a symlink for compatibility at "usr/share"

(
    mkdir -p usr/share
    cd usr/share && ln -sf /etc/zoneinfo .
)

path: recipes/db/tzdb/post-install


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

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

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

# Remote source(s)
fetch=https://www.iana.org/time-zones/repository/releases/$tarname

description="
Time zone database.

The Time Zone Database (often called tz or zoneinfo) contains code and
data that represent the history of local time for many representative
locations around the globe.  It is updated periodically to reflect
changes made by political bodies to time zone boundaries, UTC offsets,
and daylight-saving rules.  Its management procedure is documented in
BCP 175: Procedures for Maintaining the Time Zone Database.
"

homepage=https://www.iana.org/time-zones
license="Public domain | BSD"

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

# Force parallel jobs to '1'
jobs=1

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

    cd "$srcdir"

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

    make -j${jobs} CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     TOPDIR=/ \
     TZDIR=/etc/zoneinfo \
     ETCDIR=/usr/sbin \
     LIBDIR=/usr/lib${libSuffix} \
     MANDIR=$mandir \
     KSHELL="/bin/sh -" \
     DESTDIR="$destdir" install

    # 1. We do not offer 'tzselect'.
    # 2. To set default localtime.
    # 3. To be linked via post-install.
    rm -f \
     "${destdir}/usr/bin/tzselect" \
     "${destdir}/etc/localtime" \
     "${destdir}/etc/zoneinfo-posix"

    # Create .nograft to copy via post-installation the time zone files
    # instead of being linked to the package directory; this is to ensure
    # that the database is always up to date after a package update.  :-)

    find "${destdir}"/etc/zoneinfo* -type d -print | \
     while read -r directory
     do
         ( cd -- "$directory" && touch .nograft )
     done

    # 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/db/tzdb/recipe


code:
# Build recipe for autoconf.
#
# Copyright (c) 2016-2018 Matias Fonzo, <selk@dragora.org>.
# 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=autoconf
version=2.71
arch=noarch
release=1

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

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

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

description="
An extensible package of M4 macros.

Autoconf is an extensible package of M4 macros that produce shell
scripts to automatically configure software source code packages.
"

homepage=https://www.gnu.org/software/autoconf
license="GPLv2+, GPLv3+ & exception"

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

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

    cd "$srcdir"

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

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

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

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

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

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

path: recipes/devel/autoconf/recipe


code:
perl/perl5
devel/autoconf


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

# Exit immediately on any error
set -e

program=automake
version=1.16.5
arch=noarch
release=1

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

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

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

description="
A tool to generate Makefiles automatically.

Automake is a tool for automatically generating 'Makefile.in'
files compliant with the GNU Coding Standards.

Automake requires Perl and Autoconf.
"

homepage=https://www.gnu.org/software/automake
license=GPLv2+

# Source documentation
docs="AUTHORS COPYING ChangeLog 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 $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

    # Replace hard links with soft links
    (
        cd "${destdir}/usr/bin" || exit 1
        ln -sf aclocal-"${version%.*}" aclocal
        ln -sf automake-"${version%.*}" automake
    )

    # 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/devel/automake/recipe


code:
devel/flex
libs/readline
tools/texinfo


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

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

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

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

description="
An arbitrary precision numeric processing language.

Bc is an arbitrary precision numeric processing language.  Syntax is
similar to C, but differs in many substantial areas.  It supports
interactive execution of statements.

This is the version of bc maintained by Gavid D. Howard.
"

homepage=https://github.com/gavinhoward/bc
license="BSD, Custom"

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

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

    cd "$srcdir"

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

    env CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS -O3" \
        LDFLAGS="$QILDFLAGS -static" \
    sh ./configure.sh \
     --prefix=/usr \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --disable-generated-tests \
     --disable-strip

    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/devel/bc/recipe


code:
# Build recipe for binutils.
#
# 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=binutils
version=2.38
release=2

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

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

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

description="
The GNU binary utilities.

Binutils is a collection of programming tools for the manipulation
of object code in various object file formats.  These tools consist
of the GNU linker (ld), the GNU assembler (as) and the profiler
(gprof).  There is also a collection of other binary tools like
the disassembler (objdump).
"

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

# Source documentation
docs="COPYING* README"
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 Fedora (Nick Clifton)

    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-export-demangle.h.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-no-config-h-check.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-filename-in-error-messages.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-revert-PLT-elision.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-readelf-other-sym-info.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-2.27-aarch64-ifunc.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-link-with-static-libstdc++.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-special-sections-in-groups.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-mismatched-section-flags.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-CVE-2019-1010204.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-warn-unsupported.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-use-long-long.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-i386-gnu-property-notes.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-autoconf-version.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/gcc12-libtool-no-rpath.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-section-type.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gas-loc-view.patch"
    patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-use-debuginfod.patch"

    patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff"

    # Create a separate build directory
    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    # To pass extra options to binutils according to the architecture
    binutils_hash_style=gnu;
    case $arch in
    i?86 | amd64 | x32 )
        binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
        ;;
    mips*)
        binutils_hash_style=sysv;
        ;;
    esac

    # System-dependent
    MACHINE="$(gcc -dumpmachine)"

    ../configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \
     $configure_args \
     $multilib_options \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --infodir=$infodir \
     --with-docdir=$docsdir \
     --enable-deterministic-archives \
     --enable-shared \
     --enable-gold=yes \
     --enable-ld=default \
     --enable-threads=auto \
     --enable-default-hash-style=$binutils_hash_style \
     --enable-relro \
     --enable-lto \
     --enable-plugins \
     --enable-64-bit-bfd \
     --enable-install-libiberty \
     --enable-separate-code \
     --disable-nls \
     --disable-werror \
     --disable-compressed-debug-sections \
     --disable-generate-build-notes \
     --with-system-zlib \
     --with-pic \
     --build=$MACHINE \
     $binutils_targets

    unset -v binutils_targets binutils_hash_style

    make -j${jobs} V=1 tooldir=/usr/${MACHINE}
    #make -j${jobs} V=1 check
    make -j${jobs} V=1 tooldir=/usr/${MACHINE} DESTDIR="$destdir" install

    find "$destdir" -type f -print0 | xargs -0 file | \
     awk '/ELF/ && /executable/ || /shared object/' | \
      cut -f 1 -d : | xargs -0 strip --remove-section=.comment \
       --remove-section=.note 2> /dev/null || true

    cd ../

    # Replace hard-links with relative soft-links for the package size
    (
        cd "${destdir}/usr/bin" && \
        rm -f ld ; ln -sf ld.bfd ld
    )
    (
        cd "${destdir}/usr/${MACHINE}/bin" && \
        for file in *
        do
            if test -x "../../bin/$file"
            then
                rm -f "$file" && ln -s "../../bin/$file" .
            fi
        done
    )

    unset -v MACHINE

    # 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 man pages
    if test -d "${destdir}/$mandir"
    then
        lzip -9 "${destdir}/${mandir}"/man?/*
    fi

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

path: recipes/devel/binutils/recipe


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

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

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

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

description="
GNU parser generator.

Bison is a general-purpose parser generator that converts an annotated
context-free grammar into a deterministic LR or generalized LR (GLR)
parser employing LALR(1) parser tables.  As an experimental feature,
bison can also generate IELR(1) or canonical LR(1) parser tables.
Once you are proficient with Bison, you can use it to develop a wide
range of language parsers, from those used in simple desk calculators
to complex programming languages.
"

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

# Source documentation
#
# The documentation files are installed by Bison.
#
#docs="AUTHORS COPYING ChangeLog NEWS README* THANKS TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

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

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

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

    # 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 man pages
    if test -d "${destdir}/$mandir"
    then
        lzip -9 "${destdir}/${mandir}"/man?/*
    fi
}

path: recipes/devel/bison/recipe


code:
tools/sed
devel/pkgconf
devel/libtool
devel/autoconf
devel/automake
tools/texinfo


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

# Exit immediately on any error
set -e

program=check
version=0.15.2
release=1

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

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

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

description="
Unit testing framework for C.

The check package is a unit testing framework for C,
required by some packages.
"

homepage=https://libcheck.github.io/check/index.html
license=LGPLv2.1

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

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

    # Conform documentation directory as PACKAGE-VERSION
    mv "${destdir}/usr/share/doc/check" "${destdir}/$docsdir"

    # 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/devel/check/recipe


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

# Exit immediately on any error
set -e

program=clisp
version=20210628_de01f0f47;	# From https://gitlab.com/gnu-clisp/clisp
release=1

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

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="
An ANSI Common Lisp Implementation.

In computing, CLISP is an implementation of the programming language
Common Lisp originally developed by Bruno Haible and Michael Stoll for
the Atari ST.

LISP includes an interpreter, a bytecode compiler, debugger, socket
interface, high-level foreign language interface, strong
internationalization support, and two object systems:
Common Lisp Object System (CLOS) and metaobject protocol (MOP).

It is written in C and Common Lisp. It is now part of the GNU Project
and is free software, available under the terms of the GNU General
Public License (GPL).
"

hompage=https://clisp.org
license=GPLv2+

# Source documentation
docs="ANNOUNCE COPYRIGHT GNU-GPL HACKING SUMMARY"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # Build in a separate directory
    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    ../configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
    LDFLAGS="$QILDFLAGS" \
    FORCE_UNSAFE_CONFIGURE=1 \
     --srcdir=../ \
     --prefix=/usr \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-rpath \
     --with-dynamic-ffi \
     --with-module=berkeley-db \
     --with-module=gdbm \
     --with-module=pcre \
     --with-module=zlib \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" 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/devel/clisp/recipe


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

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

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

# Remote source(s)
fetch="https://cmake.org/files/v${version%.*}/$tarname"

description="
Cross-platform make system.

CMake is a family of tools designed to build, test and package
software.  CMake is used to control the software compilation process
using simple platform and compiler independent configuration files.
"

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

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

    ../configure \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     --prefix=/usr \
     --mandir=$mandir \
     --docdir=$docsdir \
     --system-libuv \
     --system-curl \
     --system-expat \
     --system-zlib \
     --system-bzip2 \
     --system-libarchive \
     --no-system-jsoncpp \
     --parallel=$jobs

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

path: recipes/devel/cmake/recipe


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

# Exit immediately on any error
set -e

program=elfutils
version=0.186
release=1

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

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

# Remote source(s)
fetch=https://sourceware.org/elfutils/ftp/${version}/$tarname

description="
Libraries and utilities to handle ELF objects.

elfutils is a collection of utilities and libraries to read,
create and modify ELF binary files, find and handle DWARF
debug data, symbols, thread state and stacktraces for
processes and core files on GNU/Linux.

Note: This package has been configured to make use of the \"eu\"
      prefix for elfutils utilities.
"

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

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

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

    cd "$srcdir"

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

    # Apply patches against Musl (Thanks to "noname-linux", xhebox)
    # Url: https://github.com/xhebox/noname-linux/tree/master/ports/elfutils
    patch -Np1 -i "${worktree}/patches/elfutils/fix-uninitialized.patch"
    patch -Np1 -i "${worktree}/patches/elfutils/musl-asm-ptrace-h.patch"
    patch -Np0 -i "${worktree}/patches/elfutils/musl-macros.patch"
    patch -Np0 -i "${worktree}/patches/elfutils/musl-strndupa.patch"

    cp -p -f "${worktree}"/archive/elfutils/error.h lib/
    cp -p -f "${worktree}"/archive/elfutils/error.h src/
    sed -i 's:-Werror::' ./*Makefile.in
    autoreconf -vif

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS -Wno-error=null-dereference" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --mandir=$mandir \
     --enable-deterministic-archives \
     --disable-debuginfod \
     --enable-libdebuginfod=dummy \
     --program-prefix=eu- \
     --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/devel/elfutils/recipe


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

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

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

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

description="
The fast lexical analyser generator.

Flex is a fast lexical analyser generator.  It is a tool for
generating programs that perform pattern-matching on text.
"

homepage=https://flex.sourceforge.net
license=Custom

# Source documentation.
#
# The documentation files are installed by Flex.
#
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 \
     --enable-shared \
     --enable-nls \
     --build="$(gcc -dumpmachine)"

    make -j${jobs}
    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 man pages
    lzip -9 "${destdir}/${mandir}"/man?/*

    # Provide compatibility with flex's predecessor, lex
    if test -f "${worktree}/archive/flex/usr/bin/lex"
    then
        cp -p "${worktree}/archive/flex/usr/bin/lex" \
              "${destdir}/usr/bin"
        chmod 755 "${destdir}/usr/bin/lex"

        ln -sf libfl.a "${destdir}/usr/lib${libSuffix}/libl.a"
    fi
}

path: recipes/devel/flex/recipe


code:
# Build recipe for fortify-headers.
#
# 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=fortify-headers
version=1.1
arch=noarch
release=1

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

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

# Remote source(s)
fetch=https://dl.2f30.org/releases/$tarname

description="
Standalone fortify source implementation.

This is a standalone implementation of fortify source.  It provides
compile time buffer checks.  It is libc-agnostic and simply overlays
the system headers by using the #include_next extension found in GCC.
It was initially intended to be used on musl based GNU/Linux
distributions.
"

homepage=https://git.2f30.org/fortify-headers/
license=BSD

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

# Limit parallel jobs for the compiler
jobs=1

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

    cd "$srcdir"

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

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

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

path: recipes/devel/fortify-headers/recipe


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

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

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

# Remote source(s)
fetch=https://github.com/ivmai/bdwgc/releases/download/v${version}/$tarname
#fetch=https://www.hboehm.info/gc/gc_source/$tarname

description="
A garbage collector for C and C++.

The gc package contains the Boehm-Demers-Weiser conservative garbage
collector, which can be used as a garbage collecting replacement for
the C malloc function or C++ new operator.  It allows you to allocate
memory basically as you normally would, without explicitly deallocating
memory that is no longer useful.  The collector automatically recycles
memory when it determines that it can no longer be otherwise accessed.

The collector is also used by a number of programming language
implementations that either use C as intermediate code, want to
facilitate easier interoperation with C libraries, or just prefer the
simple collector interface.  Alternatively, the garbage collector may
be used as a leak detector for C or C++ programs, though that is not
its primary goal.
"

homepage=https://www.hboehm.info/gc/
license=Custom

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-cplusplus \
     --enable-static=no \
     --enable-shared=yes \
     --enable-threads=posix \
     --with-libatomic-ops=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/devel/gc/recipe


code:
# Build recipe for GCC.
#
# 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=gcc
version=11-20220429
release=1

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

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

# Remote source(s)
fetch="
  https://gcc.gnu.org/pub/gcc/snapshots/${version}/$tarname
  https://mirrors.concertpass.com/gcc/snapshots/${version}/$tarname
  https://mirror.marwan.ma/gcc/snapshots/${version}/$tarname
"

homepage=https://www.gnu.org/software/gcc
license="GPLv2+, GPLv3+, LGPLv2.1, LGPLv3 + GCC runtime library exception"

description="
The GNU C Compiler Collection.

The GNU Compiler Collection (GCC) is a compiler system produced by the
GNU Project supporting various programming languages.  GCC is a key
component of the GNU toolchain.  The Free Software Foundation (FSF)
distributes GCC under the GNU General Public License (GNU GPL).

For more information about GCC, visit:  $homepage
"

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

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

    cd "$srcdir"

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

    # Apply specific patches for the support in musl.
    # https://port70.net/~nsz/musl/gcc-11.1.0/

    patch -Np1 -i "${worktree}/patches/gcc/11/0002-posix_memalign.patch"
    patch -Np1 -i "${worktree}/patches/gcc/11/0003-j2.patch"
    patch -Np1 -i "${worktree}/patches/gcc/11/0004-static-pie.patch"
    patch -Np1 -i "${worktree}/patches/gcc/11/0005-m68k-sqrt.patch"
    patch -Np1 -i "${worktree}/patches/gcc/11/extra-musl_libssp.patch"
    patch -Np1 -i "${worktree}/patches/gcc/11/extra-relro-in-dragora.patch"

    # Apply patches from "Alpine Linux" in order to improve the security (Thanks!)
    patch -Np1 -i "${worktree}/patches/gcc/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch"
    patch -Np1 -i "${worktree}/patches/gcc/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch"
    patch -Np1 -i "${worktree}/patches/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch"
    patch -Np1 -i "${worktree}/patches/gcc/0007-Enable-Wtrampolines-by-default.patch"
    patch -Np1 -i "${worktree}/patches/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch"
    patch -Np1 -i "${worktree}/patches/gcc/0021-add-fortify-headers-paths.patch"

    # Create a separate build directory
    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    # System-dependent
    MACHINE="$(gcc -dumpmachine)"

    ../configure SED=sed \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --infodir=$infodir \
     --enable-bootstrap \
     --enable-languages=c,c++,fortran,objc,obj-c++ \
     --enable-clocale=generic \
     --enable-threads=posix \
     --enable-cet=auto \
     --enable-initfini-array \
     --enable-tls \
     --enable-nls \
     --enable-lto \
     --enable-plugin \
     --enable-objc-gc \
     --enable-libstdcxx-time \
     --enable-checking=release \
     --enable-fully-dynamic-string \
     --enable-default-ssp \
     --enable-default-pie \
     --enable-libssp \
     --enable-initfini-array \
     --disable-symvers \
     --disable-libitm \
     --disable-gnu-indirect-function \
     --disable-libstdcxx-pch \
     --disable-libsanitizer \
     --disable-libcilkrts \
     --disable-install-libiberty \
     --with-system-zlib \
     --with-linker-hash-style=gnu \
     --build=$MACHINE \
     --host=$MACHINE \
     --target=$MACHINE \
     $multilib_options \
     $gcc_options

    make -j${jobs} V=1 \
     BOOT_CFLAGS="$QICFLAGS" \
     BOOT_CXXFLAGS="$QICXXFLAGS" \
     BOOT_LDFLAGS="$QILDFLAGS" \
     BOOT_CPPFLAGS="$QICPPFLAGS"

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

    # Delete non-shared version of libssp (provided on the musl package)
    rm -f "${destdir}/usr/lib${libSuffix}"/libssp_nonshared.a

    # Strip ELF executables only excluding shared objects
    find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
     cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

    # Strip static libraries in order to reduce the package size
    find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
     cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true

    cd ../

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

    # Provide compatibility and make soft links for package size
    (
        cd "${destdir}/usr/bin" || exit 1

        mv gcc gcc-${version}
        ln -sf gcc-${version} gcc
        ln -sf gcc cc
        ln -sf gcc-${version} ${MACHINE}-gcc
        ln -sf gcc-${version} ${MACHINE}-gcc-${version}

        mv g++ g++-gcc-${version}
        ln -sf g++-gcc-${version} g++
        ln -sf g++ c++
        ln -sf g++-gcc-${version} ${MACHINE}-g++
        ln -sf g++-gcc-${version} ${MACHINE}-c++

        mv gfortran gfortran-${version}
        ln -sf gfortran-${version} gfortran
        ln -sf gfortran-${version} ${MACHINE}-gfortran
        # Extra symlinks for fortran
        ln -sf gfortran g77
        ln -sf g77 f77
        ln -sf gfortran g95
        ln -sf g95 f95

        mv gcc-ar gcc-ar-${version}
        ln -sf gcc-ar-${version} gcc-ar
        ln -sf gcc-ar-${version} ${MACHINE}-gcc-ar

        mv gcc-nm gcc-nm-${version}
        ln -sf gcc-nm-${version} gcc-nm
        ln -sf gcc-nm-${version} ${MACHINE}-gcc-nm

        mv gcc-ranlib gcc-ranlib-${version}
        ln -sf gcc-ranlib-${version} gcc-ranlib
        ln -sf gcc-ranlib-${version} ${MACHINE}-gcc-ranlib
    )
    (
        cd "${destdir}/usr/lib${libSuffix}" && ln -sf ../bin/cpp .
    )

    unset -v MACHINE

    # Insert wrapper scripts for handling C89 and C99 invocations
    cat "${worktree}/archive/gcc/c89" > "${destdir}/usr/bin/c89"
    cat "${worktree}/archive/gcc/c99" > "${destdir}/usr/bin/c99"
    chmod 755 "${destdir}"/usr/bin/c?9

    # 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

    # 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/devel/gcc/recipe


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

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

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

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

description="
The GNU debugger.

GDB, the GNU Project debugger, allows you to see what is going on
inside another program while it executes, or what another program
was doing at the moment it crashed.
"

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

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

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

    cd "$srcdir"

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

    # Create a separate build directory
    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    ../configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-compressed-debug-sections=none \
     --with-python=/usr/bin/python3 \
     --with-system-zlib \
     --with-system-readline \
     --with-guile=guile-3.0 \
     --build="$(gcc -dumpmachine)"

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

    cd ../

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

    # Delete files belonging to the binutils package
    rm -f \
     "${destdir}"/usr/include/*.h \
     "${destdir}/usr/lib${libSuffix}/libbfd.a" \
     "${destdir}/usr/lib${libSuffix}/libopcodes.a" \
     "${destdir}/usr/lib${libSuffix}/libbfd.la" \
     "${destdir}/usr/lib${libSuffix}/libopcodes.la" \
     "${destdir}/${infodir}/bdf.info"

    # 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/devel/gdb/recipe


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

# Exit immediately on any error
set -e

program=git
version=2.34.1
release=1

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

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

# Remote source(s)
fetch="
  https://mirrors.edge.kernel.org/pub/software/scm/git/$tarname
  https://mirrors.edge.kernel.org/pub/software/scm/git/$tarname_manpages
"

description="
A fast, scalable, distributed revision control system.

Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.

Git is an Open Source project covered by the GNU General Public
License version 2 (some parts of it are under different licenses,
compatible with the GPLv2). It was originally written by Linus
Torvalds with help of a group of hackers around the net.
"

homepage=https://www.git-scm.org
license="GPLv2 only, LGPLv2.1"

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

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

    cd "$srcdir"

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

    cat << EOF >> config.mak
NEEDS_CRYPTO_WITH_SSL=1
INSTALL_SYMLINKS=1
EOF

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

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

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"

            # Unpack provided man-pages
            tar xf "${tardir}/$tarname_manpages"

            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
    unset -v tarname_manpages

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

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

path: recipes/devel/git/recipe


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

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

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

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

description="
Perfect hash function generator.

GNU gperf is a perfect hash function generator.  For a given list of
strings, it produces a hash function and hash table, in form of C or
C++ code, for looking up a value depending on the input string.
The hash function is perfect, which means that the hash table has no
collisions, and the hash table lookup needs a single string comparison
only.

GNU gperf is highly customizable.  There are options for generating C
or C++ code, for emitting switch statements or nested ifs instead of a
hash table, and for tuning the algorithm employed by gperf.
"

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

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)"

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

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

    # Compress manual page
    lzip -9 "${destdir}/${mandir}/man1/gperf.1"

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

    for file in $docs
    do
        cp -p $file "${destdir}/$docsdir"
    done
}

path: recipes/devel/gperf/recipe


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

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

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

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

homepage=https://www.gnu.org/software/guile/

description="
The GNU Guile programming language.

Guile is designed to help programmers create flexible applications that
can be extended by users or other programmers with plug-ins, modules,
or scripts.  With Guile you can create applications and games for the
desktop, the Web, the command-line, and more.

For more information, visit:
$homepage
"

license="GPLv3+, LGPLv3+"

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

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

    cd "$srcdir"

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

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

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

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

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

    # 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/devel/guile/recipe


code:
# Build recipe for help2man.
#
# 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=help2man
version=1.49.2
arch=noarch
release=1

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

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

# Remote source(s)
fetch=https://espejito.fder.edu.uy/gnu/help2man/$tarname

description="
A script to create simple man pages.

help2man is a script to create simple man pages from
the --help and --version output of programs.
"

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

# Source documentation
docs="COPYING debian/changelog 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 $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

    # 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 libtool.
#
# Copyright (c) 2016-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=libtool
version=2.4.7
release=1

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

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

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

description="
The GNU portable library tool.

GNU libtool is a generic library support script.  Libtool hides
the complexity of using shared libraries behind a consistent,
portable interface.
"

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

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README THANKS TODO libltdl/COPYING.LIB"
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 \
     --enable-shared \
     --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/devel/libtool/recipe


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

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

tarname=${program}-${version}.src.tar.xz
tarname_clang=clang-${version}.src.tar.xz
tarname_compilerrt=compiler-rt-${version}.src.tar.xz

# Remote source(s)
fetch="
 https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/$tarname
 https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/$tarname_clang
 https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/$tarname_compilerrt
"

homepage=https://llvm.org
license="Apachev2 + LLVM exceptions"

description="
The LLVM compiler.

The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines.  The name \"LLVM\" itself is not an
acronym; it is the full name of the project.

For more information, visit: $homepage
"

# Source documentation
docs="CREDITS.TXT LICENSE.TXT README.txt"
docsdir="${docdir}/${program}-${version}"

# Source directory used by this software
srcdir=${program}-${version}.src

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

    cd "$srcdir"

    cd tools

    unpack "${tardir}/$tarname_clang"
    mv clang-${version}.src clang

    cd ../projects

    unpack "${tardir}/$tarname_compilerrt"
    mv compiler-rt-${version}.src compiler-rt

    cd ..
    unset -v tarname_clang tarname_compilerrt

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

    # Make sure to point to Python version 3 (Thanks to BLFS!)
    grep -rl '#!.*python' | xargs sed -i '1s/python$/python3/'

    # Set the SANITIZER flag to TRUE for Musl
    patch -p0 < "${worktree}/patches/llvm/compiler_rt_sanitizer.diff"

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake CC=gcc CXX=g++ \
     -DCMAKE_C_FLAGS_RELEASE:STRING="$QICFLAGS"                            \
     -DCMAKE_CXX_FLAGS_RELEASE:STRING="$QICXXFLAGS"                        \
     -DCMAKE_EXE_LINKER_FLAGS:STRING="$QILDFLAGS -Wl,--no-keep-memory"     \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$QILDFLAGS -Wl,--no-keep-memory"  \
     -DCMAKE_INSTALL_PREFIX=/usr                                           \
     -DLLVM_LIBDIR_SUFFIX=${libSuffix}                                     \
     -DLLVM_BINUTILS_INCDIR=/usr/include                                   \
     -DCMAKE_INSTALL_MANDIR=$mandir                                        \
     -DCMAKE_INSTALL_DOCDIR=$docsdir                                       \
     -DCMAKE_BUILD_TYPE=Release                                            \
     -DLLVM_BUILD_LLVM_DYLIB=ON                                            \
     -DLLVM_LINK_LLVM_DYLIB=ON                                             \
     -DLLVM_ENABLE_FFI=ON                                                  \
     -DLLVM_ENABLE_RTTI=ON                                                 \
     -DLLVM_ENABLE_ZLIB=ON                                                 \
     -DLLVM_INSTALL_UTILS=ON                                               \
     -DLLVM_ENABLE_ASSERTIONS=OFF                                          \
     -DLLVM_APPEND_VC_REV=OFF                                              \
     -DLLVM_PARALLEL_COMPILE_JOBS=$jobs                                    \
     -DLLVM_INCLUDE_BENCHMARKS=OFF                                         \
     -G Ninja ..

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

    # Strip ELF executables only excluding shared objects
    find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
     cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

    # Strip static libraries in order to reduce the package size
    find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
     cut -f 1 -d : | xargs strip --strip-debug 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

    cd ../

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

path: recipes/devel/llvm/recipe


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

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

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

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

description="
Traditional Unix macro processor.

GNU M4 is an implementation of the traditional Unix macro processor.
It is mostly SVR4 compatible although it has some extensions (for
example, handling more than 9 positional parameters to macros).

GNU M4 also has built-in functions for including files, running shell
commands, doing arithmetic, etc.

GNU M4 is a macro processor in the sense that it copies its input
to the output expanding macros as it goes.
"

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

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

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

    cd "$srcdir"

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

    patch -Np1 -i "${worktree}/patches/m4/update-freadahead"

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

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

    # This look wrong since m4 does not support any encoding translation
    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 man pages
    lzip -9 "${destdir}/${mandir}/man1/m4.1"

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


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

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

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

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

description="
The weighted make.

GNU Make is a tool which controls the generation of executables and
other non-source files of a program from the program's source files.

Make gets its knowledge of how to build your program from a file
called the makefile, which lists each of the non-source files and
how to compute it from other files.  When you write a program, you
should write a makefile for it, so that it is possible to use Make
to build and install the program.
"

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

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

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

    cd "$srcdir"

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

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

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

    # Make symlink for "GNU make"
    ( cd "${destdir}/usr/bin" && ln -sf make gmake )

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

    for file in $docs
    do
        cp -p $file "${destdir}/$docsdir"
    done
}

path: recipes/devel/make/recipe