# Copyright 2004-2024 Gentoo Foundation.
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# This will help developers track packages, that don't respect LDFLAGS, down
# more effectively
LDFLAGS="${LDFLAGS} -Wl,--defsym=__gentoo_check_ldflags__=0"

#Adding -frecord-gcc-switches to help track down packages which don't respect *FLAGS
#should probably leave a note in /etc/portage/make.conf about keeping this when override
SPEEDFLAGS="-O3 -flto"
WARNINGFLAGS="-frecord-gcc-switches -Wstringop-overread -Wformat -Wformat-security"
#requires gcc-14 or higher
SECURITYFLAGS="-fhardened -Wno-hardened"

CFLAGS="${CFLAGS} -pipe ${SPEEDFLAGS} ${WARNINGFLAGS} ${SECURITYFLAGS}"
CXXFLAGS="${CXXFLAGS} -pipe ${SPEEDFLAGS} ${WARNINGFLAGS} ${SECURITYFLAGS}"
FFLAGS="${FFLAGS} -pipe ${SPEEDFLAGS} ${WARNINGFLAGS} ${SECURITYFLAGS}"
FCFLAGS="${FCFLAGS} -pipe ${SPEEDFLAGS} ${WARNINGFLAGS} ${SECURITYFLAGS}"

FEATURES="${FEATURES} usersandbox protect-owned userpriv userfetch fixlafiles news parallel-fetch sfperms unmerge-orphans unknown-features-warn usersync \
      multilib-strict preserve-libs parallel-install -ebuild-locks binpkg-multi-instance -buildpkg-live splitdebug compressdebug"

#for major use of binpkgs, we need to "fix" a few of gentoo's flaws:
#a package built against kernel A will attempt to be used even when remerging on kernel B (often to hilarious consequences)
#so we will define a long list of such packages and exclude them from being built and used (catch it on both ends to avoid issues)
PENTOO_BINPKG_RESTRICTED="sys-kernel/ax88179_178a x11-drivers/ati-drivers x11-drivers/nvidia-drivers sys-fs/zfs-kmod sys-kernel/spl \
			sys-power/bbswitch x11-drivers/xf86-video-virtualbox app-emulation/virtualbox-guest-additions dev-libs/pocl \
			app-emulation/virtualbox-modules app-emulation/vmware-modules app-emulation/open-vm-tools sys-kernel/genkernel dev-python/certifi \
			sys-kernel/pentoo-sources dev-python/twisted-web net-analyzer/metasploit sci-libs/lapack-reference x11-base/xorg-drivers app-admin/genmenu \
			net-wireless/rtl8812au_aircrack-ng media-libs/libepoxy net-wireless/gr-ieee802154 x11-libs/libva acct-user/* acct-group/* pentoo/* virtual/*"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --buildpkg-exclude \"${PENTOO_BINPKG_RESTRICTED}\" --usepkg-exclude \"${PENTOO_BINPKG_RESTRICTED}\""

EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --ask-enter-invalid --keep-going=y --binpkg-respect-use=y --tree --verbose --autounmask=n"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --binpkg-changed-deps=y --ignore-soname-deps=n"

XFCE_PLUGINS="${XFCE_PLUGINS} brightness menu logout trash"

#libinput replaces evdev, synaptics AND tslib; gentoo defaults keyboard and mouse have been deprecated for years, so drop them
INPUT_DEVICES="libinput"

# Log eqawarn messages
PORTAGE_ELOG_CLASSES="${PORTAGE_ELOG_CLASSES} qa"

PORTAGE_NICENESS="9"
PORTAGE_IO_NICENESS="ionice -c 3 -p \${PID}"

#tslib causes circular deps with libsdl2
USE="${USE} X abi_x86_32 adns caps curl elogind fbcon gles2 gps lm-sensors lto lua lz4 lzip lzma lzo modules-sign networkmanager oss pentoo-full perl pulseaudio python ruby samba sqlite verify-sig vdpau vaapi vulkan wayland xattr xinerama zstd"

BOOTSTRAP_USE="${BOOTSTRAP_USE} cet http2 lto openmp"

PORTAGE_BZIP2_COMMAND="lbzip2"
PORTAGE_BUNZIP2_COMMAND="lbunzip2"
PORTAGE_COMPRESS="zstd"
BINPKG_FORMAT="gpkg"
BINPKG_COMPRESS="zstd"
BINPKG_COMPRESS_FLAGS="-c -T0 -19"

#mgorny suggested this speeds up sync, in my testing it makes a rather large difference
PORTAGE_RSYNC_EXTRA_OPTS="--omit-dir-times"

DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"

ACCEPT_LICENSE="* -@EULA intel-ucode-20180807 FraunhoferFDK Intel-SDP Nordic-5"

GPSD_PROTOCOLS="nmea0183 nmea2000"

L10N="en en-US"

# These firmware files cause failure during module load
# which sometimes goes on to lock up the kernel
# but the hardware is mostly functional without them so for now
# prevent breakage by not installing the firmware
INSTALL_MASK="/lib/firmware/mediatek/BT_RAM_CODE_MT*.bin*"
