This change it introduces eight new internal variables, which our can been appended to by our Makefile fragments to declare stuff that should be cleaned upon the various "make *clean" targets; these new variables are:
- am__mostlyclean_files, am__mostlyclean_dirs - am__clean_files, am__clean_dirs - am__distclean_files, am__distclean_dirs - am__maintclean_files, am__maintclean_dirs This change also ensures that the contents of the $(MOSTLYCLEANFILES), $(CLEANFILES), $(DISTCLEANFILES) and $(MAINTAINERCLEANFILES) variables will be cleaned even if those variables where not defined in the Makefile.am (so that it is now possible to, e.g., define them in a wrapper GNUmakefile including the Automake-generated Makefile, and still have the relevant '*clean' targets remove them). * am/clean.am (distclean): Revamp to implement the new API. * lib/am/compile.am, lib/am/configure.am, lib/am/dejagnu.am, lib/am/depend.am, lib/am/clean-hdr.am, lib/am/java.am, lib/am/libs.am, lib/am/libtool.am, lib/am/lisp.am, lib/am/ltlib.am, lib/am/progs.am, lib/am/tags.am, lib/am/texi-vers.am, lib/am/texinfos.am: Where possible and easy, adjust to append to those variables instead of tweaking or extending the various '*clean' or '*clean-am' targets or their dependencies. * automake.in (handle_compile, handle_libtool, handle_clean): Adjust. * t/cleanvars.sh: New test. * t/libtoo10.sh: Extend. * t/libtool.sh, t/libtool2.sh: Remove as obsolete. * syntax-checks.am: Extend to catch possible typos in the use of the new variables (for example, it is easy to erroneously write 'am__cleanfiles' instead of 'am__clean_files'). Signed-off-by: Stefano Lattarini <[email protected]> --- automake.in | 74 +++++++++++--------------------------- lib/am/clean-hdr.am | 5 +-- lib/am/clean.am | 67 +++++++++++++++++++++------------- lib/am/compile.am | 5 +-- lib/am/configure.am | 22 ++++++------ lib/am/dejagnu.am | 13 ++++--- lib/am/depend.am | 9 ++--- lib/am/java.am | 8 +++-- lib/am/libs.am | 4 +-- lib/am/libtool.am | 14 ++------ lib/am/lisp.am | 5 +-- lib/am/ltlib.am | 13 ++----- lib/am/progs.am | 13 ++----- lib/am/tags.am | 7 ++-- lib/am/texi-vers.am | 11 ++---- lib/am/texinfos.am | 36 +++++-------------- syntax-checks.mk | 43 ++++++++++++++++++++++ t/cleanvars.sh | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ t/libtoo10.sh | 18 ++++++++++ t/libtool.sh | 41 --------------------- t/libtool2.sh | 49 ------------------------- 21 files changed, 271 insertions(+), 286 deletions(-) create mode 100755 t/cleanvars.sh delete mode 100755 t/libtool.sh delete mode 100755 t/libtool2.sh diff --git a/automake.in b/automake.in index 66071e5..46f22d1 100644 --- a/automake.in +++ b/automake.in @@ -2237,12 +2237,12 @@ sub handle_compile () { return if ! $must_handle_compiled_objects; - my @mostly_rms = map { "\t-rm -f $_" } sort keys %compile_clean_files; - my ($coms, $vars, $rules) = + my @mostly_cleaned = sort keys %compile_clean_files; + my ($coms, $vars, $rules) = &file_contents_internal (1, "$libdir/am/compile.am", new Automake::Location, 'STDINC' => ! option 'nostdinc', - 'MOSTLYRMS' => join ("\n", @mostly_rms)); + 'MOSTLY-CLEANED' => "@mostly_cleaned"); $output_vars .= $vars; $output_rules .= "$coms$rules"; } @@ -2260,20 +2260,17 @@ sub handle_libtool require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files) if $relative_dir eq '.' && ! $libtool_new_api; - my @libtool_rms; - foreach my $item (sort keys %libtool_clean_directories) - { - my $dir = ($item eq '.') ? '' : "$item/"; - # .libs is for Unix, _libs for DOS. - push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs"); - } - + # .libs is for Unix, _libs for DOS. + my @libtool_clean_directories = map { ("$_/.libs", "$_/_libs") } + (sort keys %libtool_clean_directories); check_user_variables 'LIBTOOLFLAGS'; # Output the libtool compilation rules. - $output_rules .= &file_contents ('libtool', - new Automake::Location, - LTRMS => join ("\n", @libtool_rms)); + # FIXME: actually, this only output the libtool cleaning rules ... + # FIXME: some code reorganization/refactoring is probably in order. + $output_rules .= &file_contents ( + 'libtool', new Automake::Location, + 'LIBTOOL-CLEAN-DIRECTORIES' => "@libtool_clean_directories"); } # handle_programs () @@ -4009,49 +4006,20 @@ sub handle_clean ($) { my ($makefile) = @_; - # Clean the files listed in user variables if they exist. - $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN - if var ('MOSTLYCLEANFILES'); - $clean_files{'$(CLEANFILES)'} = 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'); - - # Compute a list of "rm"s to run for each target. - my %rms = (MOSTLY_CLEAN, [], - CLEAN, [], - DIST_CLEAN, [], - MAINTAINER_CLEAN, []); - - foreach my $file (keys %clean_files) - { - 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*$/); - - push @{$rms{$when}}, "\t-$rm\n"; - } + 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; $output_rules .= &file_contents ('clean', new Automake::Location, - MOSTLYCLEAN_RMS => join ('', sort @{$rms{&MOSTLY_CLEAN}}), - CLEAN_RMS => join ('', sort @{$rms{&CLEAN}}), - DISTCLEAN_RMS => join ('', sort @{$rms{&DIST_CLEAN}}), - MAINTAINER_CLEAN_RMS => join ('', sort @{$rms{&MAINTAINER_CLEAN}}), - MAKEFILE => basename $makefile, - ); + 'MOSTLYCLEAN-FILES' => "@mostly", + 'CLEAN-FILES' => "@plain", + 'DISTCLEAN-FILES' => "@dist", + 'MAINTAINERCLEAN-FILES' => "@maint", + 'MAKEFILE' => basename $makefile); } diff --git a/lib/am/clean-hdr.am b/lib/am/clean-hdr.am index 3f377c8..b0ac222 100644 --- a/lib/am/clean-hdr.am +++ b/lib/am/clean-hdr.am @@ -14,7 +14,4 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. -.PHONY: distclean-hdr -distclean-am: distclean-hdr -distclean-hdr: - -rm -f %FILES% +am__distclean_files += %FILES% diff --git a/lib/am/clean.am b/lib/am/clean.am index da46435..e1c2a0b 100644 --- a/lib/am/clean.am +++ b/lib/am/clean.am @@ -14,44 +14,61 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. -## We must test each macro because it might be empty, and an empty "rm -## -rf" command looks disturbing. Also, the Solaris 2.4 "rm" will -## return an error if there are no arguments other than "-f". +.am.clean-cmd.f = $(if $(strip $1),-rm -f $(strip $1)) +.am.clean-cmd.d = $(if $(strip $1),-rm -rf $(strip $1)) + +am__mostlyclean_files += $(MOSTLYCLEANFILES) +am__clean_files += $(CLEANFILES) +am__distclean_files += $(DISTCLEANFILES) +am__maintclean_files += $(MAINTAINERCLEANFILES) + +am__mostlyclean_files += %MOSTLYCLEAN-FILES% +am__clean_files += %CLEAN-FILES% +am__distclean_files += %DISTCLEAN-FILES% +am__maintclean_files += %MAINTAINERCLEAN-FILES% + +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])". +am__distclean_files += $(if $(filter .,$(srcdir)),,$(CONFIG_CLEAN_VPATH_FILES)) + +## Built sources are automatically removed by maintainer-clean.ù +## This is what mainline Automake does. +am__maintclean_files += $(BUILT_SOURCES) + +## FIXME: These might cause command line length limits to be exceeded; +## FIXME: we should break them on multiple invocations when there are +## FIXME: too many files. + mostlyclean-am: mostlyclean-generic mostlyclean-generic: -%MOSTLYCLEAN_RMS% + $(call .am.clean-cmd.f,$(am__mostlyclean_files)) + $(call .am.clean-cmd.d,$(am__mostlyclean_dirs)) clean-am: clean-generic mostlyclean-am clean-generic: -%CLEAN_RMS% + $(call .am.clean-cmd.f,$(am__clean_files)) + $(call .am.clean-cmd.d,$(am__clean_dirs)) distclean-am: distclean-generic clean-am distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -%DISTCLEAN_RMS% - -## Makefiles and their dependencies cannot be cleaned by -## an -am dependency, because that would prevent other distclean -## dependencies from calling make recursively. (The multilib -## cleaning rules do this.) -## -## If you change distclean here, you probably also want to change -## maintainer-clean below. -distclean: - -rm -f %MAKEFILE% + $(call .am.clean-cmd.f,$(am__distclean_files)) + $(call .am.clean-cmd.d,$(am__distclean_dirs)) maintainer-clean-am: maintainer-clean-generic distclean-am maintainer-clean-generic: -## FIXME: shouldn't we really print these messages before running -## the dependencies? - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -%MAINTAINER_CLEAN_RMS% + $(call .am.clean-cmd.f,$(am__maintclean_files)) + $(call .am.clean-cmd.d,$(am__maintclean_dirs)) -## See comment for distclean. +## Makefiles and their dependencies cannot be cleaned by +## an '-am' dependency, because that would prevent other distclean +## dependencies from calling make recursively (the multilib cleaning +## used to do this, and it's not unreasonable to expect user-defined +## rules might do that as well). +distclean: + -rm -f %MAKEFILE% $(am__config_distclean_files) maintainer-clean: - -rm -f %MAKEFILE% + -rm -f %MAKEFILE% $(am__config_distclean_files) .PHONY: clean mostlyclean distclean maintainer-clean \ clean-generic mostlyclean-generic distclean-generic maintainer-clean-generic diff --git a/lib/am/compile.am b/lib/am/compile.am index 4ef5f35..4ee20e1 100644 --- a/lib/am/compile.am +++ b/lib/am/compile.am @@ -27,9 +27,6 @@ else !%?STDINC% AM_DEFAULT_INCLUDES = endif !%?STDINC% -mostlyclean-am: mostlyclean-compile -mostlyclean-compile: - -rm -f *.$(OBJEXT) -?MOSTLYRMS?%MOSTLYRMS% +am__mostlyclean_files += *.$(OBJEXT) %MOSTLY-CLEANED% .PHONY: mostlyclean-compile diff --git a/lib/am/configure.am b/lib/am/configure.am index f9d604a..7024e7b 100644 --- a/lib/am/configure.am +++ b/lib/am/configure.am @@ -136,23 +136,23 @@ endif %?REGEN-ACLOCAL-M4% ## Makefile depends on config.status. if %?TOPDIR_P% -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -distclean: - -rm -f $(am__CONFIG_DISTCLEAN_FILES) -## Note: you might think we should remove Makefile.in, configure, or -## aclocal.m4 here in a maintainer-clean rule. However, the GNU -## Coding Standards explicitly prohibit this. +## This variable is used in 'clean.am'. See the comments to the +## 'distclean' and 'maintainer-clean' targets there to understand +## why we cannot simply append this to $(am__distclean_files) or +## $(am__maintclean_files). +am__config_distclean_files = \ + config.status \ + config.cache \ + config.log \ + configure.lineno \ + config.status.lineno -maintainer-clean: - -rm -f $(am__CONFIG_DISTCLEAN_FILES) ## autom4te.cache is created by Autoconf; the only valid target to ## remove it is maintainer-clean, not distclean. ## If you have an autom4te.cache that cause distcheck to fail, then ## it is good news: you finally discovered that autoconf and/or ## autoheader is needed to use your tarball, which is wrong. - -rm -rf $(top_srcdir)/autom4te.cache - +am__maintclean_dirs += $(top_srcdir)/autom4te.cache endif %?TOPDIR_P% diff --git a/lib/am/dejagnu.am b/lib/am/dejagnu.am index 50c1f51..c659f87 100644 --- a/lib/am/dejagnu.am +++ b/lib/am/dejagnu.am @@ -81,13 +81,12 @@ site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG) ## Cleaning. ## ## ---------- ## -.PHONY distclean-am: distclean-DEJAGNU - -distclean-DEJAGNU: ## Any other cleaning must be done by the user or by the test suite ## itself. We can't predict what dejagnu or the test suite might ## generate. - -rm -f site.exp site.bak - -l='$(DEJATOOL)'; for tool in $$l; do \ - rm -f $$tool.sum $$tool.log; \ - done +## FIXME: we clean these on "make distclean" only for better compatibility +## FIXME: with mainline Automake, but wouldn't be more correct to clean +## FIXME: them on "make clean" instead? +am__distclean_files += site.exp site.bak +am__distclean_files += $(addsuffix .sum,$(DEJATOOL)) +am__distclean_files += $(addsuffix .log,$(DEJATOOL)) diff --git a/lib/am/depend.am b/lib/am/depend.am index c29891a..a53ecbe 100644 --- a/lib/am/depend.am +++ b/lib/am/depend.am @@ -15,10 +15,5 @@ ## along with this program. If not, see <http://www.gnu.org/licenses/>. am__mv = mv -f - -.PHONY: am--clean-depdirs -am--clean-depdirs: - -rm -rf %DEPDIRS% - -distclean-am: am--clean-depdirs -maintainer-clean-am: am--clean-depdirs +am__distclean_dirs += %DEPDIRS% +am__maintclean_dirs += %DEPDIRS% diff --git a/lib/am/java.am b/lib/am/java.am index 289013c..7b52bdc 100644 --- a/lib/am/java.am +++ b/lib/am/java.am @@ -78,9 +78,11 @@ endif %?INSTALL% ## Cleaning. ## ## ---------- ## -.PHONY clean-am: clean-%NDIR%JAVA -clean-%NDIR%JAVA: - -rm -f *.class class%NDIR%.stamp +## Do not repeat the *.class wildcard over and over. +if %?FIRST% +am__clean_files += *.class +endif +am__clean_files += class%NDIR%.stamp ## -------------- ## diff --git a/lib/am/libs.am b/lib/am/libs.am index f94a712..0e39fe9 100644 --- a/lib/am/libs.am +++ b/lib/am/libs.am @@ -101,6 +101,4 @@ endif %?INSTALL% ## Cleaning. ## ## ---------- ## -.PHONY clean-am: clean-%DIR%LIBRARIES -clean-%DIR%LIBRARIES: - -test -z "$(%DIR%_LIBRARIES)" || rm -f $(%DIR%_LIBRARIES) +am__clean_files += $(%DIR%_LIBRARIES) diff --git a/lib/am/libtool.am b/lib/am/libtool.am index 3681c45..34384a3 100644 --- a/lib/am/libtool.am +++ b/lib/am/libtool.am @@ -14,15 +14,7 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. -.PHONY: mostlyclean-libtool clean-libtool distclean-libtool -mostlyclean-am: mostlyclean-libtool -mostlyclean-libtool: - -rm -f *.lo +am__mostlyclean_files += *.lo +am__clean_dirs += %LIBTOOL-CLEAN-DIRECTORIES% -clean-am: clean-libtool -clean-libtool: -?LTRMS?%LTRMS% - -?TOPDIR_P?distclean-am: distclean-libtool -?TOPDIR_P?distclean-libtool: -?TOPDIR_P? -rm -f libtool config.lt +?TOPDIR_P?am__distclean_files += libtool config.lt diff --git a/lib/am/lisp.am b/lib/am/lisp.am index 66b8cbc..81dc865 100644 --- a/lib/am/lisp.am +++ b/lib/am/lisp.am @@ -141,10 +141,7 @@ endif %?INSTALL% ## Cleaning. ## ## ---------- ## -.PHONY clean-am: clean-lisp -clean-lisp: - -rm -f elc-stamp $(ELCFILES) - +am__clean_files += elc-stamp $(ELCFILES) ## -------------- ## ## Distributing. ## diff --git a/lib/am/ltlib.am b/lib/am/ltlib.am index af3a256..00928f3 100644 --- a/lib/am/ltlib.am +++ b/lib/am/ltlib.am @@ -107,17 +107,8 @@ endif %?INSTALL% ## Cleaning. ## ## ---------- ## -.PHONY clean-am: clean-%DIR%LTLIBRARIES -clean-%DIR%LTLIBRARIES: - -test -z "$(%DIR%_LTLIBRARIES)" || rm -f $(%DIR%_LTLIBRARIES) +am__clean_files += $(%DIR%_LTLIBRARIES) ## 'so_locations' files are created by some linkers (IRIX, OSF) when ## building a shared object. Libtool places these files in the ## directory where the shared object is created. - @list='$(%DIR%_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } +am__clean_files += $(wildcard $(addsuffix so_locations,$(sort $(dir $(%DIR%_LTLIBRARIES))))) diff --git a/lib/am/progs.am b/lib/am/progs.am index 104270c..66ecc3d 100644 --- a/lib/am/progs.am +++ b/lib/am/progs.am @@ -103,9 +103,7 @@ endif %?INSTALL% ## Cleaning. ## ## ---------- ## -.PHONY clean-am: clean-%DIR%PROGRAMS -clean-%DIR%PROGRAMS: -?!LIBTOOL? -test -z "$(%DIR%_PROGRAMS)" || rm -f $(%DIR%_PROGRAMS) +am__clean_files += $(%DIR%_PROGRAMS) ## Under Cygwin, we build 'program$(EXEEXT)'. However, if this ## program uses a Libtool library, Libtool will move it in ## '_libs/program$(EXEEXT)' and create a 'program' wrapper (without @@ -114,14 +112,7 @@ clean-%DIR%PROGRAMS: ## Cleaning the '_libs/' or '.libs/' directory is done from clean-libtool. ## FIXME: In the future (i.e., when it works) it would be nice to delegate ## this task to "libtool --mode=clean". -?LIBTOOL? @list='$(%DIR%_PROGRAMS)'; test -n "$$list" || exit 0; \ -?LIBTOOL? echo " rm -f" $$list; \ -?LIBTOOL? rm -f $$list || exit $$?; \ -?LIBTOOL? test -n "$(EXEEXT)" || exit 0; \ -?LIBTOOL? list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ -?LIBTOOL? echo " rm -f" $$list; \ -?LIBTOOL? rm -f $$list - +?LIBTOOL?am__clean_files += $(if $(EXEEXT),$(patsubst %$(EXEEXT),%,$(%DIR%_PROGRAMS))) ## ---------- ## ## Checking. ## diff --git a/lib/am/tags.am b/lib/am/tags.am index 11a786f..ffbc135 100644 --- a/lib/am/tags.am +++ b/lib/am/tags.am @@ -170,10 +170,7 @@ cscopelist: %CSCOPEDIRS% $(am__tagged_files) ## Cleaning. ## ## ---------- ## -.PHONY distclean-am: distclean-tags - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +am__distclean_files += TAGS ID GTAGS GRTAGS GSYMS GPATH tags if %?TOPDIR_P% - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files +am__distclean_files += cscope.out cscope.in.out cscope.po.out cscope.files endif %?TOPDIR_P% diff --git a/lib/am/texi-vers.am b/lib/am/texi-vers.am index 2e6a147..4c13130 100644 --- a/lib/am/texi-vers.am +++ b/lib/am/texi-vers.am @@ -40,12 +40,5 @@ am__dist_common += %VTEXI% %STAMPVTI% fi; @cp %VTEXI% $@ -mostlyclean-am: mostlyclean-%VTI% -mostlyclean-%VTI%: - -rm -f %VTI%.tmp - -maintainer-clean-am: maintainer-clean-%VTI% -maintainer-clean-%VTI%: -%MAINTAINER-MODE% -rm -f %STAMPVTI% %VTEXI% - -.PHONY: mostlyclean-%VTI% maintainer-clean-%VTI% +am__mostlyclean_files += %VTI%.tmp +%MAINTAINER-MODE%am__maintclean_files += %STAMPVTI% %VTEXI% diff --git a/lib/am/texinfos.am b/lib/am/texinfos.am index 7393ec8..d8edfc8 100644 --- a/lib/am/texinfos.am +++ b/lib/am/texinfos.am @@ -298,34 +298,14 @@ endif %?LOCAL-TEXIS% ## Cleaning. ## ## ---------- ## -## The funny name is due to --cygnus influence; in Cygnus mode, -## 'clean-info' is a target that users can use. - if %?LOCAL-TEXIS% -.PHONY mostlyclean-am: mostlyclean-aminfo -.PHONY: mostlyclean-aminfo -mostlyclean-aminfo: -## Use '-rf', not just '-f', because the %*CLEAN% substitutions can also -## contain any directory created by "makeinfo --html", as well as the -## '*.t2d' and '*.t2p' directories used by texi2dvi and texi2pdf. - -rm -rf %MOSTLYCLEAN% - -.PHONY clean-am: clean-aminfo -clean-aminfo: -## Use '-rf', not just '-f'; see comments in 'mostlyclean-aminfo' -## above for details. -?TEXICLEAN? -test -z "%TEXICLEAN%" \ -?TEXICLEAN? || rm -rf %TEXICLEAN% - -.PHONY maintainer-clean-am: maintainer-clean-aminfo -maintainer-clean-aminfo: - @list='$(INFO_DEPS)'; for i in $$list; do \ - echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9]"; \ - rm -f $$i $$i-[0-9] $$i-[0-9][0-9]; \ - done -## Use '-rf', not just '-f'; see comments in 'mostlyclean-aminfo' -## above for details. -?MAINTCLEAN? -test -z "%MAINTCLEAN%" \ -?MAINTCLEAN? || rm -rf %MAINTCLEAN% +## Append to dirs, not files, because the %*CLEAN% substitutions can +## also contain any directory created by "makeinfo --html", as well as +## the '*.t2d' and '*.t2p' directories used by texi2dvi and texi2pdf. +am__mostlyclean_dirs += %MOSTLYCLEAN% +am__clean_dirs += %TEXICLEAN% +am__maintclean_dirs += %MAINTCLEAN% + +am__maintclean_files += $(foreach f,$(INFO_DEPS),$f $f-[0-9] $f-[0-9][0-9]) endif %?LOCAL-TEXIS% diff --git a/syntax-checks.mk b/syntax-checks.mk index 27b91a9..af1b644 100644 --- a/syntax-checks.mk +++ b/syntax-checks.mk @@ -63,6 +63,7 @@ sc_no_dotmake_target \ sc_no_am_makeflags \ $(sc_obsolete_requirements_rules) \ $(sc_renamed_variables_rules) \ +$(sc_variable_typos_rules) \ sc_no_RECHECK_LOGS \ sc_tests_no_make_e \ sc_docs_no_make_e \ @@ -339,6 +340,48 @@ $(sc_renamed_variables_rules): sc_no_% : exit 1; \ fi +# Variables whose name is prone to typos. +fixtypo.am__distfiles = am__dist_files +fixtypo.am__distcommon = am__dist_common +fixtypo.am__distsources = am__dist_sources + +define typos-for-clean + +fixtypo.am__mostlyclean$1 = am__mostlyclean_$1 +fixtypo.am__clean$1 = am__clean_$1 +fixtypo.am__distclean$1 = am__distclean_$1 +fixtypo.am__maintclean$1 = am__maintclean_$1 + +fixtypo.am__mostly_clean_$1 = am__mostlyclean_$1 +fixtypo.am__dist_clean_$1 = am__distclean_$1 + +fixtypo.am__maint_clean_$1 = am__maintclean_$1 +fixtypo.am__maintainerclean_$1 = am__maintclean_$1 +fixtypo.am__maintainer_clean_$1 = am__maintclean_$1 + +endef + +$(eval $(call typos-for-clean,files)) +$(eval $(call typos-for-clean,dirs)) + +sc_variables_typos_rules = \ + $(patsubst fixtypo.%,sc_no_%,$(filter fixtypo.%,$(.VARIABLES))) + +$(sc_variable_typos_rules) : sc_no_% : + @files="\ + $(xtests) \ + $(pms) \ + $(ams) \ + $(srcdir)/automake.in \ + $(srcdir)/doc/*.texi \ + "; \ + if grep -E '\b$*\b' $$files; then \ + echo "'\$$($*)' is probably a typo." >&2; \ + echo "You should use '$(fixtypo.$*)' instead." >&2; \ + exit 1; \ + fi + + sc_no_RECHECK_LOGS: @files="\ $(xtests) \ diff --git a/t/cleanvars.sh b/t/cleanvars.sh new file mode 100755 index 0000000..2f14e17 --- /dev/null +++ b/t/cleanvars.sh @@ -0,0 +1,100 @@ +#! /bin/sh +# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check support for: +# - MOSTLYCLEANFILES +# - CLEANFILES +# - DISTCLEANFILES +# - MAINTAINERCLEANFILES +# Especially checks that it is possible to extend them also from a +# "wrapper" makefile never processed nor seen by Automake. + +. ./defs || Exit 1 + +echo AC_OUTPUT >> configure.ac + +setup () { touch mostly plain dist maint mostly2 plain2 dist2 maint2; } + +cat > Makefile.am << 'END' +MOSTLYCLEANFILES = mostly +CLEANFILES = plain +DISTCLEANFILES = dist +MAINTAINERCLEANFILES = maint +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +cat > GNUmakefile << 'END' +include Makefile +MOSTLYCLEANFILES += mostly2 +CLEANFILES += plain2 +DISTCLEANFILES += dist2 +MAINTAINERCLEANFILES += maint2 +END + +./configure +cp config.status config.sav # Save for later. + +setup +$MAKE mostlyclean +test ! -f mostly +test ! -f mostly2 +test -f plain +test -f plain2 +test -f dist +test -f dist2 +test -f maint +test -f maint2 + +setup +$MAKE clean +test ! -f mostly +test ! -f mostly2 +test ! -f plain +test ! -f plain2 +test -f dist +test -f dist2 +test -f maint +test -f maint2 + +setup +$MAKE distclean +test ! -f mostly +test ! -f mostly2 +test ! -f plain +test ! -f plain2 +test ! -f dist +test ! -f dist2 +test -f maint +test -f maint2 + +setup +# The "make distclean" before has removed Makefile and config.status. +mv config.sav config.status +./config.status Makefile +$MAKE maintainer-clean +test ! -f mostly +test ! -f mostly2 +test ! -f plain +test ! -f plain2 +test ! -f dist +test ! -f dist2 +test ! -f maint +test ! -f maint2 + +: diff --git a/t/libtoo10.sh b/t/libtoo10.sh index 0218ef3..07efaea 100755 --- a/t/libtoo10.sh +++ b/t/libtoo10.sh @@ -16,6 +16,10 @@ # Make sure .libs directories are removed for _PROGRAMS. # Report from Guillermo Ontañón. +# Also make sure the 'so_locations' files generated by some linkers +# (OSF, IRIX) are removed. +# And also make sure the generated 'libtool' script as well as the +# *.lo files are removed when they should. required='cc libtoolize' . ./defs || Exit 1 @@ -52,9 +56,23 @@ $AUTOMAKE --add-missing $AUTOCONF ./configure $MAKE all check +: > lib/so_locations +: > src/so_locations $MAKE clean +ls *.lo && Exit 1 +test -f libtool test ! -d src/.libs test ! -d src/_libs test ! -d check/.libs test ! -d check/_libs +test -f src/so_locations +test ! -f lib/so_locations +# No libtool libraries created in this directory, our rules +# shouldn't bother about possible linker files in it. +test -f src/so_locations $MAKE distcheck + +$MAKE distclean +test ! -f libtool + +: diff --git a/t/libtool.sh b/t/libtool.sh deleted file mode 100755 index 7b267a7..0000000 --- a/t/libtool.sh +++ /dev/null @@ -1,41 +0,0 @@ -#! /bin/sh -# Copyright (C) 2001-2012 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Make sure libtool is removed. -# Report from Kevin Dalley. - -required=libtool -. ./defs || Exit 1 - -cat >> configure.ac << 'END' -AC_LIBTOOL_DLOPEN -AC_DISABLE_SHARED -AC_PROG_LIBTOOL -AC_SUBST([LIBTOOL_DEPS]) -END - -: > Makefile.am - -: > ltmain.sh -: > config.guess -: > config.sub - -$ACLOCAL -$AUTOMAKE - -grep 'rm -f libtool' Makefile.in - -: diff --git a/t/libtool2.sh b/t/libtool2.sh deleted file mode 100755 index 3b8a78b..0000000 --- a/t/libtool2.sh +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/sh -# Copyright (C) 2001-2012 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Make sure libtool clean targets exist. -# Report from Eric Magnien. - -required=libtoolize -. ./defs || Exit 1 - -cat >> configure.ac << 'END' -AC_PROG_CC -AM_PROG_AR -AC_PROG_LIBTOOL -AC_CONFIG_FILES([sub/Makefile]) -AC_OUTPUT -END - -cat > Makefile.am << 'END' -SUBDIR = subdir -lib_LTLIBRARIES = libfoo.la -libfoo_la_SOURCES = foo.c -END - -mkdir sub -cat > sub/Makefile.am << 'END' -lib_LTLIBRARIES = libfoo.la -libfoo_la_SOURCES = foo.c -END - -$ACLOCAL -: > ltmain.sh -$AUTOMAKE -a - -grep 'rm -f .*\.lo' sub/Makefile.in - -: -- 1.7.9.5
