help-make
[Top][All Lists]
Advanced

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

Re: User defined function


From: Tim Murphy
Subject: Re: User defined function
Date: Fri, 14 Oct 2022 08:17:02 +0100

The makefile is parsed and expressions outside of the targets rules are
expanded, then when a target is chosen to be built, it's rule is expanded.

You're creating a shell variable hello but trying to use a make variable
$hello before this shell variable has been assigned.

you end up with
all:
<tab>hello=1    #this will create a bash variable hello in the scope of
this single line of shell code - no effect on the next line
<tab>               # nothing here because before this all got executed the
before ifeq was expanded.


So if I change it, I can make it "work"

define check_defined
$(1)=1
endef
$(eval $(call check_defined,hello))
all:
ifeq ($(hello),1)
<tab>sleep 10
endif

Cheers,

Tim

define check_defined
>     @$(1)=1;
> endefall:
>     $(call check_defined, hello)
> ifeq ($(hello),1)
>     sleep 10
> endif
>
> I am expecting, when I invoke "make all" it should sleep for 10 secs but it
> is not happening, what is wrong with it and how can I achieve it?
>
> Thanks,
> -Rajeev
>


reply via email to

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