summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 80cc67497032a38341166bf906ac3d81b27b59bf (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: Pellegrino Prevete <pellegrinoprevete@gmail.com>

# 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="libmad"
pkgname="${_platform}-${_pkg}"
pkgver="v0.15.1b"
pkgrel=1
_pkgdesc=("An high-quality MPEG audio decoder (Sony Playstation® 2 videogame system port).")
pkgdesc="${_pkgdesc[*]}"
arch=('x86_64')
license=('custom')
_ns="${_platform}${_base}"
_github="https://github.com/ps2dev"
_local="ssh://git@127.0.0.1:/home/git"
url="${_github}/${_pkgbase}"
makedepends=("${_platform}-sdk"
             "${_platform}-isjpcm")
optdepends=()
_commit="e3f9bfd51e3266b3c68de19b76f6d378f6ec643b"
source=("${pkgname}::git+${url}#commit=${_commit}")
# source=("${pkgname}::git+${_local}/${pkgname}#commit=${_commit}")
sha256sums=('SKIP')

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

_cflags=(-I"${_pe_include}"
         -I"${_ee_sdk_include}"
         -I"${_ee_include}"
         -I"${_sdk_include}")

_iop_incs=(${_cflags[*]}
           -I"${_iop_include}")

_ee_incs=(-I"${_sdk_include}")
          # -I"${_ee_include}")

_ldflags=(-L"/usr/${_ee}/lib/pthread-embedded")
          # -L"${_ee_lib}")
          # -L"/usr/${_ee}/lib/newlib-nano"
          # "${_ee_lib}/newlib-nano/libc_nano.a"
          # "${_ee_lib}/newlib-nano/libm_nano.a"
          # "${_ee_lib}/newlib-nano/libg_nano.a"
          # "${_ee_lib}/newlib-nano/crt0.o")


prepare() {
  cd "${srcdir}/${pkgname}"
  local _sample _samples=()
  _samples=($(find . | grep Makefile))
  for _sample in "${_samples[@]}"; do
    sed -i 's/include $(PS2SDK)\/samples/include $(PS2SDKDATADIR)\/samples/g' "${_sample}"
  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=""

  local _ee_cflags=(-I"${_pe_include}"
                    '-include' "${srcdir}/${pkgname}/${_pkg}/ee/include/config.h"
                    -I"../include"
                    -I"${_ee_include}")

  local _make_opts=(PS2SDKDATADIR="/usr/share/${_platform}${_base}"
                    # LDFLAGS="${_ldgflags[*]}"
                    EE_CFLAGS="${_ee_cflags[*]}")

  export CFLAGS="${_cflags[*]}"
  export PS2SDK="${srcdir}/${_platform}${_base}"
  export IOP_TOOL_PREFIX="${_iop}-elf-"
  export EE_CC="${_ee}-gcc"
  export EE_CFLAGS="${_ee_cflags[*]}"
  export PS2SDKDATADIR="/usr/share/ps2sdk"


  cd "${srcdir}/${pkgname}"
  mkdir -p ${PS2SDK}
  ls
  cd libmad
  cp -r "ee/include/global.h" "ee/src"
  cp -r "ee/include/config.h" "ee/src"
  cp -r "ee/include/bit.h" "ee/src"
  cp -r "ee/include/fixed.h" "ee/src"
  EE_CFLAGS="${_ee_cflags[*]}" \
  EE_CC="${_ee}-gcc" \
  EE_INCS="${_ee_incs[*]}" \
  PS2SDKDATADIR="/usr/share/ps2sdk" \
  make "${_make_opts[@]}" -C ee/src
}

# shellcheck disable=SC2154
package() {

  export CFLAGS=""
  export CXXFLAGS=""
  export CPPFLAGS=""
  export LDFLAGS=""
  export PS2SDK="/usr"

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

  cd "${srcdir}/${pkgname}"
  ls
  cd libmad
  make DESTDIR="${pkgdir}" "${_make_opts[@]}" -C "ee/src" install
  cd "${pkgdir}/usr"
  mv "ports" "${_ee}"
}