summaryrefslogtreecommitdiff
path: root/cross/mips64el-unknown-linux-gnu-binutils/PKGBUILD
blob: 463c53e7432ee754b3d878444359dbb01a4fe89a (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
# $Id: PKGBUILD 155399 2012-04-03 11:09:56Z allan $
# Maintainer: Allan McRae <allan@archlinux.org>

# toolchain build order: linux-api-headers->glibc->binutils->gcc->binutils->glibc
_pkgname=binutils
_target="mips64el-unknown-linux-gnu"
_sysroot="/usr/${_target}"

unset CFLAGS CXXFLAGS LDFLAGS

pkgname=${_target}-binutils
pkgver=2.22
pkgrel=5
_date=20120323
pkgdesc="A set of programs to assemble and manipulate binary and object files for the MIPS architecture"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/binutils/"
license=('GPL')
groups=("${_target}-base-devel")
depends=('glibc>=2.15' 'zlib')
checkdepends=('dejagnu')
options=('!libtool' '!distcc' '!ccache')
provides=("cross-${pkgname}")
source=(ftp://ftp.archlinux.org/other/${_pkgname}/${_pkgname}-${pkgver}_${_date}.tar.bz2)
md5sums=('de2ac4298732827f8af706fc24020330')

mksource() {
  mkdir ${_pkgname}-${_date}
  cd ${_pkgname}-${_date}
  export _TAG=binutils-2_22-branch
  export 'CVSROOT=:pserver:anoncvs@sourceware.org:/cvs/src'
  cvs -z9 co -r $_TAG binutils || return 1
  mv src binutils
  tar -cvjf ../binutils-${pkgver}_${_date}.tar.bz2 binutils/*
}

build() {
  cd ${srcdir}
  mkdir binutils-build && cd binutils-build

  [[ $CARCH == "x86_64" ]] && CONFIGFLAG="--enable-64-bit-bfd --disable-multilib"
  [[ $CARCH == "mips64el" ]] && CONFIGFLAG="--disable-multilib --disable-werror"

  msg2 "Adding cross-toolchain flags"
  CONFIGFLAG+=" --build=${CHOST} --host=${CHOST} --target=${_target} --with-sysroot=${_sysroot}"

  CFLAGS=" -pipe " \
  CXXFLAGS=" -pipe " \
  ${srcdir}/binutils/configure --prefix=/usr \
    --enable-ld=default --enable-gold \
    --enable-plugins --enable-threads \
    --disable-shared $CONFIGFLAG
#   CFLAGS=" -pipe "\
#   CXXFLAGS=" -pipe "\
#   ${srcdir}/binutils/configure --build=${CHOST} \
#               --host=${CHOST} \
#               --target=${_target} \
#               --prefix=/usr \
#               --disable-nls \
#               --disable-multilib \
#               --disable-werror \
#               --enable-ld=yes \
#               --enable-gold=no \
#               --with-sysroot=${_sysroot}

  # check the host environment and makes sure all the necessary tools are available
  msg2 "Configuring host"
  make configure-host

  msg2 "Make"
  make tooldir=${pkgdir}/${_sysroot}/usr

  msg2 "Make libiberty"
  # Rebuild libiberty.a with -fPIC
  cp -a libiberty libiberty-pic
  make -C libiberty-pic clean
  make CFLAGS="$CFLAGS -fPIC" -C libiberty-pic

  msg2 "Make BFD"
  # Rebuild libbfd.a with -fPIC
  # hidden visability prevent 3rd party shared libraries exporting bfd non-stable API
  cp -a bfd bfd-pic
  make -C bfd-pic clean
  make CFLAGS="$CFLAGS -fPIC -fvisibility=hidden" -C bfd-pic

  msg2 "Make opcodes"
  # Rebuild libopcodes.a with -fPIC
  cp -a opcodes opcodes-pic
  make -C opcodes-pic clean 
  make CFLAGS="$CFLAGS -fPIC" -C opcodes-pic
}

check() {
  cd ${srcdir}/binutils-build

  # do not abort on errors - manually check log files
  make -k -j1 check || true
}

package() {
  cd ${srcdir}/binutils-build
  make prefix=${pkgdir}/${_sysroot}/usr tooldir=${pkgdir}/${_sysroot}/usr install

  # Create include dir so gcc-core doesn't complain
  mkdir -p ${pkgdir}${_sysroot}/usr/include    
  
  # Add some useful headers
  install -m644 ${srcdir}/binutils/include/libiberty.h ${pkgdir}/${_sysroot}/usr/include/
  install -m644 ${srcdir}/binutils/include/demangle.h ${pkgdir}/${_sysroot}/usr/include/

  # install libraries rebuilt with -fPIC
  install -m644 libiberty-pic/libiberty.a ${pkgdir}/${_sysroot}/usr/lib
  install -m644 bfd-pic/libbfd.a ${pkgdir}/${_sysroot}/usr/lib
  install -m644 opcodes/libopcodes.a ${pkgdir}/${_sysroot}/usr/lib

  # Remove man pages
  rm -fv ${pkgdir}/usr/share/

  # Remove these symlinks, they are not ABI stable.
  # Programs should compile static to the .a file.
  rm -fv ${pkgdir}/${_sysroot}/usr/lib/lib{bfd,opcodes}.so
  echo "INPUT ( /${_sysroot}/usr/lib/libbfd.a -liberty -lz )" >${pkgdir}/${_sysroot}/usr/lib/libbfd.so
  echo "INPUT ( /${_sysroot}/usr/lib/libopcodes.a -lbfd )" >${pkgdir}/${_sysroot}/usr/lib/libopcodes.so

  # put $target-* binaries into /usr/bin
  mkdir -p ${pkgdir}/usr/bin
  mv -v ${pkgdir}/${_sysroot}/usr/bin/${_target}-* ${pkgdir}/usr/bin/

}