scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 71a81dc0027c360070f33bf80828ac94df93e776
parent 9c488f726b50ebedc800791caada9aef20e92a6e
Author: Quentin Rameau <quinq@fifth.space>
Date:   Wed, 15 Feb 2017 18:35:23 +0100

[cc1] Do it like gcc. Fix -M output.

Change the format from:
filename.ext: dependencies
to:
filename.o: filename.ext dependencies

Diffstat:
cc1/lex.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cc1/lex.c b/cc1/lex.c @@ -90,7 +90,9 @@ int addinput(char *fname, Symbol *hide, char *buffer) { FILE *fp; + char *extp; unsigned flags; + size_t infileln; Input *newip, *curip = input; if (hide) { @@ -105,8 +107,13 @@ addinput(char *fname, Symbol *hide, char *buffer) if ((fp = fopen(fname, "r")) == NULL) return 0; flags = IFILE; - if (curip && onlyheader) - printf("%s: %s\n", infile, fname); + if (curip && onlyheader) { + infileln = strlen(infile); + if (extp = strrchr(infile, '.')) + infileln -= strlen(extp); + printf("%.*s.o: %s %s\n", + infileln, infile, infile, fname); + } } else { /* reading from stdin */ fp = stdin;