name: macOS x86_64 Build Check

on:
  pull_request:
  push:
    paths:
      - 'Makefile'
  workflow_dispatch:

jobs:
  macos-intel-build:
    runs-on: macos-latest
    if: github.server_url == 'https://github.com'
    name: Build on Intel macOS

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Ensure x86_64
        run: |
          arch
          # Force x86_64 using Rosetta if needed
          if [ "$(arch)" != "x86_64" ]; then
            echo "Switching to Rosetta (x86_64)"
            softwareupdate --install-rosetta --agree-to-license
          fi

      - name: Install Homebrew dependencies
        run: |
          if ! command -v brew &> /dev/null; then
            /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
          fi
          brew update
          brew install faad2 taglib chafa fftw opus opusfile libogg libvorbis make curl

      - name: Build code
        run: make
