Skip to content

Instantly share code, notes, and snippets.

@ytsuboi
Created December 11, 2011 15:59
Show Gist options
  • Save ytsuboi/1461263 to your computer and use it in GitHub Desktop.
Save ytsuboi/1461263 to your computer and use it in GitHub Desktop.
MacPorts Portfile for avr-binutils @2.20.1a_1
# $Id: Portfile 78408 2011-05-07 00:01:50Z [email protected] $
PortSystem 1.0
name avr-binutils
version 2.20.1a
revision 1
# Parameters for this port.
set crossgcc-target avr
description FSF Binutils for avr cross development
long_description Free Software Foundation development toolchain ("binutils") for \
avr cross development.
platforms darwin
categories cross devel
maintainers gmail.com:metamagix
homepage http://www.gnu.org/software/binutils/binutils.html
master_sites gnu:binutils \
ftp://ftp.kernel.org/pub/linux/devel/binutils/ \
http://ftp.kernel.org/pub/linux/devel/binutils/
distname binutils-${version}
use_bzip2 yes
checksums 30-binutils-2.20.1-avr-size.patch \
rmd160 35a017052c2e726bc3f99170982661866a1836ed \
sha256 4c9ecd9adc4897d1067e0763b6fcc703748178472bc7828c894d525dc0c30f39 \
31-binutils-2.20.1-avr-coff.patch \
rmd160 dd1616c3cd2e5e7a59e21a9f82c99e09a8c60bad \
sha256 6fd2a43dc57a25826b62f32a6342ee1c2b66a34a334a3fe89a4e2a621baebf0a \
32-binutils-2.20.1-new-sections.patch \
rmd160 bd74161dde156e602b340b9d5034757dbc4f5139 \
sha256 9c8209c3a7cb9c4f46047bf724f4cd0f36ff7804667265043594ceae2246723b \
34-binutils-2.20.1-as-dwarf.patch \
rmd160 0898f846c0c128dcbca9a898b99966d81492ce2f \
sha256 0c2792732ad8f8d8247db6d89cf21777dd7a1b778e4aab108533cadfb575a1ac \
35-binutils-2.20.1-dwarf2-AVRStudio-workaround.patch \
rmd160 e71d5e530a9ec93879fcb23c569e1a0948a65be1 \
sha256 ff9d33324d072ecd1f4efa63deb342b5a7877fdf93853b4c5769e39b9bfb23a5 \
36-binutils-2.20.1-assembler-options.patch \
rmd160 39f7d460aeae0b017252f61854db33acb8382a6d \
sha256 505803a923c544d63f7675684a3cf3a0c69b11f2247b68b0b38b3e79879e2039 \
50-binutils-2.20.1-xmega.patch \
rmd160 c3ab340cd82cb0e924d0fcdfbcc24c1ce4b447e5 \
sha256 7a0a9bdd646b09c7e83ce4188e75df389309ce0fecbb00f7030e037ea06a2980 \
51-binutils-2.20.1-new-devices.patch \
rmd160 1c53c9b36abdf000573f726c4d5b1a04df10e311 \
sha256 958ebf14ac5232e46288a0ec3f005951989cb08fc468744a0de8c94c582d8ed0 \
52-binutils-2.20.1-avrtiny10.patch \
rmd160 bbe07d911752937a4434c9ceb3f7836c37b74b6f \
sha256 68604ec04ee71d3cdeec251a2989d0247bc33daaab3683350895c5848ef98e91 \
53-binutils-2.20.1-xmega128a1u-64a1u.patch \
rmd160 c4cb0cbba9b3cc363b9883537c96a45ced9e931f \
sha256 29a2003350eb9c6bf4d8f4730bb603fc106fa3e7a9961931e4dd2d7eb5dcc77d \
54-binutils-2.20.1-atxmega16x1-32x1.patch \
rmd160 d2073d4384695f6a92797df32bbd8df3984d38e8 \
sha256 b0e078db2a9ac7b733f8c4965447d16e2c90526715354061d495b18960fb7a4f \
55-binutils-2.20.1-atxmega128b1.patch \
rmd160 dafd2226da640932d3a2f37801728118c99f4b3e \
sha256 faeb2005519920f79f5feeea552451b54e6ee82effe0261fedb2adfb80e1c2ee \
56-binutils-2.20.1-atxmega256a3bu.patch \
rmd160 94a49a60e383f0542dc88c1c22e397396eb676a7 \
sha256 9f254aa2600ed36ffa3bd7955dd2ee412ef33b8f6c61427cde61b9f7acf7bba9 \
57-binutils-2.20.1-at90pwm161.patch \
rmd160 c5c42ced64a389dc079b225692a1216af85c3423 \
sha256 4e16e27aaa665e86e93d2503dea874fee80560a2ae17eb91c762787ec19b64e1 \
58-binutils-2.20.1-atmega16hvb-32hvb.patch \
rmd160 505fd714179635cc0978948b85757a55923c51e5 \
sha256 c2fc00bcf0ddd3d3b06c56826a35fcd8d688eb02d9b1714ce3b41de1a9c955f2 \
59-binutils-2.20.1-atmega32_5_50_90_pa.patch \
rmd160 4edaad919dc402c70ce7745a5f9cc09f636b8b82 \
sha256 df0f8cfb16f86cd4dc75794687f8958951fd29c6f96fa520f8b42a1a5301acba \
60-binutils-2.20.1-bug13789.patch \
rmd160 fbfe0640831f2c6d3248dc555db6743edf4a455b \
sha256 f0c13c28432c5f82f2140f43c949b9733cb62b26034533bcd92d1853ca520666 \
62-binutils-2.20.1-attiny1634.patch \
rmd160 8c0e399f82e974c2f91a780591285aabc210750d \
sha256 b7da93baf2af44df254fe0e35f976df53a1b5d3f88fd59451161d8bd7b73db60 \
64-binutils-2.20.1-atmega48pa.patch \
rmd160 7113d0c188510f89f41cff0b2a6dfa4a40ee36f5 \
sha256 080603b856a78d5c7b7301f59f12d9f66fabc1232d020b722d13d0c9adb6f271 \
binutils-2.20.1a.tar.bz2 \
rmd160 aebf86b8ae126fabd52450a81c7d491c40ff851d \
sha256 71d37c96451333c5c0b84b170169fdcb138bbb27397dc06281905d9717c8ed64
depends_lib port:gettext
# All cross ports violate the mtree layout.
destroot.violate_mtree yes
# Download everything to binutils/
dist_subdir binutils
# Build in a different directory, as advised in the README file.
pre-configure { system "cd ${workpath} && mkdir -p build"}
configure.dir ${workpath}/build
configure.cmd ${worksrcpath}/configure
configure.cc "cc -no-cpp-precomp"
# using --disable-werror because of
# "strings.c:419: warning: 'stat64' is deprecated (declared at /usr/include/sys/stat.h:465)"
# don't know how to fix this proper...
configure.args --disable-werror \
--infodir='${prefix}/share/info' \
--disable-nls \
--target=${crossgcc-target} \
--program-prefix=${crossgcc-target}- \
--mandir='${prefix}/share/man' \
--enable-install-libiberty \
--enable-install-libbfd
if {$build_arch != "" && ${os.platform} == "darwin"} {
configure.args-append --build=${build_arch}-apple-darwin${os.major} \
--host=${build_arch}-apple-darwin${os.major}
}
build.dir ${workpath}/build
patch_sites http://distribute.atmel.no/tools/opensource/avr-gcc/binutils-2.20.1/
patchfiles 30-binutils-2.20.1-avr-size.patch \
31-binutils-2.20.1-avr-coff.patch \
32-binutils-2.20.1-new-sections.patch \
34-binutils-2.20.1-as-dwarf.patch \
35-binutils-2.20.1-dwarf2-AVRStudio-workaround.patch \
36-binutils-2.20.1-assembler-options.patch \
50-binutils-2.20.1-xmega.patch \
51-binutils-2.20.1-new-devices.patch \
52-binutils-2.20.1-avrtiny10.patch \
53-binutils-2.20.1-xmega128a1u-64a1u.patch \
54-binutils-2.20.1-atxmega16x1-32x1.patch \
55-binutils-2.20.1-atxmega128b1.patch \
56-binutils-2.20.1-atxmega256a3bu.patch \
57-binutils-2.20.1-at90pwm161.patch \
58-binutils-2.20.1-atmega16hvb-32hvb.patch \
59-binutils-2.20.1-atmega32_5_50_90_pa.patch \
60-binutils-2.20.1-bug13789.patch \
62-binutils-2.20.1-attiny1634.patch \
64-binutils-2.20.1-atmega48pa.patch
# We don't want the etc module.
post-extract {
file rename ${workpath}/binutils-2.20.1 ${worksrcpath}
system "rm -rf ${worksrcpath}/etc"
}
post-patch {
namespace eval crossgcc {}
# Install avr-compatible libbfd/libiberty in the avr directory
reinplace "s|bfdlibdir=.*|bfdlibdir='${prefix}/avr/host/lib'|g" \
${worksrcpath}/bfd/configure \
${worksrcpath}/opcodes/configure
reinplace "s|bfdincludedir=.*|bfdincludedir='${prefix}/avr/host/include'|g" \
${worksrcpath}/bfd/configure \
${worksrcpath}/opcodes/configure
reinplace "s|libdir = .*|libdir = \"${prefix}/avr/host/lib\"|g" \
${worksrcpath}/libiberty/Makefile.in
reinplace "s|MULTIOSDIR = .*|MULTIOSDIR = |g" \
${worksrcpath}/libiberty/Makefile.in
# Fix the info pages and related stuff.
#
# path: path to the doc directory (e.g. gas/doc/)
# makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
# name: name of the info page (e.g. as)
# suffix: suffix of the souce page (texinfo or texi)
proc crossgcc::fixinfo { path makefile name suffix } {
global crossgcc-target worksrcpath
# Fix the source
reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
${worksrcpath}/${path}/${name}.${suffix}
reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
${worksrcpath}/${path}/${name}.${suffix}
reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
${worksrcpath}/${path}/${name}.${suffix}
# Fix the Makefile
reinplace "s|${name}.info|${crossgcc-target}-${name}.info|g" \
${worksrcpath}/${makefile}
reinplace "s|${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \
${worksrcpath}/${makefile}
# Rename the source
file rename ${worksrcpath}/${path}/${name}.${suffix} \
${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
# Fix install-info's dir.
# (note: this may be effectless if there was no info dir to be fixed)
reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-dir|g" \
"${worksrcpath}/${makefile}"
}
# Fix the gettext files and related stuff.
#
# module: name of the module (e.g. gas)
proc crossgcc::fixgettext { module } {
global crossgcc-target worksrcpath
if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
"${worksrcpath}/${module}/Makefile.in"
}
if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
"${worksrcpath}/${module}/doc/Makefile.in"
}
if { [ file exists "${worksrcpath}/${module}/po/Make-in" ] } {
reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
"${worksrcpath}/${module}/po/Make-in"
}
}
# gas/doc/as.texinfo
crossgcc::fixinfo gas/doc/ gas/doc/Makefile.in as texinfo
# bfd/doc/bfd.texinfo
crossgcc::fixinfo bfd/doc/ bfd/doc/Makefile.in bfd texinfo
# binutils/doc/binutils.texi
crossgcc::fixinfo binutils/doc/ binutils/doc/Makefile.in binutils texi
# gprof/gprof.texi
crossgcc::fixinfo gprof/ gprof/Makefile.in gprof texi
# ld/ld.texinfo
crossgcc::fixinfo ld/ ld/Makefile.in ld texinfo
# gettext stuff.
crossgcc::fixgettext bfd
crossgcc::fixgettext binutils
crossgcc::fixgettext gas
crossgcc::fixgettext gprof
crossgcc::fixgettext ld
crossgcc::fixgettext opcodes
}
post-destroot {
file rename "${destroot}/${prefix}/lib/libiberty.a" "${destroot}/${prefix}/avr/host/lib/"
}
# $Id: Portfile 78408 2011-05-07 00:01:50Z [email protected] $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment