name: ubuntu

on:
  push:
    paths-ignore:
    - '.github/workflows/**'
    - '!.github/workflows/ubuntu.yml'
  pull_request:
    paths-ignore:
    - '.github/workflows/**'
    - '!.github/workflows/ubuntu.yml'

jobs:
  ubuntu-20-04:
    runs-on: ubuntu-20.04
    steps:
    - name: checkout libva
      uses: actions/checkout@v3
      with:
        repository: intel/libva
        path: libva
    - name: checkout libva-utils
      uses: actions/checkout@v3
      with:
        path: libva-utils
    - name: install prerequisites
      run: |
        sudo apt-get update
        sudo apt-get install -y --no-install-recommends \
          libdrm-dev \
          libegl1-mesa-dev \
          libgl1-mesa-dev \
          libx11-dev \
          libxext-dev \
          libxfixes-dev \
          libwayland-dev
    - name: build libva
      run: |
        cd libva
        ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
        make -j$(nproc)
        sudo make install
    - name: build libva-utils
      run: |
        cd libva-utils
        ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
        make -j$(nproc)
        make check
        sudo make install

  ubuntu-18-04:
    runs-on: ubuntu-18.04
    steps:
    - name: checkout libva
      uses: actions/checkout@v3
      with:
        repository: intel/libva
        path: libva
    - name: checkout libva-utils
      uses: actions/checkout@v3
      with:
        path: libva-utils
    - name: install prerequisites
      run: |
        sudo apt-get update
        sudo apt-get install -y --no-install-recommends \
          libdrm-dev \
          libegl1-mesa-dev \
          libgl1-mesa-dev \
          libx11-dev \
          libxext-dev \
          libxfixes-dev \
          libwayland-dev
    - name: build libva
      run: |
        cd libva
        ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
        make -j$(nproc)
        sudo make install
    - name: build libva-utils
      run: |
        cd libva-utils
        ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
        make -j$(nproc)
        make check
        sudo make install
