chiark / gitweb /
&:include feature
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Nov 2019 13:48:21 +0000 (13:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Nov 2019 13:48:21 +0000 (13:48 +0000)
subdirmk/README
subdirmk/generate
subdirmk/regen.mk.in

index 7cf84cf..5da0c3d 100644 (file)
 & ~ thing thing... &           & may be omitted before EOL or before \EOL
                                other &'s not recognised
 
+start of line (maybe after ws):
+&:<directive> <args>....
+args are processed for & first
+&:include filename             filename should usually be foo.mk.in
+&:-include filename
+
 CAPS is [A-Z][0-9_A-Z]*(?!\w)
 lc is [a-z][-+,0-9_a-z]*(?!\w)
 
index 7b8727b..3208c8d 100755 (executable)
@@ -125,6 +125,9 @@ sub process_input_mk ($$$$$$$$) {
        return;
     }
     while (<$input>) {
+       if (s#^\s*$esc\:##) {
+           $buffering_output='';
+       }
        for (;;) {
            unless (s{^(.*?)(\\)?(?=$esc)}{}) { o $_; last; }
            o $1;
@@ -165,6 +168,20 @@ sub process_input_mk ($$$$$$$$) {
                die "bad escape $$esclitr$_ ";
            }
        }
+       if (defined $buffering_output) {
+           $_=$buffering_output;
+           $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);
+               o "\n";
+           } else {
+               die "unknown directive $_ ";
+           }
+       }
     }
     $input->error and die "read $f: $!\n";
     close $input or die "close $f: $!\n";
index 7e9f0cf..bc05e72 100644 (file)
@@ -14,11 +14,13 @@ $(CONFIG_STATUS): $(top_srcdir)/$(CONFIGURE)
 
 MAKEFILES += subdirmk/regen.mk
 
+MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.mk.in
+
 main.mk $(MAKEFILES): .makefiles.stamp ;
 .makefiles.stamp:                                              \
                $(top_srcdir)/subdirmk/generate                 \
                $(CONFIG_STATUS)                                \
-               $(top_srcdir)/Perdir.mk.in                      \
+               $(MAKEFILE_TEMPLATES)                           \
                $(foreach m,$(MAKEFILES),$(top_srcdir)/$(m).in)
 # This filtering arranges that we can often run config.status to
 # generate only particular output files.  We look for *inputs* that