我需要帮助从 shell 命令中提取测试以用于 Makefile 变量。
基本上,我在不同的服务器上使用一个软件的两个不同版本,但使用一个通用的 makefile。一个是6.4.2版本的 gnatmake,另一个是6.2.2版本。问题是6.2.2版本不支持“--unchecked-shared-lib-imports”标志,我需要在针对6.4.2版本进行编译时包含该标志。
为了找到版本,我想我可以使用“gnatmake --version”命令。这是每个返回的内容,如下所示。我怎样才能解析出版本?(6.2.2 或 6.4.2)?
gnatmake 6.2.2:
GNATMAKE Pro 6.2.2 (20090612-43)
Copyright (C) 1995-2009, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
gnatmake 6.4.2:
GNATMAKE Pro 6.4.2 (20110614-45)
Copyright (C) 1995-2010, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
以下是我认为 makefile 的设置方式,因此如果GNATMAKE_VERSION为6.4.2 ,那么--unchecked-shared-lib-imports将位于GNAT_FLAG变量中,我可以将其包含在未来的参数中。
GNATMAKE_VERSION:=$(shell gnatmake --version)
GNAT_FLAG:=
# if not equal (GNATMAKE_VERSION=6.2.2)
# GNAT_FLAG:= "--unchecked-shared-lib-imports"
#
test:
echo "$(GNATMAKE_VERSION)"
test2:
echo "$(GNAT_FLAG)"
有没有一种简单的方法可以做到这一点?