summaryrefslogtreecommitdiff
path: root/PKGBUILD
blob: b61bf97fb847b5db3516ee8283a1db91266d9a31 (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
# Maintainer: jc_gargma <jc_gargma@iserlohn-fortress.net>
# Maintainer (AUR): George Rawlinson <george@rawlinson.net.nz>
# Contributor (AUR): Max Zhao <alcasa dot mz at gmail dot com>
# Contributor (AUR): Leonard König <leonard.r.koenig at googlemail dot com>


# # I maintain this because:
# Arch version lacks additional optimization and hardening flags
# Arch version uses git
# Arch version forces compilation with all threads
# Arch version forces msse3, and single thread flto
# Arch version compiles a second time during package() with incorrect FLAGS

pkgname=endless-sky
pkgver=0.10.2
pkgrel=1
pkgdesc='A sandbox-style space exploration and combat game'
arch=('x86_64' 'i686' 'aarch64')
url='https://endless-sky.github.io/'
license=(
  'GPL3'
  'custom:CC-BY-3.0'
  'custom:CC-BY-4.0'
  'custom:CC-BY-NC-3.0'
  'custom:CC-BY-SA-3.0'
  'custom:CC-BY-SA-4.0'
  'custom:public-domain'
)
options=('lto')
depends=(
  'glibc'
  'gcc-libs'
  'openal'
  'libpng'
  'glew'
  'hicolor-icon-theme'
  'libjpeg-turbo'
  'sdl2'
  'libmad'
  'util-linux-libs'
  'libglvnd'
)
makedepends=('scons')
optdepends=(
  'endless-sky-high-dpi: high resolution graphics assets'
)
source=("$pkgname-$pkgver.tar.gz::https://github.com/endless-sky/endless-sky/archive/v${pkgver}.tar.gz")
b2sums=('57e47188aea38cd812c7cb3b388842cb698fea2ed32767ec46481ef4c87a1e07c3d5db1e1ef63900379452aa2ce4fbed77417cc3238d6191004455f9ec700ae4')

prepare() {
  cd "$pkgname-$pkgver"

  # binary is installed to /usr/games instead of /usr/bin
  sed -i 's:games", sky:bin", sky:' SConstruct

  # Stop forcing msse3, O3, and single thread flto
  sed \
  -e 's|<Add option="-msse3" />||' \
  -e 's|<Add option="-O3" />||' \
  -e 's|<Add option="-flto" />||' \
  -i EndlessSky.cbp

  sed \
  -e 's|<Add option="-msse3" />||' \
  -e 's|<Add option="-O3" />||' \
  -e 's|<Add option="-flto" />||' \
  -i EndlessSkyLib.cbp

  sed \
  -e 's|<Add option="-msse3" />||' \
  -e 's|<Add option="-O3" />||' \
  -e 's|<Add option="-flto" />||' \
  -i EndlessSkyTests.cbp

  sed \
  -e 's|, "-O3", "-flto"||' \
  -e 's|env.Append(LINKFLAGS = ["-O3", "-flto"])||' \
  -i SConstruct
}

build() {
  cd "$pkgname-$pkgver"

  export CFLAGS="$CFLAGS -O3 -fPIE"
  export CXXFLAGS="$CXXFLAGS -O3 -fPIE"
  export LDFLAGS="$LDFLAGS,-pie"

  # Fix scons to honor thread count in MAKEFLAGS
  scons "${MAKEFLAGS}"
}

package() {
  cd "$pkgname-$pkgver"

  # For reasons of black magic, adding these flags again prevents a second compilation during this step.
  # This halves compilation time.
  # Also prevents this second compilation from being used in the resulting package with incorrect FLAGS.
  # Madness.
  export CFLAGS="$CFLAGS -O3 -fPIE"
  export CXXFLAGS="$CXXFLAGS -O3 -fPIE"
  export LDFLAGS="$LDFLAGS,-pie"

  scons \
    DESTDIR="$pkgdir" \
    PREFIX=/usr \
    install

  # license
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" copyright
}