chiark / gitweb /
subdirmk: Implement new syntax
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Nov 2019 19:36:39 +0000 (19:36 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Nov 2019 19:37:07 +0000 (19:37 +0000)
But I plan to go back to ^ and ~

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
example/Subdir.sd.mk
example/lib/Subdir.sd.mk
generate

index 5c2040a..162d7ce 100644 (file)
@@ -3,7 +3,7 @@
 #  Copyright 2019 Ian Jackson
 # SPDX-License-Identifier: LGPL-2.0-or-later
 
-INCLUDES       += -I&^/lib/
+INCLUDES       += -I&;lib/
 
 include subdirmk/usual.mk
 include subdirmk/regen.mk
index c2939c5..8ac946d 100644 (file)
@@ -10,4 +10,4 @@
 &libtoy.a:     $(&OBJECTS)
        $(AR) rc $@ $^
 
--include &^/lib/for-test.mk
+-include &,for-test.mk
index 0bb4b7b..b4c52ae 100755 (executable)
--- a/generate
+++ b/generate
@@ -131,6 +131,12 @@ sub process_input_mk ($$$$$$$$) {
     }
     $input_files{$f}++;
 
+    my %pfxmap = (
+                 ''  => $dir_prefix,
+                 ',' => "\$(top_srcdir)${dir_suffix}/",
+                 ';' => "\$(top_srcdir)/",
+                );
+
     while (<$input>) {
        if (s#^\s*$esc\:##) {
            $buffering_output='';
@@ -147,19 +153,13 @@ sub process_input_mk ($$$$$$$$) {
                $targets->{$t} //= [ ];
            }
            elsif (m{^(?=$caps_re)}) { o $var_prefix }
-           elsif (m{^(?=$lc_re)}) { o $dir_prefix }
+           elsif (s{^([,;]?)(?=$lc_re)}{}) { o $pfxmap{$1} }
            elsif (s{^_}{}) { o $var_prefix }
-           elsif (s{^/}{}) { o $dir_prefix }
            elsif (s{^=_}{}) { o $var_prefix }
+           elsif (s{^([,;]?)/}{}) { o $pfxmap{$1} }
            elsif (s{^=/}{}) { o $dir_name }
-           elsif (s{^\^}{}) { o "\$(top_srcdir)${dir_suffix}" }
-           elsif (s{^\}}{}) { o "\$(abs_top_srcdir)${dir_suffix}" }
-           elsif (s{^(?:[ \t]+([~^]))?(?=[ \t])}{}) {
-               my $prefix =
-                   !$1       ? $dir_prefix                     :
-                   $1 eq '~' ? '$(abs_top_srcdir)'.$dir_suffix :
-                   $1 eq '~' ? '$(abs_top_srcdir)'.$dir_suffix :
-                   die;
+           elsif (s{^([,;]?)(?=[ \t])}{}) {
+               my $prefix = $pfxmap{$1} // die;
                my $after='';
                if (m{([ \t])$esc}) { ($_,$after) = ($`, $1.$'); }
                s{(?<=[ \t])(?=\S)(?!\\\s*$)}{$prefix}g;