blob: a9cf3d91e17c1efcd57e4a49ea54df86795c77c3 (
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: malucart <malucart_at_outlook_dot_com>
# to some extent based on https://aur.archlinux.org/packages/mipsel-elf-gcc
target_="mipsel-none-elf"
pkgname=${target_}-gcc-git
pkgver=15.r5740.066f309db6
pkgrel=1
pkgdesc="up-to-date GCC (C, C++) for baremetal MIPS"
arch=('x86_64')
url="https://www.gnu.org/software/gcc/"
license=('GPL' 'LGPL' 'FDL' 'custom')
groups=()
depends=("${target_}-binutils-git")
makedepends=('git')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
options=('!ccache' '!distcc' '!emptydirs' '!libtool' '!strip')
source=()
noextract=()
sha256sums=()
# since binutils and gcc are such massive repos, letting PKGBUILD use its normal
# git functionality would take way too long, so this command fetches sources
# and history without downloading unnecessary/outdated data
# it is not possible to simply clone with --depth 1 because that would not
# fetch tags and commits, which is needed for pkgver()
fetch() {
mkdir -p $srcdir
if [[ ! -d "$srcdir/${pkgname%-git}" ]] || dir_is_empty "$srcdir/${pkgname%-git}" ; then
git clone -j4 --filter=blob:none --filter=tree:0 --single-branch --branch master \
--origin=origin git://gcc.gnu.org/git/gcc.git "$srcdir/${pkgname%-git}"
fi
}
pkgver() {
fetch
cd "$srcdir/${pkgname%-git}"
# Git, tags available
printf "%s" "$(git describe --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" | sed -E 's/(.+\/)?gcc.//'
}
prepare() {
fetch
cd "$srcdir/${pkgname%-git}"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
}
build() {
cd "$srcdir/${pkgname%-git}"
CFLAGS=${CFLAGS/-Werror=format-security/}
CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
mkdir -p gcc-build && cd gcc-build
../configure \
--prefix=/usr --libexecdir=/usr/lib \
--target="${target_}" \
--with-newlib \
--enable-fixed-point \
--with-gnu-as --with-gnu-ld \
--disable-nls \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++ \
--disable-multilib --disable-libgcj \
--enable-lto --disable-werror \
--without-headers --disable-shared \
--enable-initfini-array
make -j$(nproc)
}
package() {
cd "$srcdir/${pkgname%-git}"
cd gcc-build
make DESTDIR="$pkgdir" install
find "$pkgdir/usr/lib/gcc/$target_/" \
-type f -and \( -name \*.a -or -name \*.o \) \
-exec "${target_}"-strip '{}' \;
find "$pkgdir/usr/bin/" "$pkgdir/usr/lib/gcc/$target_/" \
-type f -and \( -executable \) -exec strip '{}' \;
# remove unnecessary files
rm -rf "$pkgdir/usr/share"
rm "$pkgdir"/usr/lib/libcc1.*
}
|