【问题标题】:Checking ifort/icc version in makefile检查 makefile 中的 ifort/icc 版本
【发布时间】:2019-02-14 13:56:57
【问题描述】:

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

【问题讨论】:

  • icc --versionifort --version 不适合您吗?
  • 它们工作,但输出不适合我需要它们。我需要这些数字,这样我就可以在我的 makefile 中相应地设置一个特定的标志。类似 `if version > 15;然后 FLAG=+ DINTEL_NEW
  • 啊,所以你问的是“给定一个像ifort (IFORT) 19.0.1.144 20181018 这样的字符串,我怎样才能提取数字部分?”? (顺便说一句,检查编译器的版本至少为 x,通常最好将其编写为测试您使用的编译器是否支持您所需要的。这样您就不必担心有自定义每个编译器/版本的脚本(考虑 ifort 24 可能使用不同的报告方案。)
  • 是的,这就是我要找的。例如,我知道 15.0.1 之前的编译器不支持某个功能,但之后的编译器支持。所以在我的代码中,我会有一些预处理器来检查是否应该编译 X 块代码。
  • 你有 awk 还是 perl?

标签: makefile icc intel-fortran


【解决方案1】:

如果你想在 make 中解决这个问题,使用 GNUmake 的帮助库 gmtt 并不是不明智的。它具有字符串的通配符匹配器 - 通配符,而不是正则表达式。

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.

【讨论】:

    猜你喜欢
    • 2011-07-08
    • 1970-01-01
    • 2014-10-01
    • 2015-05-08
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多