Package Details: plasma-desktop-git 6.0.80_r11524.gf3a8cd50e-1

Git Clone URL: https://aur.archlinux.org/plasma-desktop-git.git (read-only, click to copy)
Package Base: plasma-desktop-git
Description: KDE Plasma Desktop
Upstream URL: https://kde.org/plasma-desktop/
Licenses: LGPL-2.0-or-later
Groups: plasma-git
Conflicts: knetattach, knetattach-git, plasma-desktop, user-manager, user-manager-git
Provides: knetattach, knetattach-git, plasma-desktop, user-manager, user-manager-git
Replaces: knetattach-git, user-manager-git
Submitter: arojas
Maintainer: IslandC0der (chaotic-aur)
Last Packager: IslandC0der
Votes: 9
Popularity: 0.000000
First Submitted: 2014-03-31 06:31 (UTC)
Last Updated: 2024-03-02 13:37 (UTC)

Required by (40)

Sources (1)

Latest Comments

« First ‹ Previous 1 2 3 4 5 6 7 8 .. 12 Next › Last »

IslandC0der commented on 2021-08-19 00:57 (UTC) (edited on 2021-08-19 00:58 (UTC) by IslandC0der)

Hmm that seems like something on your end, I've just tried and it downloaded fine :/

Anyways, it really depends on what you wanna do: you could for example change line 970 to something like makepkg -sfcCri --noconfirm || echo $dir >> ~/asp/errors.log, which would log the package name to a file if an error is encountered.

You can replace what's after || with whichever command you want to run if makepkg fails. If you want to run multiple commands, you can do:

if [[ $? != 0 ]]; then
  ## Error-handling code goes here
fi

right after makepkg, instead of ||.

Neko-san commented on 2021-08-19 00:17 (UTC) (edited on 2021-08-19 01:02 (UTC) by Neko-san)

@IslandC0der Oki

Oof, something went wrong with the source download part of makepkg :v (I also take it that error-handling would not be possible here?)

EDIT: Doing it again worked fine but this was strange; I imagine makepkg messing up, though, would mean that this process would have to be done again for any package :/

==> Making package: dolphin-emu 1:5.0.r14790.3cc274880f-1 (Wed 18 Aug 2021 06:51:51 PM CDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Cloning dolphin-emu git repo...
Cloning into bare repository '/home/neko-san/asp/dolphin-emu/trunk/dolphin-emu'...
remote: Enumerating objects: 549044, done.
remote: Counting objects: 100% (7483/7483), done.
remote: Compressing objects: 100% (2764/2764), done.
error: RPC failed; curl 56 OpenSSL SSL_read: Connection reset by peer, errno 104
error: 8174 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
==> ERROR: Failure while downloading dolphin-emu git repo
    Aborting...
neko-san@ARCH ~> 

IslandC0der commented on 2021-08-19 00:10 (UTC)

Glad I could help! :)

You can just add a *) clause at the end: it will match any input which wasn't picked up by the previous clauses.

Neko-san commented on 2021-08-18 23:57 (UTC)

@IslandC0der This seems to work! Thanks! Also, in cases where I want to do an equivalent of else, how would I do that in a bash case?

IslandC0der commented on 2021-08-18 21:59 (UTC) (edited on 2021-08-18 22:01 (UTC) by IslandC0der)

Awesome, that works! :D

However, line 951 (on the version you've emailed me, maybe you've edited the script since) must not be commented out (it marks the end of the pcsx2 clause), and esac must come right after all the clauses (i.e. right after line 965, in the same way that you would end an if statement with fi).

Tip: now, to simulate a new upstream PKGBUILD update so you can test it out (as you probably won't fetch any right now, since you've just updated the asp database), just go to a random dir and run git reset --hard HEAD~1: this will revert the last commit, which will (hopefully) trigger the script for that package as it detects it's outdated.

Neko-san commented on 2021-08-18 21:34 (UTC)

@IslandC0der Doing this stops the errors, and it seems to reset(?), but it doesn't rebuild any of the packages:

