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

Re: ifneq problem



On Mon, 22 Mar 2021 at 21:33, Richard Forst <sterbl.ta@tutanota.com> wrote:

> I have a Makefile used to check whether svn command existing or not. The content is below
>
> all:
>         $(eval svnbin=$(shell basename $(shell which svn)))
>         $(info X$(svnbin)Y)
>         $(echo X$(svnbin)Y)
> ifneq ($(strip $(svnbin)),svn)
>         @echo "$(svnbin)=/=svn"
> endif
>
> However, `make` command prints following to the console
>
> XsvnY
> svn=/=svn

> What might cause this printout to console? Or anywhere I should check for debugging?

Hi, it might become clearer if you keep in mind that
a makefile is not a script that executes from top to bottom.

I suggest you read the below reference [1] carefully,
especially the first two paragraphs, note:
"GNU make does its work in two distinct phases."

Simplified version:
- Phase 1 sets up all the variables and dependencies.
- Phase 2 runs any recipes requires to update targets.

Your 'ifneq' directive is actioned during phase 1.
Your 'echo' commands are run later, in phase 2.

[1] https://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html#Reading-Makefiles


Reply to: