chiark / gitweb /
Interface: Rename Perdir to Suffix; provide Prefix
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Dec 2019 22:45:50 +0000 (22:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 11:35:15 +0000 (11:35 +0000)
We want to be able to specify something that appears at the top of
every per-directory segment, principally to provide
for-every-directory variable settings.

A more sophisticated scheme akin to m4 diversions would be possible in
principle, but it would make organising the output files (which must
be processed by autoconf) really awkward - let alone the depenency
management for regenerating the makefiles.

So instead, simply provide a Prefix too.  Additionally, soon we are
going to introduce a Final.sd.mk which is processed right at the end.

I think this new scheme will be sufficient in principle to do anything
that might be needed.  Sadly it will continue to require that
&:include's are done in the right order.

"Suffix" and "Subdir" tab-complete really badly.  In a forthcoming
commit we will rename Subdir.sd.mk to Dir.sd.mk.

Incompatible change.  We must update the tests right away.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README
cdeps.sd.mk
clean.sd.mk
example/Suffix.sd.mk [moved from example/Perdir.sd.mk with 100% similarity]
generate
tests/filter/Perdir.sd.mk [deleted file]
tests/filter/Prefix.sd.mk [new file with mode: 0644]
tests/filter/Subdir.mk.expected
tests/filter/Suffix.sd.mk [new file with mode: 0644]
tests/filter/main.mk.expected
tests/filter/sub/dir/Subdir.mk.expected

diff --git a/README b/README
index 360afbd351686e5f2d0ebfde1a486d5ac4967b40..e3259c0924414e19770c5fa42007646696ddbdab 100644 (file)
--- a/README
+++ b/README
@@ -90,20 +90,21 @@ 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.sd.mk (see below).
+mention its name in Prefix.sd.mk or Suffix.sd.mk (see below).
 
-Perdir.sd.mk, inclusion
------------------------
+Prefix.sd.mk, Suffix.sd.mk, inclusion
+-------------------------------------
 
-The file Perdir.sd.mk in the toplevel of the source is automatically
-processed after each individual directory's Subdir.sd.mk, and the
-&-substituted contents therefore appear once for each subdirectory.
+The files Prefix.sd.mk and Suffix.sd.mk in the toplevel of the source
+are automatically processed before and 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.sd.mk
   &:include subdirmk/clean.sd.mk
-For example you could put that in Perdir.sd.mk.
+For example you could put that in Suffix.sd.mk.
 
 The top-level Subdir.sd.mk is the first makefile included after the
 autogenerated `main.mk' which merely has some basic settings and
@@ -147,7 +148,7 @@ There are two kinds of template files.
  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)
+                           Prefix, Suffix)
 
 If you `include subdirmk/regen.mk', dependency management and
 automatic regeneration for all of this template substitution, and for
@@ -354,7 +355,7 @@ probably contain:
   include subdirmk/usual.mk
   include subdirmk/regen.mk
 
-Write a Perdir.sd.mk in the toplevel, if you want.  It should probably
+Write a Suffix.sd.mk in the toplevel, if you want.  It should probably
 have:
 
   &:include subdirmk/cdeps.sd.mk
index 5a2bfb28df5bf2737c2c556eac31b1090c7b41db..37438306abbdb1243bf18d4d01f16b0cf4fec28f 100644 (file)
@@ -5,7 +5,7 @@
 
 &# Usage:
 &#   &:include subdirmk/cdeps.sd.mk
-&# (probably in Perdir.sd.mk)
+&# (probably in Suffix.sd.mk)
 &#
 &# Arranges for automatic #include dependency tracking for
 &# C compilation.  The compiler is asked to write the dependencies to
index 80c40bcab123ff29b9a3e6601b0cfcbf80fec422..b145442183d7c450ea09f49a3a87db2ffbbc9815 100644 (file)
@@ -5,7 +5,7 @@
 
 &# Usage:
 &#   &:include subdirmk/clean.sd.mk
-&# (probably in Perdir.sd.mk)
+&# (probably in Suffix.sd.mk)
 &#
 &# Provides a per-directory `clean' target, which deletes all the files
 &# in &CLEAN.  &OBJECTS, &DEPFILES and &TARGETS are automatically deleted.
similarity index 100%
rename from example/Perdir.sd.mk
rename to example/Suffix.sd.mk
index a3c8b4f96cc688a5f86ed2bba31ed85f73e3a168..5273e1543d2567a79096d3103a619fd3111cee72 100755 (executable)
--- a/generate
+++ b/generate
@@ -234,8 +234,9 @@ sub filter_subdir_mk ($) {
        my ($f, $enoentok) = @_;
        process_input_mk($targets, "${srcdir}/$f", \$esclit, $enoentok);
     };
+    $pi->("Prefix.sd.mk",              1);
     $pi->("${dir_prefix}Subdir.sd.mk", 0);
-    $pi->("Perdir.sd.mk",              1);
+    $pi->("Suffix.sd.mk",              1);
 }
 
 sub process_subtree ($$);
diff --git a/tests/filter/Perdir.sd.mk b/tests/filter/Perdir.sd.mk
deleted file mode 100644 (file)
index 0bc254d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-# Perdir in &.
diff --git a/tests/filter/Prefix.sd.mk b/tests/filter/Prefix.sd.mk
new file mode 100644 (file)
index 0000000..da3a735
--- /dev/null
@@ -0,0 +1 @@
+# Prefix in &.
index b1124418f244d2e04d428fc283134ed382bc7e74..cf4841a11794cfb852e938b9ad2e68caf7541a38 100644 (file)
@@ -1,7 +1,8 @@
 # autogenerated - do not edit
+# Prefix in .
 # test cases for generate script
 # doctests:
-# Perdir in .
+# Suffix in .
 
 all:: $(TOP_TARGETS) sub/all
 sometarget1:: $(TOP_TARGETS_sometarget1) sub/sometarget1
diff --git a/tests/filter/Suffix.sd.mk b/tests/filter/Suffix.sd.mk
new file mode 100644 (file)
index 0000000..453de60
--- /dev/null
@@ -0,0 +1 @@
+# Suffix in &.
index 4a4779f555d76a2758cec8d94c74202288b86f59..95cae4875f26cdd6188049cd5bb097f768c1f05b 100644 (file)
@@ -6,8 +6,9 @@ MAKEFILE_TEMPLATES :=
 SUBDIRMK_MAKEFILES += Subdir.mk
 SUBDIRMK_MAKEFILES += sub/Subdir.mk
 SUBDIRMK_MAKEFILES += sub/dir/Subdir.mk
-MAKEFILE_TEMPLATES += ./Perdir.sd.mk
+MAKEFILE_TEMPLATES += ./Prefix.sd.mk
 MAKEFILE_TEMPLATES += ./Subdir.sd.mk
+MAKEFILE_TEMPLATES += ./Suffix.sd.mk
 MAKEFILE_TEMPLATES += ./doctest.sd.mk
 MAKEFILE_TEMPLATES += ./sub/dir/Subdir.sd.mk
 MAKEFILE_TEMPLATES += ./sub/dir/doctest.sd.mk
index e5aadc23e3a8262b8809e5981325ef77614d1d15..6748cdcbb79b046b414ceefedff8c05b54c245df 100644 (file)
@@ -1,4 +1,5 @@
 # autogenerated - do not edit
+# Prefix in sub/dir
 # subdirectory test cases
 
 sub/dir/
@@ -10,7 +11,7 @@ sub_dir_TARGETS_sometarget2
 line joining
 
 # doctests:
-# Perdir in sub/dir
+# Suffix in sub/dir
 
 sub/dir/all:: $(sub_dir_TARGETS)
 sub/dir/sometarget1:: $(sub_dir_TARGETS_sometarget1)