neko-san@ARCH ~/asp> ./aspUpdate.sh
==> updating remote 'packages'
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 1), reused 6 (delta 1), pack-reused 0
Unpacking objects: 100% (7/7), 1.13 KiB | 1.13 MiB/s, done.
From https://github.com/archlinux/svntogit-packages
 * branch              packages/appstream -> FETCH_HEAD
 * branch              packages/ark     -> FETCH_HEAD
 * branch              packages/dolphin -> FETCH_HEAD
 * branch              packages/doxygen -> FETCH_HEAD
 * branch              packages/gnome-settings-daemon -> FETCH_HEAD
 * branch              packages/gsettings-desktop-schemas -> FETCH_HEAD
 * branch              packages/gtk3    -> FETCH_HEAD
 * branch              packages/kaccounts-integration -> FETCH_HEAD
 * branch              packages/kactivities-stats -> FETCH_HEAD
 * branch              packages/kactivitymanagerd -> FETCH_HEAD
 * branch              packages/kde-gtk-config -> FETCH_HEAD
 * branch              packages/kdelibs4support -> FETCH_HEAD
 * branch              packages/kholidays -> FETCH_HEAD
 * branch              packages/kinit   -> FETCH_HEAD
 * branch              packages/kmenuedit -> FETCH_HEAD
 * branch              packages/knotifyconfig -> FETCH_HEAD
 * branch              packages/konsole -> FETCH_HEAD
 * branch              packages/kquickcharts -> FETCH_HEAD
 * branch              packages/kscreen -> FETCH_HEAD
 * branch              packages/ksysguard -> FETCH_HEAD
 * branch              packages/ktexteditor -> FETCH_HEAD
 * branch              packages/kuserfeedback -> FETCH_HEAD
 * branch              packages/kwayland -> FETCH_HEAD
 * branch              packages/kwayland-integration -> FETCH_HEAD
 * branch              packages/kwayland-server -> FETCH_HEAD
 * branch              packages/kwin    -> FETCH_HEAD
 * branch              packages/layer-shell-qt -> FETCH_HEAD
 * branch              packages/libkscreen -> FETCH_HEAD
 * branch              packages/libksysguard -> FETCH_HEAD
 * branch              packages/libxrender -> FETCH_HEAD
 * branch              packages/milou   -> FETCH_HEAD
 * branch              packages/networkmanager-qt -> FETCH_HEAD
 * branch              packages/phonon-gstreamer -> FETCH_HEAD
 * branch              packages/pipewire -> FETCH_HEAD
 * branch              packages/plasma-desktop -> FETCH_HEAD
 * branch              packages/plasma-framework -> FETCH_HEAD
 * branch              packages/plasma-nm -> FETCH_HEAD
 * branch              packages/plasma-wayland-protocols -> FETCH_HEAD
 * branch              packages/plasma-workspace -> FETCH_HEAD
 * branch              packages/sddm    -> FETCH_HEAD
 * branch              packages/sddm-kcm -> FETCH_HEAD
 * branch              packages/sdl2    -> FETCH_HEAD
 * branch              packages/spectacle -> FETCH_HEAD
 * branch              packages/systemsettings -> FETCH_HEAD
 * branch              packages/wayland -> FETCH_HEAD
 * branch              packages/wayland-protocols -> FETCH_HEAD
 * branch              packages/xorg-server -> FETCH_HEAD
 * branch              packages/xorg-xmessage -> FETCH_HEAD
 * branch              packages/xorg-xrdb -> FETCH_HEAD
 * branch              packages/xorg-xsetroot -> FETCH_HEAD
 * branch              packages/yakuake -> FETCH_HEAD
   00f26770..c128c2e4  packages/konsole -> packages/packages/konsole
==> updating remote 'community'
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 15 (delta 1), reused 13 (delta 0), pack-reused 0
Unpacking objects: 100% (15/15), 3.68 KiB | 3.68 MiB/s, done.
From https://github.com/archlinux/svntogit-community
 * branch              packages/dolphin-emu -> FETCH_HEAD
 * branch              packages/mgba        -> FETCH_HEAD
 * branch              packages/openmw      -> FETCH_HEAD
 * branch              packages/pcsx2       -> FETCH_HEAD
 * branch              packages/xonotic     -> FETCH_HEAD
   158e551b..ca4e8956  packages/dolphin-emu -> community/packages/dolphin-emu
   ebbb02ca..692391a5  packages/pcsx2       -> community/packages/pcsx2
