help-make
[Top][All Lists]
Advanced

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

RE: looking for help with auto creating rules with eval hierarchically


From: PATTON, BILLY \(SBCSI\)
Subject: RE: looking for help with auto creating rules with eval hierarchically
Date: Thu, 16 Mar 2006 08:09:03 -0600

John,

Here's what I have now.
__BEGIN__
PROJECTS := lde ldg ldm ldf ldw lbf ldb
BB_lde := a
BB_ldg := b c
BB_ldm := d e f
BB_ldf := g h i j
BB_ldw := k l n m o
BB_lbf := p q r s t u
BB_ldb := v w x y z aa ab

.PHONY : all \
         ${PROJECTS} \
         $(addprefix BB_ , ${PROJECTS})

define proj_template
 $(1): $(addprefix BB_ , ${PROJECTS})
        @echo $(1)
endef
define bb_template
 $(1):
        @echo $(1)
endef

all : ${PROJECTS}

$(foreach var,$(PROJECTS),$(eval $(call proj_template,$(var))))

$(filter-out ldb,${PROJECTS}) : ldb

$(foreac proj,$(PROJECTS),$(foreach bb,$(BB_$(proj)), $(eval $(call
bb_template,$(bb)))))

#$(foreach proj \
#   , ${PROJECTS} \
#   , $(foreach bb \
#       , $(addprefix BB_ , ${PROJECTS}) \
#       , $(eval $(call bb_template, ${bb})) \
#      ) \
# )

__END__


and get 
gmake -f x
gmake: Circular lde <- lde dependency dropped.
gmake: Circular ldg <- lde dependency dropped.
gmake: Circular ldg <- ldg dependency dropped.
gmake: Circular ldm <- lde dependency dropped.
gmake: Circular ldm <- ldg dependency dropped.
gmake: Circular ldm <- ldm dependency dropped.
gmake: Circular ldf <- lde dependency dropped.
gmake: Circular ldf <- ldg dependency dropped.
gmake: Circular ldf <- ldm dependency dropped.
gmake: Circular ldf <- ldf dependency dropped.
gmake: Circular ldw <- lde dependency dropped.
gmake: Circular ldw <- ldg dependency dropped.
gmake: Circular ldw <- ldm dependency dropped.
gmake: Circular ldw <- ldf dependency dropped.
gmake: Circular ldw <- ldw dependency dropped.
gmake: Circular lbf <- lde dependency dropped.
gmake: Circular lbf <- ldg dependency dropped.
gmake: Circular lbf <- ldm dependency dropped.
gmake: Circular lbf <- ldf dependency dropped.
gmake: Circular lbf <- ldw dependency dropped.
gmake: Circular lbf <- lbf dependency dropped.
gmake: Circular ldb <- lde dependency dropped.
gmake: Circular ldb <- ldg dependency dropped.
gmake: Circular ldb <- ldm dependency dropped.
gmake: Circular ldb <- ldf dependency dropped.
gmake: Circular ldb <- ldw dependency dropped.
gmake: Circular ldb <- lbf dependency dropped.
gmake: Circular ldb <- ldb dependency dropped.
ldb
lbf
ldw
ldf
ldm
ldg
lde

-----Original Message-----
From: John Graham-Cumming [mailto:address@hidden On Behalf Of John
Graham-Cumming
Sent: Thursday, March 16, 2006 7:50 AM
To: PATTON, BILLY (SBCSI)
Cc: address@hidden
Subject: Re: looking for help with auto creating rules with eval
hierarchically


PATTON, BILLY (SBCSI) wrote:
> This works fine for proj alias PROJECTS
> Now looking at each of the PROJECTS I  need to create the same thing
> $(foreach var for each of the
> BB_<proj>  But I don't want to hard code all the names.  This needs to
> be expandable in the future
> This will then be further created for the TOPIC_<proj>_<bb>
> 
> My first best try
> $foreach proj,${PROJECTS},
> 
> Will give me the list names
> $(addprefix BB_,${PROJECTS})
> 
> So would it be something like
> $(foreach proj,${PROJECTS}  # to capture project name
>   , $(foreach bb, $(addprefix BB_,${proj})) # name of list BB_<proj>
>   , $(eval $(call dummy_template, ${bb}))  # call define
>  ) # foreach 

What you want to do is calculate the name of a variable and then get its

value.  That's trivial in GNU Make.  For example, take a look at this:

     X := Y
     YY := Hello!

     all:
         @echo $($X$X)

This will print Hello! because $($X$X) will first be expanded to $(YY) 
because X = Y and then $(YY) will be expanded to Hello!  So in your 
example what you want to do is this:

     $(foreac proj,$(PROJECTS),$(foreach bb,$(BB_$(proj)), $(eval $(call

dummy_template,$(bb)))))

John.
-- 
John Graham-Cumming
address@hidden

Home: http://www.jgc.org/
Blog: http://www.jgc.org/blog/

POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/
GNU Make Debugger: http://gmd.sf.net/
Fast, Parallel Builds: http://www.electric-cloud.com/

Sign up for my Spam and Anti-spam Newsletter
at http://www.jgc.org/




reply via email to

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