I have to execute a command in a makefile that has to take arguments
from the command line ...how can we pass and access command line
arguments in a makefile??The arguments are not the targets but the
options for running a particular command in the makefile ....
again i dont have to access the variables (by exporting them) .. i am
totally stuck with this..
|
|
0
|
|
|
|
Reply
|
charlotte
|
2/28/2006 10:08:20 AM |
|
>I have to execute a command in a >makefile that has to take arguments
>from the command line ...how can we >pass and access command line
>arguments in a makefile??
You can override a variable from the command line, like this
cmd:
docmd ${ARGS}
and then call
$ make ARGS="arg1 arg2 arg3" cmd
Hubble.
|
|
0
|
|
|
|
Reply
|
Hubble
|
2/28/2006 10:36:51 AM
|
|
In article <1141121300.237660.306680@z34g2000cwc.googlegroups.com>,
"charlotte" <Joshi.Bakul@gmail.com> wrote:
> I have to execute a command in a makefile that has to take arguments
> from the command line ...how can we pass and access command line
> arguments in a makefile??The arguments are not the targets but the
> options for running a particular command in the makefile ....
> again i dont have to access the variables (by exporting them) .. i am
> totally stuck with this..
If any of the make arguments are of the form var=value, the variable
will be set and can be accessed in the makefile just like any other
makefile variables.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|
|
0
|
|
|
|
Reply
|
Barry
|
2/28/2006 10:38:41 AM
|
|
Kindly specify what did you mean by docmd ${ARGS} ?
i typed it in command line but got an error message.
also there is no man documentation for docmd
|
|
0
|
|
|
|
Reply
|
charlotte
|
2/28/2006 11:59:04 AM
|
|
An example:
__BEGIN_MAKEFILE__
DOGS := mutt
..PHONY: dogs
dogs :
<tab>@echo $(DOGS)
__END_MAKEFILE__
$ make
mutt
$ make DOGS=kitty
kitty
|
|
0
|
|
|
|
Reply
|
billy
|
2/28/2006 12:27:01 PM
|
|
>Kindly specify what did you mean by docmd ${ARGS} ?
>i typed it in command line but got an error message.
>also there is no man documentation for docmd
docmd was a placeholder. If you want to invoke for example /bin/ls, you
have to specify a target (example lsa) and then use make lsa. My
example then becomes:
lsa:
/bin/ls ${ARGS}
and you invoke
make ARGS="-l" lsa
Hubble.
|
|
0
|
|
|
|
Reply
|
Hubble
|
2/28/2006 3:37:29 PM
|
|
>>You can override a variable from the command line, like this
>>
>>cmd:
>> docmd ${ARGS}
>>
>>
>>and then call
>>
>> $ make ARGS="arg1 arg2 arg3" cmd
>>
>>
>>Hubble.
"charlotte" <Joshi.Bakul@gmail.com> wrote in message
news:1141127944.194167.90000@t39g2000cwt.googlegroups.com...
> Kindly specify what did you mean by docmd ${ARGS} ?
> i typed it in command line but got an error message.
> also there is no man documentation for docmd
>
Please do not cut out the poster's comments- if we haven't read the other
messages, we won't know what you are talking about.
Hubble's "docmd" is meant to represent any command (read it as "do
command"). For example,
cc $(ARGS)
or
ld $(ARGS)
So if your makefile conatins:
..c.o:
cc $(CFLAGS) -c $*.c
then you could use the following to run your makefile to compile with debug
flag:
make CFLAGS=-g
This causes the variable CFLAGS to be set to -g and in the makefile,
$(CFLAGS) gets substituted with -g
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
|
|
0
|
|
|
|
Reply
|
Fred
|
2/28/2006 3:47:43 PM
|
|