From: Ian Jackson Date: Thu, 14 Nov 2019 19:36:39 +0000 (+0000) Subject: subdirmk: Implement new syntax X-Git-Tag: v0.5.1~21 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=commitdiff_plain;h=2226fa7498d1aafa57fb9d23a35d96089acbdfa2 subdirmk: Implement new syntax But I plan to go back to ^ and ~ Signed-off-by: Ian Jackson --- diff --git a/mtest/Subdir.sd.mk b/mtest/Subdir.sd.mk index 9921717..7c9953e 100644 --- a/mtest/Subdir.sd.mk +++ b/mtest/Subdir.sd.mk @@ -1,7 +1,7 @@ -&DEPS += $(src)/make-secnet-sites -&DEPS += $(src)/ipaddrset.py -&DEPS += &^/common.tcl +&DEPS += $; make-secnet-sites +&DEPS += $; ipaddrset.py +&DEPS += &, common.tcl &:include test-common.sd.mk diff --git a/stest/Subdir.sd.mk b/stest/Subdir.sd.mk index 222e82c..6eb3209 100644 --- a/stest/Subdir.sd.mk +++ b/stest/Subdir.sd.mk @@ -2,7 +2,7 @@ &TARGETS += & udp-preload.so &DEPS += & udp-preload.so -&DEPS += &^/common.tcl +&DEPS += &, common.tcl &DEPS += secnet &DEPS += test-example/sites.conf &DEPS += test-example/inside.key diff --git a/subdirmk/example/Subdir.sd.mk b/subdirmk/example/Subdir.sd.mk index 5c2040a..162d7ce 100644 --- a/subdirmk/example/Subdir.sd.mk +++ b/subdirmk/example/Subdir.sd.mk @@ -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 diff --git a/subdirmk/example/lib/Subdir.sd.mk b/subdirmk/example/lib/Subdir.sd.mk index c2939c5..8ac946d 100644 --- a/subdirmk/example/lib/Subdir.sd.mk +++ b/subdirmk/example/lib/Subdir.sd.mk @@ -10,4 +10,4 @@ &libtoy.a: $(&OBJECTS) $(AR) rc $@ $^ --include &^/lib/for-test.mk +-include &,for-test.mk diff --git a/subdirmk/generate b/subdirmk/generate index 0bb4b7b..b4c52ae 100755 --- a/subdirmk/generate +++ b/subdirmk/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; diff --git a/test-common.sd.mk b/test-common.sd.mk index 0584a98..b830264 100644 --- a/test-common.sd.mk +++ b/test-common.sd.mk @@ -1,7 +1,7 @@ include common.make -&TESTSCRIPTS ?= $(shell echo &^/t-*[0-9a-z]) +&TESTSCRIPTS ?= $(shell echo &,t-*[0-9a-z]) &TESTNAMES := $(patsubst t-%,%,$(notdir $(&TESTSCRIPTS))) &DEPS += $(src)/test-common.tcl @@ -15,7 +15,7 @@ include common.make CHECK_SILENT ?= @ -&d-%/ok: &^/t-% $(&DEPS) +&d-%/ok: &,t-% $(&DEPS) $(CHECK_SILENT) rm -rf &d-$*; mkdir &d-$* $(CHECK_SILENT) export SECNET_TEST_BUILDDIR=$(topbuilddir); \ export PYTHONBYTECODEBASE=/dev/null; \ diff --git a/test-example/Subdir.sd.mk b/test-example/Subdir.sd.mk index 66cdaf8..835aab6 100644 --- a/test-example/Subdir.sd.mk +++ b/test-example/Subdir.sd.mk @@ -2,11 +2,11 @@ include common.make -&/%.key: &^/%.key.b64 +&/%.key: &,/%.key.b64 base64 -d <$< >$@.new && mv -f $@.new $@ -&sites.conf: $(src)/make-secnet-sites &^/sites Subdir.mk - $(src)/make-secnet-sites &^/sites &sites.conf +&sites.conf: $(src)/make-secnet-sites &,sites Subdir.mk + $(src)/make-secnet-sites &,sites &sites.conf &clean:: rm -f *~ ./#*# *.new