name: makefile

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - '*'
env:
  DEBIAN_FRONTEND: noninteractive

jobs:
  linux-x86_64:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v3
      with:
        submodules: recursive
    - name: Set up dependencies
      run: |
        sudo apt-get update -qq
        sudo apt-get install -yq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev xvfb
    - name: Without any warnings
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror
      run: |
        make clean >/dev/null
        make -j $(nproc)
    - name: Run tests
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror
      run: |
        xvfb-run make -C tests run
    - name: As C++98 mode
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror -std=gnu++98
      run: |
        make clean >/dev/null
        make -j $(nproc)
    - name: No namespace
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror -DDONT_SET_USING_DISTRHO_NAMESPACE -DDONT_SET_USING_DGL_NAMESPACE
      run: |
        make clean >/dev/null
        make -j $(nproc)
    - name: Custom namespace
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror -DDISTRHO_NAMESPACE=WubbWubb -DDGL_NAMESPACE=DabDab
      run: |
        make clean >/dev/null
        make -j $(nproc)
    - name: With OpenGL 3.x
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror
      run: |
        make clean >/dev/null
        make -j $(nproc) USE_OPENGL3=true
    - name: Without Cairo
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror
      run: |
        make clean >/dev/null
        make -j $(nproc) HAVE_CAIRO=
    - name: Without OpenGL
      env:
        CFLAGS: -Werror
        CXXFLAGS: -Werror
      run: |
        make clean >/dev/null
        make -j $(nproc) HAVE_OPENGL=
