name: hdf4 dev autotools icx CI

on:
  workflow_call:
    inputs:
      build_mode:
        description: "release vs. debug build"
        required: true
        type: string
      build_option:
        description: "--enable-production or --disable-production"
        required: true
        type: string

permissions:
  contents: read

jobs:
  intel_oneapi_linux:
    name: "linux-oneapi ${{ inputs.build_mode }}"
    runs-on: ubuntu-latest
    steps:
      - name: Get Sources
        uses: actions/checkout@v4.1.7

      - name: Install Dependencies
        shell: bash
        run: |
          sudo apt install -y autoconf automake libtool libtool-bin libaec-dev libjpeg-dev
          sudo apt install -y doxygen libncurses-dev libquadmath0 libstdc++6 libxml2
          sudo apt install -y zlib1g-dev libcurl4-openssl-dev libjpeg-dev wget curl bzip2
          sudo apt install -y m4 flex bison cmake libzip-dev openssl build-essential

      - name: Install oneAPI (Linux)
        uses: fortran-lang/setup-fortran@v1
        id: setup-fortran
        with:
          compiler: intel
          version: '2024.1'

      - name: Autotools Configure
        shell: bash
        env:
          CC: ${{ steps.setup-fortran.outputs.cc }}
        run: |
          sh ./autogen.sh
          mkdir "${{ runner.workspace }}/build"
          cd "${{ runner.workspace }}/build"
          $GITHUB_WORKSPACE/configure \
            ${{ inputs.build_option }} \
            --enable-netcdf \
            --enable-shared \
            --disable-fortran

      - name: Autotools Build
        shell: bash
        env:
          CC: ${{ steps.setup-fortran.outputs.cc }}
        run: |
          make -j3
        working-directory: ${{ runner.workspace }}/build

      - name: Autotools Run Tests
        shell: bash
        env:
          CC: ${{ steps.setup-fortran.outputs.cc }}
        run: |
          make check -j2
        working-directory: ${{ runner.workspace }}/build

      - name: Autotools Install
        shell: bash
        env:
          CC: ${{ steps.setup-fortran.outputs.cc }}
        run: |
          make install
        working-directory: ${{ runner.workspace }}/build

#      - name: Autotools Verify Install
#        shell: bash
#        env:
#          CC: ${{ steps.setup-fortran.outputs.cc }}
#        run: |
#          make check-install
#        working-directory: ${{ runner.workspace }}/build