From /home/neko-san/.cache/asp
   158e551b..ca4e8956  community/packages/dolphin-emu -> origin/community/packages/dolphin-emu
HEAD is now at ca4e8956 archrelease: copy trunk to community-x86_64
HEAD is now at fea3a769 db-move: moved kactivities-stats from [testing] to [extra] (x86_64)
HEAD is now at 95376a4b db-move: moved kdelibs4support from [testing] to [extra] (x86_64)
HEAD is now at d71d89e1 db-move: moved kholidays from [testing] to [extra] (x86_64)
HEAD is now at 4f33d71f db-move: moved kinit from [testing] to [extra] (x86_64)
HEAD is now at 92cf4e1f db-move: moved knotifyconfig from [testing] to [extra] (x86_64)
From /home/neko-san/.cache/asp
   00f26770..c128c2e4  packages/packages/konsole -> origin/packages/packages/konsole
HEAD is now at c128c2e4 archrelease: copy trunk to extra-x86_64
HEAD is now at ca3a9c50 db-move: moved kquickcharts from [testing] to [extra] (x86_64)
HEAD is now at a0b19025 db-move: moved ktexteditor from [testing] to [extra] (x86_64)
HEAD is now at 5e3d91e3 db-move: moved kwayland from [testing] to [extra] (x86_64)
HEAD is now at 76d44ba7 db-move: moved networkmanager-qt from [testing] to [extra] (x86_64)
HEAD is now at 0ba434c3 db-move: moved openmw from [community-testing] to [community] (x86_64)
From /home/neko-san/.cache/asp
   ebbb02ca..692391a5  community/packages/pcsx2 -> origin/community/packages/pcsx2
HEAD is now at 692391a5 archrelease: copy trunk to community-x86_64
HEAD is now at c4c667b0 archrelease: copy trunk to extra-x86_64

IslandC0der commented on 2021-08-18 15:02 (UTC)

@Neko-san What if you change line 15 to git reset --hard @{upstream}?

Neko-san commented on 2021-08-17 22:39 (UTC)

@IslandC0der Oki; I sent it

IslandC0der commented on 2021-08-17 21:41 (UTC)

@Neko-san Alright, could you maybe email me your ~/asp folder? I'm stumped with this, very weird

Neko-san commented on 2021-08-15 05:08 (UTC) (edited on 2021-08-15 05:12 (UTC) by Neko-san)

@IslandC0der Okay, so I refactored it to use case instead of all those if statements but now (I had re-edited and rebuilt some packages before-hand btw) I'm getting those "fatal" git errors again and it refuses to build any new packages, even though pacman wants to download and install new versions of some the same packages I got built and installed with Asp :/

This is the terminal output:

