summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 107631493740a10132dc958a17e81211c68e4987 (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
# SPDX-License-Identifier: AGPL-3.0
#
# Maintainer: Pellegrino Prevete (tallero) <pellegrinoprevete@gmail.com>
# Maintainer: Truocolo <truocolo@aol.com>
# Contributor: Marcell Meszaros (MarsSeed) <marcell.meszaros@runbox.eu>

# shellcheck disable=SC2034
_arch="mips"
_platform="ps2"
_iop="${_arch}el-${_platform}"
_ee="${_arch}64r5900el-${_platform}-elf"
_base="sdk"
_ns="${_platform}${_base}"
_pkgbase="${_platform}${_base}-ports"
_pkg="xz"
pkgname="${_platform}-${_pkg}"
pkgver="5.4.0"
_ports_ver="1.3.0"
pkgrel=1
_pkgdesc=(
  "Free general-purpose data compression software with high compression ratio "
  "(Sony Playstation® 2 videogame system port)."
)
pkgdesc="${_pkgdesc[*]}"
arch=(
  'x86_64'
)
license=(
  'custom'
)
_ns="${_pkg}-mirror"
_github="https://github.com/${_ns}"
_local="ssh://git@127.0.0.1:/home/git"
url="${_github}/${_pkg}"
_ports_url="https://github.com/${_platform}dev/${_platform}${_base}-ports"
makedepends=(
  "${_platform}-sdk"
  "cmake")

optdepends=()
_commit="b69da6d4bb6bb11fc0cf066920791990d2b22a06"
_ports_commit="e3f9bfd51e3266b3c68de19b76f6d378f6ec643b"
source=(
  "${pkgname}::git+${url}#commit=${_commit}"
  # "${pkgname}::git+${_local}/${pkgname}#commit=${_commit}"
  "${_platform}-ports::git+${_ports_url}#commit=${_ports_commit}"
)
sha256sums=(
  'SKIP'
  'SKIP'
)

_ee_include="/usr/${_ee}/include"
_ee_lib="/usr/${_ee}/lib"
_sdk_include="/usr/include/${_platform}${_base}"
_pe_include="/usr/${_ee}/include/pthread-embedded"
_pe_lib="/usr/${_ee}/lib/pthread-embedded"

_ldflags=(
  -L"${_pe_lib}"
  -L"${_ee_lib}"
)

prepare() {
  cd \
    "${srcdir}/${_platform}-ports"
  local \
    _reps=() \
    _rep
  _reps=(
    "s~\$ENV{PS2SDK}/ee/include~${_ee_include}~g"
    "s~\$ENV{PS2SDK}/common/include~${_sdk_include}~g"
    "s~\$ENV{PS2DEV}/ee/ee~~g"
    "s~\$ENV{PS2DEV}/ee~~g"
    "s~\$ENV{PS2DEV}/ports~${pkgdir}/usr/${_ee}~g"
    "s~\$ENV{PS2DEV}~~g"
    "s~\$ENV{PS2SDK}/ports~~g"
    "s~\$ENV{PS2SDK}~~g"
    "s~CMAKE_FIND_ROOT_PATH ~CMAKE_FIND_ROOT_PATH /usr/${_ee}~g"
    "s~CMAKE_C_FLAGS_INIT \"~CMAKE_C_FLAGS_INIT \"-std=gnu++11 ~g"
    "s~-D_EE~-D_EE -r~g"
  )
  for _rep in "${_reps[@]}"; do
    sed \
      -i \
      "${_rep}" \
      "${_platform}dev.cmake"
  done
  local \
    _linker_flags=(-r)
}

build() {
  local \
    _cmake_opts=() \
    _site_opts=() \
    _extra_opts=() \
    _build
  export \
    CFLAGS="" \
    CXXFLAGS="" \
    CPPFLAGS="" \
    LDFLAGS=""
  _cmake_opts=(
    -Wno-dev
    -DCMAKE_TOOLCHAIN_FILE="${srcdir}/${_platform}-ports/ps2dev.cmake"
    -DCMAKE_INSTALL_PREFIX="/usr/${_ee}"
    -DBUILD_SHARED_LIBS=OFF
    -DLDFLAGS="-L${_ee_lib}"
    -DCMAKE_BUILD_TYPE=RelWithDebInfo
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
  )
  _site_opts=(
    -DTUKLIB_CPUCORES_FOUND=ON
    -DTUKLIB_PHYSMEM_FOUND=ON
    -DHAVE_GETOPT_LONG=OFF
    -DBUILD_TESTING=OFF
  )
  _extra_opts=(
    -G"Unix Makefiles"
  )
  _build="${srcdir}/${pkgname}/build"
  mkdir \
    -p \
    "${_build}"
  cd \
    "${_build}"
  cmake \
    "${_cmake_opts[@]}" \
    "${_site_opts[@]}" \
    "${_extra_opts[@]}" \
    ..
}

# shellcheck disable=SC2154
package() {
  cd \
    "${srcdir}/${pkgname}/build"
  make \
    DESTDIR="${pkgdir}" \
    clean \
    all \
    install
}

# vim:set sw=2 sts=-1 et: