【问题标题】:hostname manipulation in makefilemakefile 中的主机名操作
【发布时间】:2019-12-08 12:55:19
【问题描述】:

在我的 makefile 中,我使用 ifeq 指令有以下条件

HOST:=$(shell hostname)
ifeq ($(HOST),tier2-p-login-1-hpc)
        export CXX=h5c++
        export HDF5_CXX=mpic++
        export HDF5_CLINKER=mpic++
endif

我确实在集群的任意节点上进行,其主机名的形式为tier2-p-login-xxx-hpc,其中xxx 表示特定节点(例如tier2-p-login-17-hpc)。我的问题是如何将 $(HOST) 与 tier2-p-login-xxx-hpc 形式匹配?感谢您的帮助。

【问题讨论】:

  • CMake 是否与问题有关?如果不是,为什么要使用“cmake”标签?
  • 我认为该标签可能与 cmake 社区相关,但无论如何我已删除该标签。

标签: bash shell makefile gnu-make


【解决方案1】:

试试:

ifneq (,$(filter tier2-p-login-%-hpc,$(HOST)))
  ...

表示“如果针对模式tier2-p-login-%-hpc 过滤$(HOST) 的结果不为空......”(例如,该值与模式匹配)

【讨论】:

  • 以同样的思路,我尝试了这个HOST2:=$(patsubst tier2-p-login-%-hpc,tier2-p-login-hpc,$(HOST)) 然后ifeq ($(HOST2),tier2-p-login-hpc) 这样我就可以用 tier2-p-login-%-hpc 替换 tier2-p-login-hpc 并调用稍后在 makefile 中使用它的 HOST2。
猜你喜欢
  • 2020-01-25
  • 1970-01-01
  • 1970-01-01
  • 2012-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-04
  • 2012-09-02
相关资源
最近更新 更多