neko-san@ARCH ~/asp> ./aspUpdate.sh
==> updating remote 'packages'
From https://github.com/archlinux/svntogit-packages
 * branch              packages/appstream -> FETCH_HEAD
 * branch              packages/dolphin -> FETCH_HEAD
 * branch              packages/doxygen -> FETCH_HEAD
 * branch              packages/gnome-settings-daemon -> FETCH_HEAD
 * branch              packages/gsettings-desktop-schemas -> FETCH_HEAD
 * branch              packages/kaccounts-integration -> FETCH_HEAD
 * branch              packages/kactivities-stats -> FETCH_HEAD
 * branch              packages/kactivitymanagerd -> FETCH_HEAD
 * branch              packages/kde-gtk-config -> FETCH_HEAD
 * branch              packages/kdelibs4support -> FETCH_HEAD
 * branch              packages/kholidays -> FETCH_HEAD
 * branch              packages/kinit -> FETCH_HEAD
 * branch              packages/kmenuedit -> FETCH_HEAD
 * branch              packages/knotifyconfig -> FETCH_HEAD
 * branch              packages/konsole -> FETCH_HEAD
 * branch              packages/kquickcharts -> FETCH_HEAD
 * branch              packages/kscreen -> FETCH_HEAD
 * branch              packages/ksysguard -> FETCH_HEAD
 * branch              packages/ktexteditor -> FETCH_HEAD
 * branch              packages/kuserfeedback -> FETCH_HEAD
 * branch              packages/kwayland -> FETCH_HEAD
 * branch              packages/kwayland-integration -> FETCH_HEAD
 * branch              packages/kwayland-server -> FETCH_HEAD
 * branch              packages/kwin -> FETCH_HEAD
 * branch              packages/layer-shell-qt -> FETCH_HEAD
 * branch              packages/libkscreen -> FETCH_HEAD
 * branch              packages/libksysguard -> FETCH_HEAD
 * branch              packages/libxrender -> FETCH_HEAD
 * branch              packages/milou -> FETCH_HEAD
 * branch              packages/networkmanager-qt -> FETCH_HEAD
 * branch              packages/phonon-gstreamer -> FETCH_HEAD
 * branch              packages/pipewire -> FETCH_HEAD
 * branch              packages/plasma-desktop -> FETCH_HEAD
 * branch              packages/plasma-framework -> FETCH_HEAD
 * branch              packages/plasma-nm -> FETCH_HEAD
 * branch              packages/plasma-wayland-protocols -> FETCH_HEAD
 * branch              packages/plasma-workspace -> FETCH_HEAD
 * branch              packages/sddm -> FETCH_HEAD
 * branch              packages/sddm-kcm -> FETCH_HEAD
 * branch              packages/sdl2 -> FETCH_HEAD
 * branch              packages/spectacle -> FETCH_HEAD
 * branch              packages/systemsettings -> FETCH_HEAD
 * branch              packages/wayland -> FETCH_HEAD
 * branch              packages/wayland-protocols -> FETCH_HEAD
 * branch              packages/xorg-server -> FETCH_HEAD
 * branch              packages/xorg-xmessage -> FETCH_HEAD
 * branch              packages/xorg-xrdb -> FETCH_HEAD
 * branch              packages/xorg-xsetroot -> FETCH_HEAD
 * branch              packages/yakuake -> FETCH_HEAD
==> updating remote 'community'
From https://github.com/archlinux/svntogit-community
 * branch              packages/dolphin-emu -> FETCH_HEAD
 * branch              packages/mgba -> FETCH_HEAD
 * branch              packages/openmw -> FETCH_HEAD
 * branch              packages/pcsx2 -> FETCH_HEAD
 * branch              packages/xonotic -> FETCH_HEAD
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
neko-san@ARCH ~/asp> 

And this is the new version of the script:

#!/usr/bin/env bash

if [[ ./ != ~/asp/ ]]; then
cd ~/asp/
fi

asp update

for dir in */; do (
  cd $dir
  git fetch

  ## If there are upstream changes, apply them, apply ours and rebuild
  if [[ $(git rev-parse HEAD) != $(git rev-parse HEAD@{upstream}) ]]; then
    git reset --hard origin
    cd trunk
    ## sed or EOF cat commands go here

    case $dir in

      ## I followed the Clang instructions for makepkg.conf here:
      ## https://wiki.archlinux.org/title/Clang
      ## And Makepkg.conf configuration instructions over here:
      ## https://wiki.archlinux.org/title/Makepkg
      xorg-server)
        cat <<- \EOF >> PKGBUILD
        build() {
          # Since pacman 5.0.2-2, hardened flags are now enabled in makepkg.conf
          # With them, module fail to load with undefined symbol.
          # See https://bugs.archlinux.org/task/55102 / https://bugs.archlinux.org/task/54845
          export CFLAGS=${CFLAGS/-fno-plt}
          export CXXFLAGS=${CXXFLAGS/-fno-plt}
          export LDFLAGS=${LDFLAGS/,-z,now}

          arch-meson ${pkgbase}-$pkgver build \
            -D os_vendor="Archlinux" \
            -D ipv6=true \
            -D xvfb=true \
            -D xnest=true \
            -D xcsecurity=true \
            -D xorg=true \
            -D xephyr=true \
            -D xwayland=true \
            -D xwayland_eglstream=true \
            -D glamor=true \
            -D udev=true \
            -D systemd_logind=true \
            -D suid_wrapper=true \
            -D xkb_dir=/usr/share/X11/xkb \
            -D xkb_output_dir=/var/lib/xkb

          # Print config
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"
          meson configure build
          ninja -j $(nproc) -C build

          # fake installation to be seperated into packages
          DESTDIR="${srcdir}/fakeinstall" ninja -C build install
        }
