# Maintainer: Arglebargle < arglebargle at arglebargle dot dev> # Contributor: Joan Figueras # Contributor: Torge Matthies # Contributor: Jan Alexander Steffens (heftig) # -- # shellcheck disable=SC2034,SC2164 ## The following variables can be customized at build time ## ## Usage: env _microarchitecture=98 use_numa=n use_tracers=n makepkg -sc ## or: makepkg -sc -- _microarchitecture=98 use_numa=n use_tracers=n ## or: export use_numa=n use_tracers=n; makepkg -sc ## ## Xanmod-ROG options: ## ## 'amd_pstate' - Setting this variable to 'n' will disable the amd-pstate driver ## : "${amd_pstate:=y}" ## '_O3' - Enable compiler -O3 optimizations, set _O3 to anything to enable ## _O3="${_O3:+y}" ## 'makeflags_check' - If MAKEFLAGS in /etc/makepkg.conf is null or unset we'll throw a big ## warning and pause long enough for the user to cancel their build ## Set "makeflags_check" to n to skip this ## : "${makeflags_check:=y}" ## ## Xanmod options: ## ## Look inside 'choose-gcc-optimization.sh' to choose your microarchitecture ## Valid numbers between: 0 to 99 ## Default is: 93 => x86-64-v3 ## Good option if your package is for one machine: 98 (Intel native) or 99 (AMD native) : "${_microarchitecture:=93}" ## Disable NUMA since most users do not have multiple processors. Breaks CUDA/NvEnc. ## Archlinux and Xanmod enable it by default. ## Set variable "use_numa" to: n to disable (possibly increase performance) ## y to enable (stock default) : "${use_numa:=y}" ## For performance you can disable FUNCTION_TRACER/GRAPH_TRACER. Limits debugging and analyzing of the kernel. ## Stock Archlinux and Xanmod have this enabled. ## Set variable "use_tracers" to: n to disable (possibly increase performance) ## y to enable (stock default) : "${use_tracers:=y}" ## Choose between GCC or CLANG config (default is GCC) case "${_compiler,,}" in "clang" | "gcc") _compiler=${_compiler,,} ;; *) _compiler=gcc ;; # default to GCC esac ## Compress modules by default (following Arch's kernel) ## Set variable "_compress_modules" to: n to disable ## y to enable (default) : "${_compress_modules:=y}" # Compile ONLY used modules to VASTLY reduce the number of modules built # and the build time. # # To keep track of which modules are needed for your specific system/hardware, # give module_db script a try: https://aur.archlinux.org/packages/modprobed-db # This PKGBUILD read the database kept if it exists # # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db : "${_localmodcfg:=n}" # Tweak kernel options prior to a build via nconfig _makenconfig= ### IMPORTANT: Do not edit below this line unless you know what you're doing pkgbase=linux-xanmod-rog xanmod=5.16.3-xanmod1 #pkgver=${xanmod//-/.} pkgver=5.16.4.prexan0 # NOTE: ^^ for custom pkgvers pick something that version sorts 'before' next .xanmodY to avoid downgrade warnings pkgrel=1 pkgdesc='Linux Xanmod' url="http://www.xanmod.org/" arch=(x86_64) license=(GPL2) makedepends=( bc kmod libelf pahole cpio perl tar xz "gcc>=11.0" ) if [ "$_compiler" = "clang" ]; then pkgver="${pkgver}+clang" makedepends+=(clang llvm lld python) _LLVM=1 fi options=('!strip' '!ccache') _major=${xanmod%\.*\-*} # eg: 5.15 _branch=${xanmod%%\.*\-*}.x # eg: 5.x source=("https://cdn.kernel.org/pub/linux/kernel/v${_branch}/linux-${_major}.tar."{xz,sign} "https://github.com/xanmod/linux/releases/download/${xanmod}/patch-${xanmod}.xz" "choose-gcc-optimization.sh" # apply incremental kernel updates ahead of official Xanmod release #"https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.16.1.xz" "https://cdn.kernel.org/pub/linux/kernel/v5.x/incr/patch-5.16.3-4.xz" #"Linux-5.16.2.patch" #"Linux-5.16.4-rc1.patch" # Arch: misc hotfixes "Bluetooth-btintel-Fix-bdaddress-comparison-with-garb.patch" "Bluetooth-Read-codec-capabilities-only-if-supported.patch" # amd-pstate included in Xanmod # multigenerational lru included in Xanmod # 5.17 TCP Optimizations included in Xanmod # 5.17 TCP csum optimization included in Xanmod # 5.17: UDP/IPv6 optimizations "UDP-IPv6-Optimizations-from-5.17-partial.patch" # -- patch from Chromium developers; more accurately report battery state changes "acpi-battery-Always-read-fresh-battery-state-on-update.patch" # -- squelch overzealous 802.11 regdomain not set warnings "cfg80211-dont-WARN-if-a-self-managed-device.patch" # -- Reduce hid-asus object size by consolidating calls "HID-asus-Reduce-object-size-by-consolidating-calls.patch" # 5.17: ASUS ROG laptop custom fan curve support "v16-asus-wmi-Add-support-for-custom-fan-curves.patch" # mediatek mt7921 bt/wifi patches "mt76-mt7921-enable-VO-tx-aggregation.patch" "1-2-Bluetooth-btusb-Add-Mediatek-MT7921-support-for-Foxconn.patch" "2-2-Bluetooth-btusb-Add-Mediatek-MT7921-support-for-IMC-Network.patch" "Bluetooth-btusb-Add-support-for-IMC-Networks-Mediatek-Chip.patch" "Bluetooth-btusb-Add-support-for-Foxconn-Mediatek-Chip.patch" "Bluetooth-btusb-Add-support-for-IMC-Networks-Mediatek-Chip-MT7921.patch" # XXX: this patch could be buggy, recommended to only build mt76 as a module; see the mailing list "mt76-mt7921e-fix-possible-probe-failure-after-reboot.patch" # squashed s0ix enablement "9001-v5.16.3-s0ix-patch-2022-01-25.patch" ) validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linux Torvalds '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman ) sha256sums=('027d7e8988bb69ac12ee92406c3be1fe13f990b1ca2249e226225cd1573308bb' 'SKIP' '188e5f155f1dd66d5c636b725ee6b9c312f4aa2bdc866ce5ff5b3f2de1101cda' '278118011d7a2eeca9971ac97b31bf0c55ab55e99c662ab9ae4717b55819c9a2' 'e254d82ad04c0ea3f61f62518b664cd5fe892bd04a67d99b9e038343bd496619' '241f01f06849fcec462d72355ca3ab6bd34931731dec89876d785912ac532398' 'dd01bd3f774c3a9af42b6d89f534f39c4a5f200db32cd6d4b72a29325645100e' '41b0cef536675f10fdfb69eeca2f1927653c69eb351dd92f4085ab6590485851' 'f7a4bf6293912bfc4a20743e58a5a266be8c4dbe3c1862d196d3a3b45f2f7c90' '3d8961438b5c8110588ff0b881d472fc71a4304d306808d78a4055a4150f351e' '544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4' '0c422d8f420c1518aab1b980c6cdb6e029a4fa9cde1fd99a63670bb105a44f36' '1ce9fd988201c4d2e48794c58acda5b768ec0fea1d29555e99d35cd2712281e4' '236cdadf0b1472945c0d7570caeed7b95929aabed6872319c9d0969a819689e9' 'cc2aa580d69801aa1afb0d72ecf094fe13c797363d3d5928c868d3a389910b7b' '292a7e32b248c7eee6e2f5407d609d03d985f367d329adb02b9d6dba1f85b44c' '7dbfdd120bc155cad1879579cb9dd1185eb5e37078c8c93fef604a275a163812' '1444af2e125080934c67b6adb4561fd354a72ce47d3de393b24f53832ee492ac' '63ebf908ba2a66865a94e3a4af579d41ec15573522d3ebb07bf8ded3bc57e833' '0907831e3bd6b47bc83f247503dbf3d0301728a77c459e900cff6bc2a7fc4d96') export KBUILD_BUILD_HOST=${KBUILD_BUILD_HOST:-archlinux} export KBUILD_BUILD_USER=${KBUILD_BUILD_USER:-"$pkgbase"} export KBUILD_BUILD_TIMESTAMP=${KBUILD_BUILD_TIMESTAMP:-$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})} # shellcheck disable=SC2154,SC2155 prepare() { cd "linux-${_major}" # Apply patches local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" case "$src" in patch-${_major}*xanmod*.xz) # Apply Xanmod patch msg2 "Applying Xanmod patch..." patch -Np1 -i "../${src%\.xz}" ;; patch-${_major}*xz|Linux-${_major}*.xz) # Apply kernel.org point releases if we're building ahead of Xanmod official msg2 "Applying kernel.org point release ${src%\.xz} ..." patch -Np1 -i "../${src%\.xz}" ;; *.patch|*.patch.xz|*.diff|*.diff.xz) # Apply any other patches msg2 "Applying patch ${src%\.xz} ..." patch -Np1 -i "../${src%\.xz}" ;; esac done # Set kernel version msg2 "Setting version..." scripts/setlocalversion --save-scmversion echo "-$pkgrel" > localversion.99-pkgrel echo "${pkgbase#linux-xanmod}" > localversion.20-pkgname # xanmod release localversion local _xanlver=${xanmod##*\-} # pkgver localversion, chop the +clang off clang builds local _localversion=${pkgver##*\.} _localversion=${_localversion%\+*} # Monkey patch: If we're applying a point release on top of Xanmod official then we'll monkey with the # localversion and use our own localversion slug to indicate this isn't an upstream kernel. if [[ "$_xanlver" != "$_localversion" ]]; then msg2 "(Monkey)ing with kernel, rewriting localversion $_xanlver to $_localversion ..." sed -Ei "s/xanmod[0-9]+/${_localversion}/" localversion fi # Apply configuration msg2 "Applying kernel config..." cp -vf CONFIGS/xanmod/${_compiler}/config .config # enable LTO_CLANG_THIN if [ "$_compiler" = "clang" ]; then msg2 "Enabling Clang ThinLTO ..." scripts/config --disable LTO_CLANG_FULL \ --enable LTO_CLANG_THIN fi # enable O3 optimizations if [ "$_O3" = "y" ]; then msg2 "Enabling -O3 optimizations ..." scripts/config --disable CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE \ --enable CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 fi # CONFIG_STACK_VALIDATION gives better stack traces. Also is enabled in all official kernel packages by Archlinux team scripts/config --enable CONFIG_STACK_VALIDATION # Enable IKCONFIG following Arch's philosophy scripts/config --enable CONFIG_IKCONFIG \ --enable CONFIG_IKCONFIG_PROC # User set. See at the top of this file if [ "$use_tracers" = "n" ]; then msg2 "Disabling FUNCTION_TRACER/GRAPH_TRACER only if we are not compiling with clang..." if [ "$_compiler" = "gcc" ]; then scripts/config --disable CONFIG_FUNCTION_TRACER \ --disable CONFIG_STACK_TRACER fi fi # User set. See at the top of this file if [ "$use_numa" = "n" ]; then msg2 "Disabling NUMA..." scripts/config --disable CONFIG_NUMA fi # Compress modules if [ "$_compress_modules" = "y" ]; then scripts/config --disable CONFIG_MODULE_COMPRESS_NONE \ --enable CONFIG_MODULE_COMPRESS_ZSTD fi # Disable AMD pstate if requested if [ "$amd_pstate" = "n" ]; then msg2 "Disabling amd-pstate driver..." scripts/config --disable CONFIG_X86_AMD_PSTATE else scripts/config --enable CONFIG_X86_AMD_PSTATE fi # Select microarchitecture optimization target sh "${srcdir}/choose-gcc-optimization.sh" $_microarchitecture # Apply package config customizations if [[ -s ${startdir}/xanmod-rog-config ]]; then msg2 "Applying package config customization..." bash -x "${startdir}/xanmod-rog-config" fi # This is intended for the people that want to build this package with their own config # Put the file "myconfig" at the package folder (this will take precedence) or "${XDG_CONFIG_HOME}/linux-xanmod-rog/myconfig" # If we detect partial file with scripts/config commands, we execute as a script # If not, it's a full config, will be replaced for _myconfig in "${startdir}/myconfig" "${HOME}/.config/linux-xanmod-rog/myconfig" "${XDG_CONFIG_HOME}/linux-xanmod-rog/myconfig" ; do # if file exists and size > 0 bytes if [ -s "${_myconfig}" ]; then if grep -q 'scripts/config' "${_myconfig}"; then # myconfig is a partial file. Executing as a script msg2 "Applying myconfig..." bash -x "${_myconfig}" else # myconfig is a full config file. Replacing default .config msg2 "Using user CUSTOM config..." cp -f "${_myconfig}" .config fi echo break fi done ### Optionally load needed modules for the make localmodconfig # See https://aur.archlinux.org/packages/modprobed-db if [ "$_localmodcfg" = "y" ]; then if [ -f "$HOME/.config/modprobed.db" ]; then msg2 "Running Steven Rostedt's make localmodconfig now" make ${_LLVM:+LLVM=$_LLVM LLVM_IAS=$_LLVM} LSMOD="$HOME/.config/modprobed.db" localmodconfig else msg2 "No modprobed.db data found" exit 1 fi fi msg2 "Finalizing kernel config..." make ${_LLVM:+LLVM=$_LLVM LLVM_IAS=$_LLVM} olddefconfig make -s kernelrelease > version msg2 "Prepared %s version %s" "$pkgbase" "$( "${startdir}/config.last" } build() { if [[ -z "$MAKEFLAGS" ]] && [[ "$makeflags_check" == "y" ]]; then show_makeflags_warning fi cd "linux-${_major}" make ${_LLVM:+LLVM=$_LLVM LLVM_IAS=$_LLVM} all } # shellcheck disable=SC2154,SC2155 _package() { pkgdesc="The $pkgdesc kernel and modules with ASUS ROG laptop patches (Zephyrus G14, G15, etc)" depends=(coreutils kmod initramfs) optdepends=('crda: to set the correct wireless channels of your country' 'linux-firmware: firmware images needed for some devices') provides+=(ASUS-WMI-FAN-CONTROL linux-rog) cd "linux-${_major}" local kernver="$(&2 ▄▄▄▄▄▄▄ ▄▄ ▄ ▄▄▄▄▄ ▄▄▄▄▄▄▄ █ ▄▄▄ █ ▄ ▄▄█▄ ▀█ ▄ █ ▄▄▄ █ █ ███ █ ██▄█ █ █▀▀▀█ █ ███ █ █▄▄▄▄▄█ ▄▀▄ █▀▄ ▄▀█▀█ █▄▄▄▄▄█ ▄▄▄▄ ▄ ▄▀ ▀ ▄▄▀▀███▀▄ ▄▄▄ ▄ ▄▄█▄█▀▄▀▄▀ ▄▀ █ ▄▀█ ███ ▄▄▀ █▄█▀▄▄▀ ▄ █▀██▄█▄▀▄▀▀▀▀▀▄▄ ▀ █▀▄▀██▄ ▀▄█▀▄ █ █▀ ██▄▀█▄ ███ █▀▄██ ▄ ▀ ▄▄▀ ▀▀▀ ▄ █▄▀▀█▄ █ ▄▀▀▄▀ ▄▀██▄▄█ ▀█▄ ▀ ▀▀ █ ▀█▀ ▄▀█▀▀▄▄▄▄▄▄█ █▄▀█▄███▄▄▄▄█ ▄▄▄▄▄▄▄ ▀██▄█▄▄ ▀▄█ ▄ ██▀█▀ █ ▄▄▄ █ ▀▄ ▄▀██▄▄▀ █▄▄▄█▀▄█▄ █ ███ █ █ ▄█▀▄ ▀▀ ▀▀█ ▄▀▀▄ █ █▄▄▄▄▄█ █ ▀ █▄█ ▀██ ▀ █ █ YEET else cat <<-YEET >&2 ▄▄▄▄▄▄▄ ▄ ▄ ▄ ▄▄▄▄▄ ▄▄▄▄▄▄▄ █ ▄▄▄ █ ▀█▄█▀ ▀▀█ █ ██▀▄ █ ▄▄▄ █ █ ███ █ ▀▀▄▀▄█▀▄█▀ █▄ ▀██ █ ███ █ █▄▄▄▄▄█ █ █ ▄ ▄▀█▀█ █▀▄ ▄ █▄▄▄▄▄█ ▄▄▄▄▄ ▄▄▄▄▄ █▄██▀▄▀▄ ▀█▀▄▄ ▄ ▄ ▄ █ ██▀ ▄▄▀█ ▄▄▀▄▄▀█▀ ███▀▄ ▀▄▄▄▀█▀ ▄▀▄█▀▀▄ ▀█▀█ ▄█▀▀▄ ▀ ▀▄▀▀█▀▀▄▄▀ █ ▀▀▀█▄▄█▄█ ▀ ▄▄█▄ ▀▄▄▄▀ █ █▀ ▀█▀▀██▄ ▀█ █▄█▀ ▄▀▀▀▀▄█▄▄ █▄ ▀▄ ▄▀▀ ▀█▄▀▄▀ ▄▄▄▀▄▀▀█▀██▄▀▄▄█▄▄█ █▀ ▀ ▄▄▀ ▄█▄█ █ ▀█▄▄ █ ▀▀█▄▄ ▄█ ▀▄ █▀▀▀█▄▄▄▄▄▀ ▀█▄▄██▀▀▀ ▄▀█ █▀ █ █▀ █ ▀ ▀▀▄█▀▄ █▀▄▀▀▄▀ ▄██▄██▄███▀ ▄ ▄▄▄▄▄▄▄ █▄▄▄▄ ▄█▄▀▀█▄▄██ ▄ ██▀▄▀ █ ▄▄▄ █ ▄███ ▀ ▀ ▀▀█▀█▄▄▄█▀▀ █ ███ █ █▀▄ ▀██▄██ ▀██ ██▀▄▀▀▄▄▄ █▄▄▄▄▄█ █▄▀ █▀▄▄ ▄ █ ▀██▄▀█▄█▀▀▄ YEET fi plainerr "" plainerr "Edit your makepkg.conf and set appropriate MAKEFLAGS for your system to remove this warning" plainerr "or run makepkg with 'env makeflags_check=n makepkg ...'" plainerr "" printf -- "${ALL_OFF}${BOLD} > ${YELLOW}Pressing CTRL-C now and fixing this before continuing is a very good idea ${ALL_OFF}${BOLD}<\n" >&2 plainerr "" printf -- "-> Continuing in 60s " >&2 for i in {1..60}; do printf "." >&2 && sleep 1; done echo } # vim:set ts=8 sts=2 sw=2 et: