我需要帮助从Shell命令中提取测试以用于Makefile变量。Makefile帮助(和Shell命令)
基本上,我在不同的服务器上使用一个软件的两个不同版本,但使用了一个通用的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 is 6.4.2 then --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)"
有没有简单的方法来做到这一点?
这是一个非常简单的方法。它工作吗? – Beta
我不知道如何从这个命令解析出版本:$(shell gnatmake --version),所以我可以稍后使用它 – systemoutprintln