Date: Wed, 26 May 2004 12:15:57 +0530 From: "N. Raghavendra" <raghu@mri.ernet.in> To: Matthew Seaman <m.seaman@infracaninophile.co.uk> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: `call' function in `make' Message-ID: <16564.15653.674179.246862@riemann.mri.ernet.in> In-Reply-To: <20040525144451.GA49822@happy-idiot-talk.infracaninophile.co.uk> References: <16563.20591.846129.789297@riemann.mri.ernet.in> <20040525144451.GA49822@happy-idiot-talk.infracaninophile.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
At 2004-05-25T15:44:51+01:00, Matthew Seaman wrote:
> > Is there an analogue in BSD `make' of the `call' function in `gmake':
> > $(call VARIABLE,PARAM,PARAM,...)?
>
> Not as such. You can however use the '!=' operator to assign a value
> to a variable based on the output of some external command:
>
> RATIO != sh -c 'echo $$(( $a / $b ))'
Hi Matthew,
Thanks for your reply. After writing to the list yesterday, I read
make(1) carefully, and found what I wanted, namely the shell command
for creating `dir1' in this example `Makefile':
### Makefile
## Create directory FOO if it does not exist.
create_dir = if test ! -d foo ; then rm -f foo ; mkdir foo ; fi
dir1: src1
$(create_dir:S/foo/$@/g)
dir2: src2
$(create_dir:foo=$@)
### Makefile ends here
However, I don't understand something. The command for `dir1' works
perfectly well:
% make dir1
if test ! -d dir1 ; then rm -f dir1 ; mkdir dir1 ; fi
(`dir1' created)
OTOH, the command for `dir2' does not work --- `make' is not expanding
the local variable `@':
% make dir2
if test ! -d $@ ; then rm -f $@ ; mkdir $@ ; fi
(`dir2' not created)
Can someone tell me why this is happening?
Thanks,
Raghavendra.
--
N. Raghavendra <raghu@mri.ernet.in> | See mail headers for contact
Harish-Chandra Research Institute | and OpenPGP details.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16564.15653.674179.246862>
