Add -MP option

Adds a phony target to every included file, mimicking gcc's
This commit is contained in:
ISSOtm
2019-09-10 02:04:45 +02:00
parent e7eac583da
commit bfa8da78a6
3 changed files with 27 additions and 6 deletions

View File

@@ -36,6 +36,8 @@ extern struct sOptions CurrentOptions;
extern FILE *dependfile;
extern bool oGeneratePhonyDeps;
void opt_Push(void);
void opt_Pop(void);
void opt_Parse(char *s);

View File

@@ -337,8 +337,11 @@ FILE *fstk_FindFile(char *fname, char **incPathUsed)
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 @@ FILE *fstk_FindFile(char *fname, char **incPathUsed)
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;

View File

@@ -47,6 +47,8 @@ uint32_t unionStart[128], unionSize[128];
FILE *dependfile;
bool oGeneratePhonyDeps;
/*
* Option stack
*/
@@ -270,7 +272,7 @@ static void print_usage(void)
{
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 @@ int main(int argc, char *argv[])
/* yydebug=1; */
nMaxRecursionDepth = 64;
oGeneratePhonyDeps = false;
DefaultOptions.gbgfx[0] = '0';
DefaultOptions.gbgfx[1] = '1';
@@ -361,9 +364,19 @@ int main(int argc, char *argv[])
newopt.optimizeloads = false;
break;
case 'M':
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);
err(1, "Could not open dependfile %s",
optarg);
} else {
switch (optarg[0]) {
case 'P':
oGeneratePhonyDeps = true;
break;
}
}
break;
case 'o':