Unix Programming - Advanced auto-dependency generation vs. generated source

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2006 > Advanced auto-dependency generation vs. generated source





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 Advanced auto-dependency generation vs. generated source
Marco Cyriacks

2006-06-16, 1:32 pm

Hi together,

at this time I'm working on a makefile and directory structure for our
software project. First I read the paper of Peter Miller
"Recursive Make Considered Harmful" and created the structure as
described there.

After some testing I figured out that there are still problems and I
searched the net for a solution. Then I found the article of Paul D.
Smith titled "Advanced Auto-Dependency Generation" on
http://make.paulandlesley.org/autodep.html and tested that method.

My problem is now as follows:
Within our project we use generated sources (ACE/TAO sources generated
by tao_idl). In my first makefile I had a rule to create dependency files:

# ----------------------------------------------------------------
%.d: %.cpp
./depend.sh $(dir $@) $*.cpp > $@
# ................................................................


Assuming ServerS.o is listed in my objects variable and I use the
following statements to include dependency files:

# ----------------------------------------------------------------
dependencies = $(subst .o,.d,$(objects))
-include $(dependencies)
# ................................................................

then:

1. make searches for ServerS.d -> failure
2. make tries to generate ServerS.d using the rule above
3. make searches ServerS.cpp -> failure
4. make tries to generate ServerS.cpp using the rule below

# ----------------------------------------------------------------
%S.cpp %C.cpp %S.h %C.h %S.inl %C.inl: %.idl
$(TAO_IDL) $< -o $(dir $@) $(include_dirs)
# ................................................................

5. make searches Server.idl -> success
6. make generate ServerS.cpp -> success
7. make builds ServerS.d -> success
8. re-exec of make

In step 6 it generates not only the cpp file but some more files
including headers as you see in the idl-rule.

If I now use the way described in the article to avoid the re-exec of
make by removing the rule like:
%.d: %.cpp
.....

but with a compile rule like:
%.o: %.cpp
./depend.sh $(dir $@) $*.cpp > $@
$(CPP) $(CPPFLAGS) $(CPPRELEASE) $< -o $@ $(include_dirs)

I've the problem that my idl sources and especially the headers are not
generated. That results in compiler errors because of the missing headers.


Do you see a nice workaround for my problem?


Thanks in advance!


Best regards,
Marco Cyriacks
Ralf Fassel

2006-06-16, 1:32 pm

* Marco Cyriacks <news@cyriacks.net>
| If I now use the way described in the article to avoid the re-exec
| of make by removing the rule like:
| %.d: %.cpp
| .....
|
| but with a compile rule like:
| %.o: %.cpp
| ./depend.sh $(dir $@) $*.cpp > $@
| $(CPP) $(CPPFLAGS) $(CPPRELEASE) $< -o $@ $(include_dirs)

This does not look correct to me. First, you redirect the depend.sh
to the .o file. Second, even if you redirect to the .d file instead,
make does not know how to generate the .d file in case it is missing.
Third, if the dependencies are recreated, you *need* to restart make,
since the dependencies could have changed substantially.

R'
Marco Cyriacks

2006-06-19, 7:24 am

Hi Ralf,

> This does not look correct to me. First, you redirect the depend.sh
> to the .o file.


Oh yes, your are right. But my Makefile looks different. It was only a
copy and paste error from my Makefile to the mail. Sorry for that. In my
Makefile it looks like the following rule.

%.o: %.cpp
./depend.sh $(dir $@) $*.cpp > $*.d
$(CPP) $(CPPFLAGS) $(CPPRELEASE) $< -o $@ $(include_dirs)


> Second, even if you redirect to the .d file instead,
> make does not know how to generate the .d file in case it is missing.


Yes, but that's the general idea of Tom Tromeys "Advanced
Auto-Dependency Generation". It is described by Paul D. Smith on
http://make.paulandlesley.org/autodep.html. The goal is to avoid the
re-exec of make.


> Third, if the dependencies are recreated, you *need* to restart make,
> since the dependencies could have changed substantially.


The dependency files are rebuild if the corresponding object code is
rebuild. For the next run of make the dependency files are up-to-date.
If you have the time for that, have a look into the page I mentioned
above. It is realy a nice idea. But in my case it leads to the problem
described in mail first post.


Best regards,
Marco
Ralf Fassel

2006-06-19, 7:24 am

* Marco Cyriacks <news@cyriacks.net>
| Yes, but that's the general idea of Tom Tromeys "Advanced
| Auto-Dependency Generation". It is described by Paul D. Smith on
| http://make.paulandlesley.org/autodep.html. The goal is to avoid the
| re-exec of make.

Ok, this indeed sounds ok.

| It is realy a nice idea. But in my case it leads to the problem
| described in mail first post.

Hmm. What is the dependency rule which should finally trigger the .o
recompile? Sounds like it might be related to the fact that your
'sources' are named foo.idl, but the .cpp and .h files are fooS.cpp
and fooS.h (note the 'S').

Also I realized that make will remove intermediate files (like the
..cpp) after the compile step if they are not marked PRECIOUS (see
manual for details).

HTH
R'
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com