help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Makefile issues


From: Jens Schweikhardt
Subject: Re: Makefile issues
Date: Tue, 3 Jul 2001 08:21:49 +0200
User-agent: Mutt/1.2.5i

On Mon, Jul 02, 2001 at 09:32:17PM +0000, address@hidden wrote:
...
[please use linebreaks instead of 1 line per paragraph; it's
 more pleasant for many mail user agents, thanks]
...
# Is there any possible way from reading the main makefile (root
# directory of the project) and extracting this information? I don't
# necessarily use GNU make to 'make' the makefiles, but that's not the
# problem. I've found a way to extract all the directories and files used
# by a makefile tree, but I still don't know if it's possible to organize
# this by applications.

If I want the definitive and complete answer, what files an arbitrary
command looks at, I use the following approach, which may or may not
be what you are looking for.

Run the command and have all system calls printed and look for
successful calls to open(2) or equivalent, e.g. open64(),
Under Solaris you would use the truss utility. There are similar
tools for other operating systems, maybe you can use strace under
FreeBSD or Linux.

Here's what works for Solaris:

$ cat opened-files 
#!/usr/bin/ksh

# trace opened files

TRUSS_OUTPUT=/tmp/truss.out

# -f: follow all children
# -t: comma separated list of system calls to trace
# Failed open attempt contain "Err#2 ENOENT"
echo CMD: "$@" > opened-files.out
truss -f -topen "$@" 2> $TRUSS_OUTPUT
fgrep -v 'Err#2 ENOENT' $TRUSS_OUTPUT |
sed -e 's,^.*open[0-9]*(",,; s,".*,,' |
sort -u >> opened-files.out


You can run this e.g. like this

        $ opened-files gmake your-target

and have a list of opened files in ./opened-files.out. The magic is
in truss; the rest is just getting at the useful info and pretty
printing. If your make has one target per application, this should
answer your question, I think.



Regards,

        Jens
-- 
Jens Schweikhardt  http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]