Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parsing Makefile帮助(和Shell命令)_Parsing_Makefile_Echo_Gnat - Fatal编程技术网

Parsing Makefile帮助(和Shell命令)

Parsing Makefile帮助(和Shell命令),parsing,makefile,echo,gnat,Parsing,Makefile,Echo,Gnat,我需要帮助从shell命令中提取测试,以便在Makefile变量中使用 基本上,我在不同的服务器上使用一个软件的两个不同版本,但是使用一个通用的makefile。一个是gnatmake的6.4.2版本,另一个是6.2.2版本。问题是6.2.2版本不支持“--unchecked shared lib imports”标志,在针对6.4.2版本进行编译时需要包含该标志 为了找到版本,我想我可以使用'gnatmake--version'命令。这是每个人的回报,如下。。我如何解析出这个版本?(6.2.2

我需要帮助从shell命令中提取测试,以便在Makefile变量中使用

基本上,我在不同的服务器上使用一个软件的两个不同版本,但是使用一个通用的makefile。一个是gnatmake的6.4.2版本,另一个是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_版本6.4.2,那么--未选中的共享库导入将位于GNAT_标志变量中,我可以将其包含在未来的参数中

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)"
有没有一个简单的方法可以做到这一点?

(很抱歉,我一开始不理解这个问题。)

如果您有
sed
,请尝试以下操作:

GNATMAKE_VERSION:=$(shell gnatmake --version | sed -e '/GNATMAKE/!d' -e 's/GNATMAKE Pro \([^ ]*\) .*/\1/')
或者,如果您有
头部
切割

GNATMAKE_VERSION:=$(shell gnatmake --version | head -n 1 | cut -f3 -d' ')
或者,如果Gnatmake允许:

GNATMAKE_VERSION:=$(shell gnatmake --version)
GNATMAKE_VERSION:=$(word 3,$(GNATMAKE_VERSION))

这是一个非常简单的方法。它能工作吗?我不知道如何从以下命令解析出版本:$(shell gnatmake--Version),以便以后使用它