From: Alexandre Duret-Lutz Date: Sat, 24 Aug 2002 20:43:01 +0000 (+0000) Subject: * automake.in (CLEAN, MAINTAINER_CLEAN): New constants. X-Git-Tag: Release-1-6d~41 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=c9094e71300c38655b93901bf53e0f633c15bf61;p=automake.git * automake.in (CLEAN, MAINTAINER_CLEAN): New constants. (maintainer_clean_files): Replace by ... (clean_files): ... this new variable. (initialize_per_input, lang_yacc_target_hook, lang_lex_target_hook): Use %clean_files instead of @maintainer_clean_files. (handle_clean): Rewrite, using %clean_files. (require_build_directory_maybe): Use %clean_files instead of %compile_clean_files. This allows using &require_build_directory_maybe for non-compiling targets. * lib/am/clean.am (mostlyclean-generic, clean-generic, distclean-generic, maintainer-clean-generic): Rewrite using %MOSTLYCLEAN_RMS%, %CLEAN_RMS%, %DISTCLEAN_RMS%, and %MAINTAINER_CLEAN_RMS%. --- diff --git a/ChangeLog b/ChangeLog index d0d41968..e26d841a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2002-08-24 Alexandre Duret-Lutz + * automake.in (CLEAN, MAINTAINER_CLEAN): New constants. + (maintainer_clean_files): Replace by ... + (clean_files): ... this new variable. + (initialize_per_input, lang_yacc_target_hook, + lang_lex_target_hook): Use %clean_files instead of + @maintainer_clean_files. + (handle_clean): Rewrite, using %clean_files. + (require_build_directory_maybe): Use %clean_files instead + of %compile_clean_files. This allows using + &require_build_directory_maybe for non-compiling targets. + * lib/am/clean.am (mostlyclean-generic, clean-generic, + distclean-generic, maintainer-clean-generic): Rewrite using + %MOSTLYCLEAN_RMS%, %CLEAN_RMS%, %DISTCLEAN_RMS%, and + %MAINTAINER_CLEAN_RMS%. + For Debian Bug#157778: * m4/python.m4: Fix output of `python' in checking messages when no version of Python is required. diff --git a/automake.in b/automake.in index 302a736e..686b8c05 100755 --- a/automake.in +++ b/automake.in @@ -193,11 +193,11 @@ use constant GNITS => 2; use constant AC_CANONICAL_HOST => 1; use constant AC_CANONICAL_SYSTEM => 2; -# Values indicating when something should be cleaned. Right now we -# only need to handle `mostly'- and `dist'-clean; add more as -# required. -use constant MOSTLY_CLEAN => 0; -use constant DIST_CLEAN => 1; +# Values indicating when something should be cleaned. +use constant MOSTLY_CLEAN => 0; +use constant CLEAN => 1; +use constant DIST_CLEAN => 2; +use constant MAINTAINER_CLEAN => 3; # Libtool files. my @libtool_files = qw(ltmain.sh config.guess config.sub); @@ -550,8 +550,9 @@ my %dependencies; # only when keys exists in %DEPENDENCIES. my %actions; -# A list of files deleted by `maintainer-clean'. -my @maintainer_clean_files; +# Keys in this hash table are files to delete. The associated +# value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.) +my %clean_files; # Keys in this hash table are object files or other files in # subdirectories which need to be removed. This only holds files @@ -777,7 +778,7 @@ sub initialize_per_input () ); %actions = (); - @maintainer_clean_files = (); + %clean_files = (); @sources = (); @dist_sources = (); @@ -4714,30 +4715,46 @@ sub do_check_merge_target # Handle all 'clean' targets. sub handle_clean { - my %transform; + # Clean the files listed in user variables if they exist. + $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN + if variable_defined ('MOSTLYCLEANFILES'); + $clean_files{'$(CLEANFILES)'} = CLEAN + if variable_defined ('CLEANFILES'); + $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN + if variable_defined ('DISTCLEANFILES'); + $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN + if variable_defined ('MAINTAINERCLEANFILES'); + + # Built sources are automatically removed by maintainer-clean. + $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN + if variable_defined ('BUILT_SOURCES'); + + # Compute a list of "rm"s to run for each target. + my %rms = (MOSTLY_CLEAN, [], + CLEAN, [], + DIST_CLEAN, [], + MAINTAINER_CLEAN, []); - # Don't include `MAINTAINER'; it is handled specially below. - foreach my $name ('MOSTLY', '', 'DIST') + foreach my $file (keys %clean_files) { - $transform{"${name}CLEAN"} = variable_defined ("${name}CLEANFILES"); - } + my $when = $clean_files{$file}; + prog_error 'invalid entry in %clean_files' + unless exists $rms{$when}; + + my $rm = "rm -f $file"; + # If file is a variable, make sure when don't call `rm -f' without args. + $rm ="test -z \"$file\" || $rm" + if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/); - # Built sources are automatically removed by maintainer-clean. - push (@maintainer_clean_files, '$(BUILT_SOURCES)') - if variable_defined ('BUILT_SOURCES'); - push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)') - if variable_defined ('MAINTAINERCLEANFILES'); + push @{$rms{$when}}, "\t-$rm\n"; + } - $output_rules .= &file_contents ('clean', - (%transform, - 'MCFILES' - # Join with no space to avoid - # spurious `test -z' success at - # runtime. - => join ('', @maintainer_clean_files), - 'MFILES' - # A space is required in the join here. - => "@maintainer_clean_files")); + $output_rules .= &file_contents + ('clean', + MOSTLYCLEAN_RMS => join ('', @{$rms{&MOSTLY_CLEAN}}), + CLEAN_RMS => join ('', @{$rms{&CLEAN}}), + DISTCLEAN_RMS => join ('', @{$rms{&DIST_CLEAN}}), + MAINTAINER_CLEAN_RMS => join ('', @{$rms{&MAINTAINER_CLEAN}})); } @@ -5497,11 +5514,11 @@ sub lang_yacc_target_hook # statically, and the GNU rules say that yacc/lex output files # should be removed by maintainer-clean. So that's what we # do. - push (@maintainer_clean_files, $header); + $clean_files{$header} = MAINTAINER_CLEAN; } # Erase $OUTPUT on `make maintainer-clean' (by GNU standards). # See the comment above for $HEADER. - push (@maintainer_clean_files, $output); + $clean_files{$output} = MAINTAINER_CLEAN; } # This is a lex helper which is called whenever we have decided to @@ -5514,7 +5531,7 @@ sub lang_lex_target_hook # shouldn't be touched. However, we can't determine this # statically, and the GNU rules say that yacc/lex output files # should be removed by maintainer-clean. So that's what we do. - push (@maintainer_clean_files, $output); + $clean_files{$output} = MAINTAINER_CLEAN; } # This is a helper for both lex and yacc. @@ -8613,7 +8630,7 @@ sub require_build_directory ($) $directory_map{$directory} = 1; # Directory must be removed by `make distclean'. - $compile_clean_files{$dirstamp} = DIST_CLEAN; + $clean_files{$dirstamp} = DIST_CLEAN; $output_rules .= ("$dirstamp:\n" . "\t\@\$(mkinstalldirs) $directory\n" diff --git a/lib/am/clean.am b/lib/am/clean.am index f436a9e4..59c72617 100644 --- a/lib/am/clean.am +++ b/lib/am/clean.am @@ -21,16 +21,16 @@ ## return an error if there are no arguments other than "-f". mostlyclean-am: mostlyclean-generic mostlyclean-generic: -?MOSTLYCLEAN? -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) +%MOSTLYCLEAN_RMS% clean-am: clean-generic mostlyclean-am clean-generic: -?CLEAN? -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) +%CLEAN_RMS% distclean-am: distclean-generic clean-am distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -?DISTCLEAN? -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) +%DISTCLEAN_RMS% maintainer-clean-am: maintainer-clean-generic distclean-am maintainer-clean-generic: @@ -38,7 +38,7 @@ maintainer-clean-generic: ## the dependencies? @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -?MFILES? -test -z "%MCFILES%" || rm -f %MFILES% +%MAINTAINER_CLEAN_RMS% .PHONY: clean mostlyclean distclean maintainer-clean \ clean-generic mostlyclean-generic distclean-generic maintainer-clean-generic