From: Stefano Lattarini Date: Mon, 30 Jul 2012 17:39:12 +0000 (+0200) Subject: [ng] general: new internal vars to hold path of current Makefile{,.in,.am} X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0dd19a0d764b250a13ee18fb7142af72f521513;p=thirdparty%2Fautomake.git [ng] general: new internal vars to hold path of current Makefile{,.in,.am} This is preferable to having to use the '%MAKEFILE%', '%MAKEFILE-IN%' and '%MAKEFILE-AM%' transforms in several places, and will enable us to do more sweeping refactorings in the future. * automake.in (generate_makefile): Define new private make variables: - am.relpath.makefile.am - am.relpath.makefile.in - am.relpath.makefile * automake.in (handle_configure, handle_clean, generate_makefile), lib/am/configure.am, lib/am/check-typos.am, lib/am/clean.am: Adjust throughout to use them instead of the corresponding transforms. * t/remake.sh: Adjust and extend grepping checks. Signed-off-by: Stefano Lattarini --- diff --git a/automake.in b/automake.in index 64fc560f3..549953052 100644 --- a/automake.in +++ b/automake.in @@ -3570,21 +3570,17 @@ sub handle_config_headers () qw/$(am.config-hdr.local) $(am.config-hdr.non-local)/); } -# &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS) -# ------------------------------------------------------------------ +# &handle_configure ($MAKEFILE, @INPUTS) +# -------------------------------------- # Handle remaking and configure stuff. # We need the name of the input file, to do proper remaking rules. -sub handle_configure ($$$@) +sub handle_configure ($@) { - my ($makefile_am, $makefile_in, $makefile, @inputs) = @_; + my ($makefile, @inputs) = @_; prog_error 'empty @inputs' unless @inputs; - my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am, - $makefile_in); - my $rel_makefile = basename $makefile; - my $colon_infile = ':' . join (':', @inputs); $colon_infile = '' if $colon_infile eq ":$makefile.in"; my @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs); @@ -3602,13 +3598,10 @@ sub handle_configure ($$$@) $output_rules .= file_contents ('configure', new Automake::Location, - MAKEFILE => $rel_makefile, 'MAKEFILE-DEPS' => "@rewritten", 'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@', - 'MAKEFILE-IN' => $rel_makefile_in, 'HAVE-MAKEFILE-IN-DEPS' => (@include_stack > 0), 'MAKEFILE-IN-DEPS' => "@include_stack", - 'MAKEFILE-AM' => $rel_makefile_am, 'AUTOMAKE-OPTIONS' => $automake_options, 'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile", 'REGEN-ACLOCAL-M4' => $regen_aclocal_m4, @@ -3910,8 +3903,8 @@ sub handle_user_recursion () } } -# handle_clean ($MAKEFILE) -# ------------------------ +# handle_clean() +# -------------- # Handle all 'clean' targets. sub handle_clean ($) { @@ -3940,7 +3933,7 @@ sub handle_clean ($) 'CLEAN-DIRS' => "@dplain", 'DISTCLEAN-DIRS' => "@ddist", 'MAINTAINERCLEAN-DIRS' => "@dmaint", - 'MAKEFILE' => basename $makefile); + ); } @@ -6863,6 +6856,11 @@ sub generate_makefile ($$) # Must do this after reading .am file. define_variable ('subdir', INTERNAL, $relative_dir); define_variable ('am.conf.aux-dir', INTERNAL, $am_config_aux_dir); + define_variable ('am.relpath.makefile', INTERNAL, basename ($makefile)); + define_variable ('am.relpath.makefile.am', INTERNAL, + prepend_srcdir ($makefile_am)); + define_variable ('am.relpath.makefile.in', INTERNAL, + prepend_srcdir ($makefile_in)); # If DIST_SUBDIRS is defined, make sure SUBDIRS is, so that # recursive rules are enabled. @@ -6876,7 +6874,7 @@ sub generate_makefile ($$) verbatim ('am-dir'); handle_config_headers; - handle_configure ($makefile_am, $makefile_in, $makefile, @inputs); + handle_configure ($makefile, @inputs); handle_gettext; handle_libraries; handle_ltlibraries; @@ -6939,8 +6937,7 @@ sub generate_makefile ($$) my $output_checks = ''; # See if any _SOURCES (or _LIBADD, or ...) variable were misspelled. - $output_checks .= preprocess_file ("$libdir/am/check-typos.am", - MAKEFILE => basename ($makefile)); + $output_checks .= preprocess_file ("$libdir/am/check-typos.am"); # Bail out if we have encountered errors at make runtime. The # relevant diagnostic should have already been reported by any # call to the function '$(am.error)', so we just print a generic diff --git a/lib/am/check-typos.am b/lib/am/check-typos.am index 89e7db76a..f4629fe4a 100644 --- a/lib/am/check-typos.am +++ b/lib/am/check-typos.am @@ -120,7 +120,7 @@ ifdef .am/sanity-checks-failed $(shell rm -f $(am.dir)/check-typos-stamp.mk) $(error Some Automake-NG sanity checks failed) else -$(am.dir)/check-typos-stamp.mk: %MAKEFILE% | $(am.dir) +$(am.dir)/check-typos-stamp.mk: $(am.relpath.makefile) | $(am.dir) @if \ $(MAKE) --no-print-directory AM_FORCE_SANITY_CHECKS=yes .am/nil; \ then \ diff --git a/lib/am/clean.am b/lib/am/clean.am index e49a6bead..8b6f57144 100644 --- a/lib/am/clean.am +++ b/lib/am/clean.am @@ -64,9 +64,9 @@ maintainer-clean-generic: # this, and it's not unreasonable to expect user-defined rules might # do that as well). distclean: - rm -f %MAKEFILE% $(am__config_distclean_files) + rm -f $(am.relpath.makefile) $(am__config_distclean_files) maintainer-clean: - rm -f %MAKEFILE% $(am__config_distclean_files) + rm -f $(am.relpath.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/configure.am b/lib/am/configure.am index 13a936b2f..53990476a 100644 --- a/lib/am/configure.am +++ b/lib/am/configure.am @@ -19,7 +19,8 @@ ## --------------------- ## ## This rule remakes the Makefile.in. -%MAKEFILE-IN%: %MAINTAINER-MODE% %MAKEFILE-AM% %MAKEFILE-IN-DEPS% $(am.remake.configure-deps) +$(am.relpath.makefile.in): %MAINTAINER-MODE% $(am.relpath.makefile.am) \ + %MAKEFILE-IN-DEPS% $(am.remake.configure-deps) ## If configure.ac or one of configure's dependencies has changed, all ## Makefile.in are to be updated; it is then more efficient to run ## automake on all the Makefiles at once. It also allow Automake to be @@ -47,9 +48,9 @@ ## Ensure that GNU make doesn't remove Makefile if ./config.status (below) ## is interrupted. Otherwise, the user would need to know to rerun ## ./config.status to recreate the lost Makefile. -.PRECIOUS: %MAKEFILE% +.PRECIOUS: $(am.relpath.makefile) ## This rule remakes the Makefile. -%MAKEFILE%: %MAKEFILE-DEPS% $(top_builddir)/config.status +$(am.relpath.makefile): %MAKEFILE-DEPS% $(top_builddir)/config.status ## If Makefile is to be updated because of config.status, then run ## config.status without argument in order to (i) rerun all the ## AC_CONFIG_COMMANDS including those that are not visible to @@ -71,7 +72,7 @@ ## Avoid the "deleted header file" problem for the dependencies. ?HAVE-MAKEFILE-IN-DEPS?%MAKEFILE-IN-DEPS%: -am.dist.common-files += %MAKEFILE-AM% +am.dist.common-files += $(am.relpath.makefile.am) ## --------------------------- ## diff --git a/t/remake.sh b/t/remake.sh index b883d2ad5..1e50eee45 100755 --- a/t/remake.sh +++ b/t/remake.sh @@ -33,6 +33,9 @@ mkdir sub $ACLOCAL $AUTOMAKE -grep '^Makefile' sub/Makefile.in +grep -i makefile sub/Makefile.in # For debugging. +grep '^am\.relpath\.makefile = Makefile$' sub/Makefile.in +grep '^am\.relpath\.makefile\.in = \$(srcdir)/Makefile\.in$' sub/Makefile.in +grep '^am\.relpath\.makefile\.am = \$(srcdir)/Makefile\.am$' sub/Makefile.in :