summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 95157cf188c6498f1bbcc6648fec8cac6d259abd (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
147
148
149
150
# Maintainer: Pellegrino Prevete <pellegrinoprevete@gmail.com>

# shellcheck disable=SC2034
_module="iop"
_platform="ps2"
_target="mipsel-${_platform}"
target="${_target}-irx"
_base="toolchain"
pkgname=("${target}-gcc-stage1")
pkgver="v11.3.0"
pkgrel=1
_pkgdesc=("The GNU Compiler Collection. Stage 1 for toolchain building (${target}).")
pkgdesc="${_pkgdesc[*]}"
arch=('x86_64')
license=('BSD')
_github="https://github.com/ps2dev"
_local="ssh://git@127.0.0.1:/home/git"
url="${_github}/gcc"
makedepends=("${target}-binutils"
             "libgmp-static"
             "mpfr-static"
             "libmpc-static"
             "gmp4-static"
             "zstd-static")
optdepends=()
_branch="${_module}-${pkgver}"
_commit="331453616ac96717cfef82d21c03573c8984f17d"
source=("${pkgname}::git+${url}#commit=${_commit}")
# source=("${pkgname}::git+${_local}/${_platform}-gcc#commit=${_branch}")
sha256sums=('SKIP')

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

# shellcheck disable=SC2154
build() {
  local _target

  CFLAGS=""
  CXXFLAGS=""
  CPPFLAGS=""
  LDFLAGS=""
  export CFLAGS
  export CXXFLAGS
  export CPPFLAGS
  export LDFLAGS
  export PATH="${PATH}:${_bu_bin}"
  export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib"

  local _cflags=(-D_FORTIFY_SOURCE=0
                 -O2
                 -Wno-implicit-function-declaration
                 -I/usr/include
                 -L/usr/lib
                 # -ldl
                 -static)

  local _ldflags=(-I/usr/include
                  # -rdynamic
                  -L/usr/lib
                  # -ldl
                  -Bstatic
                  -s)

  local _libs=(-L/usr/lib)
               # -ldl
               # /usr/lib/libmpc.so
               # /usr/lib/libmpfr.so
               # /usr/lib/libgmp.so)

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

  cd "${srcdir}/${pkgname}"

  for _target in "${target}"; do
    rm -rf "build-${_target}"
    mkdir -p "build-${_target}"
    cd "build-${_target}"
    local _configure_opts=(--prefix="/usr"
                           --target="${_target}"
                           --host=${CHOST}
                           --build=${CHOST}
                           --infodir="/usr/${_target}/share/info"
                           --mandir="/usr/${_target}/share/man"
                           --enable-languages="c"
                           --with-float=soft
                           --with-gmp
                           --with-mpfr
                           --with-mpc
                           --without-headers
                           --with-headers=no
                           --without-newlib
                           --without-cloog
                           --without-ppl
                           --disable-bootstrap
                           --disable-decimal-float
                           --disable-libada
                           --disable-libatomic
                           --disable-libffi
                           --disable-libgomp
                           --disable-libmudflap
                           --disable-libquadmath
                           --disable-libssp
                           --disable-libstdcxx-pch
                           --disable-multilib
                           --disable-shared
                           --disable-threads
                           --disable-target-libiberty
                           --disable-target-zlib
                           --disable-nls
                           --disable-tls)

    LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib" \
    CC="/usr/bin/gcc" \
    CXX="/usr/bin/g++" \
    CFLAGS="${_cflags[*]}" \
    CXXFLAGS="${_cxxflags[*]}" \
    LDFLAGS="${_ldflags[*]}" \
    LIBS="${_libs[*]}" \
    "../configure" ${_configure_opts[@]}

    LD_LIBRARY_PATH=/usr/lib \
    CC="/usr/bin/gcc" \
    CXX="/usr/bin/g++" \
    CFLAGS="${_cflags[*]}" \
    CXXFLAGS="${_cxxflags[*]}" \
    LDFLAGS="${_ldflags[*]}" \
    LIBS="${_libs[*]}" \
    make "${_build_opts[@]}" all

    cd ..
  done
}

# shellcheck disable=SC2154
package() {
  local _target
  cd "${srcdir}/${pkgname}"
  for _target in "${target}"; do
    cd "build-${_target}"
    make DESTDIR="${pkgdir}" "${_make_opts[@]}" install-strip
    rm -rf "${pkgdir}/usr/${target}/share/info/dir"
    cd ..
  done
}