This is the mail archive of the
mailing list for the Cygwin project.
RE: problems using gcc -MM on source with Windows-style #include paths
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: <cygwin at cygwin dot com>
- Date: Wed, 15 Dec 2004 13:12:18 -0000
- Subject: RE: problems using gcc -MM on source with Windows-style #include paths
> -----Original Message-----
> From: cygwin-owner On Behalf Of Benjamin Drucker
> Sent: 14 December 2004 18:39
> I want to generate dependencies for my adopted C code
> with "Windows-style" #include paths like this:
> #include <stdio.h>
> #include "Common\Misc\Boot.c"
> I am building from a cygwin [CYGWIN_NT-5.1] window. I
> thought to use gcc -MM, but my version ["3.3.3 (cygwin
> special)"] croaks on the #include paths with
WFM. In fact it nicely turns the backslashes into forward slashes in the
dependency output for me:
dk@mace /test> cat foo.c
int x = WHATEVER;
dk@mace /test> cat temp/foo.h
#define WHATEVER 6
dk@mace /test> gcc -c -MM foo.c
foo.o: foo.c temp/foo.h
What do you actually mean by 'croak'? This is not a clearly-worded error
> 3. Some makefile wizardry involving sed and whatever
> to do this cleanly. This is the route I've been
> pursuing and it's getting to be a mess.
It needn't be, you should be able to use the standard dependency generation
techniques, and all you need to do is add one level of dependency: instead of
having the .d files depend on the .c files and built using a rule with gcc -MM,
you have the .d files depend on an intermediate (e.g a .x file) still using the
gcc -MM rule, and the .x file depends on the .c and is built from it using a
rule which greps out just the lines with #include and seds the backslashes into
forward ones, i.e.
%.x : %.c
grep ^[ \t]*#[ \t]*include[ \t] | sed -e 's,\\,/,g'
[not 100% sure if that backslash has the right amount of escaping for the level
of quoting but you get the idea.]
Can't think of a witty .sigline today....
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html