EOF
    ;;

      xorg-xsetroot)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd xsetroot-${pkgver}
          ./configure --prefix=/usr
          make -j $(nproc)
        }
EOF
    ;;

      libxrender)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd libXrender-${pkgver}
          ./configure --prefix=/usr --disable-static
          make -j $(nproc)
        }
EOF
    ;;

      xorg-xrdb)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd xrdb-${pkgver}
          # --with-cpp=path       comma-separated list of paths to cpp command for xrdb to use at runtime
          # mcpp is small but can fail, FS#46934
          ./configure --prefix=/usr --with-cpp=/usr/bin/clang,/usr/bin/mcpp
          make -j $(nproc)
        }
EOF
    ;;

      xorg-xmessage)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd xmessage-${pkgver}
          ./configure --prefix=/usr
          sed -i 's/O2/O3/g' "$srcdir/xmessage-$pkgver/Makefile"
          sed -i 's/O1/O3/g' "$srcdir/xmessage-$pkgver/Makefile"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/xmessage-$pkgver/Makefile"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/xmessage-$pkgver/Makefile"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"
          make -j $(nproc)
        }
EOF
    ;;

      kdelibs4support)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      plasma-desktop)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON \
            -DCMAKE_BUILD_TYPE=Release
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      kde-gtk-config)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF\
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON \
            -DCMAKE_BUILD_TYPE=Release
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      pipewire)
        cat <<- \EOF >> PKGBUILD
        build() {
          local meson_options=(
            -D docs=enabled
            -D jack=disabled
            -D libcamera=disabled
            -D udevrulesdir=/usr/lib/udev/rules.d
            -D roc=disabled
          )

          arch-meson pipewire build "${meson_options[@]}"
          meson compile -j $(nproc) -C build
        }
EOF
    ;;

      sdl2)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd SDL2-${pkgver}
          cmake \
            -Bbuild \
            -GNinja \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DSDL_STATIC=OFF \
            -DSDL_DLOPEN=ON \
            -DARTS=OFF \
            -DESD=OFF \
            -DNAS=OFF \
            -DALSA=ON \
            -DHIDAPI=ON \
            -DPULSEAUDIO_SHARED=ON \
            -DVIDEO_WAYLAND=ON \
            -DRPATH=OFF \
            -DCLOCK_GETTIME=ON \
            -DJACK_SHARED=ON \
            -DPIPEWIRE=ON \
            -DPIPEWIRE_SHARED=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON \
            -DCMAKE_BUILD_TYPE=Release
          sed -i 's/O2/O3/g' "$srcdir/SDL2-${pkgver}/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/SDL2-${pkgver}/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/SDL2-${pkgver}/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/SDL2-${pkgver}/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops"

          ninja -j $(nproc) -C build
        }

        package() {
          cd SDL2-${pkgver}
          DESTDIR="${pkgdir}" ninja -C build install

          if [ -f "$pkgdir"/usr/lib/cmake/SDL2/SDL2Targets-noconfig.cmake ];then
            sed -i "s/libSDL2\.a/libSDL2main.a/g" "$pkgdir"/usr/lib/cmake/SDL2/SDL2Targets-noconfig.cmake
          fi

          install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
        }
