?
Solved

Generate dependancy lists using make in AIX's xlC...

Posted on 2007-10-12
6
Medium Priority
?
361 Views
Last Modified: 2013-11-17
Hi,

I have a shell script that will look at given C and cpp files looking for lines that start with "#include". Then the script will output a dependancy list like the ones used for 'make'.

The problem with this script is that it only digs down one file, the main source file. It doesn't continue down to files included by the header files.

For instance, say my C file contains:
#include "myfile.h"
int myfunc(int myvar)
{
 struct mystruct s;
}

and the header file contains:
#include "defmystruct.h"
int myfunc(int myvar);

and defmystruct.h contains:
struct mystruct
{
 int one;
 int two;
}

Then say I change the definition of struct mystruct{} to something like this:
struct mystruct
{
 int one;
 int two;
 char three[1024];
}

Then when I run my script, it will only build a dependancy list containing:
myfile.C:  myfile.C myfile.h
   xlC myfile.C

so changing mystruct{} will not force the makefile to recompile myfile.C...

How can I generate a dependancy list that will make sure that future compilations will be accurate?

I'm using xlC on an AIX box with AIX make...
0
Comment
Question by:bganoush
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:peetm
ID: 20067811
The change to defmystruct.h should be picked up by your make file - that's really the main purpose of make and makefiles.

Why don't you just use a makefile - sounds like you're trying to re-invent something here?
0
 

Author Comment

by:bganoush
ID: 20067827

I am using makefile...  the problem is and the reason for this question is "How do I force the make to pick up all the dependancies automatically?" If I don't add a dependancy list, then none is generated for me so as a workaround, I wrote a script to pick up the dependancies.

0
 

Author Comment

by:bganoush
ID: 20067891

I jsut thought of something... I don't believe make "picks up" anything... make is not language dependant. In other words, how would make know that the files are C files at all? make is a generic project building tool that could just as easily build a java application or Pascal for that matter...

I think the question would be "How do I force xlC to generate a dependancy list?"....  since xlC is the only part that knows what a "#include" is and which files are included in a source file.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:peetm
ID: 20068351
Ok, I see what you're doing I think: what you're attempting to do is to create a tool for automatically keeping your makefile up-to-date?

Of course, that latter bit is usually achieved by *manually* adding a [new dependency] file to those already in your makefile.  All make does is to look at the dependencies, then see if a target file is younger than one or more of its dependents - if it is, it then make applies whatever remedy you've set in the makefile.

Of course, some IDEs and compilers can work this out - if the compiler can't, well, it'd be a pretty poor show - lol

That said, such a tool would need to be recursive.

Say I #include stdio.h, but then touch - say - some include included by stdio [that could be stdlib or stdarg on a quick glance into the first few lines of my stdio] - well, such a tool would need to spot that, which would probably mean it would always have to exhaustively descend the hierarchy of all the included includes, ... recurse.  Obviously, all possible, and relatively simple to do.  But, it might be time consuming -- thus perhaps the responsibility of the developer to maintain their own list of dependencies?

Of course, one doesn't usually change any of the standard headers - but the I used those purely for illustration -- I've seen many a project where there are many more [as in number] of headers etc than those that come with a standard compiler.

Anyway, someone may well jump in with such a makefile maker.  Good luck!







0
 
LVL 15

Accepted Solution

by:
efn earned 2000 total points
ID: 20070258
Perhaps you could use Makedep.

http://sourceforge.net/projects/makedep
0
 

Author Closing Comment

by:bganoush
ID: 31408147
Yes, that's what I want.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question