开发者

Makefile help (and Shell command)

I need help extracting test from a shell command for use in a Makefile variable.

Basically, I am using two different versions of a piece a software on different servers, but using a common makefile. One is the 6.4.2 version of gnatmake, the other is the 6.2.2 version. The problem is that the 6.2.2 version does not support the "--unchecked-shared-lib-imports" flag, which I need to have included when compiling against the 6.4.2 version.

To find the version, I figured I could use the 'gnatmake --version' command. This is what each returns, below.. How can I parse out the version? (6.2.2 or 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.

Here is how I was thinking the makefile would be set up, so if the GNATMAKE_VERSION is 6.4.2 then --unchecked-shared-lib-imports will be in the GNAT_FLAG variable which I can include in future parameters.

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)"

Is there a simple way to do 开发者_JAVA技巧this?


(Sorry, I didn't understand the problem at first.)

Try this, if you have sed:

GNATMAKE_VERSION:=$(shell gnatmake --version | sed -e '/GNATMAKE/!d' -e 's/GNATMAKE Pro \([^ ]*\) .*/\1/')

or this, if you have head and cut:

GNATMAKE_VERSION:=$(shell gnatmake --version | head -n 1 | cut -f3 -d' ')

or this, if Gnatmake allows it:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