summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1b350f0dbe52721d767a9b2dec643dc836a349b0 (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# Maintainer: xiota / aur.chaotic.cx
# Contributor: Kerrick Staley <kerrick@kerrickstaley.com>
# Contributor: schuay <jakob.gruber@gmail.com>
# Contributor: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Jeremy Newton (Mystro256) <alexjnewt@gmail.com>

# options
: ${_debugfast:=false}

: ${_avx_build:=false}
: ${_pkgtype:=debugfast-git}


if [[ x"${_avx_build::1}" == "xt" ]] ; then
  if [ x"${_pkgtype: -4}" == "x-git" ] ; then
    _pkgtype="${_pkgtype%-*}-avx-${_pkgtype##*-}"
  elif [ x"${_pkgtype::1}" == "xg" ] ; then
    _pkgtype="avx-$_pkgtype"
  else
    _pkgtype+="-avx"
  fi
fi

# basic info
_pkgname="dolphin-emu"
pkgname="$_pkgname${_pkgtype:+-$_pkgtype}"
pkgver=5.0.r20511.gc54e8d733f
pkgrel=1
pkgdesc='A Gamecube / Wii / Triforce emulator'
arch=(x86_64)
_url="https://github.com/dolphin-emu/dolphin"
url="https://dolphin-emu.org"
license=(GPL2)

# main package
_main_package() {
  depends=(
    alsa-lib
    bluez-libs
    curl
    ffmpeg
    gcc-libs
    glibc
    libevdev
    libgl
    libpulse
    libudev.so
    libx11
    libxi
    libxrandr
    qt6-base
    qt6-svg

    ## optional
    bzip2
    cubeb
    curl
    fmt
    hidapi
    libiconv
    liblzma.so
    libspng
    libusb
    lz4
    lzo
    mbedtls2
    miniupnpc
    minizip-ng
    pugixml
    sdl2
    sfml
    zstd

    ## broken
    #enet
    #libmgba
    #xxhash
    #zlib-ng
  )
  makedepends+=(
    cmake
    git
    python
  )
  optdepends=(
    'pulseaudio: PulseAudio backend'
  )

  options=(!emptydirs !lto)

  if [ x"$pkgname" == x"$_pkgname" ] ; then
    _main_stable
  else
    _main_git
  fi

  _source_dolphin_emu
}

# submodules
_source_dolphin_emu() {
  source+=(
    #'bylaws.libadrenotools'::'git+https://github.com/bylaws/libadrenotools.git'
    #'curl'::'git+https://github.com/curl/curl.git'
    #'dolphin-emu.ext-win-ffmpeg'::'git+https://github.com/dolphin-emu/ext-win-ffmpeg.git'
    #'dolphin-emu.ext-win-qt'::'git+https://github.com/dolphin-emu/ext-win-qt.git'
    #'fmtlib.fmt'::'git+https://github.com/fmtlib/fmt.git'
    #'google.googletest'::'git+https://github.com/google/googletest.git'
    #'khronosgroup.spirv-cross'::'git+https://github.com/KhronosGroup/SPIRV-Cross.git'
    #'libsdl-org.sdl'::'git+https://github.com/libsdl-org/SDL.git'
    #'libusb'::'git+https://github.com/libusb/libusb.git'
    #'lz4'::'git+https://github.com/lz4/lz4.git'
    #'mozilla.cubeb'::'git+https://github.com/mozilla/cubeb.git'
    #'randy408.libspng'::'git+https://github.com/randy408/libspng.git'

    'cyan4973.xxhash'::'git+https://github.com/Cyan4973/xxHash.git'
    'epezent.implot'::'git+https://github.com/epezent/implot.git'
    'gpuopen-librariesandsdks.vulkanmemoryallocator'::'git+https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git'
    'mgba-emu.mgba'::'git+https://github.com/mgba-emu/mgba.git'
    'retroachievements.rcheevos'::'git+https://github.com/RetroAchievements/rcheevos.git'
    'zlib-ng'::'git+https://github.com/zlib-ng/zlib-ng.git'
  )
  sha256sums+=(
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'
    #'SKIP'

    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
  )

  _prepare_dolphin_emu() (
    cd "${srcdir:?}/$_pkgsrc"
    local -A _submodules=(
      #['bylaws.libadrenotools']='Externals/libadrenotools'
      #['curl']='Externals/curl/curl'
      #['dolphin-emu.ext-win-ffmpeg']='Externals/FFmpeg-bin'
      #['dolphin-emu.ext-win-qt']='Externals/Qt'
      #['fmtlib.fmt']='Externals/fmt/fmt'
      #['google.googletest']='Externals/gtest'
      #['khronosgroup.spirv-cross']='Externals/spirv_cross/SPIRV-Cross'
      #['libsdl-org.sdl']='Externals/SDL/SDL'
      #['libusb']='Externals/libusb/libusb'
      #['lz4']='Externals/lz4/lz4'
      #['mozilla.cubeb']='Externals/cubeb/cubeb'
      #['randy408.libspng']='Externals/libspng/libspng'

      ['cyan4973.xxhash']='Externals/xxhash/xxHash'
      ['epezent.implot']='Externals/implot/implot'
      ['gpuopen-librariesandsdks.vulkanmemoryallocator']='Externals/VulkanMemoryAllocator'
      ['mgba-emu.mgba']='Externals/mGBA/mgba'
      ['retroachievements.rcheevos']='Externals/rcheevos/rcheevos'
      ['zlib-ng']='Externals/zlib-ng/zlib-ng'
    )
    _submodule_update
  )
}

# stable package
_main_stable() {
  :
}

# git package
_main_git() {
  url="${_url:?}"

  provides=("$_pkgname")
  conflicts=("$_pkgname")

  _pkgsrc="$_pkgname"
  source=("$_pkgname"::"git+$url.git")
  sha256sums+=('SKIP')

  pkgver() {
    cd "$_pkgsrc"
    git describe --long --tags | sed -E 's/([^-]*-g)/r\1/;s/-/./g'
  }
}

# common functions
prepare() {
  _submodule_update() {
    for key in ${!_submodules[@]} ; do
      git submodule init "${_submodules[${key}]}"
      git submodule set-url "${_submodules[${key}]}" "${srcdir}/${key}"
      git -c protocol.file.allow=always submodule update "${_submodules[${key}]}"
    done
  }

  _prepare_dolphin_emu

  # Fix version string
  local _pkgver=$(pkgver)
  sed -Ez \
    -e 's@\n\s+execute_process\([^\(\)]+\bdescribe [^\(\)]*--dirty\b[^\(\)]+\)@\n\nset(DOLPHIN_WC_DESCRIBE "'"${_pkgver:?}"'")@' \
    -i "${srcdir:?}/$_pkgsrc/CMake/ScmRevGen.cmake"

  # Fix minizip-ng name for Arch
  sed -E -e 's@(pkgconfig\(MINIZIP minizip)([^a-z]+)@\1-ng\2@' \
    -i "${srcdir:?}/$_pkgsrc/CMakeLists.txt"
}

build() {
  if [[ x"${_avx_build::1}" == "xt" ]] ; then
    export CFLAGS="$(echo "$CFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=skylake -O3"
    export CXXFLAGS="$(echo "$CFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=skylake -O3"
  fi

  local _cmake_options=(
    -B build
    -S "$_pkgname"

    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DDISTRIBUTOR='aur.chaotic.cx'
    -DENABLE_AUTOUPDATE=OFF
    # -DENABLE_ANALYTICS=OFF # ON is opt-in
    # -DUSE_SYSTEM_LIBS=ON # AUTO

    -DUSE_SYSTEM_ENET=OFF
    -DUSE_SYSTEM_LIBMGBA=OFF
    -DUSE_SYSTEM_XXHASH=OFF
    -DUSE_SYSTEM_ZLIB=OFF

    -DENABLE_LTO=OFF # segfault when on
    -DENABLE_TESTS=OFF
    -Wno-dev
  )

  if [ x"${_debugfast::1}" == "xt" ] ; then
    _cmake_options+=(-DFASTLOG=ON)
  fi

  cmake "${_cmake_options[@]}"
  cmake --build build
}

package() {
  DESTDIR="${pkgdir:?}" cmake --install build

  install -Dm644 "${srcdir:?}/$_pkgsrc/Data/51-usb-device.rules" \
    -t "${pkgdir:?}/usr/lib/udev/rules.d/"

  rm -rf "${pkgdir:?}"/usr/{include,lib/libdiscord-rpc.a}
}

# execute
_main_package