chiark / gitweb /
change filenames
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Nov 2019 16:12:20 +0000 (16:12 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Nov 2019 16:12:20 +0000 (16:12 +0000)
Perdir.mk.in [deleted file]
Perdir.sd.mk [new file with mode: 0644]
Subdir.sd.mk [moved from Subdir.mk.in with 61% similarity]
lib/Subdir.sd.mk [moved from lib/Subdir.mk.in with 100% similarity]
lib/t/Subdir.sd.mk [moved from lib/t/Subdir.mk.in with 100% similarity]
src/Subdir.sd.mk [moved from src/Subdir.mk.in with 100% similarity]
subdirmk/README
subdirmk/clean.sd.mk [moved from subdirmk/clean.mk.in with 100% similarity]
subdirmk/generate
subdirmk/regen.mk.in
subdirmk/subdirmk.ac

diff --git a/Perdir.mk.in b/Perdir.mk.in
deleted file mode 100644 (file)
index 2b08993..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-&:include subdirmk/cdeps.mk.in
-&:include subdirmk/clean.mk.in
diff --git a/Perdir.sd.mk b/Perdir.sd.mk
new file mode 100644 (file)
index 0000000..76a83a9
--- /dev/null
@@ -0,0 +1,3 @@
+
+&:include subdirmk/cdeps.sd.mk
+&:include subdirmk/clean.sd.mk
similarity index 61%
rename from Subdir.mk.in
rename to Subdir.sd.mk
index e80ef5238ac816ceebbd07a8518aab6acc372c6f..4a8eec923032dba2caae29af7c94d9ac1d6b7929 100644 (file)
@@ -1,5 +1,5 @@
 
 INCLUDES       += -I&^/lib/
 
-&:include subdirmk/usual.mk.in
+include subdirmk/usual.mk
 include subdirmk/regen.mk
similarity index 100%
rename from lib/Subdir.mk.in
rename to lib/Subdir.sd.mk
similarity index 100%
rename from lib/t/Subdir.mk.in
rename to lib/t/Subdir.sd.mk
similarity index 100%
rename from src/Subdir.mk.in
rename to src/Subdir.sd.mk
index 28cff6ede159050a46044db7efdcac2abf40c422..256fdbc8e7e8ef54b83ecdd9362ebd93225d0c28 100644 (file)
@@ -26,7 +26,7 @@ Basic approach
 --------------
 
 The developer is expected to write a makefile fragment in each
-relevant subdirectory called `Subdir.mk.in'.
+relevant subdirectory called `Subdir.sd.mk'.
 
 These fragments may contain ordinary make language.
 
@@ -34,11 +34,11 @@ However, the sigil & is treated specially.  By and large, it refers to
 `the current directory'.  There are a variety of convenient
 constructions.
 
-The result is that to a large extent, the Subdir.mk.in has an easy way
+The result is that to a large extent, the Subdir.sd.mk has an easy way
 to namespace its "local" make variables, and an easy way to refer to
 its "local" filenames.
 
-The Subdir.mk.in's are filtered, fed through autoconf in the usual way
+The Subdir.sd.mk's are filtered, fed through autoconf in the usual way
 (for @..@-substitutions) and included by one autogenerated toplevel
 makefile.
 
@@ -50,7 +50,7 @@ Each subdirectory is also provided with an autogenerated `Makefile'
 which exists purely to capture ordinary make invocations and arrange
 for something suitable to happen.
 
-Where there are dependencies between subdirectories, each Subdir.mk.in
+Where there are dependencies between subdirectories, each Subdir.sd.mk
 can simply refer to files in other subdirectories directly.
 
 Invocation, "recursive" per-directory targets
@@ -66,7 +66,7 @@ But `foo' can also be a conventional target like `all'.
 Each subdirectory has its own `all' target.  For example a
 subdirectory `src' has a target `src/all'.  The rules for these are
 automatically generated from the settings of the per-directory
-&TARGETS variables.  (In src/Subdir.mk.in, this of course refers to a
+&TARGETS variables.  (In src/Subdir.sd.mk, this of course refers to a
 make variable called src_TARGETS.)
 
 The `all' target in a parent directory is taken to imply the `all'
@@ -86,24 +86,42 @@ Unlike `all', these other targets only exist in areas of the project
 where at least something mentions them.  So for example, if
 &TARGETS_zonk is mentioned in src but not lib, `make zonk' in
 lib will fail.  If you want to make a target exist everywhere,
-mention its name in Perdir.mk.in (see below).
+mention its name in Perdir.sd.mk (see below).
 
-Perdir.mk.in, inclusion
+Perdir.sd.mk, inclusion
 -----------------------
 
-The file Perdir.mk.in in the toplevel of fthe source is automatically
-processed after each individual directory's Subdir.mk.in, and the
+The file Perdir.sd.mk in the toplevel of fthe source is automatically
+processed after each individual directory's Subdir.sd.mk, and the
 &-substituted contents therefore appear once for each subdirectory.
 
 This lets you do per-directory boilerplate.  Some useful boilerplate
 is already provided in subdirmk, for you to reference like this:
-  &:include subdirmk/cdeps.mk.in
-  &:include subdirmk/clean.mk.in
+  &:include subdirmk/cdeps.sd.mk
+  &:include subdirmk/clean.sd.mk
+(for example in Perdir.sd.mk).
 
-Note that you must use &:include, which is an include processed during
-the generation of the per-directory Subdir.mk files.  That ensures
-that the contents of these files is replicated, with appropriate
-per-directory substitutions, for each directory.
+Subdirectory templates `.sd.mk' vs plain autoconf templates `.mk.in'
+--------------------------------------------------------------------
+
+There are two kinds of template files.
+
+ Filename                 .sd.mk                  .mk.in
+
+ Processed by             &-substitution,         autoconf only
+                          then autoconf
+
+ Need to be mentioned     No, but Subdir.sd.mk    All not in subdirmk/
+ in configure.ac          via SUBDIRMK_SUBDIRS    via SUBDIRMK_MAKEFILES
+
+ How to include           `&:include foo.sd.mk'   `include foo.mk'
+                         in all relevant .sd.mk  in only one
+                          (but not needed for     Subdir.sd.mk
+                           Subdir and Perdir)
+
+If you `include subdirmk/regen.mk', dependency management and
+automatic regeneration for all of this template substitution, and for
+config.status etc. is done for you.
 
 Global definitions
 ------------------
similarity index 100%
rename from subdirmk/clean.mk.in
rename to subdirmk/clean.sd.mk
index 55323d2770aec5d0ecfa2a96a132acaeaa1eb7cf..4b303bb655e20bb7765d38af5d8b40e037a847b5 100755 (executable)
@@ -3,10 +3,10 @@
 # $(srcdir)/subdirmk/generate [--srcdir=SRCDIR] [--] SUBDIR...
 #
 # generates in each subdirectory       from in each subdirectory
-#     Subdir.mk.tmp                        Subdir.mk.in
+#     Subdir.mk.tmp                        Subdir.sd.mk
 #     Makefile
 # and in toplevel                      and in toplevel
-#     main.mk.tmp                          Perdir.mk.in
+#     main.mk.tmp                          Perdir.sd.mk
 
 use strict;
 use POSIX;
@@ -124,6 +124,8 @@ sub process_input_mk ($$$$$$$$) {
        die "open $f: $!\n" unless $!==ENOENT && $enoent_ok;
        return;
     }
+    o "MAKEFILE_TEMPLATES += $f\n";
+
     while (<$input>) {
        if (s#^\s*$esc\:##) {
            $buffering_output='';
@@ -173,7 +175,6 @@ sub process_input_mk ($$$$$$$$) {
            $buffering_output=undef;
            if (m#^(-?)include\s+(\S+)\s+$#) {
                my $subf = "$srcdir/$2";
-               o "MAKEFILE_TEMPLATES += $subf\n";
                process_input_mk($dir_prefix, $dir_suffix, $dir_name,
                                 $var_prefix, $targets,
                                 $subf, $esclitr, $subf);
@@ -202,8 +203,8 @@ sub filter_subdir_mk ($$$$$) {
                         $var_prefix, $targets,
                         "${srcdir}/$f", \$esclit, $enoentok);
     };
-    $pi->("${dir_prefix}Subdir.mk.in", 0);
-    $pi->("Perdir.mk.in",              1);
+    $pi->("${dir_prefix}Subdir.sd.mk", 0);
+    $pi->("Perdir.sd.mk",              1);
 }
 
 sub process_subtree ($$);
index b8e031f7686c929cf5e1da072162a43bebe621e3..eb54fc3f7353bf50ee60fc6400407178e66fe495 100644 (file)
@@ -12,16 +12,16 @@ $(top_srcdir)/$(CONFIGURE): $(addprefix $(top_srcdir)/,$(CONFIGURE_ACS))
 $(CONFIG_STATUS): $(top_srcdir)/$(CONFIGURE)
        ./$(CONFIG_STATUS) --recheck
 
-MAKEFILES += subdirmk/regen.mk
-
-MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.mk.in
+MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.sd.mk
+MAKEFILE_TEMPLATES += $(addprefix $(top_srcdir)/, $(addsuffix .in, \
+       @_SUBDIRMK_MAKEFILES@ \
+       ))
 
 main.mk $(MAKEFILES): .makefiles.stamp ;
 .makefiles.stamp:                                              \
                $(top_srcdir)/subdirmk/generate                 \
                $(CONFIG_STATUS)                                \
-               $(MAKEFILE_TEMPLATES)                           \
-               $(foreach m,$(MAKEFILES),$(top_srcdir)/$(m).in)
+               $(MAKEFILE_TEMPLATES)
 # This filtering arranges that we can often run config.status to
 # generate only particular output files.  We look for *inputs* that
 # have changed.  If the only inputs that have changed are ones that we
@@ -31,11 +31,12 @@ main.mk $(MAKEFILES): .makefiles.stamp ;
 # regen.mk.in twice because if $(top_srcdir) is `.', make elides the
 # directory part from $?.
        ./$(CONFIG_STATUS) $(if                                 \
-               $(filter-out Subdir.mk.in %/Subdir.mk.in        \
-                       subdirmk/regen.mk.in                    \
-                       $(top_srcdir)/subdirmk/regen.mk.in      \
+               $(filter-out Subdir.sd.mk %/Subdir.sd.mk        \
+                            %.mk.in                            \
                        , $?),,                                 \
-               $(sort $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?))))
+               $(sort                                          \
+                       $(patsubst %.sd.mk,%.mk,$(filter %.sd.mk,$?)) \
+                       $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?))))
        touch $@
 
 realclean:: clean
