distributable:
  url: https://github.com/p7zip-project/p7zip/archive/v{{version.raw}}.tar.gz
  strip-components: 1

versions:
  github: p7zip-project/p7zip # reads github release *names*
  strip: /^p7zip /

build:
  script:
    - run: mv makefile.macosx_llvm_64bits makefile.machine
      if: darwin
    - run: |
        mv makefile.linux_any_cpu makefile.machine
        sed -i.bak -e 's/-std=gnu/-fPIC -std=gnu/' \
          C/makefile.glb \
          CPP/7zip/CMAKE/CMakeLists.txt \
          makefile.glb
        rm C/makefile.glb.bak \
          CPP/7zip/CMAKE/CMakeLists.txt.bak \
          makefile.glb.bak
      if: linux

    - make --jobs {{ hw.concurrency }} all3
    - make DEST_HOME={{prefix}} DEST_MAN={{prefix}}/man install

    # relocatability
    - run: |
        for x in *; do
          echo "#!/bin/sh" > $x
          echo 'd="$(cd "$(dirname "$0")/.." && pwd)"' >> $x
          echo "exec \"\$d\"/lib/p7zip/$x \"\$@\"" >> $x
        done
      working-directory: ${{prefix}}/bin

provides:
  - bin/7z
  - bin/7za
  - bin/7zr

test:
  script: |
    7z a -t7z foo.7z $FIXTURE
    7z e foo.7z -oout
    test "hello world!" = "$(cat out/*)"
  fixture: hello world!
