%% "PATTON, BILLY \(SBCSI\)" <[EMAIL PROTECTED]> writes:

  pb> REFRESH+ldb+celltools+pub := dogs

  pb> all :
  pb>         @list=REFRESH+ldb+celltools+pub ;\
  pb>         echo "list = '$$list'" ;\
  pb>         echo "contents = '$($$list)'" ; \
  pb>         def=$(origin $$list); \
  pb>         echo "def = $$def" ; \
  pb>         if ! [ "$$def" = "undefined" ] ; then \
  pb>                 echo "if defined"; \
  pb>         else \
  pb>                 echo "else undefined" ; \
  pb>         fi

This is a mess as well.  You're still trying to access make constructs
from the shell script, and shell constructs (variables) from make
functions.

You can't do it.

No matter how many different ways you try to do it, it still won't
work.  Trust me :-).


Expand your script as make would, and you get:

        list=REFRESH+ldb+celltools+pub ;\
        echo "list = '$list'" ;\
        echo "contents = ''" ; \
        def=undefined; \
        echo "def = $def" ; \
        if ! [ "$def" = "undefined" ] ; then \
                echo "if defined"; \
        else \
                echo "else undefined" ; \
        fi

Getting rid of the useless lines the guts of this script is:

        def=undefined; \
        if ! [ "$def" = "undefined" ] ; then \
                echo "if defined"; \
        else \
                echo "else undefined" ; \
        fi

Obviously, the shell variable $def is always "undefined" here.


Why?  Here's how make expands things:

  - echo "list = '$$list'" ;

        ->  echo "list = '$list'"
    This is pretty obvious.

  - echo "contents = '$($$list)'" ;

        ->  echo "contents = '$($list)'"
    "$$list" expands to a literal string '$list'.

        ->  echo "contents = ''"
    There's no make variable with the name '$list', so '$($list)'
    expands to the empty string.

  - def=$(origin $$list);

        -> def=$(origin $list);
    Again, '$$list' expands to '$list'

        -> def=undefined;
    Again, there is no make variable '$list', so the $(origin ...)
    function expands to "undefined".

-- 
-------------------------------------------------------------------------------
 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://lists.gnu.org/mailman/listinfo/help-make

Reply via email to