summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b9ea75fff8e66c90b971e48acdc409437c1af325 (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
# Maintainer:
# Contributor: Manuel <mdomlop@gmail.com>

# options
: ${_build_clang:=false}

: ${_use_sodeps:=false}

_pkgname="flycast"
pkgname="$_pkgname-git"
pkgver=2.5.r205.g5bce763
pkgrel=2
pkgdesc='Sega Dreamcast, Naomi, and Atomiswave emulator'
url="https://github.com/flyinghead/flycast"
license=('GPL-2.0-only')
arch=('x86_64')

depends=(
  'alsa-lib'
  'glslang'
  'hicolor-icon-theme'
  'libao'
  'libcdio'
  'libpulse'
  'libzip'
  'miniupnpc'
  'sdl2'
)
makedepends=(
  'cmake'
  'git'
  'ninja'
  'python'
  'vulkan-headers'
)

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

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

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

prepare() {
  cd "$_pkgsrc"
  git rm -r core/deps/SDL
  git rm -r core/deps/Vulkan-Headers
  git rm -r core/deps/breakpad
  git rm -r core/deps/glslang
  git rm -r core/deps/googletest
  git rm -r core/deps/oboe
  git submodule update --init --depth=1

  # use system vulkan-headers
  sed -E -e '/add_subdirectory/s&^.*Vulkan-Headers.*$&find_package(VulkanHeaders)&' -i CMakeLists.txt

  sed -E -e 's&vk::(resultCheck|DynamicLoader)&vk::detail::\1&' \
    -i core/rend/vulkan/vmallocator.cpp \
    core/rend/vulkan/vmallocator.h \
    core/rend/vulkan/vulkan_context.cpp

  # fix missing headers
  sed -e '1i #include <cstddef>' -i core/network/miniupnp.cpp
  sed -e '1i #include <set>' -i core/rend/vulkan/vulkan_context.cpp
}

pkgver() {
  cd "$_pkgsrc"
  git describe --long --tags --abbrev=7 --exclude='*[a-zA-Z][a-zA-Z]*' \
    | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
}

build() {
  if [[ "${_build_clang::1}" == "t" ]]; then
    export CC CXX LDFLAGS
    CC=clang
    CXX=clang++
    LDFLAGS="$(sed -E -e 's/\S*fuse-ld\S*//g' <<< "$LDFLAGS") -fuse-ld=lld"
  fi

  export CFLAGS CXXFLAGS
  CFLAGS+=" -DNDEBUG"
  CXXFLAGS+=" -DNDEBUG"

  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -G Ninja
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DBUILD_TESTING=$CHECKFUNC
    -Wno-dev

    -DUSE_BREAKPAD=OFF
    -DUSE_HOST_GLSLANG=ON
    -DUSE_HOST_SDL=ON
    -DUSE_LIBCDIO=ON
  )

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

package() {
  if [[ "${_use_sodeps::1}" == "t" ]]; then
    eval "depends+=(
      'libao.so'
      'libasound.so'
      'libcurl.so'
      'libminiupnpc.so'
      'libpulse.so'
      'libz.so'
      'libzip.so'
    )"
  fi

  DESTDIR="$pkgdir" cmake --install build

  # unwanted
  rm -rf "$pkgdir"/usr/{include,lib,share/pixmaps}
}