summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 41c1fe5231a5daafb1d47b728c27ff8c143ffd68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Maintainer: Sébastien TERRIER <ouinouin at ouinouin dot eu>
# Maintainer: HurricanePootis <hurricanepootis@protonmail.com>
pkgname=citron
pkgver=2026.02.1
pkgrel=2
pkgdesc="Nintendo Switch emulator forked from yuzu."
arch=(x86_64)
url=https://citron-emu.org
license=(GPL-2.0-or-later)
depends=('qt6-base' 'qt6-webengine' 'fmt' 'boost-libs' 'ffmpeg' 'sdl2' 'hicolor-icon-theme' 'brotli' 'libusb' 'enet' 'opus' 'zydis' 'lz4' 'zlib' 'glibc' 'libva' 'zstd' 'gcc-libs' 'openssl' 'openal'
	 'speexdsp' 'bash')
makedepends=('git' 'cmake' 'boost' 'glslang' 'ninja' 'nlohmann-json' 'rapidjson' 'qt6-multimedia' 'qt6-tools' 'gamemode' 'doxygen' 'vulkan-headers' 'vulkan-utility-libraries' 'qt6-svg')
optdepends=('gamemode: Gamemoded support')
options=(!debug)
source=(${pkgname}::git+https://git.citron-emu.org/citron/emulator.git#tag=${pkgver}
        cubeb::git+https://github.com/mozilla/cubeb.git
        discord-rpc::git+https://github.com/yuzu-mirror/discord-rpc.git
        dynarmic::git+https://github.com/yuzu-mirror/dynarmic.git
        Vulkan-Headers::git+https://github.com/KhronosGroup/Vulkan-Headers.git
        sirit::git+https://github.com/yuzu-mirror/sirit.git
        mbedtls::git+https://github.com/yuzu-mirror/mbedtls.git
        xbyak::git+https://github.com/herumi/xbyak.git
        cpp-httplib::git+https://github.com/yhirose/cpp-httplib.git
        cpp-jwt::git+https://github.com/arun11299/cpp-jwt.git
        libadrenotools::git+https://github.com/bylaws/libadrenotools.git
        tzdb_to_nx::git+https://github.com/lat9nq/tzdb_to_nx.git
        VulkanMemoryAllocator::git+https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
        breakpad::git+https://github.com/yuzu-mirror/breakpad.git
        simpleini::git+https://github.com/brofield/simpleini.git
        oaknut::git+https://github.com/yuzu-mirror/oaknut.git
        Vulkan-Utility-Libraries::git+https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git
        googletest::git+https://github.com/google/googletest.git
        sanitizers-cmake::git+https://github.com/arsenm/sanitizers-cmake.git
        zycore::git+https://github.com/zyantific/zycore-c.git
        linkernsbypass::git+https://github.com/bylaws/liblinkernsbypass.git
        tz::git+https://github.com/eggert/tz.git
	SPIRV-Headers::git+https://github.com/KhronosGroup/SPIRV-Headers.git
)
b2sums=('71b24de767d8060cf1fee5959c95633c96c8b7c2cda5b1cafe93abda6920cb7a41443b3ea707eaae2fad8ec140f199683003362a64dad467a30e54fc9cee8e23'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP')

prepare() {
  cd "$srcdir/$pkgname"
  git rm -f externals/SDL
  git rm -f externals/ffmpeg/ffmpeg
  git rm -f externals/enet
  git rm -f externals/opus
  git rm -f externals/vcpkg
  git rm -f externals/libusb/libusb

  for _submodule in cubeb discord-rpc dynarmic Vulkan-Headers sirit mbedtls xbyak cpp-httplib cpp-jwt libadrenotools tzdb_to_nx VulkanMemoryAllocator breakpad simpleini oaknut Vulkan-Utility-Libraries;
    do
      git config submodule.$_submodule.url "${srcdir}/$_submodule"
    done
  git -c protocol.file.allow=always submodule update

  pushd externals/cubeb
    git config submodule.cmake/sanitizers-cmake.url "${srcdir}"/sanitizers-cmake
    git config submodule.googletest.url "${srcdir}"/googletest
    git -c protocol.file.allow=always submodule update
  popd

  pushd externals/dynarmic/externals/zydis
    git config submodule.dependencies/zycore.url "${srcdir}"/zycore
    git -c protocol.file.allow=always submodule update
  popd

  pushd externals/libadrenotools
    git config submodule.lib/linkernsbypass.url "${srcdir}"/linkernsbypass
    git -c protocol.file.allow=always submodule update
  popd

  pushd externals/nx_tzdb/tzdb_to_nx
    git config submodule.externals/tz/tz.url "${srcdir}"/tz
    git -c protocol.file.allow=always submodule update
  popd

  pushd externals/sirit
    git config submodule.externals/SPIRV-Headers.url "${srcdir}"/SPIRV-Headers
    git -c protocol.file.allow=always submodule update
  popd

  # Ensure cubeb is used from externals
  sed -i '395d;396d;397d' CMakeLists.txt

  # Fix QT for 6.10.0
  #sed -i 's/find_package(Qt6 REQUIRED COMPONENTS Widgets/find_package(Qt6 REQUIRED COMPONENTS Widgets GuiPrivate/g;s/set(CITRON_QT_COMPONENTS2 Core/set(CITRON_QT_COMPONENTS2 Core GuiPrivate/g' CMakeLists.txt
  #sed -i 's/target_link_libraries(citron PRIVATE Boost\:\:headers/target_link_libraries(citron PRIVATE Boost\:\:headers Qt6\:\:GuiPrivate/g' src/citron/CMakeLists.txt
}

build() {
  cd "$srcdir"
  # Forcing GCC since clang currently fails to compile citron
  case $LTOFLAGS in
	  *thin*)
		  export CFLAGS="${CFLAGS//thin/auto}"
		  export CXXFLAGS="${CXXFLAGS//thin/auto}"
		  export LDFLAGS="${LDFLAGS//thin/auto}"
		  echo "YOU GOT THIN"
	  ;;
  esac
  case $LDFLAGS in
	  *lld*)
		  export LDFLAGS="${LDFLAGS//lld/bfd}"
		  echo "YOU GOT LLD"
		  ;;
  esac
  echo $CFLAGS
  echo $CXXFLAGS
  echo $LDFLAGS
  cmake -B build -GNinja -S "$pkgname" \
    -DCITRON_USE_BUNDLED_VCPKG=OFF \
    -DCITRON_USE_BUNDLED_QT=OFF \
    -DCITRON_USE_BUNDLED_FFMPEG=OFF \
    -DCITRON_USE_EXTERNAL_VULKAN_HEADERS=OFF \
    -DCITRON_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES=OFF \
    -DCITRON_USE_BUNDLED_SDL2=OFF \
    -DCITRON_USE_EXTERNAL_SDL2=OFF \
    -DCITRON_TESTS=OFF \
    -DCITRON_CHECK_SUBMODULES=OFF \
    -DCITRON_ENABLE_LTO=ON \
    -DCITRON_USE_QT_MULTIMEDIA=ON \
    -DCITRON_USE_QT_WEB_ENGINE=ON \
    -DCITRON_DOWNLOAD_TIME_ZONE_DATA=ON \
    -DENABLE_QT_TRANSLATION=ON \
    -DUSE_DISCORD_PRESENCE=ON \
    -DCITRON_USE_FASTER_LD=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS -DNDEBUG" \
    -DCMAKE_C_FLAGS="$CFLAGS -DNDEBUG" \
    -DTITLE_BAR_FORMAT_RUNNING="citron | ${pkgver} {}" \
    -DTITLE_BAR_FORMAT_IDLE="citron | ${pkgver} {}" \
    -DBUILD_ID="archlinux.org" \
    -DCMAKE_SYSTEM_PROCESSOR=$CARCH \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
    -DCMAKE_C_COMPILER=gcc \
    -DCMAKE_CXX_COMPILER=g++ \
    -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
    -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS" \
    -DCMAKE_C_FLAGS="$CFLAGS" \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS"

    cmake --build build
}

