Only call $(RM) if there are files to delete

This commit is contained in:
Pierre Pronchery 2019-02-14 17:38:37 +01:00
parent 1fe41d4e4a
commit 69c7c2ac3e

View File

@ -1995,6 +1995,7 @@ static int _clean_targets(Makefile * makefile)
String const * p; String const * p;
String * targets; String * targets;
String * q; String * q;
size_t cnt;
size_t i; size_t i;
char c; char c;
int phony; int phony;
@ -2005,8 +2006,7 @@ static int _clean_targets(Makefile * makefile)
return 1; return 1;
q = targets; q = targets;
/* remove all of the object files */ /* remove all of the object files */
_makefile_print(makefile, "%s", "\t$(RM) --"); for(i = 0, cnt = 0;; i++)
for(i = 0;; i++)
{ {
if(targets[i] != ',' && targets[i] != '\0') if(targets[i] != ',' && targets[i] != '\0')
continue; continue;
@ -2015,14 +2015,19 @@ static int _clean_targets(Makefile * makefile)
if(_makefile_get_type(makefile, targets) != TT_COMMAND if(_makefile_get_type(makefile, targets) != TT_COMMAND
&& _makefile_get_type(makefile, targets) && _makefile_get_type(makefile, targets)
!= TT_SCRIPT) != TT_SCRIPT)
{
if(cnt++ == 0)
_makefile_print(makefile, "%s", "\t$(RM) --");
_makefile_print(makefile, "%s%s%s", " $(", targets, _makefile_print(makefile, "%s%s%s", " $(", targets,
"_OBJS)"); "_OBJS)");
}
if(c == '\0') if(c == '\0')
break; break;
targets[i] = c; targets[i] = c;
targets += i + 1; targets += i + 1;
i = 0; i = 0;
} }
if(cnt > 0)
_makefile_print(makefile, "%c", '\n'); _makefile_print(makefile, "%c", '\n');
targets = q; targets = q;
/* let each scripted target remove the relevant object files */ /* let each scripted target remove the relevant object files */