检查makefile中的ifort / icc版本

问题描述 投票:0回答:1

在这个问题“Checking the gcc version in a Makefile?”中,它回答了如何提取gcc编译器的版本。但是,这似乎不适用于英特尔编译器作为icc和ifort?有没有人知道使用icc --versionifort --version让它提供相同的输出

makefile icc intel-fortran
1个回答
0
投票

如果你想从make中解决它,使用gmtt,一个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.
© www.soinside.com 2019 - 2024. All rights reserved.