Discussion:
probs with eval
Vikas Joshi
2004-10-19 22:30:38 UTC
Permalink
I have following construct. When I run substituting eval with warning it shows the correct rules constructed. When run using eval it cannot find the rules. Am I missing something ?

-vj

COMMONSRC := a.c \
xyz\b.c \
pqr\abc\d.c

SRC := $(COMMONSRC)

define SRC_CP_template
$(1): $(2)
echo $(1) needs to be copied
endef

$(foreach source,$(SRC),$(eval $(call SRC_CP_template,$(addprefix $(VAR1)\,$(source)),$(addprefix $(VAR2)\, $(source)))))

tst : $(addprefix $(VAR1)\,$(SRC))
echo $!
Paul D. Smith
2004-10-19 21:35:31 UTC
Permalink
%% "Vikas Joshi" <***@dlemailx.itg.ti.com> writes:

vj> I have following construct. When I run substituting eval with
vj> warning it shows the correct rules constructed. When run using
vj> eval it cannot find the rules. Am I missing something ?

Are you sure you're using a new-enough version of GNU make?

To use eval you need GNU make 3.80.

vj> COMMONSRC := a.c \
vj> xyz\b.c \
vj> pqr\abc\d.c

It's a very bad idea to use backslashes in filenames in make. You
should always use forward slashes. Most Windows programs will work with
both.
--
-------------------------------------------------------------------------------
Paul D. Smith <***@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Paul D. Smith
2004-10-20 12:27:25 UTC
Permalink
%% "Joshi, Vikas" <v-***@ti.com> writes:

jv> I am sure I am not using 3.8.

Then eval won't work (it's 3.80, not 3.8...)

jv> If I cannot upgrade then what are my options other than explicitly
jv> mentioning all the expandable constructs ? If there is a patch for
jv> eval for the version I am using then I might be able to use the
jv> patch but for sure cannot upgrade at this time.

There is no patch.

The only option for writing dynamic rules in versions of make older than
3.80 is to use the auto-re-exec feature. Make will re-invoke itself if
it can and does rebuild any of the makefiles it included. So, something
like this:

include dynamic.mk

dynamic.mk : Makefile
<shell script to generate the makefile>

should do it.
--
-------------------------------------------------------------------------------
Paul D. Smith <***@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Joshi, Vikas
2004-10-20 09:57:20 UTC
Permalink
I am sure I am not using 3.8.

If I cannot upgrade then what are my options other than explicitly
mentioning all the expandable constructs ? If there is a patch for eval
for the version I am using then I might be able to use the patch but for
sure cannot upgrade at this time.

The version I am using is:

GNU Make version 3.79.1 (Symbian build 004), by Richard Stallman and
Roland McGrath.
Built for Windows32
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

Report bugs to <bug-***@gnu.org>.

-Vikas

-----Original Message-----
From: Paul Smith [mailto:***@nortelnetworks.com] On Behalf Of Paul D.
Smith
Sent: Tuesday, October 19, 2004 4:36 PM
To: Joshi, Vikas
Cc: help-***@gnu.org
Subject: Re: probs with eval

%% "Vikas Joshi" <***@dlemailx.itg.ti.com> writes:

vj> I have following construct. When I run substituting eval with
vj> warning it shows the correct rules constructed. When run using
vj> eval it cannot find the rules. Am I missing something ?

Are you sure you're using a new-enough version of GNU make?

To use eval you need GNU make 3.80.

vj> COMMONSRC := a.c \
vj> xyz\b.c \
vj> pqr\abc\d.c

It's a very bad idea to use backslashes in filenames in make. You
should always use forward slashes. Most Windows programs will work with
both.
--
------------------------------------------------------------------------
-------
Paul D. Smith <***@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist
Loading...