EOF
    ;;

      plasma-workspace)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgbase-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF \-DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      systemsetings|kmenuedit|plasma-nm)
        cat <<- \EOF >> PKGBUILD
        build() {
        cmake -B build -S $pkgname-$pkgver \
          -DBUILD_TESTING=OFF \
          -DCMAKE_CXX_COMPILER=clang++ \
          -DCMAKE_C_COMPILER=clang \
          -DUSE_NATIVE_INSTRUCTIONS=ON \
          -DCMAKE_BUILD_TYPE=Release
        sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
        sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
        sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
        sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
        CXXFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin -stdlib=libc++ -lstdc++"
        CFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin"

        cmake --build build -j $(nproc)
      }
EOF
    ;;

      networkmanager-qt)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -flto-compression-level=19 -fuse-linker-plugin"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      knotifyconfig)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      kuserfeedback)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd build
          cmake ../$pkgname-$pkgver \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/Makefile"
          sed -i 's/O1/O3/g' "$srcdir/build/Makefile"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/Makefile"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/Makefile"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          make -j $(nproc) -C build
        }
EOF
    ;;

      plasma-framework)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_BUILD_TYPE=Release \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      kinit)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

        kwin)
          cat <<- \EOF >> PKGBUILD
          build() {
            cmake -B build -S $pkgname-$pkgver \
              -DCMAKE_INSTALL_LIBEXECDIR=lib \
              -DBUILD_TESTING=OFF \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_CXX_COMPILER=clang++ \
              -DCMAKE_C_COMPILER=clang \
              -DUSE_NATIVE_INSTRUCTIONS=ON
            sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
            sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
            sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
            sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
            CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
            CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

            cmake --build build -j $(nproc)
          }
EOF
    ;;

      libimobiledevice)
        cat <<- \EOF >> PKGBUILD
        build() (
          cd $pkgname
          ./configure --prefix=/usr --disable-openssl
          sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
          make -j $(nproc)
        )

        check() {
          cd $pkgname
          make -j $(nproc) check
        }
EOF
    ;;

      kwayland|libkscreen)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      kwayland-integration|sddm-kcm|kaccounts-integration|milou|kquickcharts|konsole|dolphin|yakuake|ksysguard|spectacle)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DBUILD_TESTING=OFF \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      kwayland-server|kactivities-stats)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      plasma-wayland-protocols|layer-shell-qt)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      sddm)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/sddm \
            -DDBUS_CONFIG_DIR=/usr/share/dbus-1/system.d \
            -DDBUS_CONFIG_FILENAME=sddm_org.freedesktop.DisplayManager.conf \
            -DBUILD_MAN_PAGES=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      wayland)
        cat <<- \EOF >> PKGBUILD
        build() {
          meson build $pkgbase-$pkgver \
            --buildtype=release \
            --prefix=/usr\
            -Dqt=true \
            -Dvapi=true \
            -Dc_args='-minline-all-stringops -D_FORTIFY_SOURCE=2 -march=native -march=native -mtune=native' \
            -Dcompose=true
          meson compile -j $(nproc) -C build
        }

        check() {
          ninja -j $(nproc) -C build test
        }
EOF
    ;;

      wayland-protocols)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd $pkgname-$pkgver

          ./configure --prefix=/usr
          sed -i 's/O2/O3/g' "$srcdir/wayland-protocols-$pkgver/Makefile"
          sed -i 's/O1/O3/g' "$srcdir/wayland-protocols-$pkgver/Makefile"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/wayland-protocols-$pkgver/Makefile"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/wayland-protocols-$pkgver/Makefile"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"
          make -j $(nproc)
        }

        check() {
          cd $pkgname-$pkgver

          make -j $(nproc) check
        }
EOF
    ;;

      kscreen)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      kactivitymanagerd|libksysguard)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DBUILD_TESTING=OFF \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      ktexteditor|kholidays)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -B build -S $pkgname-$pkgver \
            -DBUILD_TESTING=OFF \
            -DBUILD_QCH=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/Makefile"
          sed -i 's/O1/O3/g' "$srcdir/build/Makefile"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/Makefile"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/Makefile"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      appstream-qt)
        cat <<- \EOF >> PKGBUILD
        build() {
          meson build AppStream-$pkgver \
            --prefix=/usr \
            -Dqt=true \
            -Dvapi=true \
            -Dc_args='-minline-all-stringops -D_FORTIFY_SOURCE=2 -march=native -march=native -mtune=native' \
            -Dcompose=true
          meson compile -j $(nproc) -C build
        }
