1
0
mirror of https://github.com/PDP-10/klh10.git synced 2026-01-11 23:52:54 +00:00
PDP-10.klh10/mk/bld.mk
Olaf Seibert 7d3bc2cfba Add carefully crafted Makefile for recursing into subdirectories...
that is compatile with both real Make and GNU Make.
2016-02-12 20:56:42 +01:00

29 lines
1.1 KiB
Makefile

# 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}