`call' function in `make'
N. Raghavendra
raghu at mri.ernet.in
Tue May 25 23:48:34 PDT 2004
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 at mri.ernet.in> | See mail headers for contact
Harish-Chandra Research Institute | and OpenPGP details.
More information about the freebsd-questions
mailing list