EOF
    ;;

      phonon-gstreamer)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd build
          cmake ../phonon-backend-gstreamer-$pkgver \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/Makefile"
          sed -i 's/O1/O3/g' "$srcdir/build/Makefile"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/Makefile"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/Makefile"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          make -j $(nproc)
        }
EOF
    ;;

      doxygen)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd ${pkgbase}-Release_${pkgver//./_}

          cmake -B build \
            -DCMAKE_INSTALL_PREFIX:PATH=/usr \
            -DDOC_INSTALL_DIR:PATH=share/doc/doxygen \
            -DPYTHON_EXECUTABLE:FILE=/usr/bin/python \
            -Dbuild_doc:BOOL=ON \
            -Dbuild_wizard:BOOL=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/${pkgbase}-Release_${pkgver//./_}/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/${pkgbase}-Release_${pkgver//./_}/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/${pkgbase}-Release_${pkgver//./_}/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/${pkgbase}-Release_${pkgver//./_}/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          make -j $(nproc) -C build
          make -j $(nproc) -C build docs
        }

        check() {
          cd ${pkgbase}-Release_${pkgver//./_}
          make -j $(nproc) -C build tests
        }
EOF
    ;;

      ## I had a build fail with this function; not sure why because it shouldn't have
      webkit2gtk)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -S webkitgtk-$pkgver -B build -G Ninja \
            -DPORT=GTK \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DCMAKE_INSTALL_LIBDIR=lib \
            -DCMAKE_INSTALL_LIBEXECDIR=lib \
            -DCMAKE_SKIP_RPATH=ON \
            -DENABLE_GTKDOC=ON \
            -DENABLE_MINIBROWSER=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/-O2/-O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-O1/-O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          cmake --build build -j $(nproc)
        }
EOF
    ;;

      openmw)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd openmw
          cmake . \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DCMAKE_BUILD_TYPE=Release \
            -DDESIRED_QT_VERSION=5 \
            -GNinja \
            -Bbuild \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/$pkgname/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/$pkgname/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/$pkgname/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/$pkgname/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          ninja -j $(nproc) -C build
        }
EOF
    ;;

    xonotic)
        cat <<- \EOF >> PKGBUILD
        build() {
          CXXFLAGS+=" -minline-all-stringops -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops"

          # compile engine
            make -j $(nproc) -C Xonotic/source/darkplaces CPUOPTIMIZATIONS="${CFLAGS}" DP_FS_BASEDIR=/usr/share/xonotic/ DP_LINK_TO_LIBJPEG=1 cl-release
            make -j $(nproc) -C Xonotic/source/darkplaces CPUOPTIMIZATIONS="${CFLAGS}" DP_FS_BASEDIR=/usr/share/xonotic/ DP_LINK_TO_LIBJPEG=1 sdl-release
            make -j $(nproc) -C Xonotic/source/darkplaces CPUOPTIMIZATIONS="${CFLAGS}" DP_FS_BASEDIR=/usr/share/xonotic/ DP_LINK_TO_LIBJPEG=1 sv-release

          cd "$srcdir"/Xonotic/source/d0_blind_id
          sh autogen.sh
          ./configure --prefix=/usr
          make -j $(nproc)
        }
EOF
    ;;

      mgba)
        cat <<- \EOF >> PKGBUILD
        build() {
          cd build
          cmake "$srcdir"/mgba-$pkgver \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DCMAKE_INSTALL_LIBDIR=lib \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          make -j $(nproc)
        }
EOF
    ;;

      dolphin-emu)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -S dolphin-emu -B build \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DUSE_SHARED_ENET=ON \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON \
            -DDISTRIBUTOR=archlinux.org
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          make -j $(nproc) -C build
        }
