aboutsummaryrefslogtreecommitdiff
path: root/arm-linux-gnueabi-gcc/PKGBUILD
blob: bd3825ddac3801daa3fe24bcf4332daa09abe676 (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
151
152
153
154
155
# Contributor: Wojtek Kosior <kwojtus@protonmail.com>

# TODO Maybe enable more languages? And pack them separately?

_target=arm-linux-gnueabi
pkgname=${_target}-gcc
pkgver=6.3.0
pkgrel=1
pkgdesc="The GNU Compiler Collection - cross compiler for ARM GNU/Linux EABI target"
arch=('i686' 'x86_64')
license=('GPL-3' 'LGPL-3' 'custom:GCC-Exception-3.1' 'FDL-1.3')
url="https://gcc.gnu.org"
groups=('cross-devel')
depends=("${_target}-binutils>=2.28" "${_target}-glibc" 'libmpc')
makedepends=('gcc-ada' 'doxygen' "gcc-source=${pkgver}")
# Check()ing a cross-compiler would require using an emulator (qemu), I believe.
# For now - leave checkdepends commented-out
# checkdepends=('dejagnu' 'inetutils')
options=('!emptydirs' 'staticlibs' '!strip')
source=(COPYING.DOC)
sha512sums=('bea1788b2bdc84f470e459114b871cf4ee991718964a63e18adde65116806d7676484cb30857cf74dece5eef5f96a015ee4a21900e019623e5d3484868b28b7f')

prepare() {
    cd "${srcdir}"
    
    prepare-gcc-source .
    
    # Do not run fixincludes
    sed -i 's@\./fixinc\.sh@-c true@' gcc-${pkgver}/gcc/Makefile.in
    
    # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
    sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" gcc-${pkgver}/{libiberty,gcc}/configure
    
    mkdir gcc_build
}

build() {
  cd "${srcdir}/gcc_build"

  # using -pipe causes spurious test-suite failures
  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
  CFLAGS=${CFLAGS/-pipe/}
  CXXFLAGS=${CXXFLAGS/-pipe/}

  # libmpx seems to be some intel stuff - x86 only
  "${srcdir}/gcc-${pkgver}/configure"                   \
	   --prefix=/usr                                \
	   --libdir=/usr/lib                            \
	   --libexecdir=/usr/libexec                    \
	   --with-local-prefix=/usr/${_target}          \
	   --with-sysroot=/usr/${_target}               \
	   --with-build-sysroot=/usr/${_target}         \
	   --with-as=/usr/bin/${_target}-as             \
	   --with-ld=/usr/bin/${_target}-ld             \
	   --with-native-system-header-dir=/include     \
	   --with-bugurl=https://issues.hyperbola.info/ \
	   --enable-languages=c,c++,lto                 \
	   --enable-shared                              \
	   --enable-threads=posix                       \
	   `[[ $_target =~ (i686)|(x86_64) ]] && 
	       echo --enable-libmpx`                    \
	   --with-system-zlib                           \
	   --with-isl                                   \
	   --enable-__cxa_atexit                        \
	   --disable-libunwind-exceptions               \
	   --enable-clocale=gnu                         \
	   --disable-libstdcxx-pch                      \
	   --disable-libssp                             \
	   --enable-gnu-unique-object                   \
	   --enable-linker-build-id                     \
	   --enable-lto                                 \
	   --enable-plugin                              \
	   --enable-install-libiberty                   \
	   --with-linker-hash-style=gnu                 \
	   --enable-gnu-indirect-function               \
	   --disable-multilib                           \
	   --disable-werror                             \
	   --enable-checking=release                    \
	   --disable-nls                                \
	   --target=${_target}
  
  make
}

# maybe check() using qemu?

package() {
  cd "${srcdir}/gcc_build"

  make DESTDIR="${pkgdir}" install-gcc                          \
       install-target-{libgcc,libstdc++-v3,libgomp,libquadmath}
  
  # TODO I'm not sure about this stripping. Everybody seems to be doing it a different way...
  # I commented out all 2>/dev/null to be able to see what's going on. Uncomment them once
  # everything works as it should :)
  
  # strip target binaries
  find "${pkgdir}/usr/lib/gcc/${_target}/" "${pkgdir}/usr/${_target}/lib" \
       -type f -and \( -name \*.a -or -name \*.o \)                       \
       -exec ${_target}-strip $STRIP_STATIC '{}' + 2>/dev/null

  find "${pkgdir}/usr/lib/gcc/${_target}/" "${pkgdir}/usr/${_target}/lib" \
       -not -name 'libgcc_s.so' -name \*.so -type f                       \
       -exec ${_target}-strip $STRIP_SHARED '{}' + 2>/dev/null

  # strip host binaries
  find "${pkgdir}/usr/bin/" "${pkgdir}/usr/lib/gcc/${_target}/"           \
       -type f -executable -exec strip $STRIP_BINARIES '{}' + 2>/dev/null
       
  # many packages expect this symlink
  ln -s "${_target}-gcc" "${pkgdir}/usr/bin/${_target}-cc"

  # POSIX conformance launcher scripts for c89 and c99
  cat > "${pkgdir}/usr/bin/${_target}-c89" <<"EOF"
#!/bin/sh
fl="-std=c89"
for opt; do
  case "$opt" in
    -ansi|-std=c89|-std=iso9899:1990) fl="";;
    -std=*) echo "`basename $0` called with non ANSI/ISO C option $opt" >&2
	    exit 1;;
  esac
done
exec gcc $fl ${1+"$@"}
EOF
sed -i "s|exec gcc|exec ${_target}-gcc|" "${pkgdir}/usr/bin/${_target}-c89"

  cat > "${pkgdir}/usr/bin/${_target}-c99" <<"EOF"
#!/bin/sh
fl="-std=c99"
for opt; do
  case "$opt" in
    -std=c99|-std=iso9899:1999) fl="";;
    -std=*) echo "`basename $0` called with non ISO C99 option $opt" >&2
	    exit 1;;
  esac
done
exec gcc $fl ${1+"$@"}
EOF
sed -i "s|exec gcc|exec ${_target}-gcc|" "${pkgdir}/usr/bin/${_target}-c99"

  chmod 755 "${pkgdir}/usr/bin/${_target}"-c{8,9}9
 
  # Remove man documents that conflict with host version
  rm -rf ${pkgdir}/usr/share/man/man7

  # Remove unused dirs
  rm -rf ${pkgdir}/usr/share/{info,gcc-${pkgver}}

  # Add licenses
  install -m755 -d "${pkgdir}/usr/share/licenses/${_target}-gcc"
  install -m644 "${srcdir}/gcc-${pkgver}"/COPYING{3{,.LIB},.RUNTIME} "${srcdir}/COPYING.DOC" \
	  "${pkgdir}/usr/share/licenses/${_target}-gcc"
}