diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-06-12 14:48:12 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-07-02 15:02:59 +0200 |
commit | 3da1457d426f1be7b9f792fce1461a7b8227d7e7 (patch) | |
tree | 390a6401061fe9385ee81c18c692fb01c3459776 /m4 | |
parent | 097930059adbd5061a5f78e2b91e339f91a32a18 (diff) | |
download | automake-3da1457d426f1be7b9f792fce1461a7b8227d7e7.tar.gz |
recursion: support user-defined recursive targets
The user can now define his own recursive targets that recurse
in the directories specified in $(SUBDIRS). That can be done by
specifying the name of such targets in invocations of the new
'AM_EXTRA_RECURSIVE_TARGETS' m4 macro.
The API goes like this:
$ cat configure.ac
AC_INIT([pkg-name], [1.0]
AM_INIT_AUTOMAKE
AM_EXTRA_RECURSIVE_TARGETS([foo])
AC_CONFIG_FILES([Makefile sub/Makefile])
AC_OUTPUT
$ cat Makefile.am
SUBDIRS = sub
foo-local:
@echo This will be run by "make foo".
$ cat sub/Makefile.am
foo-local:
@echo This too will be run by a "make foo" issued either in
@echo the 'sub/' directory or in the top-level directory.
Like for the "default" recursive targets (e.g., 'all' and 'check'),
the user-defined recursive targets descend in the $(SUBDIRS) in a
depth-first fashion, and process '.' last (unless that is explicitly
specified in $(SUBDIRS)).
* NEWS, doc/automake.texi: Document the new feature.
* automake.in (@extra_recursive_targets): New global variable.
(scan_autoconf_traces): Trace macro '_AM_EXTRA_RECURSIVE_TARGETS'.
(handle_user_recursion): New subroutine; among other things, it defines
the new internal '$(am__extra_recursive_targets)' make variable, and
the '*-am', '*-local' and '*-recursive' targets associated with the
user-specified user recursive targets.
(generate_makefile): Call the new subroutine.
* lib/am/subdirs.am (am__recursive_targets): New internal make variable,
listing all of '$(RECURSIVE_TARGETS)', '$(RECURSIVE_CLEAN_TARGETS)' and
'$(am__extra_recursive_targets)' together.
(AM_RECURSIVE_TARGETS): Adjust the definition of this variable ...
(.PHONY, .MAKE): ... and the list of dependencies of these special targets
to take advantage of the new '$(am__recursive_targets)' variable.
($(am__recursive_targets)): New targets, superseding ...
($(RECURSIVE_TARGETS), $(RECURSIVE_CLEAN_TARGETS)): ... these, and
inheriting their rules. This way, the rules to handle recursion for
built-in recursive targets (e.g., 'all', 'dvi', 'clean') and for user
defined recursive targets are the same.
* m4/extra-recurs.m4: New file, contain definition of new macro
'AM_EXTRA_RECURSIVE_TARGETS' and '_AM_EXTRA_RECURSIVE_TARGETS'.
These macros are basically dummy, only used for tracing by automake.
* m4/Makefile.am (dist_automake_ac_DATA): Update.
* t/recurs-user.sh: New test.
* t/recurs-user2.sh: Likewise.
* t/recurs-user-deeply-nested.sh: Likewise.
* t/recurs-user-indir.sh: Likewise.
* t/recurs-user-keep-going.sh: Likewise.
* t/recurs-user-many.sh: Likewise.
* t/recurs-user-no-subdirs.sh: Likewise.
* t/recurs-user-no-top-level.sh: Likewise.
* t/recurs-user-override.sh: Likewise.
* t/recurs-user-phony.sh: Likewise.
* t/recurs-user-wrap.sh: Likewise.
* t/remake-recurs-user.sh: Likewise.
* t/list-of-tests.mk: Update.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'm4')
-rw-r--r-- | m4/extra-recurs.m4 | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/m4/extra-recurs.m4 b/m4/extra-recurs.m4 new file mode 100644 index 000000000..7b7ecc71b --- /dev/null +++ b/m4/extra-recurs.m4 @@ -0,0 +1,17 @@ +# AM_EXTRA_RECURSIVE_TARGETS -*- Autoconf -*- + +# Copyright (C) 2012 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_EXTRA_RECURSIVE_TARGETS +# -------------------------- +# Define the list of user recursive targets. This macro exists only to +# be traced by Automake, which will ensure that a proper definition of +# user-defined recursive targets (and associated rules) is propagated +# into all the generated Makefiles. +AC_DEFUN([AM_EXTRA_RECURSIVE_TARGETS], [_$0(m4_flatten([$1]))]) +# TODO: We should really reject non-literal arguments here... +m4_define([_AM_EXTRA_RECURSIVE_TARGETS], []) |