From 983e0900816ece898f3d53a530fe0f2c73932bbc Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 12:11:34 +0000 Subject: [PATCH 01/16] site, pubkeys: Avoid for (int a=... In jessie, gcc hates this unless you pass -std=gnu11 or something. Signed-off-by: Ian Jackson --- pubkeys.c | 3 ++- site.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pubkeys.c b/pubkeys.c index 6dc741b..6ea877b 100644 --- a/pubkeys.c +++ b/pubkeys.c @@ -30,7 +30,8 @@ void keyset_dispose(struct peer_keyset **ks_io) ks->refcount--; assert(ks->refcount>=0); if (ks->refcount) return; - for (int ki=0; kinkeys; ki++) { + int ki; + for (ki=0; kinkeys; ki++) { struct sigpubkey_if *pk=ks->keys[ki].pubkey; pk->dispose(pk->st); } diff --git a/site.c b/site.c index 72cee24..0887513 100644 --- a/site.c +++ b/site.c @@ -787,7 +787,8 @@ static bool_t unpick_msg(struct site *st, uint32_t type, if (type_is_msg23(type) && m->remote.extrainfo.size) { m->n_pubkeys_accepted_nom = buf_unprepend_uint8(&m->remote.extrainfo); if (!m->n_pubkeys_accepted_nom) return False; - for (int ki_nom=0; ki_nomn_pubkeys_accepted_nom; ki_nom++) { + int ki_nom; + for (ki_nom=0; ki_nomn_pubkeys_accepted_nom; ki_nom++) { CHECK_AVAIL(&m->remote.extrainfo,KEYIDSZ); struct sigkeyid *kid = buf_unprepend(&m->remote.extrainfo,KEYIDSZ); if (ki_nompubkeys_accepted[ki_nom] = kid; -- 2.30.2 From e340aa7d80a9b2844cee91731496b4715b674f5e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 12:40:51 +0000 Subject: [PATCH 02/16] Revert "site, pubkeys: Avoid for (int a=..." This reverts commit 983e0900816ece898f3d53a530fe0f2c73932bbc. --- pubkeys.c | 3 +-- site.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pubkeys.c b/pubkeys.c index 6ea877b..6dc741b 100644 --- a/pubkeys.c +++ b/pubkeys.c @@ -30,8 +30,7 @@ void keyset_dispose(struct peer_keyset **ks_io) ks->refcount--; assert(ks->refcount>=0); if (ks->refcount) return; - int ki; - for (ki=0; kinkeys; ki++) { + for (int ki=0; kinkeys; ki++) { struct sigpubkey_if *pk=ks->keys[ki].pubkey; pk->dispose(pk->st); } diff --git a/site.c b/site.c index 0887513..72cee24 100644 --- a/site.c +++ b/site.c @@ -787,8 +787,7 @@ static bool_t unpick_msg(struct site *st, uint32_t type, if (type_is_msg23(type) && m->remote.extrainfo.size) { m->n_pubkeys_accepted_nom = buf_unprepend_uint8(&m->remote.extrainfo); if (!m->n_pubkeys_accepted_nom) return False; - int ki_nom; - for (ki_nom=0; ki_nomn_pubkeys_accepted_nom; ki_nom++) { + for (int ki_nom=0; ki_nomn_pubkeys_accepted_nom; ki_nom++) { CHECK_AVAIL(&m->remote.extrainfo,KEYIDSZ); struct sigkeyid *kid = buf_unprepend(&m->remote.extrainfo,KEYIDSZ); if (ki_nompubkeys_accepted[ki_nom] = kid; -- 2.30.2 From 6c10f89e825f80f027fac2cb3b3b0b86bcd1d7ef Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 12:39:39 +0000 Subject: [PATCH 03/16] configure[.ac]: Arrange to cope with jessie's gcc Signed-off-by: Ian Jackson --- configure | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 22 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/configure b/configure index 43de16e..152c8ed 100755 --- a/configure +++ b/configure @@ -4132,6 +4132,54 @@ fi done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking required gcc -std flag" >&5 +$as_echo_n "checking required gcc -std flag... " >&6; } +if ${secnet_cv_gcc_std_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else + + secnet_cv_gcc_std_flag="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +void x(void) { for (int i=0; i<1; i++) { } } + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + + old_cflags="$CFLAGS" + CFLAGS="$CFLAGS -std=gnu11" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +void x(void) { for (int i=0; i<1; i++) { } } + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + secnet_cv_gcc_std_flag=" -std=gnu11" + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failure!" >&5 +$as_echo "failure!" >&6; } + as_fn_error 1 "cannot get test program to compile" "$LINENO" 5 + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$old_cflags" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $secnet_cv_gcc_std_flag" >&5 +$as_echo "$secnet_cv_gcc_std_flag" >&6; } +CFLAGS="$CFLAGS$secnet_cv_gcc_std_flag" + { $as_echo "$as_me:${as_lineno-$LINENO}: Checking requirements for IPv6 support..." >&5 $as_echo "$as_me: Checking requirements for IPv6 support..." >&6;} enable_ipv6=true diff --git a/configure.ac b/configure.ac index 674ed36..471a6e7 100644 --- a/configure.ac +++ b/configure.ac @@ -102,6 +102,28 @@ REQUIRE_HEADER([adns.h]) AC_CHECK_FUNCS([fmemopen funopen]) +dnl gcc 4.9.2 (jessie) requires -std=gnu11 to cope with for (int i=... +dnl but we do not want to pass that everywhere because we don't want +dnl to nail down the C dialect this way. Why oh why oh why. +m4_define([for_gcc_std],[ +void x(void) { for (int i=0; i<1; i++) { } } +]) +AC_CACHE_CHECK([required gcc -std flag],[secnet_cv_gcc_std_flag],[ + secnet_cv_gcc_std_flag="" + AC_COMPILE_IFELSE([AC_LANG_SOURCE(for_gcc_std)],[],[ + old_cflags="$CFLAGS" + CFLAGS="$CFLAGS -std=gnu11" + AC_COMPILE_IFELSE([AC_LANG_SOURCE(for_gcc_std)],[ + secnet_cv_gcc_std_flag=" -std=gnu11" + ],[ + AC_MSG_RESULT([failure!]) + AC_MSG_ERROR([cannot get test program to compile],1) + ]) + CFLAGS="$old_cflags" + ]) +]) +CFLAGS="$CFLAGS$secnet_cv_gcc_std_flag" + AC_MSG_NOTICE([Checking requirements for IPv6 support...]) enable_ipv6=true m4_define(NO_IPV6,[enable_ipv6=false]) -- 2.30.2 From 8d8707b7b3f83131e70ae47522dc15092544f4fd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 12:48:27 +0000 Subject: [PATCH 04/16] Finalise 0.6.0 Signed-off-by: Ian Jackson --- Dir.sd.mk | 2 +- debian/changelog | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dir.sd.mk b/Dir.sd.mk index baabaf6..7671a38 100644 --- a/Dir.sd.mk +++ b/Dir.sd.mk @@ -20,7 +20,7 @@ .PHONY: all clean realclean distclean dist install PACKAGE:=secnet -VERSION=0.5.1 +VERSION=0.6.0 VPATH:=@srcdir@ srcdir:=@srcdir@ diff --git a/debian/changelog b/debian/changelog index d6c135c..a801484 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -secnet (0.6.0~) unstable; urgency=medium +secnet (0.6.0) unstable; urgency=medium Bugfixes: * mobile sites: Do not ever expire peer addresses. In practice @@ -68,7 +68,7 @@ secnet (0.6.0~) unstable; urgency=medium * stest: Better support for cwd with longish pathname. * stest: More flexibility, env var hooks, etc. - -- + -- Ian Jackson Sun, 16 Feb 2020 12:48:13 +0000 secnet (0.5.1) unstable; urgency=medium -- 2.30.2 From 467bca7101e601aa31eb30a210db7fcad3dff900 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 13:00:49 +0000 Subject: [PATCH 05/16] changelog: Start 0.6.1 Signed-off-by: Ian Jackson --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index a801484..9ee83bd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +secnet (0.6.1~) unstable; urgency=medium + + * + + -- + secnet (0.6.0) unstable; urgency=medium Bugfixes: -- 2.30.2 From 553de1ddc3e88cb2f198f4ebef12c5464511c165 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 13:21:00 +0000 Subject: [PATCH 06/16] startup: Break out start_sites We were going to want to change when this happens. But actually it seems that is not right. Keep the commit anyway, as I think it improves clarity a bit. No functional change. Signed-off-by: Ian Jackson --- secnet.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/secnet.c b/secnet.c index 69467de..de16eb3 100644 --- a/secnet.c +++ b/secnet.c @@ -187,11 +187,9 @@ static void parse_options(int argc, char **argv) static void setup(dict_t *config) { list_t *l; - item_t *site; dict_t *system; struct passwd *pw; struct cloc loc; - int i; l=dict_lookup(config,"system"); @@ -226,6 +224,12 @@ static void setup(dict_t *config) "that secnet retain root privileges while running.", require_root_privileges_explanation); } +} + +static void start_sites(dict_t *config) { + int i; + list_t *l; + item_t *site; /* Go along site list, starting sites */ l=dict_lookup(config,sites_key); @@ -504,6 +508,7 @@ int main(int argc, char **argv) enter_phase(PHASE_SETUP); setup(config); + start_sites(config); if (just_check_config) { Message(M_INFO,"configuration file check complete\n"); -- 2.30.2 From 3909ecb7f090c792902cc97ecba00bb1660d1f53 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 14:42:31 +0000 Subject: [PATCH 07/16] logging: start rather earlier This moves some messages printed by by early netlink and polypath setup to the proper logfile / syslog directly, rather than having them captured by the stderr capture from daemonize. Signed-off-by: Ian Jackson --- log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/log.c b/log.c index f3b5cbd..f937d2e 100644 --- a/log.c +++ b/log.c @@ -455,7 +455,7 @@ static list_t *logfile_apply(closure_t *self, struct cloc loc, dict_t *context, st->level=string_list_to_word(dict_lookup(dict,"class"), message_class_table,"logfile"); - add_hook(PHASE_GETRESOURCES,logfile_phase_hook,st); + add_hook(PHASE_DAEMONIZE,logfile_phase_hook,st); add_hook(PHASE_CHILDPERSIST,logfile_childpersist_hook,st); return new_closure(&st->cl); @@ -567,7 +567,7 @@ static list_t *syslog_apply(closure_t *self, struct cloc loc, dict_t *context, st->facility=string_to_word(facstr,loc, syslog_facility_table,"syslog"); st->open=False; - add_hook(PHASE_GETRESOURCES,syslog_phase_hook,st); + add_hook(PHASE_DAEMONIZE,syslog_phase_hook,st); add_hook(PHASE_CHILDPERSIST,syslog_phase_hook,st); return new_closure(&st->cl); -- 2.30.2 From df16d73e458739ba66c1c6a1fb07f57b3ddcd5c4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 14:21:09 +0000 Subject: [PATCH 08/16] logging: site: Introduce transport_peers_init which doesn't log This eliminates some spurious startup messages. It also allows transport_peers_clear to read *peers, since it doesn't have to do initialisation. Signed-off-by: Ian Jackson --- site.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/site.c b/site.c index 72cee24..ee4c310 100644 --- a/site.c +++ b/site.c @@ -257,6 +257,7 @@ typedef struct { } transport_peers; /* Basic operations on transport peer address sets */ +static void transport_peers_init(struct site *st, transport_peers *peers); static void transport_peers_clear(struct site *st, transport_peers *peers); static int transport_peers_valid(transport_peers *peers); static void transport_peers_copy(struct site *st, transport_peers *dst, @@ -2512,8 +2513,8 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, st->chosen_transform=0; st->current.key_timeout=0; st->auxiliary_key.key_timeout=0; - transport_peers_clear(st,&st->peers); - transport_peers_clear(st,&st->setup_peers); + transport_peers_init(st,&st->peers); + transport_peers_init(st,&st->setup_peers); /* XXX mlock these */ st->dhsecret=safe_malloc(st->dh->len,"site:dhsecret"); st->sharedsecretlen=st->sharedsecretallocd=0; @@ -2729,6 +2730,9 @@ static void transport_data_msgok(struct site *st, const struct comm_addr *a) { static int transport_peers_valid(transport_peers *peers) { return peers->npeers; } +static void transport_peers_init(struct site *st, transport_peers *peers) { + peers->npeers= 0; +} static void transport_peers_clear(struct site *st, transport_peers *peers) { peers->npeers= 0; transport_peers_debug(st,peers,"clear",0,0,0); -- 2.30.2 From a45f890ecb0ab78d56ec95dbbbf01400eda22939 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 14:18:49 +0000 Subject: [PATCH 09/16] logging; site: Do not log transport_peers_clear if already clear This suppresses a pointles message at startup. Signed-off-by: Ian Jackson --- site.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site.c b/site.c index ee4c310..317bdc5 100644 --- a/site.c +++ b/site.c @@ -2734,8 +2734,10 @@ static void transport_peers_init(struct site *st, transport_peers *peers) { peers->npeers= 0; } static void transport_peers_clear(struct site *st, transport_peers *peers) { + bool_t need_debug=!!peers->npeers; peers->npeers= 0; - transport_peers_debug(st,peers,"clear",0,0,0); + if (need_debug) + transport_peers_debug(st,peers,"clear",0,0,0); } static void transport_peers_copy(struct site *st, transport_peers *dst, const transport_peers *src) { -- 2.30.2 From 03896be378f2295290f2d75cfec28f5b9b430136 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 14:23:24 +0000 Subject: [PATCH 10/16] site: Change site->control(bool_t) to site->startup() This is only ever called with run=True. We are going to want to rely on this property. If we ever do more runtime reconfig that will be done differently. Signed-off-by: Ian Jackson --- secnet.c | 2 +- secnet.h | 4 ++-- site.c | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/secnet.c b/secnet.c index de16eb3..a00124f 100644 --- a/secnet.c +++ b/secnet.c @@ -247,7 +247,7 @@ static void start_sites(dict_t *config) { cfgfatal(site->loc,"system","non-site closure in site list"); } s=site->data.closure->interface; - s->control(s->st,True); + s->startup(s->st); } } } diff --git a/secnet.h b/secnet.h index d447ffb..fd4b48f 100644 --- a/secnet.h +++ b/secnet.h @@ -659,11 +659,11 @@ void log_early_init(void); /* Pretty much a placeholder; allows starting and stopping of processing, key expiry, etc. */ -typedef void site_control_fn(void *st, bool_t run); +typedef void site_startup_fn(void *st); typedef uint32_t site_status_fn(void *st); struct site_if { void *st; - site_control_fn *control; + site_startup_fn *startup; site_status_fn *status; }; diff --git a/site.c b/site.c index 317bdc5..a071500 100644 --- a/site.c +++ b/site.c @@ -2283,11 +2283,10 @@ static bool_t site_incoming(void *sst, struct buffer_if *buf, return False; } -static void site_control(void *vst, bool_t run) +static void site_startup(void *vst) { struct site *st=vst; - if (run) enter_state_run(st); - else enter_state_stop(st); + enter_state_run(st); } static void site_phase_hook(void *sst, uint32_t newphase) @@ -2331,7 +2330,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, st->cl.apply=NULL; st->cl.interface=&st->ops; st->ops.st=st; - st->ops.control=site_control; + st->ops.startup=site_startup; st->ops.status=site_status; st->peerkeys_path=0; st->peerkeys_tmpl.buffer=0; -- 2.30.2 From 9eba4abfe44617aa78f625d900fe6bc2c58bb4cb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 14:47:24 +0000 Subject: [PATCH 11/16] logging: Move "starting" message earlier We are going to add some log messages to PHASE_RUN hooks. We want the overall startup message to come first. Doing this right after PHASE_DAEMONIZE makes sense as PHASE_DAEMONIZE now sets up logging, too. Signed-off-by: Ian Jackson --- secnet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/secnet.c b/secnet.c index a00124f..2ebcddc 100644 --- a/secnet.c +++ b/secnet.c @@ -329,8 +329,6 @@ static void run(void) struct pollfd *fds=0; int allocdfds=0, shortfall=0; - Message(M_NOTICE,"%s [%d]: starting\n",version,secnet_pid); - do { if (gettimeofday(&tv_now_global, NULL)!=0) { fatal_perror("main loop: gettimeofday"); @@ -517,6 +515,7 @@ int main(int argc, char **argv) enter_phase(PHASE_DAEMONIZE); become_daemon(); + Message(M_NOTICE,"%s [%d]: starting\n",version,secnet_pid); enter_phase(PHASE_GETRESOURCES); /* Appropriate phase hooks will have been run */ -- 2.30.2 From 1c56b25a6e2054c0f0628e2f343f5a0df2a7772c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 15:06:00 +0000 Subject: [PATCH 12/16] site: Rename site_phase_hook to site_phase_shutdown_hook This is misnamed. And we are going to add yet another phase hook. Signed-off-by: Ian Jackson --- site.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site.c b/site.c index a071500..358f406 100644 --- a/site.c +++ b/site.c @@ -2289,7 +2289,7 @@ static void site_startup(void *vst) enter_state_run(st); } -static void site_phase_hook(void *sst, uint32_t newphase) +static void site_phase_shutdown_hook(void *sst, uint32_t newphase) { struct site *st=sst; @@ -2551,7 +2551,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, enter_state_stop(st); - add_hook(PHASE_SHUTDOWN,site_phase_hook,st); + add_hook(PHASE_SHUTDOWN,site_phase_shutdown_hook,st); add_hook(PHASE_CHILDPERSIST,site_childpersist_clearkeys,st); return new_closure(&st->cl); -- 2.30.2 From 4d9d6e20e19c1aaa0d138e70897d136b36d673c0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 15:06:34 +0000 Subject: [PATCH 13/16] logging: site: Log state on PHASE_RUN entry instead of initially site_startup calls enter_state_run which would print a message, but logging is not set up that early. The result is a message printed to stderr before daemonisation. We can distinguish this situation from other calls to enter_state_run because the old state is SITE_STOP, which only occurs between config reading (closure invocation) and site_startup being called. So we can suppress this message. But it did serve a purpose: it would only be printed if the site was listed in `sites'; otherwise site_startup wouldn't be called and the `entering state RUN' message would be absent. So instead we provide a more explicit way to tell: on entering PHASE_RUN, site_startup has either been called, or not. And logging is set up. state is then STOP or RUN. Signed-off-by: Ian Jackson --- site.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/site.c b/site.c index 358f406..191c364 100644 --- a/site.c +++ b/site.c @@ -1712,8 +1712,9 @@ static void set_link_quality(struct site *st) static void enter_state_run(struct site *st) { - slog(st,LOG_STATE,"entering state RUN%s", - current_valid(st) ? " (keyed)" : " (unkeyed)"); + if (st->state!=SITE_STOP) + slog(st,LOG_STATE,"entering state RUN%s", + current_valid(st) ? " (keyed)" : " (unkeyed)"); st->state=SITE_RUN; st->timeout=0; @@ -2297,6 +2298,13 @@ static void site_phase_shutdown_hook(void *sst, uint32_t newphase) send_msg7(st,"shutting down"); } +static void site_phase_run_hook(void *sst, uint32_t newphase) +{ + struct site *st=sst; + slog(st,LOG_STATE,"entering phase RUN in state %s", + state_name(st->state)); +} + static void site_childpersist_clearkeys(void *sst, uint32_t newphase) { struct site *st=sst; @@ -2552,6 +2560,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, enter_state_stop(st); add_hook(PHASE_SHUTDOWN,site_phase_shutdown_hook,st); + add_hook(PHASE_RUN, site_phase_run_hook, st); add_hook(PHASE_CHILDPERSIST,site_childpersist_clearkeys,st); return new_closure(&st->cl); -- 2.30.2 From e289974c7a39cad65013d4c5e472558b5669506d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 17:29:52 +0000 Subject: [PATCH 14/16] README: Fix documentation errors relating to &{ etc. Signed-off-by: Ian Jackson --- README | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README b/README index bea3c1b..c30f3b6 100644 --- a/README +++ b/README @@ -229,15 +229,15 @@ STUFF $ THINGS .. STUFF $$ THINGS &{..$..} => ${eval ${call ..$$..}} (matches { } pairs to find the end) content is $-doubled (unless it contains &$- to turn that off) - cf &(...), see "Convenience syntax for eval", below. + contrast &(...), see "Convenience syntax for call", below. -Together &:macro and &${...} provide a more reasonable macro facility +Together &:macro and &{...} provide a more reasonable macro facility than raw make. They solve the problem that make expansions cannot -directly generate multiple rules, variable, etc.; instead, `$(eval )' +directly generate multiple rules, variables, etc.; instead, `$(eval )' must be used, but that re-expands the argument, meaning that all the literal text must be $-doubled. This applies to the macro text and to the arguments. Also `$(eval $(call ...))' is an unfortunate syntax. -Hence &:macro and &${...}. +Hence &:macro and &{...}. While dollar-doubling: - - - - - - - - - - - @@ -253,7 +253,7 @@ A few contexts do not support $-doubling, such as directive arguments or places where this might imply $-quadrupling. (There is no way to get $-quadrupling.) -Convenience syntax for eval +Convenience syntax for call - - - - - - - - - - - - - - &(thing => $(call thing @@ -265,6 +265,10 @@ Convenience syntax for eval Unlike &{...}, this does not involve any dollar-doubling. +Use this when the expansion is going to be a piece of text to be used +as part of a rule, filename, etc. When the expansion is top-level +make text (eg, rules), use &:macro and &{...}. + Invocation, "recursive" per-directory targets --------------------------------------------- -- 2.30.2 From 2a5416707829f758cd5435e1d7c6075e633ef3fd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 18:39:51 +0000 Subject: [PATCH 15/16] README: Update copyright date Signed-off-by: Ian Jackson --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index c30f3b6..f79a280 100644 --- a/README +++ b/README @@ -542,8 +542,8 @@ Legal information ================= subdirmk is + Copyright 2019-2020 Ian Jackson Copyright 2019 Mark Wooding - Copyright 2019 Ian Jackson subdirmk and its example is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public -- 2.30.2 From 53121a9100463959968d21a7f9372844d71dfb6a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Feb 2020 18:06:23 +0000 Subject: [PATCH 16/16] Makefiles: Use Final.sd.mk to implementing RECHECK_RM This is now read by make after all the other makefiles. This allows us to move the addition of {stest,mtest}/d-* to RECHECK_RM from Dir.sd.mk into test-common.sd.mk, where it belongs. Signed-off-by: Ian Jackson --- Dir.sd.mk | 11 ----------- Final.sd.mk | 25 +++++++++++++++++++++++++ test-common.sd.mk | 2 ++ 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 Final.sd.mk diff --git a/Dir.sd.mk b/Dir.sd.mk index 7671a38..a2c54eb 100644 --- a/Dir.sd.mk +++ b/Dir.sd.mk @@ -129,17 +129,6 @@ TESTDIRS=stest mtest &TARGETS_fullcheck += msgcode-test.confirm RECHECK_RM += $(&TARGETS_check) -RECHECK_RM += $(addsuffix /d-*, $(TESTDIRS)); -# Really the eval below should come very late, so that subdirs can add -# their stuff to RECHECK_RM, but we do not have a way to do that with -# subdirmk yet. So we embed ad-hoc knowledge about TESTDIRS. - -# This contrives to delete things before make starts, if the user -# said "recheck". The alternative is having recheck be a target -# which contains the rm's and then runs $(MAKE) again but then -# we recursively re-enter make in parallel, which is Bad. -$(eval $(if $(filter recheck,$(MAKECMDGOALS)), \ - $(shell set -x; rm -rf $(RECHECK_RM) ))) recheck: check diff --git a/Final.sd.mk b/Final.sd.mk new file mode 100644 index 0000000..fc26601 --- /dev/null +++ b/Final.sd.mk @@ -0,0 +1,25 @@ +# Final.sd.mk for secnet +# +# This file is part of secnet. +# See README for full list of copyright holders. +# +# secnet is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# secnet is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# version 3 along with secnet; if not, see +# https://www.gnu.org/licenses/gpl.html. + +# This contrives to delete things before make starts, if the user +# said "recheck". The alternative is having recheck be a target +# which contains the rm's and then runs $(MAKE) again but then +# we recursively re-enter make in parallel, which is Bad. +$(eval $(if $(filter recheck,$(MAKECMDGOALS)), \ + $(shell set -x; rm -rf $(RECHECK_RM) ))) diff --git a/test-common.sd.mk b/test-common.sd.mk index 0b7f4df..2bc48eb 100644 --- a/test-common.sd.mk +++ b/test-common.sd.mk @@ -15,6 +15,8 @@ endif &check-real: $(foreach t,$(&TESTNAMES),&d-$t/ok) +RECHECK_RM += &d-* + CHECK_SILENT ?= @ &d-%/ok: &^/t-% $(&DEPS) -- 2.30.2