distributable:
  url: https://ftp.gnu.org/gnu/binutils/binutils-{{ version.raw }}.tar.gz
  strip-components: 1

versions:
  url: https://ftp.gnu.org/gnu/binutils/
  match: /binutils-\d+\.\d+(\.\d+)?.tar.gz/
  strip:
    - /binutils-/
    - /.tar.gz/

build:
  dependencies:
    gnu.org/bison: '*'
    gnu.org/texinfo: '*'
    linux:
      gnu.org/gcc: '*'
  script: |
    ./configure $ARGS
    make --jobs {{ hw.concurrency }}
    make install
  env:
    ARGS:
      - --prefix={{ prefix }}
    linux:
      ARGS:
        - --enable-gold=yes

test:
  script: objdump -x $(which objdump) | grep -s $TEST_STRING
  env:
    # Representitive output to look for
    darwin:
      TEST_STRING: _opendir
    linux:
      TEST_STRING: GNU_HASH

provides:
  darwin:
    - bin/addr2line
    - bin/ar
    - bin/c++filt
    - bin/elfedit
    - bin/nm
    - bin/objcopy
    - bin/objdump
    - bin/ranlib
    - bin/readelf
    - bin/size
    - bin/strings
    - bin/strip
  linux:
    - bin/addr2line
    - bin/ar
    - bin/as
    - bin/c++filt
    - bin/elfedit
    - bin/gp-archive
    - bin/gp-collect-app
    - bin/gp-display-html
    - bin/gp-display-src
    - bin/gp-display-text
    - bin/gprof
    - bin/gprofng
    - bin/ld
    - bin/ld.bfd
    - bin/ld.gold
    - bin/nm
    - bin/objcopy
    - bin/objdump
    - bin/ranlib
    - bin/readelf
    - bin/size
    - bin/strings
    - bin/strip
