summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 506d831b15801e76e81d3ffcc44e682ba6918138 (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
# Maintainer:

# options
: ${_build_clang:=true}

: ${_build_avx:=false}
: ${_build_git:=false}

unset _pkgtype
[[ "${_build_avx::1}" == "t" ]] && _pkgtype+="-avx"
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

# basic info
_pkgname=flycast
pkgname="$_pkgname${_pkgtype:-}"
pkgver=2.4
pkgrel=1
pkgdesc='Sega Dreamcast, Naomi, and Atomiswave emulator'
url="https://github.com/flyinghead/flycast"
license=('GPL-2.0-only')
arch=('x86_64' 'i686')

depends=(
  'alsa-lib'
  'libgl'
  'libzip'
)
makedepends=(
  'cmake'
  'git'
  'ninja'
  'python'
)

if [[ "${_build_clang::1}" == "t" ]]; then
  makedepends+=(
    'clang'
    'lld'
    'llvm'
  )
fi

_source_main() {
  _pkgsrc="$_pkgname"
  source=(
    "$_pkgsrc"::"git+$url.git#tag=v$pkgver"
  )
  sha256sums=(
    'f92414666d141e744273086eb68145c5e418387719af1a874fbde6e4cbeb84f9'
  )
}

_source_flycast() {
  source+=(
    'bylaws.libadrenotools'::'git+https://github.com/bylaws/libadrenotools.git'
    'flyinghead.mingw-breakpad'::'git+https://github.com/flyinghead/mingw-breakpad.git'
    'google.googletest'::'git+https://github.com/google/googletest.git'
    'google.oboe'::'git+https://github.com/google/oboe.git'
    'gpuopen-librariesandsdks.vulkanmemoryallocator'::'git+https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git'
    'harmonytf.discord-rpc'::'git+https://github.com/harmonytf/discord-rpc.git'
    'khronosgroup.glslang'::'git+https://github.com/KhronosGroup/glslang.git'
    'khronosgroup.vulkan-headers'::'git+https://github.com/KhronosGroup/Vulkan-Headers.git'
    'libsdl-org.sdl'::'git+https://github.com/libsdl-org/SDL.git'
    'retroachievements.rcheevos'::'git+https://github.com/RetroAchievements/rcheevos.git'
    'rtissera.libchdr'::'git+https://github.com/rtissera/libchdr.git'
    'vinniefalco.luabridge'::'git+https://github.com/vinniefalco/LuaBridge.git'
    'vkedwardli.spout2'::'git+https://github.com/vkedwardli/Spout2.git'
    'vkedwardli.syphon-framework'::'git+https://github.com/vkedwardli/Syphon-Framework.git'
  )
  sha256sums+=(
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
  )
}

_prepare_flycast() (
  cd "$srcdir/$_pkgsrc"
  local _submodules=(
    'bylaws.libadrenotools'::'core/deps/libadrenotools'
    'flyinghead.mingw-breakpad'::'core/deps/breakpad'
    'google.googletest'::'core/deps/googletest'
    'google.oboe'::'core/deps/oboe'
    'gpuopen-librariesandsdks.vulkanmemoryallocator'::'core/deps/VulkanMemoryAllocator'
    'harmonytf.discord-rpc'::'core/deps/discord-rpc'
    'khronosgroup.glslang'::'core/deps/glslang'
    'khronosgroup.vulkan-headers'::'core/deps/Vulkan-Headers'
    'libsdl-org.sdl'::'core/deps/SDL'
    'retroachievements.rcheevos'::'core/deps/rcheevos'
    'rtissera.libchdr'::'core/deps/libchdr'
    'vinniefalco.luabridge'::'core/deps/luabridge'
    'vkedwardli.spout2'::'core/deps/Spout'
    'vkedwardli.syphon-framework'::'core/deps/Syphon'
  )
  _submodule_update
)

_source_main
_source_flycast

prepare() {
  _submodule_update() {
    local _module
    for _module in "${_submodules[@]}"; do
      git submodule init "${_module##*::}"
      git submodule set-url "${_module##*::}" "$srcdir/${_module%::*}"
      git -c protocol.file.allow=always submodule update "${_module##*::}"
    done
  }

  apply-patch() {
    if patch -Np1 -F100 --dry-run -i "$1" &> /dev/null; then
      printf '\nApplying patch: %s\n' "$1"
      patch -Np1 -F100 -i "$1"
    else
      printf '\nPatch already applied: %s\n' "$1"
    fi
  }

  _prepare_flycast
}

build() {
  if [[ "${_build_clang::1}" == "t" ]]; then
    export CC CXX LDFLAGS
    CC=clang
    CXX=clang++
    LDFLAGS="${LDFLAGS//-fuse-ld=*/} -fuse-ld=lld"
  fi

  if [[ "${_build_avx::1}" == "t" ]]; then
    export CFLAGS CXXFLAGS
    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=generic -O3"
    CXXFLAGS="$(echo "$CXXFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=generic -O3"
  fi

  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -G Ninja
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DUSE_BREAKPAD=OFF
    -Wno-dev
  )

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

package() {
  depends+=(
    'hicolor-icon-theme'
  )

  DESTDIR="$pkgdir" cmake --install build
}