makefile

I’m trying to setup the following rules

%.o : %.c
ifeq ( $(findstring _zu, $<),_zu )
echo with zu
else
echo without zu
endif

The test always success (with zu) whatever the c filename is. Any pointers?

  • Mario

Mario Charest postmaster@127.0.0.1 wrote:

I’m trying to setup the following rules

%.o : %.c
ifeq ( $(findstring _zu, $<),_zu )
echo with zu
else
echo without zu
endif

The test always success (with zu) whatever the c filename is. Any pointers?

The “ifeq” is expanded at the time the Makefile is read - way too early
for the $< variable to set properly. Try this:

CMD_zu=echo $< with zu
CMD=echo $< without zu

%.o : %.c
$(CMD$(findstring _zu, $<))

\

Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

<bstecher@qnx.com> wrote in message news:bq5206$m92$1@nntp.qnx.com

Mario Charest postmaster@127.0.0.1 wrote:
I’m trying to setup the following rules

%.o : %.c
ifeq ( $(findstring _zu, $<),_zu )
echo with zu
else
echo without zu
endif

The test always success (with zu) whatever the c filename is. Any
pointers?


The “ifeq” is expanded at the time the Makefile is read - way too early
for the $< variable to set properly. Try this:

CMD_zu=echo $< with zu
CMD=echo $< without zu

%.o : %.c
$(CMD$(findstring _zu, $<))

Bow

P.S. I had a feeling you would be the one replying :wink:


Brian Stecher (> bstecher@qnx.com> ) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M
1W8