help-make
[Top][All Lists]
Advanced

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

Re: ifeq problem?


From: Paul Smith
Subject: Re: ifeq problem?
Date: Tue, 02 Oct 2018 13:20:25 -0400

On Tue, 2018-10-02 at 15:20 +0000, F L wrote:
> Thank you very much Paul and Philip. I still need to read what you
> pointed out.
> 
> What I want is very straightforward. during make/build process, I
> want to run a shell command to extract two numbers from two different
> files. If they are same(or different), then I do something.
> 
> That is why my prototype uses echo to get the number?
> 
> $(eval v1=$(shell sh -c "echo 1"))

OK, but you don't need to set make variables, or use make shell
functions.  A recipe is run by the shell already and the shell is a
complete programming language (more complete than makefile language!)
so you can just use shell commands directly and set shell variables.

Also, $(shell sh -c "echo 1") is redundant because the make shell
function starts a shell, then you are asking that shell to run another
shell ("sh -c") and asking that second shell to run the "echo 1"
command.

You can get rid of one shell by just saying: $(shell echo 1) rather
than starting a new shell with "sh -c".

But it's simpler by far (IMO) to simply use the recipe, which is
already in a shell, and write shell syntax:

  testrule:
          v1=`echo 1`; \
          v2=`echo 2`; \
          if [ "$$v1" = "$$v2" ]; then echo "v1 == v2"; fi





reply via email to

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