help-make
[Top][All Lists]
Advanced

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

Re: Problems with eval


From: Greg Kilfoyle
Subject: Re: Problems with eval
Date: Wed, 29 Sep 2004 12:52:25 -0700

A colleague was working on the problem in parallel and spent time
working out the subtleties of eval. I've now been able to get it working
using the first approach I showed. Here's the revised code in the top
level make file (some lines may wrap):

# Build library dependencies
define recur
 $$(foreach lib_$(1),$$(lib_dep_$(1)),$$(eval $$(call
libdep,$$(lib_$(1)))))
endef
define libdep
 $$(eval $$(call recur,$(1)))
 tmplib      :=
 tmplib      := $$(if $$(findstring $(1),$$(all_dep)),,$(1))
 all_dep     += $$(tmplib)
 extra_flags += $$(link_flags_$(1))
endef
define prgdep
 all_dep :=
 $$(foreach lib,$$(prg_dep_$(1)),$$(eval $$(call libdep,$$(lib))))
 prg_flg_$(1) := $$(strip $$(sort $$(all_dep:%=-l%) $$(extra_flags)))
endef
$(foreach prog,$(all_progs),$(eval $(call prgdep,$(prog))))

Then, within the build command for a program, I have something like:

$(CC) $(prg_flg_$(call getnotdir,$@))

...getnotdir just leaves the trailing filename from address@hidden

When the library make file is included, it sets lib_dep_$(lib); and when
the program make file is included, it sets prg_dep_$(prog).

Thanks for all the suggestions.

I rule that can be gleaned from this (that my colleague suggested) for
using eval with define is that any '$' which is not a function argument
(such as $(1)) must be preceded by an extra '$'. The above code
certainly demonstrates this.

Cheers, Greg.
-- 
Greg Kilfoyle <address@hidden>





reply via email to

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