🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #90

Re: #include file dependancies

#90
From: David Reed Smith
Date: Thu, 23 Jul 1992 14:46
64 lines
3225 bytes
>>>>> On Wed, 22 Jul 1992 16:45:44 GMT, ajg@controls.ccd.harris.com
>>>>> (Arnold Goldberg) said:


    Arnold> We here have a very large source tree.

    Arnold> What I'm looking for is a script or utility that will
    Arnold> somehow tell me which #include files are not actually
    Arnold> needed for a source file.

    Arnold> any takers???


    Arnold> arnold

Arnold, sometime back I wrote a perl script that does what you want.
Besides perl, it makes use of 2 public domain packages: 'mkmf' and
'mkid'.

mkmf is a program that figures out makefile dependencies.

mkid is, according to the man page:

 Mkid builds a database that stores numbers and identifier
          names, as well as the names of the files in which they
          occur.  Mkid is particularly useful with large programs
          spread out across multiple source files.  It serves as an
          aid for program maintenance and as a guide for perusing a
          program.

The process works like this:

(1) You run mkmf to figure out the dependencies.  'mkmf' inserts
    the /usr/include .h files dependencies in your makefile.

(2) Run mkid on all the source files, all the local include files, and
    all the system includes - even system includes included by other
    system includes (which mkmf figures out for you).  It is easy to
    set up a target in your makefile to do this.

(3) Run the perl script on a C file.  It uses the 'fid' program
    (included in the mkid package) to query the database for all the
    identifiers that occur both in a include file and the C file.
    If no identifiers occur in the include file that are used by the C
    file, it reports that the include file is unused.  This process is
    continued for all the include files that the C file uses.

If that doesn't scare you off, and you would still be interested in
what I've done, send me some mail.  I'll post the perl script if there
is enough interest.

davids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Smith				davids@davids.b11.ingr.com (Internet)
Intergraph Corporation	 		uunet!ingr!b11!davids!davids (UUCP)
Huntsville, AL 35807			(205) 730-5752
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Smith				davids@davids.b11.ingr.com (Internet)
Intergraph Corporation	 		uunet!ingr!b11!davids!davids (UUCP)
Huntsville, AL 35807			(205) 730-5752
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Technical Details
Message-ID: <1992Jul23.144652.1785@b11.b11.ingr.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!b11!davids!davids
References: <AJG.92Jul22114544@sp1.ccd.harris.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer,comp.unix.questions,comp.lang.c
Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!b11!davids!davids
From: davids@davids.b11.ingr.com (David Reed Smith)
Subject: Re: #include file dependancies
In-Reply-To: ajg@controls.ccd.harris.com's message of Wed, 22 Jul 1992 16: 45:44 GMT
Message-ID: <1992Jul23.144652.1785@b11.b11.ingr.com>
Sender: usenet@b11.b11.ingr.com (Usenet Network)
Reply-To: davids@davids.b11.ingr.com
Organization: Intergraph Corp., Huntsville, AL
References: <AJG.92Jul22114544@sp1.ccd.harris.com>
Date: Thu, 23 Jul 1992 14:46:52 GMT
Lines: 64