Makefile help
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > Makefile help




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Makefile help  
skyfaye@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-04-05 11:00 PM

Hi,

Is it possible to pass the value of a shell var in one target to
another target?  The code below does not work because each target uses
a different subshell to execute it's command.  Of course I can set
NAME=John when I invoke this Makefile but I want my Makefile to handle
all this.


////////////////////////////////////////
SHELL=/bin/sh

x :
echo "My name is $$NAME"

y: y_pre x

y_pre:
NAME=John
/////////////////////////////////////////

What I want to see when I execute the target y is --> My name is John.

Thanks,
Hung






[ Post a follow-up to this message ]



    Re: Makefile help  
Jamie Beverly


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-04-05 11:00 PM

skyfaye@gmail.com wrote:

> Hi,
>
>   Is it possible to pass the value of a shell var in one target to
> another target?  The code below does not work because each target uses
> a different subshell to execute it's command.  Of course I can set
> NAME=John when I invoke this Makefile but I want my Makefile to handle
> all this.
>

Unfortunately, the answer to your question is simply no, however, you can
often accomplish something similar using Makefile macros, i.e.

macronumberone = `ls -al somefile.in | awk '{print $$5}'`
macronumbertwo = `echo $(macronumberone) | wc -c`

somefile: somefile.in
sed -e 's/filesize=.*/filesize='$(macronumbertwo)'/g' somefile.in \
> somefile

Unfortunately this is somewhat limited; which means that if you really need
to do some scripting, it's better done in a script that the Makefile calls
to build a rule.

Hope it helps.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:11 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register