From f3d60905c4aa3b85e61a218e67903185c68f1074 Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Thu, 11 Jan 2018 11:04:34 +0100 Subject: [PATCH 1/3] Adds SUBDIR_ALL to make it optional that all targets recurse --- subdir.mk.nw | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/subdir.mk.nw b/subdir.mk.nw index e8b0f65..1559685 100644 --- a/subdir.mk.nw +++ b/subdir.mk.nw @@ -6,8 +6,15 @@ The subdirectories must be listed in the variable [[SUBDIR]], which holds a space-separated list of directory names. Then each subdirectory may in turn hold a new set of subdirectories to descend into. -We note that the subdirectories will be built in depth-first search order. +We note that the subdirectories will be built in depth-first search order +(unless we allow parallel execution). +By default, for any goals passed on the command line we will add the directories +in [[SUBDIR]] as prerequisites. +This behaviour can be overridden by setting [[SUBDIR_ALL]] to anything different +from [[yes]]. +Like this we can add the subdirectories in [[SUBDIR]] as prerequisites manually +to only a subset of desired targets. \section{Implementation} @@ -20,10 +27,15 @@ ifndef SUBDIR_MK SUBDIR_MK=true ifdef SUBDIR -<> <> endif +SUBDIR_ALL?=yes + +ifeq (${SUBDIR_ALL},yes) +<> +endif + endif @ @@ -35,7 +47,9 @@ with the goals specified on the command-line. <>= ${SUBDIR}:: ${MAKE} -C $@ ${MAKECMDGOALS} -@ To ensure these recipes are run we need to ensure that they are prerequisites +@ + +To ensure these recipes are run we need to ensure that they are prerequisites to the goals. This also means that if no goals are given on the command-line, then we should use the default goal. From 64f6866ba3f12c265c27b723cb760be947cbc808 Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Thu, 11 Jan 2018 11:05:59 +0100 Subject: [PATCH 2/3] Adds new precompiled version of subdir.mk --- subdir.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subdir.mk b/subdir.mk index b689b61..2c6c54e 100644 --- a/subdir.mk +++ b/subdir.mk @@ -2,14 +2,19 @@ ifndef SUBDIR_MK SUBDIR_MK=true ifdef SUBDIR +${SUBDIR}:: + ${MAKE} -C $@ ${MAKECMDGOALS} +endif + +SUBDIR_ALL?=yes + +ifeq (${SUBDIR_ALL},yes) ifneq (${MAKECMDGOALS},) .PHONY: ${MAKECMDGOALS} ${MAKECMDGOALS}: ${SUBDIR} else ${.DEFAULT_GOAL}: ${SUBDIR} endif -${SUBDIR}:: - ${MAKE} -C $@ ${MAKECMDGOALS} endif endif From 87566175636a4868c280df90c94ec567488a867c Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Thu, 11 Jan 2018 11:26:49 +0100 Subject: [PATCH 3/3] subdir.mk propagates INCLUDE_MAKEFILES as search path We want to propagate the INCLUDE_MAKEFILES so that we only have to modify the root Makefile in an old (MIUN) repo. --- subdir.mk | 5 ++++- subdir.mk.nw | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/subdir.mk b/subdir.mk index 2c6c54e..be687fc 100644 --- a/subdir.mk +++ b/subdir.mk @@ -1,9 +1,12 @@ ifndef SUBDIR_MK SUBDIR_MK=true +INCLUDE_MAKEFILES?=. + ifdef SUBDIR +.PHONY: ${SUBDIR} ${SUBDIR}:: - ${MAKE} -C $@ ${MAKECMDGOALS} + ${MAKE} -C $@ -I ${INCLUDE_MAKEFILES} ${MAKECMDGOALS} endif SUBDIR_ALL?=yes diff --git a/subdir.mk.nw b/subdir.mk.nw index 1559685..95228ed 100644 --- a/subdir.mk.nw +++ b/subdir.mk.nw @@ -26,6 +26,8 @@ containing the space-separated list of subdirectories, exists. ifndef SUBDIR_MK SUBDIR_MK=true +INCLUDE_MAKEFILES?=. + ifdef SUBDIR <> endif @@ -45,9 +47,14 @@ the targets specified on the command-line, in all subdirectories listed in For each directory, we specify a recipe which runs make in the subdirectory with the goals specified on the command-line. <>= +.PHONY: ${SUBDIR} ${SUBDIR}:: - ${MAKE} -C $@ ${MAKECMDGOALS} -@ + ${MAKE} -C $@ -I ${INCLUDE_MAKEFILES} ${MAKECMDGOALS} +@ We also want to give the sub-make access to our [[INCLUDE_MAKEFILES]], hence +the [[-I]] option. +This is mostly due to (backwards) compatibility with the MIUN versions (see +\cref{miun.compat.mk}) of the makefiles, which pre-dates the +[[INCLUDE_MAKEFILES]] construction. To ensure these recipes are run we need to ensure that they are prerequisites to the goals.