source: npl/system/binutils/binutils.SlackBuild.orig @ d2a077a

perl-5.22
Last change on this file since d2a077a was aafe99e, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

new version for gcc building

  • Property mode set to 100755
File size: 7.4 KB
Line 
1#!/bin/sh
2
3# Copyright 2005-2016  Patrick J. Volkerding, Sebeka, Minnesota, USA
4# All rights reserved.
5#
6# Redistribution and use of this script, with or without modification, is
7# permitted provided that the following conditions are met:
8#
9# 1. Redistributions of this script must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11#
12#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
13#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
15#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
18#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23# Modified 2011 by Eric Hameleers <alien at slackware.com> for ARM port.
24
25
26PKGNAM=binutils
27VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
28BUILD=${BUILD:-2}
29
30# Automatically determine the architecture we're building on:
31MARCH=$( uname -m )
32if [ -z "$ARCH" ]; then
33  case "$MARCH" in
34    i?86)    export ARCH=i586 ;;
35    armv7hl) export ARCH=$MARCH ;;
36    arm*)    export ARCH=arm ;;
37    # Unless $ARCH is already set, use uname -m for all other archs:
38    *)       export ARCH=$MARCH ;;
39  esac
40fi
41
42NUMJOBS=${NUMJOBS:-" -j7 "}
43
44# Uncomment this to include the experimental gold linker:
45GOLD=" --enable-gold=yes --enable-ld=default "
46
47# Set to ld.gold or ld.bfd:
48DEFAULT_LD=ld.bfd
49
50# The --enable-initfini-array option was added in binutils-2.21.51.0.3.
51# This option currently causes a world of hurt trying to compile glibc,
52# and might break static libraries or cause other ill effects.  There
53# is an upstream patch for glibc but it does not avoid all of the known
54# problems (and there may be some unknown ones, too), so we will avoid
55# introducing this feature for now.
56# References:
57# http://sourceware.org/bugzilla/show_bug.cgi?id=12343
58# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
59NO_INITFINI=" --disable-initfini-array "
60
61if [ "$ARCH" = "i586" ]; then
62  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
63  # The config option below is currently needed to compile on x86:
64  WERROR="--enable-werror=no"
65  LIBDIRSUFFIX=""
66elif [ "$ARCH" = "i686" ]; then
67  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
68  # The config option below is currently needed to compile on x86:
69  WERROR="--enable-werror=no"
70  LIBDIRSUFFIX=""
71elif [ "$ARCH" = "s390" ]; then
72  SLKCFLAGS="-O2"
73  LIBDIRSUFFIX=""
74elif [ "$ARCH" = "x86_64" ]; then
75  SLKCFLAGS="-O2 -fPIC"
76  LIBDIRSUFFIX="64"
77elif [ "$ARCH" = "armv7hl" ]; then
78  SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16"
79  LIBDIRSUFFIX=""
80else
81  SLKCFLAGS="-O2"
82  LIBDIRSUFFIX=""
83fi
84
85case "$ARCH" in
86    arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
87    *)    TARGET=$ARCH-slackware-linux ;;
88esac
89
90CWD=$(pwd)
91TMP=${TMP:-/tmp}
92PKG=$TMP/package-binutils
93
94rm -rf $PKG
95mkdir -p $TMP $PKG
96
97cd $TMP
98rm -rf binutils-$VERSION
99tar xvf $CWD/binutils-$VERSION.tar.xz || \
100  tar xvf $CWD/binutils-$VERSION.tar.bz2 || exit 1
101cd binutils-$VERSION
102
103# Various upstream patches:
104zcat $CWD/patches/binutils-2.20.51.0.2-libtool-lib64.patch.gz | patch -p1 --verbose || exit 1
105zcat $CWD/patches/binutils-2.20.51.0.10-ppc64-pie.patch.gz | patch -p1 --verbose || exit 1
106zcat $CWD/patches/binutils-2.25-version.patch.gz | patch -p1 --verbose || exit 1
107zcat $CWD/patches/binutils-2.25-set-long-long.patch.gz | patch -p1 --verbose || exit 1
108zcat $CWD/patches/binutils-2.20.51.0.10-copy-osabi.patch.gz | patch -p1 --verbose || exit 1
109zcat $CWD/patches/binutils-2.20.51.0.10-sec-merge-emit.patch.gz | patch -p1 --verbose || exit 1
110zcat $CWD/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch.gz | patch -p1 --verbose || exit 1
111zcat $CWD/patches/binutils-2.24-ldforcele.patch.gz | patch -p1 --verbose || exit 1
112zcat $CWD/patches/binutils-2.25.1-cleansweep.patch.gz | patch -p2 --verbose || exit 1
113
114# Export the demangle.h header file:
115zcat $CWD/patches/binutils.export.demangle.h.diff.gz | patch -p1 --verbose || exit 1
116# Don't check to see if "config.h" was included in the installed headers:
117zcat $CWD/patches/binutils.no-config-h-check.diff.gz | patch -p1 --verbose || exit 1
118
119# Set %version to something halfway meaningful:
120sed -i -e 's/%''{release}/slack15/g' bfd/Makefile{.am,.in}
121
122chown -R root:root .
123find . \
124  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
125  -exec chmod 755 {} \; -o \
126  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
127  -exec chmod 644 {} \;
128
129# End of preparations
130if echo "$*" | grep -qw -- --prep ; then
131  exit 0
132fi
133
134# Build for an x86 glibc2-based Linux system:
135CFLAGS="$SLKCFLAGS" \
136./configure \
137  --prefix=/usr \
138  --libdir=/usr/lib${LIBDIRSUFFIX} \
139  --mandir=/usr/man \
140  --infodir=/usr/info \
141  --with-docdir=/usr/doc/binutils-$VERSION \
142  --disable-compressed-debug-sections \
143  --enable-shared \
144  --enable-multilib \
145  --enable-64-bit-bfd \
146  --enable-plugins \
147  --enable-threads \
148  --enable-targets=i386-efi-pe,${TARGET} \
149  --enable-install-libiberty \
150  $GOLD \
151  $NO_INITFINI \
152  $WERROR \
153  --build=$TARGET \
154  || exit 1
155
156make clean || exit 1
157make $NUMJOBS || make || exit 1
158make install DESTDIR=$PKG || exit 1
159
160# Differentiate between BSD strings and GNU strings
161( cd $PKG/usr/bin ; mv strings strings-GNU )
162( cd $PKG/usr/man/man1 ; mv strings.1 strings-GNU.1 )
163
164# Move ldscripts to /usr/lib${LIBDIRSUFFIX}, and then put symlinks in place
165mv $PKG/usr/${TARGET}/lib/ldscripts $PKG/usr/lib${LIBDIRSUFFIX}
166( cd $PKG/usr/${TARGET}
167  ln -s /usr/lib${LIBDIRSUFFIX}/ldscripts lib/ldscripts
168  for FILE in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip ; do
169    if [ -r "/usr/bin/$FILE" ]; then
170      rm -f bin/$FILE
171      ln -s /usr/bin/$FILE bin/$FILE
172    fi
173  done
174)
175
176# If the requested default linker is present, make it the default:
177# Set the link differently on the system to change the default at runtime.
178if [ -r $PKG/usr/bin/$DEFAULT_LD ]; then
179  ( cd $PKG/usr/bin ; rm -f ld ; ln -sf $DEFAULT_LD ld )
180fi
181     
182find $PKG | xargs file | grep -e "executable" -e "shared object" \
183  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
184
185# Remove some unneeded man pages, and then compress the rest
186rm -f $PKG/usr/man/man1/{dlltool,windres}.1
187( cd $PKG/usr/man
188  find . -type f -exec gzip -9 {} \;
189  for i in $(find . -type l) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
190)
191
192# Compress info pages
193rm -f $PKG/usr/info/dir
194gzip -9 $PKG/usr/info/*
195
196mkdir -p $PKG/usr/doc/binutils-$VERSION
197cp \
198  COPYING* MAI* README* \
199  $PKG/usr/doc/binutils-$VERSION
200
201# If there's a ChangeLog, installing at least part of the recent history
202# is useful, but don't let it get totally out of control:
203if [ -r ChangeLog ]; then
204  DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION)
205  cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog
206  touch -r ChangeLog $DOCSDIR/ChangeLog
207fi
208
209chown -R root:root $PKG/usr/doc/binutils-$VERSION
210
211# Add slack-desc:
212mkdir -p $PKG/install
213cat $CWD/slack-desc > $PKG/install/slack-desc
214
215cd $PKG
216/sbin/makepkg -l y -c n $TMP/binutils-$VERSION-$ARCH-$BUILD.txz
217
218cat << EOF
219
220#############################
221oprofile links to libbfd so
222be sure to recompile that
223#############################
224
225EOF
Note: See TracBrowser for help on using the repository browser.