Title: RE: TR: Adresses email sur les probl?mes gmake

Thank you, for your quickness and accuracy.

I've understood I can't use these kind of variables to accurately define my prerequisites. Ok.

But, please, have you got an idea about how I could change my makefile so as to dynamically load the prerequisites of a target from another file, (whose name depends on the target name) ? Not speaking about writing the makefile, but about the best mechanics to do it ?

Great thanks both of you anyway,

Laurent.


    -----Message d'origine-----
    De:     Paul Smith [SMTP:[EMAIL PROTECTED] � la place de Paul D. Smith
    Date:   vendredi 9 janvier 2004 23:09
    �:      Robert Mecklenburg
    Cc:     Massonnier Laurent; [EMAIL PROTECTED]
    Objet:  Re: TR: Adresses email sur les probl?mes gmake

    %% Robert Mecklenburg <[EMAIL PROTECTED]> writes:

      ML> bin/CIBLE_%.elf : SUBST=$(shell echo $* | sed "s|^CIBLE_||")

      rm> This doesn't work as you seem to expect.  Remember, make operates
      rm> in two phases: reading and evaluating the dag.  Here, the RHS is
      rm> evaluated immediately upon reading the makefile - the shell
      rm> command is run before any file is bound to the rule.

    Actually, this is not really true... or rather you have the right reason
    but are quoting the wrong line.  Target-specific variables are expanded
    like any other variable setting; in this case since the variable is
    recursive it's not expanded here.

    However:

      ML> bin/CIBLE_%.elf : DEPENDANCES=$(addprefix lib/CIBLE_, $(shell cat src/$(SUBST).mk | egrep "^$(SUBST).elf" | cut -d':' -f2))

    Again, this is OK: it merely sets the target-specific variable
    DEPENDANCES to this _unexpanded_ value.

      ML> bin/CIBLE_%.elf:$(DEPENDANCES)

    _THIS_ is where the problem really occurs.

    Because $(DEPENDANCES) is in the prerequisite list, as Robert points out
    it is expanded when the makefile is read in.  Target-specific variables
    are only valid (only have their value) when they appear inside command
    scripts, they do not have their value when they appear in prerequisite
    lists.

    So, DEPENDANCES is expanded to whatever the global value of this
    variable has, which is nothing.  Just as you've seen.


    Check the GNU make manual section "How 'make' Reads a Makefile" to learn
    more about when variables (and functions--they behave the same way WRT
    expansion) are expanded.

    --
    -------------------------------------------------------------------------------
     Paul D. Smith <[EMAIL PROTECTED]>          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

_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to