ref: bfa8da78a6240935b82caa8f15966f53aaf55bb0
parent: e7eac583daf97ff6eb69b7d6b36cb227fcee6876
author: ISSOtm <[email protected]>
date: Mon Sep 9 22:04:45 EDT 2019
Add -MP option Adds a phony target to every included file, mimicking gcc's
--- a/include/asm/main.h
+++ b/include/asm/main.h
@@ -36,6 +36,8 @@
extern FILE *dependfile;
+extern bool oGeneratePhonyDeps;
+
void opt_Push(void);
void opt_Pop(void);
void opt_Parse(char *s);
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -337,8 +337,11 @@
f = fopen(fname, "rb");
if (f != NULL || errno != ENOENT) {
- if (dependfile)
+ if (dependfile) {
fprintf(dependfile, "%s: %s\n", tzObjectname, fname);
+ if (oGeneratePhonyDeps)
+ fprintf(dependfile, "%s:\n", fname);
+ }
return f;
}
@@ -364,8 +367,11 @@
if (f != NULL || errno != ENOENT) {
if (dependfile) {
fprintf(dependfile, "%s: %s\n", tzObjectname,
- path);
+ fname);
+ if (oGeneratePhonyDeps)
+ fprintf(dependfile, "%s:\n", fname);
}
+
if (incPathUsed)
*incPathUsed = IncludePaths[i];
return f;
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -47,6 +47,8 @@
FILE *dependfile;
+bool oGeneratePhonyDeps;
+
/*
* Option stack
*/
@@ -270,7 +272,7 @@
{
fputs(
"Usage: rgbasm [-EhLVvw] [-b chars] [-D name[=value]] [-g chars] [-i path]\n"
-" [-M depend_file] [-o out_file] [-p pad_value] [-r depth]\n"
+" [-M depend_file] [-MP] [-o out_file] [-p pad_value] [-r depth]\n"
" [-W warning] <file> ...\n"
"Useful options:\n"
" -E, --export-all export all labels\n"
@@ -306,6 +308,7 @@
/* yydebug=1; */
nMaxRecursionDepth = 64;
+ oGeneratePhonyDeps = false;
DefaultOptions.gbgfx[0] = '0';
DefaultOptions.gbgfx[1] = '1';
@@ -361,9 +364,19 @@
newopt.optimizeloads = false;
break;
case 'M':
- dependfile = fopen(optarg, "w");
- if (dependfile == NULL)
- err(1, "Could not open dependfile %s", optarg);
+ ep = strchr("P", optarg[0]);
+ if (!ep || !*ep || optarg[1]) {
+ dependfile = fopen(optarg, "w");
+ if (dependfile == NULL)
+ err(1, "Could not open dependfile %s",
+ optarg);
+ } else {
+ switch (optarg[0]) {
+ case 'P':
+ oGeneratePhonyDeps = true;
+ break;
+ }
+ }
break;
case 'o':