parameters:
- name: os
  type: string
  default: 'ubuntu2204'
- name: componentName
  type: string
  default: ''
- name: configureFlags
  type: string
  default: ''
- name: buildDir
  type: string
  default: '$(Build.SourcesDirectory)'
- name: installDir
  type: string
  default: '$(Build.BinariesDirectory)'
- name: makeCallPrefix
  type: string
  default: ''

steps:
- task: Bash@3
  displayName: '${{ parameters.componentName }} configure flags'
  inputs:
    targetType: inline
    workingDirectory: ${{ parameters.buildDir }}
    script: |
      ${{ iif(eq(parameters.os, 'almalinux8'), 'source /opt/rh/gcc-toolset-14/enable', '') }}
      ./configure --prefix=${{ parameters.installDir }} ${{ parameters.configureFlags }}
- task: Bash@3
  displayName: '${{ parameters.componentName }} make'
  inputs:
    targetType: inline
    workingDirectory: ${{ parameters.buildDir }}
    script: |
      ${{ iif(eq(parameters.os, 'almalinux8'), 'source /opt/rh/gcc-toolset-14/enable', '') }}
      ${{ parameters.makeCallPrefix }} make -j$(nproc)
- task: Bash@3
  displayName: '${{ parameters.componentName }} make install'
  inputs:
    targetType: inline
    workingDirectory: ${{ parameters.buildDir }}
    script: |
      ${{ iif(eq(parameters.os, 'almalinux8'), 'source /opt/rh/gcc-toolset-14/enable', '') }}
      make install
