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

# shellcheck disable=SC2034
target="mips64r5900el-ps2-elf"
_module="ee"
_platform="ps2"
_pe="pthread-embedded"
_base="toolchain"
pkgname=("${target}-newlib")
pkgver="v4.1.0"
pkgrel=1
pkgdesc="A C library intended for use on embedded systems (${target})"
arch=('x86_64')
license=('BSD')
_github="https://github.com/ps2dev"
_local="ssh://git@127.0.0.1:/home/git"
url="${_github}/${_platform}${_base}-${_module}"
makedepends=("${target}-binutils"
             "${target}-gcc-stage1"
             "libgmp-static"
             "mpfr-static"
             "libmpc-static"
             "zstd-static")
optdepends=()
_branch="${_module}-${pkgver}"
_commit="6b90d31371ff4e0f41d64d7539038864899a6b40"
source=("${target}-newlib::git+${_github}/newlib#commit=${_commit}")
# source=("${target}-newlib::git+${_local}/${_platform}-newlib#commit=${_branch}")
sha256sums=('SKIP')

_n_cpu="$(getconf _NPROCESSORS_ONLN)"
_make_opts=(-j "${_n_cpu}")

cflags=(-static
        -Wno-implicit-function-declaration)

ldflags=(${LDFLAGS}
         -Bstatic
         -s)

# shellcheck disable=SC2154
build() {
  local _target
  CFLAGS=""
  CXXFLAGS=""
  CPPFLAGS=""
  LDFLAGS=""
  export CFLAGS
  export CXXFLAGS
  export CPPFLAGS
  export LDFLAGS

  local _cflags=(${cflags[@]})
                 # -O2
                 # -D_FORTIFY_SOURCE=0)

  local _ldflags=(${ldflags[@]})
                  # -ldl)

  local _build_opts=(${_make_opts[@]}
                     CFLAGS="${_cflags[*]}"
                     CPPFLAGS="${_cflags[*]}"
                     LDFLAGS="${_ldflags[*]}")

  cd "${srcdir}/${target}-newlib"

  for _target in "${target}"; do
    rm -rf "build-${_target}"
    mkdir -p "build-${_target}"
    cd "build-${_target}"
    local _configure_opts=(--prefix="/usr"
                           --target="${_target}")

    # CFLAGS_FOR_TARGET="-02" \
    CFLAGS="${_cflags[*]}" \
    "../configure" "${_configure_opts[@]}"

    make "${_build_opts[@]}" all

    cd ..
  done
}

# shellcheck disable=SC2154
package() {
  local _target
  cd "${srcdir}/${target}-newlib"
  for _target in "mips64r5900el-ps2-elf"; do
    cd "build-${_target}"
    make DESTDIR="${pkgdir}" ${_make_opts[@]} install-strip
    # make ${_make_opts[@]} clean
    cd ..
  done
}