summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2009-06-21 10:06:52 +0000
committerFabian Groffen <grobian@gentoo.org>2009-06-21 10:06:52 +0000
commit740526828429ff6690955c9e4833d36af9b81da8 (patch)
tree968fbb21f8257eda0b64a1b42e8face328d62275 /sys-devel/binutils-apple
parentHousekeeping, Sir (diff)
downloadgentoo-2-740526828429ff6690955c9e4833d36af9b81da8.tar.gz
gentoo-2-740526828429ff6690955c9e4833d36af9b81da8.tar.bz2
gentoo-2-740526828429ff6690955c9e4833d36af9b81da8.zip
add sys-devel/binutils-apple from Gentoo Prefix tree
(Portage version: 2.1.6.13/cvs/Linux x86_64)
Diffstat (limited to 'sys-devel/binutils-apple')
-rw-r--r--sys-devel/binutils-apple/ChangeLog70
-rw-r--r--sys-devel/binutils-apple/binutils-apple-3.1.1.ebuild212
-rw-r--r--sys-devel/binutils-apple/binutils-apple-3.1.2-r1.ebuild244
-rw-r--r--sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild214
-rw-r--r--sys-devel/binutils-apple/files/Makefile12
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch69
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch98
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch17
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch15
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch38
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch15
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch17
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch53
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch102
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch11
-rw-r--r--sys-devel/binutils-apple/metadata.xml5
16 files changed, 1192 insertions, 0 deletions
diff --git a/sys-devel/binutils-apple/ChangeLog b/sys-devel/binutils-apple/ChangeLog
new file mode 100644
index 000000000000..6a519aa82f67
--- /dev/null
+++ b/sys-devel/binutils-apple/ChangeLog
@@ -0,0 +1,70 @@
+# ChangeLog for sys-devel/binutils-apple
+# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/ChangeLog,v 1.1 2009/06/21 10:06:52 grobian Exp $
+
+*binutils-apple-3.1.2-r1 (01 Jun 2009)
+
+ 01 Jun 2009; Fabian Groffen <grobian@gentoo.org>
+ +binutils-apple-3.1.2-r1.ebuild:
+ Version bump for 64-bits native testing purposes, not yet ready for
+ prime-time
+
+ 01 Jan 2009; Fabian Groffen <grobian@gentoo.org>
+ +files/binutils-apple-3.1.2-as-Makefile.patch,
+ binutils-apple-3.1.2.ebuild, binutils-apple-3.1.2.ebuild:
+ Add patch to avoid having to do a make -k
+
+*binutils-apple-3.1.2 (21 Dec 2008)
+
+ 21 Dec 2008; Fabian Groffen <grobian@gentoo.org>
+ binutils-apple-3.1.2.ebuild, ChangeLog:
+ Version bump to Xcode Tools 3.1.2
+
+*binutils-apple-3.1.1 (08 Oct 2008)
+
+ 08 Oct 2008; Fabian Groffen <grobian@gentoo.org>
+ +files/binutils-apple-3.1.1-as-dir.patch,
+ +files/binutils-apple-3.1.1-libtool-ranlib.patch,
+ +files/binutils-apple-3.1.1-ranlib.patch,
+ -files/20080922-libtool-ranlib.patch,
+ +files/binutils-apple-3.1.1-no-efi-man.patch, -files/20080922-as.patch,
+ -files/20080922-as-dir.patch, -files/20080922-nmedit.patch,
+ +files/binutils-apple-3.1.1-no-oss-dir.patch,
+ -files/20080922-no-efi-man.patch, -files/20080922-no-oss-dir.patch,
+ -files/20080922-ranlib.patch, +files/binutils-apple-3.1.1-as.patch,
+ +files/binutils-apple-3.1.1-nmedit.patch,
+ -files/20080922-no-headers.patch,
+ +files/binutils-apple-3.1.1-no-headers.patch,
+ -files/20080922-testsuite.patch,
+ +files/binutils-apple-3.1.1-testsuite.patch, +binutils-apple-3.1.1.ebuild,
+ -binutils-apple-20080922.ebuild:
+ Reversion to binutils-apple-3.1.1 matching Xcode release it comes from.
+
+ 03 Oct 2008; Fabian Groffen <grobian@gentoo.org>
+ +files/20080922-as-dir.patch, +files/Makefile,
+ binutils-apple-20080922.ebuild:
+ Add latest patches by Elias Pipping to get as behave nicely.
+
+ 28 Sep 2008; Fabian Groffen <grobian@gentoo.org>
+ +files/20080922-no-headers.patch, binutils-apple-20080922.ebuild:
+ Add patch from pipping to remove obsolete headers, manpages and includes
+
+ 28 Sep 2008; Fabian Groffen <grobian@gentoo.org>
+ +files/20080922-libtool-ranlib.patch, binutils-apple-20080922.ebuild:
+ Add patch to make libtool better detect whether it's called as ranlib
+
+ 28 Sep 2008; Fabian Groffen <grobian@gentoo.org> +files/20080922-as.patch,
+ binutils-apple-20080922.ebuild:
+ Two patches by Elias pipping: 1) fix version string of ld64 2) no longer
+ build hppa, sparc, etc. assemblers.
+
+*binutils-apple-20080922 (27 Sep 2008)
+
+ 27 Sep 2008; Fabian Groffen <grobian@gentoo.org> +.,
+ +files/20080922-nmedit.patch, +files/20080922-no-oss-dir.patch, +files,
+ +files/20080922-no-efi-man.patch, +files/20080922-ranlib.patch,
+ +files/20080922-testsuite.patch, +metadata.xml,
+ +binutils-apple-20080922.ebuild:
+ Initial import of binutils-apple, Apple's linker tools, based on the work by
+ Elias Pipping in bug #238601. Not ready for public consumption.
+
diff --git a/sys-devel/binutils-apple/binutils-apple-3.1.1.ebuild b/sys-devel/binutils-apple/binutils-apple-3.1.1.ebuild
new file mode 100644
index 000000000000..99cb28dae701
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-3.1.1.ebuild
@@ -0,0 +1,212 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-3.1.1.ebuild,v 1.1 2009/06/21 10:06:52 grobian Exp $
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test mirror" # the test suite will test what's installed.
+
+LD64=ld64-85.2.2
+CCTOOLS=cctools-698
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools 3.1.1"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.gentoo.org/~grobian/distfiles/${LD64}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${CCTOOLS}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x86-macos"
+IUSE="test"
+SLOT="0"
+
+DEPEND="sys-devel/binutils-config
+ test? ( >=dev-lang/perl-5.8.8 )"
+RDEPEND="${DEPEND}"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}"
+else
+ SLOT="0"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+unpack_ld64() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/Makefile .
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64}\\n\""
+ sed -i \
+ -e '/^#define LTO_SUPPORT 1/s:1:0:' \
+ ObjectDump.cpp
+ echo '#undef LTO_SUPPORT' > configure.h
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ elog "Deleted $c tests that were bound to fail"
+}
+
+src_unpack() {
+ unpack ${A}
+ unpack_ld64
+ cd "${S}"
+
+ epatch "${FILESDIR}"/${P}-as.patch
+ epatch "${FILESDIR}"/${P}-as-dir.patch
+ epatch "${FILESDIR}"/${P}-ranlib.patch
+ epatch "${FILESDIR}"/${P}-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${P}-nmedit.patch
+ epatch "${FILESDIR}"/${P}-no-efi-man.patch
+ epatch "${FILESDIR}"/${P}-no-headers.patch
+ epatch "${FILESDIR}"/${P}-no-oss-dir.patch
+ epatch "${FILESDIR}"/${P}-testsuite.patch
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+compile_ld64() {
+ cd "${S}"/${LD64}/src
+ # 'struct linkedit_data_command' is defined in mach-o/loader.h on leopard,
+ # but not on tiger.
+ [[ ${CHOST} == *-apple-darwin8 ]] && \
+ append-flags -isystem "${S}"/${CCTOOLS}/include/
+ emake
+ use test && emake build_test
+}
+
+compile_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LTO= \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ RC_CFLAGS="${CFLAGS}"
+ cd "${S}"/${CCTOOLS}/as
+ # the errors can be ignored
+ emake -k \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}"
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}"
+}
+
+src_compile() {
+ compile_cctools
+ compile_ld64
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-3.1.2-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-3.1.2-r1.ebuild
new file mode 100644
index 000000000000..28ca5bcda71e
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-3.1.2-r1.ebuild
@@ -0,0 +1,244 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-3.1.2-r1.ebuild,v 1.1 2009/06/21 10:06:52 grobian Exp $
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-85.2.1
+CCTOOLS=cctools-698.1
+LP64PATCHES=binutils-apple-LP64-patches-1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools 3.1.2"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.gentoo.org/~grobian/distfiles/${LD64}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${CCTOOLS}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${LP64PATCHES}.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="test"
+SLOT="0"
+
+DEPEND="sys-devel/binutils-config
+ test? ( >=dev-lang/perl-5.8.8 )"
+RDEPEND="${DEPEND}"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}"
+else
+ SLOT="0"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+unpack_ld64() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/Makefile .
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ sed -i \
+ -e '/^#define LTO_SUPPORT 1/s:1:0:' \
+ ObjectDump.cpp || die
+ echo '#undef LTO_SUPPORT' > configure.h
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ elog "Deleted $c tests that were bound to fail"
+}
+
+src_unpack() {
+ unpack ${A}
+ unpack_ld64
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-3.1.1-as.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-efi-man.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.2-as-Makefile.patch
+ epatch "${WORKDIR}"/LP64/cctools/*.patch
+ cd "${S}"/${LD64}
+ epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+ epatch "${WORKDIR}"/LP64/ld64/*.patch
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+ ebegin "patching for LP64 mode"
+ ebegin " replacing SWAP_LONG() with SWAP_INT()"
+ find . -name "*.c" -print0 | xargs -0 sed \
+ -i \
+ -e 's/SWAP_LONG((long)/SWAP_INT((int)/g' \
+ -e 's/SWAP_LONG(/SWAP_INT(/g'
+ eend $?
+ ebegin " replacing sizeof(long) with sizeof(int)"
+ find . -name "*.c" -print0 | xargs -0 sed \
+ -i \
+ -e 's/sizeof(long)/sizeof(int)/g' \
+ -e 's/sizeof(unsigned long)/sizeof(unsigned int)/g' \
+ && sed -i \
+ -e '/long long \*/!s/long \*/int */g' \
+ ${CCTOOLS}/misc/{strip,lipo}.*
+ eend $?
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+compile_ld64() {
+ cd "${S}"/${LD64}/src
+ # 'struct linkedit_data_command' is defined in mach-o/loader.h on leopard,
+ # but not on tiger.
+ [[ ${CHOST} == *-apple-darwin8 ]] && \
+ append-flags -isystem "${S}"/${CCTOOLS}/include/
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LTO= \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_cctools
+ compile_ld64
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ local ED=${ED-${D}}
+
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild b/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild
new file mode 100644
index 000000000000..b9210df0397b
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild
@@ -0,0 +1,214 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild,v 1.1 2009/06/21 10:06:52 grobian Exp $
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-85.2.1
+CCTOOLS=cctools-698.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools 3.1.2"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.gentoo.org/~grobian/distfiles/${LD64}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${CCTOOLS}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x86-macos"
+IUSE="test"
+SLOT="0"
+
+DEPEND="sys-devel/binutils-config
+ test? ( >=dev-lang/perl-5.8.8 )"
+RDEPEND="${DEPEND}"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}"
+else
+ SLOT="0"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+unpack_ld64() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/Makefile .
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64}\\n\""
+ sed -i \
+ -e '/^#define LTO_SUPPORT 1/s:1:0:' \
+ ObjectDump.cpp
+ echo '#undef LTO_SUPPORT' > configure.h
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ elog "Deleted $c tests that were bound to fail"
+}
+
+src_unpack() {
+ unpack ${A}
+ unpack_ld64
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-3.1.1-as.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-efi-man.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.2-as-Makefile.patch
+ cd "${S}"/${LD64}
+ epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+compile_ld64() {
+ cd "${S}"/${LD64}/src
+ # 'struct linkedit_data_command' is defined in mach-o/loader.h on leopard,
+ # but not on tiger.
+ [[ ${CHOST} == *-apple-darwin8 ]] && \
+ append-flags -isystem "${S}"/${CCTOOLS}/include/
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LTO= \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ RC_CFLAGS="${CFLAGS}" || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_cctools
+ compile_ld64
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ local ED=${ED-${D}}
+
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/files/Makefile b/sys-devel/binutils-apple/files/Makefile
new file mode 100644
index 000000000000..9d8f92818a87
--- /dev/null
+++ b/sys-devel/binutils-apple/files/Makefile
@@ -0,0 +1,12 @@
+all: ld64 rebase
+
+build_test: machocheck ObjectDump
+
+ld64: debugline.o Options.o ld.o version.o
+ $(CXX) $(LDFLAGS) -o $@ $^
+
+machocheck: machochecker.o
+ $(CXX) $(LDFLAGS) -o $@ $^
+
+ObjectDump: ObjectDump.o debugline.o
+ $(CXX) $(LDFLAGS) -o $@ $^
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch
new file mode 100644
index 000000000000..8d9203e33953
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch
@@ -0,0 +1,69 @@
+handles the libexecdir for as and other fixes
+
+--- cctools-698/as/driver.c
++++ cctools-698/as/driver.c
+@@ -27,6 +27,9 @@
+ char **envp)
+ {
+ const char *LIB =
++#ifdef ASLIBEXECDIR
++ ASLIBEXECDIR;
++#else
+ #if defined(__OPENSTEP__) || defined(__HERA__) || \
+ defined(__GONZO_BUNSEN_BEAKER__) || defined(__KODIAK__)
+ "/usr/libexec/";
+@@ -40,6 +42,7 @@
+ #else
+ "/usr/local/libexec/gcc/darwin/";
+ #endif
++#endif
+ const char *AS = "/as";
+
+ int i;
+@@ -170,7 +170,11 @@
+ }
+
+ }
++#ifndef ASLIBEXECDIR
+ as = makestr(prefix, LIB, arch_name, AS, NULL);
++#else
++ as = makestr(LIB, arch_name, AS, NULL);
++#endif
+
+ /*
+ * If this assembler exist try to run it else print an error message.
+@@ -182,6 +182,9 @@
+ else
+ exit(1);
+ }
++#ifdef ASLIBEXECDIR
++ as_local = "";
++#else
+ as_local = makestr(prefix, LOCALLIB, arch_name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+ argv[0] = as_local;
+@@ -193,6 +198,8 @@
+ exit(1);
+ }
+ else{
++#endif
++ {
+ printf("%s: assembler (%s or %s) for architecture %s not "
+ "installed\n", progname, as, as_local, arch_name);
+ arch_flags = get_arch_flags();
+@@ -183,6 +190,7 @@
+ printf("%s for architecture %s\n", as, arch_flags[i].name);
+ count++;
+ }
++#ifndef ASLIBEXECDIR
+ else{
+ as_local = makestr(LOCALLIB, arch_flags[i].name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+@@ -193,6 +201,7 @@
+ count++;
+ }
+ }
++#endif
+ }
+ if(count == 0)
+ printf("%s: no assemblers installed\n", progname);
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch
new file mode 100644
index 000000000000..c0cff44550db
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch
@@ -0,0 +1,98 @@
+make building for obsolete architectures optional.
+
+--- cctools-698/as/Makefile
++++ cctools-698/as/Makefile
+@@ -1,3 +1,4 @@
++BUILD_OBSOLETE_ARCH = yes
+ RC_OS = macos
+ export USE_APPLE_PB_SUPPORT = all
+ OFLAG = -Os
+@@ -31,26 +32,34 @@
+ SYMROOT = .
+ OBJROOT = .
+ SYM_DIRS = $(SYMROOT)/driver_dir \
+- $(SYMROOT)/a68_dir \
+- $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a386_dir \
+ $(SYMROOT)/ax86_64_dir \
+ $(SYMROOT)/appc_dir \
+- $(SYMROOT)/appc64_dir \
++ $(SYMROOT)/appc64_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++SYM_DIRS += \
++ $(SYMROOT)/a68_dir \
++ $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a860_dir \
+ $(SYMROOT)/ahppa_dir \
+ $(SYMROOT)/asparc_dir
++endif
+
+ OFILE_DIRS = $(OBJROOT)/driver_dir \
+- $(OBJROOT)/a68_dir \
+- $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a386_dir \
+ $(OBJROOT)/ax86_64_dir \
+ $(OBJROOT)/appc_dir \
+- $(OBJROOT)/appc64_dir \
++ $(OBJROOT)/appc64_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++OFILE_DIRS += \
++ $(OBJROOT)/a68_dir \
++ $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a860_dir \
+ $(OBJROOT)/ahppa_dir \
+ $(OBJROOT)/asparc_dir
++endif
+
+ BINDIR = /bin
+ USRBINDIR = /usr/bin
+@@ -109,9 +118,13 @@
+ OBJS_hppa = $(CFILES_hppa:.c=.o)
+ OBJS_sparc = $(CFILES_sparc:.c=.o)
+
+-all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a68_build a88_build a386_build \
+- ax86_64_build a860_build appc_build appc64_build ahppa_build \
+- $(A_BUILD) asparc_build
++all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a386_build \
++ ax86_64_build appc_build appc64_build \
++ $(A_BUILD)
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++all: a68_build a88_build a860_build ahppa_build asparc_build
++endif
+
+ all_test: a68_test a88_test a860_test a386_test appc_test ahppa_test
+
+@@ -414,12 +427,14 @@
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/ppc64
+ install -c -s -m 555 $(SYMROOT)/appc64_dir/as \
+ $(DSTROOT)$(LIBDIR)/ppc64/as
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m68k
+ install -c -s -m 555 $(SYMROOT)/a68_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m68k/as
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/sparc
+ install -c -s -m 555 $(SYMROOT)/asparc_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/sparc/as
++endif
+
+ nextstep_install: common_install
+ $(MKDIRS) $(DSTROOT)$(BINDIR)
+@@ -439,6 +454,7 @@
+ $(DSTROOT)$(LOCLIBDIR)/ppc/as
+
+ common_install:
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m88k
+ install -c -s -m 555 $(SYMROOT)/a88_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m88k/as
+@@ -448,6 +464,7 @@
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/i860
+ install -s -m 555 $(SYMROOT)/a860_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/i860/as
++endif
+
+ $(OFILE_DIRS) $(SYM_DIRS):
+ $(MKDIRS) $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch
new file mode 100644
index 000000000000..fc86ddea118a
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch
@@ -0,0 +1,17 @@
+match "ranlib" at the back of the string, such that <CHOST>-ranlib also
+works correctly
+
+--- cctools-698/misc/libtool.c
++++ cctools-698/misc/libtool.c
+@@ -336,8 +336,9 @@
+ p++;
+ else
+ p = argv[0];
+- if(strncmp(p, "ranlib", sizeof("ranlib") - 1) == 0)
+- cmd_flags.ranlib = TRUE;
++ if ((i = strlen(p)) >= sizeof("ranlib") - 1 &&
++ strcmp(p + (i - (sizeof("ranlib") - 1)), "ranlib") == 0)
++ cmd_flags.ranlib = TRUE;
+
+ /* The default is to used long names */
+ cmd_flags.use_long_names = TRUE;
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch
new file mode 100644
index 000000000000..3b14e3dd4e69
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch
@@ -0,0 +1,15 @@
+don't create a symlink to nmedit from the dir nmedit is in
+
+--- cctools-698/misc/Makefile
++++ cctools-698/misc/Makefile
+@@ -427,8 +427,10 @@
+ install -c -s -m 555 $(SYMROOT)/redo_prebinding.NEW \
+ $(DSTROOT)$(USRBINDIR)/redo_prebinding
+ install -c -s -m 555 $(SYMROOT)/nmedit.NEW $(DSTROOT)$(USRBINDIR)/nmedit
++ifneq "$(USRBINDIR)" "$(LOCBINDIR)"
+ (cd $(DSTROOT)$(LOCBINDIR); rm -f nmedit; \
+ ln -s $(USRBINDIR)/nmedit nmedit)
++endif
+ install -c -s -m 555 $(SYMROOT)/install_name_tool.NEW \
+ $(DSTROOT)$(USRBINDIR)/install_name_tool
+ install -c -s -m 555 $(SYMROOT)/codesign_allocate.NEW \
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch
new file mode 100644
index 000000000000..978f1aba9aee
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch
@@ -0,0 +1,38 @@
+don't install efi's manpages since we don't install efi
+
+--- cctools-698/man/Makefile
++++ cctools-698/man/Makefile
+@@ -27,14 +27,21 @@
+ MANL3 = libsyminfo.3 redo_prebinding.3
+
+ INSTALL_FILES = Makefile $(COMMON_MAN1) $(OTHER_MAN1) $(MAN3) $(MAN5) $(MANL) \
+- $(MANL3) $(DYLD_MAN1) $(DYLD_MAN3) $(DYLD_MANL3) $(EFI1) notes
++ $(MANL3) $(DYLD_MAN1) $(DYLD_MAN3) $(DYLD_MANL3) notes
++
++ifeq "$(EFITOOLS)" "efitools"
++ INSTALL_FILES += $(EFI1)
++endif
+
+ MANDIR = /usr/share/man
+ LOCMANDIR = /usr/local/man
+ EFIMANDIR = /usr/local/efi/share/man
+ DSTDIRS = $(DSTROOT)$(MANDIR)/man1 $(DSTROOT)$(MANDIR)/man3 \
+ $(DSTROOT)$(MANDIR)/man5 $(DSTROOT)$(LOCMANDIR)/man1 \
+- $(DSTROOT)$(LOCMANDIR)/man3 $(DSTROOT)$(EFIMANDIR)/man1
++ $(DSTROOT)$(LOCMANDIR)/man3
++ifeq "$(EFITOOLS)" "efitools"
++ DSTDIR += $(DSTROOT)$(EFIMANDIR)/man1
++endif
+
+ install: $(DSTDIRS) $(COMMON_MAN1) $(OTHER_MAN1) $(MAN3) $(MAN5) $(MANL) \
+ $(RC_OS) $(MANL3)
+@@ -51,7 +58,9 @@
+ install -c -m 444 $(MAN5) $(DSTROOT)$(MANDIR)/man5
+ install -c -m 444 $(MANL) $(DSTROOT)$(LOCMANDIR)/man1
+ install -c -m 444 $(MANL3) $(DSTROOT)$(LOCMANDIR)/man3
++ifeq "$(EFITOOLS)" "efitools"
+ install -c -m 444 $(EFI1) $(DSTROOT)$(EFIMANDIR)/man1
++endif
+ if [ $(OLD_DYLD_STUFF) ]; \
+ then \
+ install -c -m 444 $(DYLD_MANL3) $(DSTROOT)$(LOCMANDIR)/man3;\
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch
new file mode 100644
index 000000000000..098a95fb0de5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch
@@ -0,0 +1,15 @@
+get rid of libraries, includes, and obsolete manpages
+
+--- cctools-698/Makefile
++++ cctools-698/Makefile
+@@ -170,7 +170,9 @@
+ DSTROOT=$$DSTROOT install_tools lib_ofiles_install; \
+ fi
+
+-install_tools: installhdrs
++install_tools: installhdrs install_all_but_headers
++
++install_all_but_headers:
+ @if [ $(SRCROOT) ]; \
+ then \
+ CWD=`pwd`; cd "$(DSTROOT)"; DSTROOT=`pwd`; cd "$$CWD"; \
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch
new file mode 100644
index 000000000000..5ed823752357
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch
@@ -0,0 +1,17 @@
+don't create an OpenSource dir
+
+--- cctools-698/as/Makefile
++++ cctools-698/as/Makefile
+@@ -408,12 +408,6 @@
+ $(MKDIRS) $(DSTROOT)$(USRBINDIR)
+ install -c -s -m 555 $(SYMROOT)/driver_dir/driver \
+ $(DSTROOT)$(USRBINDIR)/as
+- $(MKDIRS) $(DSTROOT)/usr/local/OpenSourceVersions/
+- install -c -s -m 444 $(SRCROOT)/cctools.plist \
+- $(DSTROOT)/usr/local/OpenSourceVersions/cctools.plist
+- $(MKDIRS) $(DSTROOT)/usr/local/OpenSourceLicenses/
+- install -c -s -m 444 $(SRCROOT)/COPYING \
+- $(DSTROOT)/usr/local/OpenSourceLicenses/cctools.txt
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/ppc
+ install -c -s -m 555 $(SYMROOT)/appc_dir/as \
+ $(DSTROOT)$(LIBDIR)/ppc/as
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch
new file mode 100644
index 000000000000..94865fb126dd
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch
@@ -0,0 +1,53 @@
+run ranlib before installation so we needn't touch permissions
+
+--- cctools-698/libmacho/Makefile
++++ cctools-698/libmacho/Makefile
+@@ -316,29 +316,29 @@
+ $(MKDIRS) $(DSTROOT)$(SYSTEMDIR)
+ if [ $(SRCROOT) = . ]; \
+ then \
++ ranlib dtmp_obj/libmacho.a; \
+ install -c -m 444 dtmp_obj/libmacho.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+ (cd $(DSTROOT)$(SYSTEMDIR) ; \
+ rm -f libmacho_debug.a ; ln -s libmacho.a libmacho_debug.a); \
++ ranlib ptmp_obj/libmacho_pg.a; \
+ install -c -m 444 ptmp_obj/libmacho_pg.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
++ ranlib otmp_obj/libmacho_static.a; \
+ install -c -m 444 otmp_obj/libmacho_static.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+ else \
++ ranlib $(SYMROOT)/libmacho.a; \
+ install -c -m 444 $(SYMROOT)/libmacho.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+ (cd $(DSTROOT)$(SYSTEMDIR) ; \
+ rm -f libmacho_debug.a ; ln -s libmacho.a libmacho_debug.a); \
++ ranlib $(SYMROOT)/libmacho_pg.a; \
+ install -c -m 444 $(SYMROOT)/libmacho_pg.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
++ ranlib $(SYMROOT)/libmacho_static.a; \
+ install -c -m 444 $(SYMROOT)/libmacho_static.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+ fi
+
+ teflon_lib_ofiles_install nextstep_lib_ofiles_install:
+--- cctools-698/cbtlibs/Makefile
++++ cctools-698/cbtlibs/Makefile
+@@ -80,9 +80,9 @@
+
+ lib_ofiles_install: lib_ofiles
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)
++ ranlib $(SYMROOT)/libsyminfo.a
+ install -p -c -m 444 $(SYMROOT)/libsyminfo.a \
+ $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+- ranlib $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+
+ -include $(OFILE_DIR)/Makedep
+
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch
new file mode 100644
index 000000000000..b3913262db26
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch
@@ -0,0 +1,102 @@
+fix the test suite so it is even usable
+
+--- ld64-85.2.2/unit-tests/test-cases/commons-alignment/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/commons-alignment/Makefile
+@@ -29,9 +29,9 @@
+
+ all:
+ ${CC} ${CCFLAGS} foo.s -c -o foo.o
+- nm -m foo.o | grep '(alignment 2^6)' | ${FAIL_IF_EMPTY}
++ nm -m foo.o | fgrep '(alignment 2^6)' | ${FAIL_IF_EMPTY}
+ ${LD} foo.o -r -o foo2.o
+- nm -m foo2.o | grep '(alignment 2^6)' | ${PASS_IFF_STDIN}
++ nm -m foo2.o | fgrep '(alignment 2^6)' | ${PASS_IFF_STDIN}
+
+ clean:
+ rm -rf foo.o foo2.o
+--- ld64-85.2.2/unit-tests/test-cases/order_file/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/order_file/Makefile
+@@ -33,7 +33,7 @@
+ run: all
+
+ all:
+- as -arch ${ARCH} -L extra.s -o extra.o
++ as -L extra.s -o extra.o
+ ${CC} ${CCFLAGS} main.c extra.o -o main1 -Wl,-order_file -Wl,main1.order
+ ${FAIL_IF_BAD_MACHO} main1
+ nm -n -g -j main1 | grep "_main" > main1.nm
+@@ -44,7 +44,7 @@
+ nm -n -j main2 | egrep '^_[a-z]+[0-9]$$' > main2.nm
+ ${PASS_IFF} diff main2.nm main2.expected
+
+- ${CC} -arch ${ARCH} -c main.c -o main.o
++ ${CC} -c main.c -o main.o
+ ${CC} ${CCFLAGS} main.o extra.o -o main3 -Wl,-order_file -Wl,main3.order
+ ${FAIL_IF_BAD_MACHO} main3
+ nm -n -g -j main3 | grep "_main" > main3.nm
+--- ld64-85.2.2/unit-tests/test-cases/16-byte-alignment/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/16-byte-alignment/Makefile
+@@ -30,13 +30,13 @@
+ run: all
+
+ all:
+- ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -arch ${ARCH} -c -O2 tl_test2.c -o tl_test2-${ARCH}.o
++ ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -c -O2 tl_test2.c -o tl_test2-${ARCH}.o
+
+ # verify that the alignment is correct in the .o
+ ObjectDump -only _ai -align -no_content tl_test2-${ARCH}.o|${FAIL_IF_ERROR} grep '\<0 mod 16\>' >/dev/null
+
+ # now verify the executable
+- ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -arch ${ARCH} -O2 tl_test2-${ARCH}.o -o tl_test2-${ARCH}
++ ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -O2 tl_test2-${ARCH}.o -o tl_test2-${ARCH}
+ ${FAIL_IF_ERROR} sh -c "nm tl_test2-${ARCH}|grep '0 D _ai\>' >/dev/null"
+ ${PASS_IFF_GOOD_MACHO} tl_test2-${ARCH}
+
+--- ld64-85.2.2/unit-tests/test-cases/eh-strip-test/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/eh-strip-test/Makefile
+@@ -27,7 +27,7 @@
+
+
+ all:
+- ${FAIL_IF_ERROR} $(CXX) main.cxx -arch ${ARCH} -o main
++ ${FAIL_IF_ERROR} $(CXX) main.cxx -o main
+ ${FAIL_IF_ERROR} nm -j main | grep '\.eh$$'| ${FAIL_IF_STDIN}
+ ${PASS_IFF_GOOD_MACHO} main
+ clean:
+--- ld64-85.2.2/unit-tests/test-cases/strip-test2/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/strip-test2/Makefile
+@@ -50,10 +50,10 @@
+
+
+ all:
+- $(CXX) main.cxx -arch ${ARCH} -o main
++ $(CXX) main.cxx -o main
+ ${FAIL_IF_BAD_MACHO} main
+ ${FAIL_IF_ERROR} nm -j main >main-no-strip.nm
+- $(CXX) main.cxx -arch ${ARCH} -o main
++ $(CXX) main.cxx -o main
+ ${FAIL_IF_BAD_MACHO} main
+
+ # Make sure there are no symbols in the stripped file that aren't
+--- ld64-85.2.2/unit-tests/test-cases/literals-coalesce/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/literals-coalesce/Makefile
+@@ -32,7 +32,7 @@
+
+ all:
+ ${CC} ${ASMFLAGS} literals.s -c -o literals-${ARCH}.o
+- ${FAIL_IF_ERROR} ${OBJECTDUMP} literals-${ARCH}.o | grep 'name:'| uniq -c | grep -v '^ [1|2]' | ${FAIL_IF_STDIN}
++ ${FAIL_IF_ERROR} ${OBJECTDUMP} literals-${ARCH}.o | grep 'name:'| uniq -c | grep -v '^ *[1|2]' | ${FAIL_IF_STDIN}
+ ${LD} -arch ${ARCH} -r literals-${ARCH}.o -o literals-r-${ARCH}.o
+ ${FAIL_IF_ERROR} ${OBJECTDUMP} literals-r-${ARCH}.o | grep 'name:' | uniq -d | ${PASS_IFF_EMPTY}
+
+--- ld64-85.2.2/unit-tests/test-cases/stabs-coalesce/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/stabs-coalesce/Makefile
+@@ -38,7 +38,7 @@
+ ${FAIL_IF_BAD_MACHO} stabs-hello-${ARCH}
+ nm -ap stabs-hello-${ARCH} | grep FUN | grep _Z3fooi | wc -l > stabs-hello-foo-count
+ echo " 1" > one
+- ${PASS_IFF} diff stabs-hello-foo-count one
++ ${PASS_IFF} diff -w stabs-hello-foo-count one
+
+ hello.o : hello.cxx
+ ${CXX} ${CCXXFLAGS} -gstabs+ -gused hello.cxx -c -o $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch
new file mode 100644
index 000000000000..554fed1cbe39
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch
@@ -0,0 +1,11 @@
+--- as/Makefile
++++ as/Makefile
+@@ -343,7 +343,7 @@
+ makeUser.o $(LIBSTUFF_DIR) $(LIBSTUFF)
+ $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/as $(SYMROOT)/as.private.o
+
+-makeUser.c messages.c: make.h
++makeUser.c ../messages.c: make.h
+
+ make.h makeUser.c: make.defs
+ $(MIG) $(MIG_FLAGS) $(SRCROOT)/make.defs
diff --git a/sys-devel/binutils-apple/metadata.xml b/sys-devel/binutils-apple/metadata.xml
new file mode 100644
index 000000000000..925cf70da957
--- /dev/null
+++ b/sys-devel/binutils-apple/metadata.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>apple</herd>
+</pkgmetadata>