@@ -10,14 +10,14 @@ MFORT := "$(shell command -v amdflang)"
1010mtest: FC := $(MFORT) -std=f$(FSTD)
1111
1212# AMD AOCC Flang
13- DFORT := "$(shell find -L /opt/AMD -type f -name flang -exec test -x {} \; -print 2> /dev/null | sort | tail -n 1)"
13+ DFORT := "$(shell find -L /opt/AMD -type f -name flang -exec test -x {} \; -print 2> /dev/null | sort -V | tail -n 1)"
1414dtest: FC := $(DFORT) -Wall -Wextra -std=f$(FSTD) -Mstandard
1515
1616# LLVM Flang
1717# Note that AOMP and AOCC also provide "flang". We define FFORT as follows to make sure the correct
1818# one is being called. Otherwise, flang may be resolved to the one provided by AOMP or AOCC, which
1919# did happen in our tests.
20- FFORT := "$(shell find -L /usr/local/llvm* /usr/lib/llvm* /opt/homebrew /usr/local/opt /usr/local/Cellar -type f -name flang -exec test -x {} \; -print 2>/dev/null | sort | tail -n 1)"
20+ FFORT := "$(shell find -L /usr/local/llvm* /usr/lib/llvm* /opt/homebrew /usr/local/opt /usr/local/Cellar -type f -name flang -exec test -x {} \; -print 2>/dev/null | sort -V | tail -n 1)"
2121# If the above command fail to find flang (it happens on Windows), we try setting FFORT manually.
2222ifeq ($(FFORT),"") # The quotation marks are necessary
2323 FFORT := "$(shell command -v flang)"
@@ -27,10 +27,10 @@ ifeq ($(OS),Windows_NT)
2727 # Architecture part of the target triple, e.g., "x86_64" or "aarch64".
2828 ARCH := $(shell $(FFORT) -dumpmachine | cut -d- -f1)
2929 # Note the quotation marks to handle spaces in the path.
30- CLANGRT := "$(shell find "/c/Program Files/LLVM/lib" -name clang_rt.builtins*$(ARCH)* 2>/dev/null)"
30+ CLANGRT := "$(shell find "/c/Program Files/LLVM/lib" -name clang_rt.builtins*$(ARCH)* 2>/dev/null | sort -V | tail -n 1 )"
3131 # In case nothing is found above, we try clang_rt without the architecture part
3232 ifeq ($(CLANGRT),"")
33- CLANGRT := "$(shell find "/c/Program Files/LLVM/lib" -name "clang_rt.builtins*" -print -quit 2>/dev/null)"
33+ CLANGRT := "$(shell find "/c/Program Files/LLVM/lib" -name "clang_rt.builtins*" 2>/dev/null | sort -V | tail -n 1 )"
3434 endif
3535 FFORT := $(FFORT) $(CLANGRT)
3636endif
0 commit comments