[Tinyos-devel] Re: Make issue in Tinyos

Cory Sharp cory.sharp at gmail.com
Mon Feb 28 13:44:36 PST 2005


Okay, I have a solution for you.  Try this

    BORK_PLAT_telos = iggly wiggly
    BORK_PLAT_mica2 = jiggly gee

    BORK_VAR = Hello world!
    BORK_VAR += $(PLATFORM) platform says: $(BORK_PLAT_$(PLATFORM))

    BUILD_EXTRA_DEPS += echobork

    echobork: FORCE
        echo $(BORK_VAR)

Basically, set up all your includes as individual variables with names
that include the platform.  Then reference it as an indirect variable
name, which will follow the late binding expansion semantics.

You'll note this actually works

    Blink> make telos bork
    mkdir -p build/telos
    echo Hello world! telos platform says: iggly wiggly
    Hello world! telos platform says: iggly wiggly
        compiling Blink to a telos binary
    ... etc ...

Of course set BORK_PLAT_<platform> to your include flags and change
BORK_VAR to PFLAGS.

Cory



On Sun, 27 Feb 2005 00:40:07 -0800, jprabhu at xbow.com <jprabhu at xbow.com> wrote:
> Cory,
> 
>    Thanks for the explaination. After some research I now know more about
> late binding than I care for :).
>    But, I still haven't fixed what I originally set out to do. The symptom
> is easy to reproduce in the example you have quoted. Wrap the following 2
> lines between the "BORK_VAR += .." line thus, and you will see what I mean.
> 
> ifeq ($(PLATFORM),telosb)
> BORK_VAR += in $(PLATFORM) platform.
> endif
> 
> ...
> 
> #check if platform was set to anything at all
> ifeq ($(PLATFORM),)
> $(error Haven't set PLATFORM variable)
> endif
> 
>    ... I always catch this error, so while evaluating this extra, $PLATFORM
> is not yet set.
> 
>     Is there any other method of setting variables based on $(PLATFORM) in a
> .extra file? I basically want to set some #defines based on whether the
> platform is micaz or mica2.
> 
> -Jaidev
> 
> -----Original Message-----
> From: Cory Sharp
> To: jprabhu at xbow.com
> Cc: mturon at xbow.com; tinyos-devel
> Sent: 2/25/05 6:12 PM
> Subject: Re: Make issue in Tinyos
> 
> Jaidev,
> 
> I've cc'ed tinyos-devel because I like these sorts of
> questions/answers to be archived for the world.
> 
> That's unusual behavior and not what I would expect.  Make is a funny
> thing, and it's not executing in the way you might think a normal
> program does.  It's true that $(PLATFORM) may not yet be defined when
> an .extra is processed, but that's okay because the assignment doesn't
> resolve the values of variables until they're used in an actual make
> rule.  (late binding)
> 
> You can override that behavior and force make to expand variable right
> then (early binding) instead of later by doing an assignment with :=
> instead of = or +=.  So, if there's a PFLAGS assignment like that
> hanging around (like there is in tinysec.extra, that should be fixed),
> then there's a chance that it's being expanded/evaluated before
> PLATFORM is defined.
> 
> Bottom line, using $(PLATFORM) in $(PFLAGS) should be doing what you
> expect as long as there's no := assignments elsewhere mucking things
> up.
> 
> As proof, I just tested this scenario by creating a test extra file
> called tools/make/bork.extra with these contents
> 
>     BORK_VAR = Hello world
>     BORK_VAR += in $(PLATFORM) platform.
> 
>     BUILD_EXTRA_DEPS += echobork
> 
>     echobork: FORCE
>             echo $(BORK_VAR)
> 
> Then in Blink I did "make telosb bork" which produced the following
> output
> 
> Blink> make telos bork
> mkdir -p build/telos
> echo Hello world in telos platform.
> Hello world in telos platform.
>     compiling Blink to a telos binary
> ... etc ...
> 
> As you can see, I added $(PLATFORM) to $(BORK_VAR) inside bork.extra
> and it produced the expected value at execution time.
> 
> So, look through your make files and see if anything weird is going on
> and let me know if you figure out how your PFLAGS is getting mucked
> up.
> 
> - Cory
> 
> On Fri, 25 Feb 2005 17:47:59 -0800, jprabhu at xbow.com <jprabhu at xbow.com>
> wrote:
> > Hi Cory,
> >
> >    We are trying to set up some options in a .extras file and notice
> that
> > since the "targets" is executed after the "extras", $PLATFORM is not
> yet set
> > while processing the extras - for example if I set up foo.extra and
> try to
> > add something like - PFLAGS += -I%T/platform/$(PLATFORM) - I do not
> get
> > ...platform/mica2 or .../platform/micaz.
> >    Is there something we can do to be able to get this in the right
> order?
> >
> > -Jaidev
>


More information about the Tinyos-devel mailing list