help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conditionals based on compiler version?


From: Ian Britten
Subject: Re: Conditionals based on compiler version?
Date: Fri, 13 Sep 2002 11:33:01 -0300

On Fri, 13 Sep 2002 09:19:55 -0400
"Paul D. Smith" <address@hidden> wrote:

> Well, you have to keep firmly in mind the difference between running a
> command and expanding a variable.
> 
> Something like this:
> 
>   FOO = cc --version
> 
>   ifeq ($(FOO),2.95)
> 
> will not do what you want, because the make variable $(FOO) is expanded
> returning the string "cc --version", but the "cc --version" command is
> _NOT_ executed!

Ya, as I discovered... :-/

> If you want to run a command you want the $(shell ...) function.
> 
> So:
> 
>   FOO := $(shell $(CC) --version)
> 
> will run the command and set FOO to the results.

Ok, that's what I was looking for.
(I've never used the 'shell' stuff before - At least I know what to read
up on now...)

> Then you can test it using patsubst, filter, or whatever you prefer.
> 
> If you want more flexibility you can just do the whole test in the
> shell, like this:
> 
>   FOO := ${shell case `$(CC) --version` in 3.*) echo 3 ;; 2.*) echo 2 ;; esac}

Oh man!  That's SWEET!  Kudos to whoever added *that* to GNU make!
Many thanks!
Ian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]