archrelease: copy trunk to community-any
[ArchLinux/community.git] / arm-none-eabi-gcc / trunk / PKGBUILD
blobda1a674a82fa8763d60f0decbb9256a25a968424
1 # Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>
2 # Contributor: Martin Schmölzer <mschmoelzer@gmail.com>
4 _target=arm-none-eabi
5 pkgname=$_target-gcc
6 pkgver=13.1.0
7 pkgrel=1
8 #_snapshot=8-20180427
9 pkgdesc='The GNU Compiler Collection - cross compiler for ARM EABI (bare-metal) target'
10 arch=(x86_64)
11 url='https://gcc.gnu.org/'
12 license=(GPL LGPL FDL)
13 depends=($_target-binutils zlib libmpc libisl zstd)
14 makedepends=(gmp mpfr $_target-newlib)
15 optdepends=('arm-none-eabi-newlib: Standard C library optimized for embedded systems')
16 options=(!emptydirs !strip !lto)
17 source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz{,.sig})
18         #ftp://gcc.gnu.org/pub/gcc/snapshots/$_snapshot/gcc-$_snapshot.tar.xz
19 sha256sums=('61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86'
20             'SKIP')
21 validpgpkeys=(33C235A34C46AA3FFB293709A328C3A2C3C45C06  # Jakub Jelinek <jakub@redhat.com>
22               D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62  # Jakub Jelinek <jakub@redhat.com>
23               13975A70E63C361C73AE69EF6EEB81F8981C74C7) # Richard Guenther <richard.guenther@gmail.com>
25 if [ -n "$_snapshot" ]; then
26   _basedir=gcc-$_snapshot
27 else
28   _basedir=gcc-$pkgver
31 prepare() {
32   cd $_basedir
34   echo $pkgver > gcc/BASE-VER
36   mkdir "$srcdir"/build-{gcc,gcc-nano}
39 _build_gcc() {
40   "$srcdir"/$_basedir/configure \
41     --target=$_target \
42     --prefix=/usr \
43     --with-sysroot=/usr/$_target \
44     --with-native-system-header-dir=/include \
45     --libexecdir=/usr/lib \
46     --enable-languages=c,c++ \
47     --enable-plugins \
48     --disable-decimal-float \
49     --disable-libffi \
50     --disable-libgomp \
51     --disable-libmudflap \
52     --disable-libquadmath \
53     --disable-libssp \
54     --disable-libstdcxx-pch \
55     --disable-nls \
56     --disable-shared \
57     --disable-threads \
58     --disable-tls \
59     --with-gnu-as \
60     --with-gnu-ld \
61     --with-system-zlib \
62     --with-newlib \
63     --with-headers=/usr/$_target/include \
64     --with-python-dir=share/gcc-arm-none-eabi \
65     --with-gmp \
66     --with-mpfr \
67     --with-mpc \
68     --with-isl \
69     --with-libelf \
70     --enable-gnu-indirect-function \
71     --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
72     --with-pkgversion='Arch Repository' \
73     --with-bugurl='https://bugs.archlinux.org/' \
74     --with-multilib-list=rmprofile
76   make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
79 build() {
80   # Credits @allanmcrae
81   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
82   # TODO: properly deal with the build issues resulting from this
83   CFLAGS=${CFLAGS/-Werror=format-security/}
84   CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
86   cd "$srcdir"/build-gcc
87   export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
88   export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
89   _build_gcc
91   # Build libstdc++ without exceptions support (the 'nano' variant)
92   cd "$srcdir"/build-gcc-nano
93   export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
94   export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'  
95   _build_gcc
98 package() {
99   cd "$srcdir"/build-gcc
100   make DESTDIR="$pkgdir" install -j1
102   cd "$srcdir"/build-gcc-nano
103   make DESTDIR="$pkgdir.nano" install -j1
104   # we need only libstdc nano files
105   multilibs=( $("$pkgdir"/usr/bin/$_target-gcc -print-multi-lib 2>/dev/null) )
106   for multilib in "${multilibs[@]}"; do
107     dir="${multilib%%;*}"
108     from_dir="$pkgdir".nano/usr/$_target/lib/"$dir"
109     to_dir="$pkgdir"/usr/$_target/lib/"$dir"
110     cp -f "$from_dir"/libstdc++.a "$to_dir"/libstdc++_nano.a
111     cp -f "$from_dir"/libsupc++.a "$to_dir"/libsupc++_nano.a
112   done
114   # strip target binaries
115   find "$pkgdir"/usr/lib/gcc/$_target/$pkgver "$pkgdir"/usr/$_target/lib -type f -and \( -name \*.a -or -name \*.o \) -exec $_target-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
117   # strip host binaries
118   find "$pkgdir"/usr/bin/ "$pkgdir"/usr/lib/gcc/$_target/$pkgver -type f -and \( -executable \) -exec strip '{}' \;
120   # Remove files that conflict with host gcc package
121   rm -r "$pkgdir"/usr/share/man/man7
122   rm -r "$pkgdir"/usr/share/info
123   rm "$pkgdir"/usr/lib/libcc1.*