Unix administration - Makefile help

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > August 2005 > Makefile help





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Makefile help
skyfaye@gmail.com

2005-08-04, 6: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

Jamie Beverly

2005-08-04, 6: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.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com