在“检查gcc版本的制造文件?”这个问题中,回答了如何提取gcc编译器的版本。然而,这似乎不适用于英特尔编译器,如icc和ifort?有人知道如何使用icc --version或ifort --version提供相同的输出吗?
发布于 2019-02-14 15:36:07
如果您想从make内部解决这个问题,那么使用格特 ( GNUmake的助手库)并不是不明智的。它具有一个用于字符串的通配符-通配符,而不是正则表达式。
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.https://stackoverflow.com/questions/54692137
复制相似问题