EOF
    ;;

      pcsx2)
        cat <<- \EOF >> PKGBUILD
        build() {
          cmake -S pcsx2 -B build -G Ninja \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DDISABLE_ADVANCE_SIMD=ON \
            -DDISABLE_BUILD_DATE=OFF \
            -DDISABLE_PCSX2_WRAPPER=ON \
            -DENABLE_TESTS=OFF \
            -DSDL2_API=ON \
            -DPACKAGE_MODE=ON \
            -DREBUILD_SHADER=ON \
            -DUSE_LTO=ON \
            -DUSE_SYSTEM_YAML=OFF \
            -DUSE_VTUNE=OFF \
            -DXDG_STD=ON \
            -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config-gtk3 \
            -Wno-dev \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_COMPILER=clang \
            -DUSE_NATIVE_INSTRUCTIONS=ON
          sed -i 's/O2/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/O1/O3/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-march=x86-64/-march=native/g' "$srcdir/build/CMakeCache.txt"
          sed -i 's/-mtune=generic/-mtune=native/g' "$srcdir/build/CMakeCache.txt"
          CXXFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19 -stdlib=libc++ -lstdc++"
          CFLAGS+=" -minline-all-stringops -flto=16 -fuse-linker-plugin -flto-compression-level=19"

          ninja -j $(nproc) -C build
        }
EOF
    # ;;

## This doesn't work for some reason; maybe a Clang incompatibility?
#       desmume)
#         elif [ $dir == "desmume" ]; then
#         cat <<- \EOF >> PKGBUILD
#         build() {
#           cd "$srcdir/$pkgname-$pkgver"

#           ./configure --prefix=/usr --enable-wifi --enable-openal --enable-glx --enable-hud --enable-hardcore
#           make -j $(nproc)
#         }
# EOF

      rm -f *.tar*
      rm -f *.xz*
      rm -f *.zip
      makepkg -sfcCri --noconfirm

      sh -c 'if [ -f kwin*.pkg.tar.zst ]; then
        notify-send "AUTHENTICATION: Kwin ASP post-install/upgrade setup" --app-name=Authentication --icon=stock_keyring --urgency=critical;
        sudo setcap CAP_SYS_NICE=+ep /usr/bin/kwin_wayland

        elif [ -f kinit*.pkg.tar.zst ]; then
        notify-send "AUTHENTICATION: Kinit ASP post-install/upgrade setup" --app-name=Authentication --icon=stock_keyring --urgency=critical;
        sudo setcap CAP_SYS_RESOURCE=+ep /usr/lib/kf5/start_kdeinit

        elif [ -f libksysguard*.pkg.tar.zst ]; then
        notify-send "AUTHENTICATION: libksysguard ASP post-install/upgrade setup" --app-name=Authentication --icon=stock_keyring --urgency=critical;
        sudo setcap CAP_NET_RAW=+ep /usr/lib/ksysguard/ksgrd_network_helper

        elif [ -f pcsx2*.pkg.tar.zst ]; then
        rm -rf ./yaml-cpp ./libchdr ./pcsx2

        elif [ -f openmw*.pkg.tar.zst ]; then
        rm -rf ./openmw

        elif [ -f pipewire*.pkg.tar.zst ]; then
        rm -rf ./pipewire

        elif [ -f gsettings-desktop-schemas*.pkg.tar.zst ]; then
        rm -rf ./gsettings-desktop-schemas

      fi'

## Xorg post-install message (doesn't work as-is in this script):
#       sh -c 'if [ -f xorg-server*.pkg.tar.zst ]; then
#         if (( $(vercmp $2 1.16.0-3) < 0 )); then
#           cat <<MSG
# >>> xorg-server has now the ability to run without root rights with
#     the help of systemd-logind. xserver will fail to run if not launched
#     from the same virtual terminal as was used to log in.
#     Without root rights, log files will be in ~/.local/share/xorg/ directory.

#     Old behavior can be restored through Xorg.wrap config file.
#     See Xorg.wrap man page (man xorg.wrap).
# MSG
#         fi
#       fi'

      rm -f *.tar*
      rm -f *.xz*
      rm -f *.zip
    esac
  fi
) done