Skip to content

Instantly share code, notes, and snippets.

@exoosh
Created February 15, 2023 16:23
Show Gist options
  • Save exoosh/41b868ad169bce7ba5483fa508be4034 to your computer and use it in GitHub Desktop.
Save exoosh/41b868ad169bce7ba5483fa508be4034 to your computer and use it in GitHub Desktop.
Detecting most recent Clang tools (GNU make)
# Small function to use Bash to detect the latest available clang and clang++ binaries, if using them by that name fails
detect_newest=$(shell bash -c 'for v in "" -{32..1}; do test -n "$$(which -- $1$$v)" && { echo "$1$$v"; break; }; done')
override CXX:=$(call detect_newest,clang++)
override CC:=$(call detect_newest,clang)
$(warning CC: $(CC))
$(warning CXX: $(CXX))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment