1
0
mirror of https://github.com/PDP-10/klh10.git synced 2026-02-08 01:01:56 +00:00

Add carefully crafted Makefile for recursing into subdirectories...

that is compatile with both real Make and GNU Make.
This commit is contained in:
Olaf Seibert
2016-02-12 20:32:14 +01:00
parent 056e6bfadc
commit 7d3bc2cfba
2 changed files with 29 additions and 0 deletions

28
mk/bld.mk Normal file
View File

@@ -0,0 +1,28 @@
# Makefile to build in the subdirectories.
# Designed to be both BSD Make and GNU Make compatible
# (as are all the other Makefiles).
#
# The RECURSE macro uses a shell variable $TARGET for delayed expansion.
RECURSE=for d in bld-* ; \
do \
${MAKE} -C $$d $${TARGET} ; \
done
# This carefully crafted rule will run Make in all subdirectories with
# the same target, no matter what it is (as long as it is just one
# target).
#
# .TARGETS is a BSD specific variable, and MAKECMDGOALS is the GNU version.
# .TARGETS becomes "rEmOvEmE" when no targets are given on the
# command line (because this is the default target).
# MAKECMDGOALS remains empty in that case.
# Do not use "all" as the extra target, since that fails when that is
# given as target on the command line (you get duplicate targets).
# The shell variable substitution removes "rEmOvEmE" if present.
# So when no target is given, the recursion uses no target either.
${.TARGETS} ${MAKECMDGOALS} rEmOvEmE :
# set -x; T="${.TARGETS}${MAKECMDGOALS}"; echo "T=$$T"; TARGET="$${T%%rEmOvEmE}"; echo "TARGET=$$TARGET"
T="${.TARGETS}${MAKECMDGOALS}"; TARGET="$${T%%rEmOvEmE}"; ${RECURSE}