我需要幫助從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