From: Stefano Lattarini Date: Wed, 20 Jun 2012 23:10:14 +0000 (+0200) Subject: [ng] automake: new global variable '%clean_dirs' X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=931cdfb8953d6ad0f4e3023bf7a870955c04d0ac;p=thirdparty%2Fautomake.git [ng] automake: new global variable '%clean_dirs' Similar to the '%clean_files' variable, but it will allow us to declare directories (rather than regular files) that are to be cleaned by the four flavours of cleaning targets ('mostlyclean', 'clean', 'distclean', 'maintainer-clean'). This will be especially useful in later changes. * automake.in (%clean_dirs): New global. (initialize_per_input): Reset it. * automake.in (handle_clean), lib/am/clean.am: Extend to clean the directories registered in '%clean_dirs'. Signed-off-by: Stefano Lattarini --- diff --git a/automake.in b/automake.in index 46f22d16f..49c98066d 100644 --- a/automake.in +++ b/automake.in @@ -525,9 +525,10 @@ my @all; my @check; my @check_tests; -# 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 files and directories to delete. The +# associated value tells when this should happen (MOSTLY_CLEAN, +# DIST_CLEAN, etc). +my (%clean_files, %clean_dirs); # Keys in this hash table are object files or other files in # subdirectories which need to be removed. This only holds files @@ -655,6 +656,7 @@ sub initialize_per_input () @check_tests = (); %clean_files = (); + %clean_dirs = (); %compile_clean_files = (); # We always include '.'. This isn't strictly correct. @@ -4006,19 +4008,29 @@ sub handle_clean ($) { my ($makefile) = @_; - my @keys = keys %clean_files; - my @mostly = grep { $clean_files{$_} == MOSTLY_CLEAN } @keys; - my @plain = grep { $clean_files{$_} == CLEAN } @keys; - my @dist = grep { $clean_files{$_} == DIST_CLEAN } @keys; - my @maint = grep { $clean_files{$_} == MAINTAINER_CLEAN } @keys; + my @fkeys = keys %clean_files; + my @fmostly = grep { $clean_files{$_} == MOSTLY_CLEAN } @fkeys; + my @fplain = grep { $clean_files{$_} == CLEAN } @fkeys; + my @fdist = grep { $clean_files{$_} == DIST_CLEAN } @fkeys; + my @fmaint = grep { $clean_files{$_} == MAINTAINER_CLEAN } @fkeys; + + my @dkeys = keys %clean_dirs; + my @dmostly = grep { $clean_dirs{$_} == MOSTLY_CLEAN } @dkeys; + my @dplain = grep { $clean_dirs{$_} == CLEAN } @dkeys; + my @ddist = grep { $clean_dirs{$_} == DIST_CLEAN } @dkeys; + my @dmaint = grep { $clean_dirs{$_} == MAINTAINER_CLEAN } @dkeys; $output_rules .= &file_contents ('clean', new Automake::Location, - 'MOSTLYCLEAN-FILES' => "@mostly", - 'CLEAN-FILES' => "@plain", - 'DISTCLEAN-FILES' => "@dist", - 'MAINTAINERCLEAN-FILES' => "@maint", + 'MOSTLYCLEAN-FILES' => "@fmostly", + 'CLEAN-FILES' => "@fplain", + 'DISTCLEAN-FILES' => "@fdist", + 'MAINTAINERCLEAN-FILES' => "@fmaint", + 'MOSTLYCLEAN-DIRS' => "@dmostly", + 'CLEAN-DIRS' => "@dplain", + 'DISTCLEAN-DIRS' => "@ddist", + 'MAINTAINERCLEAN-DIRS' => "@dmaint", 'MAKEFILE' => basename $makefile); } diff --git a/lib/am/clean.am b/lib/am/clean.am index 8c739a21c..d05cd660d 100644 --- a/lib/am/clean.am +++ b/lib/am/clean.am @@ -27,6 +27,11 @@ am__clean_files += %CLEAN-FILES% am__distclean_files += %DISTCLEAN-FILES% am__maintclean_files += %MAINTAINERCLEAN-FILES% +am__mostlyclean_dirs += %MOSTLYCLEAN-DIRS% +am__clean_dirs += %CLEAN-DIRS% +am__distclean_dirs += %DISTCLEAN-DIRS% +am__maintclean_dirs += %MAINTAINERCLEAN-DIRS% + am__distclean_files += $(CONFIG_CLEAN_FILES) ## Some files must be cleaned only in VPATH builds -- e.g., those linked ## in usages like "AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])".