#!/bin/bash # binutils.SlackBuild # by Stuart Winter for the Slackware porting Project. # Heavily based on the original Slackware build script. # 30-May-2004 # Record toolchain & other info for the build log: slackbuildinfo # Paths to skeleton port's source & real Slackware source tree: export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM export PORTCWD=$PWD # Temporary build locations: export TMPBUILD=$TMP/build-$PKGNAM export PKG=$TMP/package-$PKGNAM mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD # Determine extra configurations for this architecture: case $ARCH in arm) WERROR="--enable-werror=no" # Needed for i486 but doesn't harm on ARM ;; esac # The --enable-initfini-array option was added in binutils-2.21.51.0.3. # This option currently causes a world of hurt trying to compile glibc, # and might break static libraries or cause other ill effects. There # is an upstream patch for glibc but it does not avoid all of the known # problems (and there may be some unknown ones, too), so we will avoid # introducing this feature for now. # References: # http://sourceware.org/bugzilla/show_bug.cgi?id=12343 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770 NO_INITFINI=" --disable-initfini-array " # Uncomment this to include the experimental gold linker: GOLD=" --enable-gold=yes --enable-ld=default " # Set to ld.gold or ld.bfd: DEFAULT_LD=ld.bfd # Extract source: # It's easier to stick with what Debian are doing. I've been bitten too many # times in the past by weirdness with binutils. #tar xvvf $PORTCWD/sources/$PKGNAM*$VERSION*tar*z* tar xvvf $CWD/$PKGNAM*$VERSION*?z* cd $PKGNAM* || exit 1 slackhousekeeping # Apply Slackware patches: zcat $CWD/patches/binutils-2.20.51.0.2-libtool-lib64.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.20.51.0.10-ppc64-pie.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.25-version.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.25-set-long-long.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.20.51.0.10-copy-osabi.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.20.51.0.10-sec-merge-emit.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.22.52.0.1-relro-on-by-default.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.24-ldforcele.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.25.1-cleansweep.patch | patch -p2 --verbose || exit 1 zcat $CWD/patches/binutils-2.26-formatting.patch | patch -p2 --verbose || exit 1 zcat $CWD/patches/binutils-2.26-fix-compile-warnings.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.26-Bsymbolic_PIE.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.26-lto.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-rh1312151.patch | patch -p1 --verbose || exit 1 zcat $CWD/patches/binutils-2.26-fix-GOT-offset-calculation.patch | patch -p1 --verbose || exit 1 # Export the demangle.h header file: zcat $CWD/patches/binutils.export.demangle.h.diff.gz | patch -p1 --verbose || exit 1 # Don't check to see if "config.h" was included in the installed headers: zcat $CWD/patches/binutils.no-config-h-check.diff.gz | patch -p1 --verbose || exit 1 # Apply local patches: if [ -f $PORTCWD/sources/$PKGNAM*diff* ]; then echo "*** Applying patches from Debian ***" ( xz -dc $PORTCWD/sources/$PKGNAM*diff* | patch -p1 ) || exit 1 # grep -A99 "# patches taken from the trunk" debian/patches/series | egrep -v "^#" | while read pf ; do for pf in \ \ pr-ld-19263.diff \ pr-ld-19264.diff ; do auto_apply_patch debian/patches/$pf || exit 1 done fi # Configure: CFLAGS="$SLKCFLAGS" \ CPPFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ ./configure $WERROR $GOLD $NO_INITFINI \ --prefix=/usr \ --mandir=/usr/man \ --infodir=/usr/info \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --with-docdir=/usr/doc/binutils-$VERSION \ --enable-targets=i386-efi-pe,$ARCH-slackware-linux-gnueabi \ --enable-install-libiberty \ --enable-shared \ --enable-plugins \ --enable-threads \ --build=$ARCH-slackware-linux-gnueabi || failconfig # Not for ARM: # --enable-multilib \ # --enable-64-bit-bfd \ # Build: make clean make $NUMJOBS || make || failmake make info # Install into package: make install DESTDIR=$PKG || exit 1 # Differentiate between BSD strings and GNU strings ( cd $PKG/usr/bin ; mv strings strings-GNU ) ( cd $PKG/usr/man/man1 ; mv strings.1 strings-GNU.1 ) # Move ldscripts to /usr/lib${LIBDIRSUFFIX}, and then put symlinks in place mv $PKG/usr/${ARCH}-slackware-linux-gnueabi/lib/ldscripts $PKG/usr/lib${LIBDIRSUFFIX} ( cd $PKG/usr/${ARCH}-slackware-linux-gnueabi ln -vfs ../../lib${LIBDIRSUFFIX}/ldscripts lib/ for FILE in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip ; do if [ -r "/usr/bin/$FILE" ]; then rm -f bin/$FILE ln -s /usr/bin/$FILE bin/$FILE fi done ) # If the requested default linker is present, make it the default: # Set the link differently on the system to change the default at runtime. if [ -r $PKG/usr/bin/$DEFAULT_LD ]; then ( cd $PKG/usr/bin ; rm -f ld ; ln -sf $DEFAULT_LD ld ) fi # Remove some unneeded man pages, and then compress the rest rm -f $PKG/usr/man/man1/{dlltool*,windres*,windmc*} ( cd $PKG/usr/man find . -type f -exec gzip -9 {} \; for i in $(find . -type l) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) # Remove unneeded binaries - these are for Windows: # This is probably a bit agressive actually, since it's only "windres" that doesn't # work ("cannot detect architecture") and causes builds to fail. #rm -fv $PKG/usr/bin/{windmc,dlltool,dllwrap,windres} #rm -fv $PKG/usr/*-slackware-linux*/bin/dlltool rm -fv $PKG/usr/bin/windres # Copy docs: mkdir -p $PKG/usr/doc/binutils-$VERSION cp \ $CWD/release.binutils-* \ COPYING* ChangeLog.linux MAI* README* \ $PKG/usr/doc/binutils-$VERSION changelogliposuction ChangeLog $PKGNAM $VERSION # Trim down a "ChangeLog" file # If necessary, start the fakeroot server so we can set file/dir ownerships: start_fakeroot # Apply generic Slackware packaging policies: cd $PKG slackstripall # strip all .a archives and all ELFs slackgzpages -i # compress man & info pages and delete usr/info/dir slackslack # chown -R root:root, chmod -R og-w, slackchown, slack644docs slackdesc # install slack-desc and doinst.sh slackmp # run makepkg -l y -c n # Perform any final checks on the package: cd $PKG slackhlinks # search for any hard links cat << EOF ###################################################################### Now rebuild oprofile because it links to libbfd (part of this package) ###################################################################### EOF