Reading user argument from make command
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 Programming > Reading user argument from make command




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

    Reading user argument from make command  
Thierry


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


 
10-14-06 12:46 AM

On linux redhat, using GNU makefile, is it possible to read the
argument of a make command, for example:


make hello

Is there a programmable way to read the argument hello?






[ Post a follow-up to this message ]



    Re: Reading user argument from make command  
toby


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


 
10-14-06 12:46 AM

Thierry wrote:
> On linux redhat, using GNU makefile, is it possible to read the
> argument of a make command, for example:
>
>
> make hello
>
> Is there a programmable way to read the argument hello?

Not in the way you are probably expecting. Make processes arguments
into "goals" (build targets).

See 'info make':
\\
`Make' will set the special variable `MAKECMDGOALS' to the list of
goals you specified on the command line.  If no goals were given on the
command line, this variable is empty.  Note that this variable should
be used only in special circumstances.
//






[ Post a follow-up to this message ]



    Re: Reading user argument from make command  
SM Ryan


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


 
10-14-06 12:46 AM

"Thierry" <lamthierry@gmail.com> wrote:
# On linux redhat, using GNU makefile, is it possible to read the
# argument of a make command, for example:
#
#
# make hello

target=hello make $target

@ more makefile
TARGET=$(target)
hello:
echo hello $(TARGET)
bonjour:
cat t.c
cc t.c
a.out

@ target=hello make $target
echo hello hello
hello hello
@ target=bonjour make $target
cat t.c
#include <stdlib.h>
#include <stdio.h>

int main(int N,char **P) {
puts(getenv("target"));
return 0;
}
cc t.c
a.out
bonjour


It's trivial to write a shell script, say ~/bin/make, to do this
for you. Ignoring quote errors, something like
#!/bin/sh
target=$1 /usr/bin/make $*

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Don't say anything. Especially you.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:10 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