This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Makefile rule and dependencies problem


>>>>> "Jifl" == Jonathan Larmour <jlarmour@redhat.co.uk> writes:

    Jifl> Fabrice Gautier wrote:
    >> 
    >> Unfortunately, the two following lines:
    >> 
    >> @echo $@ ':' $< '\' > $@
    >> @tail +2 $(@:.o.d=.tmp) >> $@
    >> 
    >> assume that the first dependency line generated by gcc contains only one the
    >> .c file dependency. So it would work for something like:
    >> 
    >> file.o : file.c \
    >> file1.h \
    >> file2.h
    >> 
    >> but not if the generated depends is like:
    >> 
    >> file.o : file.c file1.h file2.h
    >> 
    >> Don't know how to correct that however.

    Jifl> Are you saying that you have a gcc that produces
    Jifl> dependencies in this form? If so, which version?

Actually, all recent versions of gcc do this. Specifically they try to
generate .d files with lines of up to 72 or 80 characters, I do not
remember the exact details.

In theory this can go wrong. In practice it is not an issue because of
the various trees involved in an eCos build and the resulting long
pathnames. When I investigated it seemed that the first header file
would always overflow the first line, so tail +2 is safe.

There is actually a possibility that the source file will also cause
an overflow on the second line, i.e. the .d file would end up looking
something like:

  <target>: \
  <source>  \
  <hdr1>    \
  <hdr2>    \
  ...

You end up with the source file listed twice as a dependency - which
should be harmless.

If and when we switch to single makefile approach, dependencies will
be handled differently. Instead of processing each .d file with an
echo and a tail, there will be a run of a Tcl script that processes
all the .d files in one go. That would allow the .d files to be parsed
properly, preventing any nasty surprises.

Obviously this only applies to building eCos. The tail +2 trick may
fail for application makefiles.

Bart

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]