Mail Archives: djgpp/1999/05/18/07:52:52
Ephraim Ben-Ishai writes:
> I use gcc with the -MM switch to make dependencies. My dependency
> file comes out as follows:
>
> file1.o: file1.c dep1.h dep2.h dep3.h dep4.h .......
>
> my problem is as follows:
>
> all the dependency files contain the correct path to the however the
> target does not have the path just the name:
This is a problem with gcc, and I don't know any way around it. Depending
which version you use the dependency file might be written for a target
in the current directory, or for a target in the same directory as the
first dependency, but it ignores any other directory that was specified
with the -o switch.
One way around this is to always run gcc from the same directory as your
output files. Another option is to tweak the dependency files to correct
the error. In the current Allegro WIP versions I do this using SED, eg:
depend:
gcc -MM -MG src/*.c > _depend.tmp
sed -e "s/^[a-zA-Z0-9_\/]*\///" _depend.tmp > _depend2.tmp
sed -e "s/^\([a-zA-Z0-9_]*\.o:\)/obj\/djgpp\/\1/" _depend2.tmp >
makefile.dep
rm _depend.tmp _depend2.tmp
That is a slightly simplified version of the actual target, but you
should be able to get the idea. The first SED command strips off any
path from the dependency target, and the second one adds my own output
directory (obj/djgpp). This works with any version of gcc.
Shawn Hargreaves.
- Raw text -