name: Autotools

on: [push, pull_request]

jobs:

 AutoMakeBuild:
    name: AutoMake/${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name: "Linux/GCC",
            os: ubuntu-latest,
            compiler: gcc,
            automakeconfig:
          }
        - {
            name: "Linux/GCC/EnableAssertions",
            os: ubuntu-latest,
            compiler: gcc,
            buildconfig: --enable-assertions
          }
        - {
            name: "Linux/GCC/EnableCustomModes",
            os: ubuntu-latest,
            compiler: gcc,
            buildconfig: --enable-assertions --enable-custom-modes
          }
        - {
            name: "Linux/GCC/EnableDNN",
            os: ubuntu-latest,
            compiler: gcc,
            buildconfig: --enable-assertions --enable-custom-modes --enable-dred --enable-osce
          }
    steps:
      - uses: actions/checkout@v3
        # No AutoMake on Mac so let's install it
      - name: Install AutoConf, AutoMake and LibTool on MacOSX
        if: matrix.config.os == 'macos-latest'
        run: brew install autoconf automake libtool
      - name: Autogen
        run: CC=${{ matrix.config.compiler }} ./autogen.sh
      - name: Configure
        run: CFLAGS="-mavx -mfma -mavx2 -O2 -ffast-math" ./configure --enable-float-approx ${{ matrix.config.buildconfig }}
      - name: Build
        run: make -j 2
      - name: Test
        run: make check -j 2
