Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE3013ACFB4@probe-2.acclaim-euro.net> From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: using gcc to make dependencies Date: Tue, 18 May 1999 12:53:09 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1460.8) Content-Type: text/plain Reply-To: djgpp AT delorie DOT com 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.