#!/bin/sh

if ! LLVM_CONFIG=$(command -v "$LLVM_CONFIG"); then
  llvm_config_version=$(llvm-config --version 2>/dev/null)
  for version in $(cat "$(dirname $0)/llvm-versions.txt"); do
    LLVM_CONFIG=$(
    command -v llvm-config-${version%.*} || \
    command -v llvm-config-$version || \
    command -v llvm-config${version%.*}${version#*.} || \
    command -v llvm${version%.*}-config || \
    [ "${llvm_config_version#$version}" = "$llvm_config_version" ] || command -v llvm-config)
    [ "$LLVM_CONFIG" ] && break
  done
fi
printf "$LLVM_CONFIG"