package() {
  cd "$srcdir"
  DESTDIR="$pkgdir/" cmake --install build
  install -dm755 "$pkgdir/usr/lib/$pkgname"
  mv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/$pkgname"
  cat >> "$pkgdir/usr/bin/$pkgname" <<-EOF
#!/usr/bin/env bash
# Ensure the qt-config.ini is fixed
_fix_theme(){
	sed -i 's/theme=colorful/theme=default/g' "\$HOME/.config/citron/qt-config.ini"
}
if [[ -f "\$HOME/.config/citron/qt-config.ini" ]]
then
	_fix_theme
else
	/usr/lib/$pkgname/$pkgname
	_fix_theme
fi
/usr/lib/$pkgname/$pkgname "\$@"
EOF
  chmod 755 "$pkgdir/usr/bin/$pkgname"
  cd "$srcdir/$pkgname/LICENSES"
  for file in *.txt;
  do
    install -Dm644 $file "$pkgdir/usr/share/licenses/$pkgname/$file"
  done
  install -Dm644 "$srcdir/$pkgname/dist/72-citron-input.rules" "$pkgdir/usr/lib/udev/rules.d/72-citron-input.rules"
  # Fix udev rules for systemd 258
  sed -i 's/KERNEL==/ACTION!="remove", KERNEL==/' "$pkgdir/usr/lib/udev/rules.d/72-citron-input.rules"
}