name: make
on: [push, pull_request]
jobs:
  ubuntu:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-18.04, ubuntu-20.04]
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: |
          sudo apt -qq update
          sudo apt install -y texlive-binaries texlive-metapost libproj-dev libwxgtk3.0-gtk3-dev libvtk7-dev survex imagemagick ghostscript
          sudo sed -i '/pattern="PDF"/d' /etc/ImageMagick-6/policy.xml  # turn off policy preventing PDF conversion
      - name: compile therion
        run: |
          make config-debian
          make
          make tests
          make samples
          sudo make install
          ./therion --print-symbols
  mac:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-10.15, macos-11.0]
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: |
          brew update
          brew tap homebrew/core
          brew unlink gcc@8
          brew unlink gcc@9
          rm /usr/local/bin/2to3
          brew install wxmac vtk proj
      - name: compile therion
        run: |
          make config-macosx
          make ./therion
          make loch/loch
          make tests
          ./therion --version
  mxe-i686:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: |
          sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
          sudo add-apt-repository 'deb [arch=amd64] https://mirror.mxe.cc/repos/apt focal main'
          sudo apt -qq update
          sudo apt install -y mxe-i686-w64-mingw32.static-binutils mxe-i686-w64-mingw32.static-bzip2 mxe-i686-w64-mingw32.static-expat mxe-i686-w64-mingw32.static-freetype-bootstrap mxe-i686-w64-mingw32.static-gcc mxe-i686-w64-mingw32.static-gettext mxe-i686-w64-mingw32.static-glib mxe-i686-w64-mingw32.static-harfbuzz mxe-i686-w64-mingw32.static-jpeg mxe-i686-w64-mingw32.static-libiconv mxe-i686-w64-mingw32.static-libpng mxe-i686-w64-mingw32.static-tiff mxe-i686-w64-mingw32.static-vtk mxe-i686-w64-mingw32.static-wxwidgets mxe-i686-w64-mingw32.static-xz mxe-i686-w64-mingw32.static-zlib mxe-i686-w64-mingw32.static-proj
      - name: compile therion
        run: |
          export PATH=/usr/lib/mxe/usr/bin:$PATH
          perl makeconfig.pl PLATFORM WIN32CROSS
          cd loch; perl makeconfig.pl PLATFORM WIN32CROSS; cd ..
          make OUTDIR=. therion
          make OUTDIR=. loch/loch
  mxe-x86_64:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: |
          sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
          sudo add-apt-repository 'deb [arch=amd64] https://mirror.mxe.cc/repos/apt focal main'
          sudo apt -qq update
          sudo apt install -y mxe-x86-64-w64-mingw32.static-binutils mxe-x86-64-w64-mingw32.static-bzip2 mxe-x86-64-w64-mingw32.static-expat mxe-x86-64-w64-mingw32.static-freetype-bootstrap mxe-x86-64-w64-mingw32.static-gcc mxe-x86-64-w64-mingw32.static-gettext mxe-x86-64-w64-mingw32.static-glib mxe-x86-64-w64-mingw32.static-harfbuzz mxe-x86-64-w64-mingw32.static-jpeg mxe-x86-64-w64-mingw32.static-libiconv mxe-x86-64-w64-mingw32.static-libpng mxe-x86-64-w64-mingw32.static-tiff mxe-x86-64-w64-mingw32.static-vtk mxe-x86-64-w64-mingw32.static-wxwidgets mxe-x86-64-w64-mingw32.static-xz mxe-x86-64-w64-mingw32.static-zlib mxe-x86-64-w64-mingw32.static-proj
      - name: compile therion
        run: |
          export PATH=/usr/lib/mxe/usr/bin:$PATH
          perl makeconfig.pl PLATFORM WIN32CROSS
          cd loch; perl makeconfig.pl PLATFORM WIN32CROSS; cd ..
          make CROSS=x86_64-w64-mingw32.static- OUTDIR=. therion
          make CROSS=x86_64-w64-mingw32.static- OUTDIR=. loch/loch
  mingw:
    runs-on: windows-latest
    strategy:
      matrix:
        include: [
          { msystem: MINGW64, arch: x86_64 },
          { msystem: MINGW32, arch: i686   }
        ]
    defaults:
      run:
        shell: msys2 {0}
    steps:
      - uses: actions/checkout@v2
      - uses: msys2/setup-msys2@v2
        with:
          msystem: ${{ matrix.msystem }}
          update: true
          install: mingw-w64-${{ matrix.arch }}-cmake mingw-w64-${{ matrix.arch }}-proj mingw-w64-${{ matrix.arch }}-vtk mingw-w64-${{ matrix.arch }}-wxWidgets mingw-w64-${{ matrix.arch }}-gcc mingw-w64-${{ matrix.arch }}-make mingw-w64-${{ matrix.arch }}-tcl mingw-w64-${{ matrix.arch }}-jbigkit
      - name: compile therion
        env:
          WD: D:/a/_temp/msys/msys64/usr/bin/
        run: |
          mingw32-make config-win32
          mingw32-make OUTDIR=. therion
          mingw32-make OUTDIR=. loch/loch
          mingw32-make OUTDIR=. tests
