name: C-lang CI

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - name: install libs
        run: sudo apt install -y libglfw3-dev libgl-dev libv4l-dev libasound2-dev libbsd-dev
      - name: gcc
        run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DVIDEO_IN

  build-no-video:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - name: install libs
        run: sudo apt install -y libglfw3-dev libgl-dev libasound2-dev libbsd-dev
      - name: gcc
        run: mkdir -p build && gcc -v -Werror src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE

  build-release:
    needs: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - name: install libs
        run: sudo apt install -y libglfw3-dev libgl-dev libv4l-dev libasound2-dev libbsd-dev
      - name: aclocal
        run: aclocal
      - name: autoconf
        run: autoconf
      - name: automake
        run: automake --add-missing
      - name: configure
        run: ./configure
      - name: make
        run: make
      - name: make distcheck
        run: make distcheck
