summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2acc89c895e770b79d899f8f48a34fd9dde9beef (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
# Maintainer: Pellegrino Prevete <pellegrinoprevete@gmail.com>

# shellcheck disable=SC2034
_arch="mips"
_platform="ps2"
_iop="${_arch}el-${_platform}"
_ee="${_arch}64r5900el-${_platform}-elf"
_base="sdk"
_pkgname="${_platform}${_base}"
_pkg="gskit"
pkgname="${_pkg}"
pkgver="v1.3.0"
pkgrel=1
_pkgdesc=("C interface to the Sony Playstation® 2 videogame system Graphics Synthesizer.")
pkgdesc="${_pkgdesc[*]}"
arch=('x86_64')
license=("custom:AFL")
_github="https://github.com/ps2dev"
_local="ssh://git@127.0.0.1:/home/git"
url="${_github}/${_pkg}"
makedepends=("${_platform}-${_base}=${pkgver}")
optdepends=()
# _commit_132="32c5f7c39b8353de9790b94486385dfc08d0409d"
_commit="13ec7767aec3506cd16119288e09849b621df147"
source=("${pkgname}::git+${url}#commit=${_commit}")
# source=("${pkgname}::git+${_local}/${pkgname}#commit=${_commit}")
sha256sums=('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"

prepare() {
  cd "${srcdir}/${pkgname}"
  local _mf _rep
  local _mfs=($(find . | grep Makefile)
              $(find . | grep Rules.make))

  local GSKITSRC="${srcdir}/${pkgname}"
  local _reps=("s~include \$(PS2SDK)/samples~include \$(PS2SDKDATADIR)/samples~g"
               "s~\$(PS2SDK)/Defs.make~/usr/share/${_platform}${_base}/Defs.make~g"
               "s~\$(PS2SDK)/bin/bin2c~/usr/bin/bin2c~g"
               "s~\$(PS2DEV)/isjpcm/bin~/usr/${_iop}\-irx/irx~g"
               "s~-I\$(PS2DEV)/isjpcm/include~-include ${_ee_include}/sjpcm.h~g"
               "s~-L\$(PS2DEV)/isjpcm/lib~${_ee_lib}/libsjpcm.a~g"
               "s~-L\$(PS2SDK)/ee/lib~-L${_ee_lib}~g"
               "s~-I\$(PS2SDK)/common/include~-I${_sdk_include}~g"
               "s~-I\$(PS2SDK)/ee/include~-I${_ee_include}~g"
               "s~-I\$(PS2SDK)/ports/include~${_ee_include}~g"
               "s~-L\$(PS2SDK)/ports/lib~-L${_ee_lib} -r ~g"
               "s~-T\$(PS2SDK)/ee/startup/linkfile~-T/usr/${_ee}/startup/linkfile~g"
               "s~-lgskit -ldmakit~${GSKITSRC}/lib/libgskit.a ${GSKITSRC}/lib/libdmakit.a -r~g"
)

  for _mf in "${_mfs[@]}"; do
    for _rep in "${_reps[@]}"; do
      sed -i "${_rep}" "${_mf}"
    done
  done
}

build() {
  export CFLAGS=""
  export CXXFLAGS=""
  export CPPFLAGS=""
  export LDFLAGS=""
  export IOP_CC=""
  export EE_CC=""
  export EE_INCS=""
  export EE_CFLAGS=""
  export EE_CFLAGS=""
  export PS2SDKDATADIR=""

  export PS2SDK="/usr"
  export PS2SDKDATADIR="/usr/share/${_platform}${_base}"
  export GSKITSRC="${srcdir}/${pkgname}"

  local _make_opts=(PS2SDKDATADIR="/usr/share/${_platform}${_base}"
                    GSKITSRC="${GSKITSRC}")

  cd "${srcdir}/${pkgname}"
  GSKITSRC="${srcdir}/${pkgname}" \
  PS2SDKDATADIR="/usr/share/ps2sdk" \
  make "${_make_opts[@]}"
}

# shellcheck disable=SC2154
package() {

  export CFLAGS=""
  export CXXFLAGS=""
  export CPPFLAGS=""
  export LDFLAGS=""

  local _make_opts=(PS2SDKDATADIR="/usr/share/${_platform}${_base}"
                    DESTDIR="${pkgdir}")

  cd "${srcdir}/${pkgname}"
  make "${_make_opts[@]}" install
  cd "${pkgdir}"
  mkdir "usr"
  mv "gsKit" "usr/${_ee}"
}