mirror of
https://github.com/immortalwrt/immortalwrt.git
synced 2025-08-07 22:06:25 +08:00

It seems that, for whatever reason in this case,
the function "vardef ($var, $cond)" does not work
while "$var->def ($cond)" does work for conditionals.
Also, do not define it conditionally when defined unconditionally.
Even though the reordering patch would make that functionally sound,
it still throws a warning which can cause a build to fail
when warnings are treated as errors.
Instead, just add BUILT_SOURCES to every existing case
rather than only when BUILT_SOURCES is defined.
Fixes: 6d2bfe50d3
("tools/automake: control all cleaning with clean variables")
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/19593
Signed-off-by: Robert Marko <robimarko@gmail.com>
50 lines
2.0 KiB
Diff
50 lines
2.0 KiB
Diff
--- a/bin/automake.in
|
|
+++ b/bin/automake.in
|
|
@@ -4760,12 +4760,42 @@ sub handle_clean
|
|
if var ('CLEANFILES');
|
|
$clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
|
|
if var ('DISTCLEANFILES');
|
|
- $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
|
|
- if var ('MAINTAINERCLEANFILES');
|
|
|
|
# Built sources are automatically removed by maintainer-clean.
|
|
- $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
|
|
- if var ('BUILT_SOURCES');
|
|
+ # For each defined condition of the maintainer-clean variable, append built sources
|
|
+ # and create an unconditional definition with built sources if not already defined.
|
|
+ # Then, for each definition of built sources without maintainer-clean defined, define it.
|
|
+ # Otherwise, if the variable is not user-defined, define it with built sources.
|
|
+ my $mcleanvar = var ('MAINTAINERCLEANFILES');
|
|
+ if ($mcleanvar) {
|
|
+ foreach my $rcond ($mcleanvar->conditions->conds)
|
|
+ {
|
|
+ if (! grep { $_ eq '$(BUILT_SOURCES)' } $mcleanvar->value_as_list ($rcond)) {
|
|
+ Automake::Variable::define ($mcleanvar->name, VAR_MAKEFILE, '+', $rcond,
|
|
+ '$(BUILT_SOURCES)', '', INTERNAL, VAR_ASIS)
|
|
+ if var ('BUILT_SOURCES');
|
|
+ }
|
|
+ }
|
|
+ my $bsources = var ('BUILT_SOURCES');
|
|
+ if ($bsources) {
|
|
+ foreach my $rcond ($bsources->conditions->conds)
|
|
+ {
|
|
+ Automake::Variable::define ($mcleanvar->name, VAR_MAKEFILE, '', $rcond,
|
|
+ '$(BUILT_SOURCES)', '', INTERNAL, VAR_ASIS)
|
|
+ if ! ($mcleanvar->def ($rcond) || $mcleanvar->def (TRUE));
|
|
+ }
|
|
+ if (! $mcleanvar->def (TRUE)) {
|
|
+ Automake::Variable::define ($mcleanvar->name, VAR_MAKEFILE, '', TRUE,
|
|
+ '$(BUILT_SOURCES)', '', INTERNAL, VAR_ASIS);
|
|
+ }
|
|
+ }
|
|
+ } else {
|
|
+ Automake::Variable::define ('MAINTAINERCLEANFILES', VAR_MAKEFILE, '', TRUE,
|
|
+ '$(BUILT_SOURCES)', '', INTERNAL, VAR_ASIS)
|
|
+ if var ('BUILT_SOURCES');
|
|
+ }
|
|
+ $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
|
|
+ if var ('MAINTAINERCLEANFILES');
|
|
|
|
# Compute a list of "rm"s to run for each target.
|
|
my %rms = (MOSTLY_CLEAN, [],
|