index aebde1638d45e95f7057b1b8e66ffd13256a5789..e8150f48ae9faa6fe16bd00911ce49b96e16c218 100644 (file)
@@ -1,19 +1,31 @@
 
+_SUBDIRMK_MAKEFILES=""
+AC_SUBST([_SUBDIRMK_MAKEFILES])
+
 AC_DEFUN([SUBDIRMK_SUBDIRS],
-[m4_map_args_w([$1],[_SUBDIRMK_SUBDIR(],[/)])])dnl
+[_SUBDIRMK_INIT
+m4_map_args_w([$1],[_SUBDIRMK_SUBDIR(],[/)])])dnl
 
 AC_DEFUN_ONCE([_SUBDIRMK_INIT],[
   AC_CONFIG_FILES([
        main.mk:main.mk.tmp
        Subdir.mk:Subdir.mk.tmp
-       subdirmk/regen.mk
        ],[],[
-     '$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirsmk_subdirs 
+     '$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirmk_subdirs
   ])
+  SUBDIRMK_MAKEFILES([subdirmk/regen.mk subdirmk/usual.mk])
 ])
 
 AC_DEFUN([_SUBDIRMK_SUBDIR],[
-  AC_REQUIRE([_SUBDIRMK_INIT])
-  subdirsmk_subdirs="$subdirsmk_subdirs '$1'"
+  subdirmk_subdirs="$subdirmk_subdirs '$1'"
   AC_CONFIG_FILES([$1Subdir.mk:$1Subdir.mk.tmp])
 ])
+
+AC_DEFUN([SUBDIRMK_MAKEFILES],
+[_SUBDIRMK_INIT
+m4_map_args_w([$1],[_SUBDIRMK_MAKEFILE(],[)])])dnl
+
+AC_DEFUN([_SUBDIRMK_MAKEFILE],[
+  _SUBDIRMK_MAKEFILES="$_SUBDIRMK_MAKEFILES $1"
+  AC_CONFIG_FILES([$1:$1.in])
+])