检查 makefile 中的 ifort/icc 版本
Checking ifort/icc version in makefile
在这个问题“Checking the gcc version in a Makefile?”中回答了如何提取 gcc 编译器的版本。但是,这似乎不适用于 icc 和 ifort 等 intel 编译器?
有谁知道使用 icc --version
或 ifort --version
让它给出相同的输出
如果你想在 make 中解决它,使用 GNUmake 的辅助库 gmtt 是不明智的。它具有字符串通配符匹配器 - wildcards,而不是正则表达式。
include gmtt-master/gmtt-master/gmtt.mk
# Pattern for 3 version numbers: a string, a string, then 3 strings separated by '.'
# (hopefully the version numbers)
PATTERN3 := * * *.*.*
# the same for 4 version numbers (consistency, eh?)
PATTERN4 := * * *.*.*.*
# We take only words 1-3 from the version string and try to pattern match it,
# taking only the numbers from the result. The possibility of either 3 or 4 numbers
# complicates matters, we have to test if PATTERN4 matches, if not then we try PATTERN3
VERSION_NR = $(if $(call glob-match,$(wordlist 1,3,$(CC_VERSION)),$(PATTERN4)),\
$(wordlist 5,11,$(call glob-match,$(wordlist 1,3,$(CC_VERSION)),$(PATTERN4))),\
$(wordlist 5,9,$(call glob-match,$(wordlist 1,3,$(CC_VERSION)),$(PATTERN3))))
# just assume the contents of CC_VERSION is the result of $(shell $(CC) --version) etc.
CC_VERSION := ifort version 15.0.1
$(info $(VERSION_NR))
CC_VERSION := ifort version 19.0.1.144
$(info $(VERSION_NR))
define CC_VERSION
ifort (IFORT) 19.0.1.144 20181018
Copyright (c) (C) 1985-2014 Intel Corporation. All rights reserved.
endef
$(info $(VERSION_NR))
输出:
$ make
15 . 0 . 1
19 . 0 . 1 . 144
19 . 0 . 1 . 144
makefile:36: *** end.
在这个问题“Checking the gcc version in a Makefile?”中回答了如何提取 gcc 编译器的版本。但是,这似乎不适用于 icc 和 ifort 等 intel 编译器?
有谁知道使用 icc --version
或 ifort --version
如果你想在 make 中解决它,使用 GNUmake 的辅助库 gmtt 是不明智的。它具有字符串通配符匹配器 - wildcards,而不是正则表达式。
include gmtt-master/gmtt-master/gmtt.mk
# Pattern for 3 version numbers: a string, a string, then 3 strings separated by '.'
# (hopefully the version numbers)
PATTERN3 := * * *.*.*
# the same for 4 version numbers (consistency, eh?)
PATTERN4 := * * *.*.*.*
# We take only words 1-3 from the version string and try to pattern match it,
# taking only the numbers from the result. The possibility of either 3 or 4 numbers
# complicates matters, we have to test if PATTERN4 matches, if not then we try PATTERN3
VERSION_NR = $(if $(call glob-match,$(wordlist 1,3,$(CC_VERSION)),$(PATTERN4)),\
$(wordlist 5,11,$(call glob-match,$(wordlist 1,3,$(CC_VERSION)),$(PATTERN4))),\
$(wordlist 5,9,$(call glob-match,$(wordlist 1,3,$(CC_VERSION)),$(PATTERN3))))
# just assume the contents of CC_VERSION is the result of $(shell $(CC) --version) etc.
CC_VERSION := ifort version 15.0.1
$(info $(VERSION_NR))
CC_VERSION := ifort version 19.0.1.144
$(info $(VERSION_NR))
define CC_VERSION
ifort (IFORT) 19.0.1.144 20181018
Copyright (c) (C) 1985-2014 Intel Corporation. All rights reserved.
endef
$(info $(VERSION_NR))
输出:
$ make
15 . 0 . 1
19 . 0 . 1 . 144
19 . 0 . 1 . 144
makefile:36: *** end.