shithub: scc

Download patch

ref: e1ff5918e33b69a9d16929e59014db4ffe9a1f7d
parent: 3e95097ce623d14228f5fe8f4206efe7d3490a9a
author: Quentin Rameau <[email protected]>
date: Wed Feb 15 13:35:23 EST 2017

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

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

--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -90,7 +90,9 @@
 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 @@
 		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;