Commit c0a2d90c authored by Sam Stephenson's avatar Sam Stephenson
Browse files

Look for gcc-* anywhere in $PATH. Fixes #109

parent 8e6e2372
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -252,9 +252,7 @@ require_gcc() {

locate_gcc() {
  local gcc gccs
  shopt -s nullglob
  gccs=( /usr/bin/gcc-* )
  shopt -u nullglob
  IFS=: gccs=($(gccs_in_path))

  verify_gcc "$CC" ||
  verify_gcc "$(command -v gcc || true)" || {
@@ -266,6 +264,22 @@ locate_gcc() {
  return 1
}

gccs_in_path() {
  local gcc path paths
  local gccs=()
  IFS=: paths=($PATH)

  shopt -s nullglob
  for path in "${paths[@]}"; do
    for gcc in "$path"/gcc-*; do
      gccs["${#gccs[@]}"]="$gcc"
    done
  done
  shopt -u nullglob

  printf :%s "${gccs[@]}"
}

verify_gcc() {
  local gcc="$1"
  if [ -z "$gcc" ]; then