Unix Programming - makefile command line

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2004 > makefile command line





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 command line
Billy Patton

2004-11-17, 5:51 pm

How would I gather all the command line arguments in a makefile?
I know I can do an origin of a variable and it will say command line if it were
a command line input.
But I need to record what the command line was for proof.

___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-patton@ti.com
Trent Buck

2004-11-17, 5:51 pm

Quoth Billy Patton on or about 2004-11-17:
> How would I gather all the command line arguments in a makefile?
> I know I can do an origin of a variable and it will say command line if it were
> a command line input.
> But I need to record what the command line was for proof.


`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.

That's just the targets, I think. Look through the manual; I'm off to
bed.

-trent
Pascal Bourguignon

2004-11-17, 5:51 pm

Trent Buck <NOSPAMfubarbaz@bigpond.com> writes:

> Quoth Billy Patton on or about 2004-11-17:
>
> `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.
>
> That's just the targets, I think. Look through the manual; I'm off to
> bed.


There's MFLAG too.

For example, for make -k all -p other we get:

MFLAGS=-pk
MAKECMDGOALS=all other

If you need to trace make invocations, you could replace $(which make)
with a script that logs the arguments and exec the true make:

make=$(which make)
mv $make ${make}.real
cat >$make <<EOF
#!/bin/bash
echo "$(date +%Y%m%d%H%M%S) $UID $(pwd) $@" >> /var/log/make.log
exec ${0}.real $@
EOF
chmod 755 $make

--
__Pascal Bourguignon__ http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com