Skip to content

Instantly share code, notes, and snippets.

@lzlrd
Created March 29, 2025 11:28
Show Gist options
  • Save lzlrd/ec6df3086806e1b8a8a9464bb3fa49ee to your computer and use it in GitHub Desktop.
Save lzlrd/ec6df3086806e1b8a8a9464bb3fa49ee to your computer and use it in GitHub Desktop.
#! /hint/bash
# shellcheck disable=2034
#
# /etc/makepkg.conf
#
DLAGENTS=(
'file::/usr/bin/curl -qgC - -o %o %u'
'ftp::/usr/bin/aria2c -UWget -s4 -x4 %u -o %o --follow-metalink=mem --async-dns=false'
'http::/usr/bin/aria2c -UWget -s4 -x4 %u -o %o --follow-metalink=mem --async-dns=false'
'https::/usr/bin/aria2c -UWget -s4 -x4 %u -o %o --follow-metalink=mem --async-dns=false'
'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o'
)
VCSCLIENTS=(
'bzr::breezy'
'fossil::fossil'
'git::git'
'hg::mercurial'
'svn::subversion'
)
CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"
# The following configuration is are inspired by
# https://somegit.dev/ALHP/ALHP.GO/src/branch/main/flags.yaml.
SET_FET_LVL="v4"
USE_OPT_LTO="true"
USE_CC_LLVM="false"
USE_CC_ZEN4="true"
USE_LD_MOLD="false"
if [ "USE_CC_LLVM" == "true" ]; then
CC="clang"
CXX="clang++"
else
CC="gcc"
CXX="g++"
fi
# CPPFLAGS=""
# See https://somegit.dev/ALHP/ALHP.GO/issues/92 for the reasoning behind
# "-mpclmul".
CFLAGS="-march=$([ "$USE_CC_ZEN4" == "true" ] && echo -n "znver4" || echo -n "x86-64-$SET_FET_LVL") -mtune=native -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mpclmul"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs$([ "$USE_LD_MOLD" == "true" ] && echo -n " -fuse-ld=mold" || ([ "$USE_CC_LLVM" == "true" ] && echo -n " -fuse-ld=lld"))"
# See https://github.com/InBetweenNames/gentooLTO/issues/164 for the
# reasoning behind "-falign-functions=32".
LTOFLAGS="-flto=$([ "$USE_CC_LLVM" == "true" ] && echo -n "thin" || echo -n "auto") -falign-functions=32"
# See https://somegit.dev/ALHP/ALHP.GO/issues/116 for the reasoning behind
# GOAMD64.
GOAMD64="$SET_FET_LVL"
# See https://somegit.dev/ALHP/ALHP.GO/issues/110 for the reasoning behind
# RUSTFLAGS. Additionally, remove "-Ccodegen-units=1" when building !lto.
RUSTFLAGS="-Copt-level=3 -Ctarget-cpu=$([ "$USE_CC_ZEN4" == "true" ] && echo -n "znver4" || echo -n "x86-64-$SET_FET_LVL") -Clink-arg=-z -Clink-arg=pack-relative-relocs$([ "$USE_OPT_LTO" == "true" ] && (([ "$USE_CC_LLVM" == "true" ] && [ "$USE_LD_MOLD" != "true" ]) && echo -n " -Z thinlto" || echo -n " -Ccodegen-units=1")) -Clink-arg=-fuse-ld=$([ "$USE_LD_MOLD" == "true" ] && echo -n "mold" || ([ "$USE_CC_LLVM" == "true" ] && echo -n "lld" || echo -n "ld"))"
KCFLAGS=" -march=$([ "$USE_CC_ZEN4" == "true" ] && echo -n "znver4" || echo -n "x86-64-$SET_FET_LVL") -O3"
KCPPFLAGS=" -march=$([ "$USE_CC_ZEN4" == "true" ] && echo -n "znver4" || echo -n "x86-64-$SET_FET_LVL") -O3"
FFLAGS="-O3 -march=$([ "$USE_CC_ZEN4" == "true" ] && echo -n "znver4" || echo -n "x86-64-$SET_FET_LVL")"
FCFLAGS="$FFLAGS"
# Only define when building lto.
[ "$USE_OPT_LTO" == "true" ] && CARGO_PROFILE_RELEASE_LTO="fat"
MAKEFLAGS="-j$(($(nproc) - 2))"
NINJAFLAGS="-j$(($(nproc) - 2))"
DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
BUILDENV=(!distcc color ccache check !sign)
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug $([ "$USE_OPT_LTO" == "true" ] && echo -n "lto"))
INTEGRITY_CHECK=(b2)
STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug"
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
DBGSRCDIR="/usr/src/debug"
LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32')
PACKAGER="Diab Neiroukh <[email protected]>"
# GPGKEY=""
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -)
COMPRESSZST=(zstd -c -T0 -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)
PKGEXT='.pkg.tar.zst'
SRCEXT='.src.tar.zst'
# vim: set ft=sh ts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment