1994-08-04 21:09:27 +00:00
|
|
|
# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
|
1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
1997-03-09 00:14:00 +00:00
|
|
|
#
|
|
|
|
# The include file <bsd.subdir.mk> contains the default targets
|
2005-01-06 11:12:43 +00:00
|
|
|
# for building subdirectories.
|
1997-03-09 00:14:00 +00:00
|
|
|
#
|
|
|
|
# For all of the directories listed in the variable SUBDIRS, the
|
|
|
|
# specified directory will be visited and the target made. There is
|
|
|
|
# also a default target which allows the command "make subdir" where
|
|
|
|
# subdir is any directory listed in the variable SUBDIRS.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# +++ variables +++
|
|
|
|
#
|
2002-04-23 22:16:41 +00:00
|
|
|
# DISTRIBUTION Name of distribution. [base]
|
1997-03-09 00:14:00 +00:00
|
|
|
#
|
|
|
|
# SUBDIR A list of subdirectories that should be built as well.
|
|
|
|
# Each of the targets will execute the same target in the
|
2020-03-17 18:17:32 +00:00
|
|
|
# subdirectories. SUBDIR.yes and SUBDIR.yes.yes are
|
|
|
|
# automatically appended to this list.
|
1997-03-09 00:14:00 +00:00
|
|
|
#
|
|
|
|
# +++ targets +++
|
|
|
|
#
|
|
|
|
# distribute:
|
|
|
|
# This is a variant of install, which will
|
|
|
|
# put the stuff into the right "distribution".
|
|
|
|
#
|
2016-01-19 22:42:07 +00:00
|
|
|
# See SUBDIR_TARGETS for list of targets that will recurse.
|
1997-03-09 00:14:00 +00:00
|
|
|
#
|
2015-10-23 21:30:27 +00:00
|
|
|
# Targets defined in STANDALONE_SUBDIR_TARGETS will always be ran
|
|
|
|
# with SUBDIR_PARALLEL and will not respect .WAIT or SUBDIR_DEPEND_
|
|
|
|
# values.
|
|
|
|
#
|
2016-01-19 22:42:07 +00:00
|
|
|
# SUBDIR_TARGETS and STANDALONE_SUBDIR_TARGETS can be appended to
|
|
|
|
# via make.conf or src.conf.
|
|
|
|
#
|
1997-03-09 00:14:00 +00:00
|
|
|
|
2012-11-07 22:02:02 +00:00
|
|
|
.if !target(__<bsd.subdir.mk>__)
|
|
|
|
__<bsd.subdir.mk>__:
|
|
|
|
|
2017-11-01 21:22:16 +00:00
|
|
|
.if ${MK_AUTO_OBJ} == "no"
|
|
|
|
_obj= obj
|
|
|
|
.endif
|
|
|
|
|
2016-01-19 22:42:07 +00:00
|
|
|
SUBDIR_TARGETS+= \
|
2016-02-26 22:14:00 +00:00
|
|
|
all all-man analyze buildconfig buildfiles buildincludes \
|
2016-01-19 22:42:07 +00:00
|
|
|
checkdpadd clean cleandepend cleandir cleanilinks \
|
|
|
|
cleanobj depend distribute files includes installconfig \
|
2018-09-17 22:15:09 +00:00
|
|
|
installdirs \
|
2017-11-17 18:16:46 +00:00
|
|
|
installfiles installincludes print-dir realinstall \
|
2017-11-01 21:22:16 +00:00
|
|
|
maninstall manlint ${_obj} objlink tags \
|
2015-10-13 19:42:57 +00:00
|
|
|
|
2015-10-23 21:30:27 +00:00
|
|
|
# Described above.
|
2016-01-19 22:42:07 +00:00
|
|
|
STANDALONE_SUBDIR_TARGETS+= \
|
2016-02-24 22:27:22 +00:00
|
|
|
all-man buildconfig buildfiles buildincludes check checkdpadd \
|
|
|
|
clean cleandepend cleandir cleanilinks cleanobj files includes \
|
2018-09-17 22:15:09 +00:00
|
|
|
installconfig installdirs installincludes installfiles print-dir \
|
2016-08-31 19:30:52 +00:00
|
|
|
maninstall manlint obj objlink
|
2016-02-24 22:27:22 +00:00
|
|
|
|
|
|
|
# It is safe to install in parallel when staging.
|
2017-06-21 18:56:53 +00:00
|
|
|
.if defined(NO_ROOT) || !empty(SYSROOT)
|
2016-02-24 22:27:22 +00:00
|
|
|
STANDALONE_SUBDIR_TARGETS+= realinstall
|
|
|
|
.endif
|
2015-10-23 21:30:27 +00:00
|
|
|
|
2002-04-17 13:49:29 +00:00
|
|
|
.include <bsd.init.mk>
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2016-08-31 19:30:52 +00:00
|
|
|
.if make(print-dir)
|
|
|
|
NEED_SUBDIR= 1
|
|
|
|
ECHODIR= :
|
|
|
|
.SILENT:
|
|
|
|
.if ${RELDIR:U.} != "."
|
|
|
|
print-dir: .PHONY
|
|
|
|
@echo ${RELDIR}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2017-11-01 21:22:16 +00:00
|
|
|
.if ${MK_AUTO_OBJ} == "yes" && !target(obj)
|
|
|
|
obj: .PHONY
|
|
|
|
.endif
|
|
|
|
|
2015-06-10 18:14:38 +00:00
|
|
|
.if !defined(NEED_SUBDIR)
|
2016-11-13 00:11:05 +00:00
|
|
|
# .MAKE.DEPENDFILE==/dev/null is set by bsd.dep.mk to avoid reading
|
|
|
|
# Makefile.depend
|
|
|
|
.if ${.MAKE.LEVEL} == 0 && ${MK_DIRDEPS_BUILD} == "yes" && !empty(SUBDIR) && \
|
|
|
|
${.MAKE.DEPENDFILE} != "/dev/null"
|
2012-08-22 19:25:57 +00:00
|
|
|
.include <meta.subdir.mk>
|
|
|
|
# ignore this
|
|
|
|
_SUBDIR:
|
|
|
|
.endif
|
|
|
|
.endif
|
2015-08-27 01:55:00 +00:00
|
|
|
|
Moved the `distribute' target from bsd.obj.mk to bsd.subdir.mk,
to make it call `install' in the bsd.subdir.mk-driven makefiles
too. (share/examples/Makefile,v 1.29 changed the bsd.prog.mk
to bsd.subdir.mk and many stuff was lost during "make release".
I then merged this change in rev. 1.28.2.2 to work around the
namespace pollution (FILES) in this makefile.)
There was an added complexity here. Both the `distribute' and
`install' targets are recursive (they propagate to SUBDIRs).
So `distribute' first calls `install' in the ${.CURDIR}, then
calls `distribute' in each SUBDIR, etc. The problem is that
`install' (being also recursive) causes the stuff from SUBDIR
to be installed twice, first time thru `install' in ${.CURDIR}
triggered by `distribute', second time by `distribute' run in
the SUBDIR. This problem is not new, but it became apparent
only after I moved the `distribute' target from bsd.obj.mk to
bsd.subdir.mk. My first attempt testing the fix failed due to
this, because the whole world was distributed twice, causing
all the imaginable mess (kerberos5 stuff was installed into both
"base" and "krb5" dists, there was /sbin/init.bak, etc.)
I say the problem is not new because bsd.prog.mk and bsd.lib.mk
makefiles with SUBDIR (even without this fix) had this problem
for years. Try e.g. running ``make distribute DISTDIR=/foo''
from usr.bin/bzip2 or from lib/libcom_err (without the fix) and
watch the output.
So the solution was to make `install' behave non-recursive when
executed by `distribute'. My first attempt in passing SUBDIR=
to the `install' in the `distribute' body failed because of the
way how src/Makefile and src/Makefile.inc1 communicate with each
other. SUBDIR='s assignment precedence on the "make install
SUBDIR=" command line is lowered after src/Makefile wrapper calls
"make ... -f ${.CURDIR}/Makefile.inc1 install" because SUBDIR=
is moved into environment, and Makefile.inc1's assignments now
take higher precedence. This may be fixed someday when we merge
Makefile with Makefile.inc1. For now, this is implemented as a
NO_SUBDIR knob.
Spotted by: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
Prodded by: des
MFC after: 3 days
2002-07-12 15:09:35 +00:00
|
|
|
DISTRIBUTION?= base
|
|
|
|
.if !target(distribute)
|
2013-06-14 16:25:41 +00:00
|
|
|
distribute: .MAKE
|
Moved the `distribute' target from bsd.obj.mk to bsd.subdir.mk,
to make it call `install' in the bsd.subdir.mk-driven makefiles
too. (share/examples/Makefile,v 1.29 changed the bsd.prog.mk
to bsd.subdir.mk and many stuff was lost during "make release".
I then merged this change in rev. 1.28.2.2 to work around the
namespace pollution (FILES) in this makefile.)
There was an added complexity here. Both the `distribute' and
`install' targets are recursive (they propagate to SUBDIRs).
So `distribute' first calls `install' in the ${.CURDIR}, then
calls `distribute' in each SUBDIR, etc. The problem is that
`install' (being also recursive) causes the stuff from SUBDIR
to be installed twice, first time thru `install' in ${.CURDIR}
triggered by `distribute', second time by `distribute' run in
the SUBDIR. This problem is not new, but it became apparent
only after I moved the `distribute' target from bsd.obj.mk to
bsd.subdir.mk. My first attempt testing the fix failed due to
this, because the whole world was distributed twice, causing
all the imaginable mess (kerberos5 stuff was installed into both
"base" and "krb5" dists, there was /sbin/init.bak, etc.)
I say the problem is not new because bsd.prog.mk and bsd.lib.mk
makefiles with SUBDIR (even without this fix) had this problem
for years. Try e.g. running ``make distribute DISTDIR=/foo''
from usr.bin/bzip2 or from lib/libcom_err (without the fix) and
watch the output.
So the solution was to make `install' behave non-recursive when
executed by `distribute'. My first attempt in passing SUBDIR=
to the `install' in the `distribute' body failed because of the
way how src/Makefile and src/Makefile.inc1 communicate with each
other. SUBDIR='s assignment precedence on the "make install
SUBDIR=" command line is lowered after src/Makefile wrapper calls
"make ... -f ${.CURDIR}/Makefile.inc1 install" because SUBDIR=
is moved into environment, and Makefile.inc1's assignments now
take higher precedence. This may be fixed someday when we merge
Makefile with Makefile.inc1. For now, this is implemented as a
NO_SUBDIR knob.
Spotted by: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
Prodded by: des
MFC after: 3 days
2002-07-12 15:09:35 +00:00
|
|
|
.for dist in ${DISTRIBUTION}
|
2004-08-09 10:54:05 +00:00
|
|
|
${_+_}cd ${.CURDIR}; \
|
2016-06-01 20:44:28 +00:00
|
|
|
${MAKE} install installconfig -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
|
Moved the `distribute' target from bsd.obj.mk to bsd.subdir.mk,
to make it call `install' in the bsd.subdir.mk-driven makefiles
too. (share/examples/Makefile,v 1.29 changed the bsd.prog.mk
to bsd.subdir.mk and many stuff was lost during "make release".
I then merged this change in rev. 1.28.2.2 to work around the
namespace pollution (FILES) in this makefile.)
There was an added complexity here. Both the `distribute' and
`install' targets are recursive (they propagate to SUBDIRs).
So `distribute' first calls `install' in the ${.CURDIR}, then
calls `distribute' in each SUBDIR, etc. The problem is that
`install' (being also recursive) causes the stuff from SUBDIR
to be installed twice, first time thru `install' in ${.CURDIR}
triggered by `distribute', second time by `distribute' run in
the SUBDIR. This problem is not new, but it became apparent
only after I moved the `distribute' target from bsd.obj.mk to
bsd.subdir.mk. My first attempt testing the fix failed due to
this, because the whole world was distributed twice, causing
all the imaginable mess (kerberos5 stuff was installed into both
"base" and "krb5" dists, there was /sbin/init.bak, etc.)
I say the problem is not new because bsd.prog.mk and bsd.lib.mk
makefiles with SUBDIR (even without this fix) had this problem
for years. Try e.g. running ``make distribute DISTDIR=/foo''
from usr.bin/bzip2 or from lib/libcom_err (without the fix) and
watch the output.
So the solution was to make `install' behave non-recursive when
executed by `distribute'. My first attempt in passing SUBDIR=
to the `install' in the `distribute' body failed because of the
way how src/Makefile and src/Makefile.inc1 communicate with each
other. SUBDIR='s assignment precedence on the "make install
SUBDIR=" command line is lowered after src/Makefile wrapper calls
"make ... -f ${.CURDIR}/Makefile.inc1 install" because SUBDIR=
is moved into environment, and Makefile.inc1's assignments now
take higher precedence. This may be fixed someday when we merge
Makefile with Makefile.inc1. For now, this is implemented as a
NO_SUBDIR knob.
Spotted by: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
Prodded by: des
MFC after: 3 days
2002-07-12 15:09:35 +00:00
|
|
|
.endfor
|
|
|
|
.endif
|
bsd.subdir.mk: Only recurse on called targets, rather than dependencies.
This is to fix 'make all' causing it to recurse on both 'all' and 'buildconfig'
due to 'buildconfig' being in ALL_SUBDIR_TARGETS and being a dependency of
'all'.
This now adds all of the '*includes', '*files' targets as subdir targets,
allowing them to recurse.
This also removes the need for some 'realinstall' hacks in bsd.subdir.mk since
it no longer recurses; only 'install' will recurse and call the proper
'beforeinstall', 'realinstall', and 'afterinstall' in each sub-directory.
This fixes 'make includes' and 'make files' to not be a rerolled ${MAKE}
sub-shell but to rather just recurse on 'inclues' and 'files'. This avoids
various issues such as the one fixed in r289462. As such revert Makefile.inc1
back to using 'includes' which avoids an extra tree walk and parallelizes
the includes phases better.
Makefile.inc1 includes a guard so that 'make all' will not use SUBDIR_PARALLEL,
added in r289438. This is so users do not get a probably broken build if they
run 'make all' from the top-level. Before the change in this commit, the
workaround for 'make everything' was 'par-all' which would depend on 'all' and
cause a proper parallel recursion. Now that will not work so a new
_PARALLEL_SUBUDIR_OK is used to allow it.
This is still part of an effort to combine bsd.(files|incs|confs).mk and move
some of its logic out of bsd.subdir.mk, as attempted in r289282 and reverted in
r289331. This commit fixes the problems found there which was mostly double
recursing during 'includes' which would recurse on itself and 'buildincludes'
and 'installincludes', all in parallel. The logic is still in bsd.subdir.mk
for now.
I've been cautious about this commit but have experienced no breakage on the
tree except for the 'par-all' case which was already a hack. If something foo
is depending on something bar that should recurse, it is very likely that the
foo target is being recursed on already meaning that bar will still effectively
recurse once sub-directories call foo.
Discussed on: arch@
MFC after: never
Sponsored by: EMC / Isilon Storage Division
2015-12-02 01:50:22 +00:00
|
|
|
# Convenience targets to run 'build${target}' and 'install${target}' when
|
|
|
|
# calling 'make ${target}'.
|
|
|
|
.for __target in files includes
|
|
|
|
.if !target(${__target})
|
|
|
|
${__target}: build${__target} install${__target}
|
|
|
|
.ORDER: build${__target} install${__target}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
# Make 'install' supports a before and after target. Actual install
|
|
|
|
# hooks are placed in 'realinstall'.
|
|
|
|
.if !target(install)
|
|
|
|
.for __stage in before real after
|
|
|
|
.if !target(${__stage}install)
|
|
|
|
${__stage}install:
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
install: beforeinstall realinstall afterinstall
|
|
|
|
.ORDER: beforeinstall realinstall afterinstall
|
|
|
|
.endif
|
2016-02-16 02:14:15 +00:00
|
|
|
.ORDER: all install
|
bsd.subdir.mk: Only recurse on called targets, rather than dependencies.
This is to fix 'make all' causing it to recurse on both 'all' and 'buildconfig'
due to 'buildconfig' being in ALL_SUBDIR_TARGETS and being a dependency of
'all'.
This now adds all of the '*includes', '*files' targets as subdir targets,
allowing them to recurse.
This also removes the need for some 'realinstall' hacks in bsd.subdir.mk since
it no longer recurses; only 'install' will recurse and call the proper
'beforeinstall', 'realinstall', and 'afterinstall' in each sub-directory.
This fixes 'make includes' and 'make files' to not be a rerolled ${MAKE}
sub-shell but to rather just recurse on 'inclues' and 'files'. This avoids
various issues such as the one fixed in r289462. As such revert Makefile.inc1
back to using 'includes' which avoids an extra tree walk and parallelizes
the includes phases better.
Makefile.inc1 includes a guard so that 'make all' will not use SUBDIR_PARALLEL,
added in r289438. This is so users do not get a probably broken build if they
run 'make all' from the top-level. Before the change in this commit, the
workaround for 'make everything' was 'par-all' which would depend on 'all' and
cause a proper parallel recursion. Now that will not work so a new
_PARALLEL_SUBUDIR_OK is used to allow it.
This is still part of an effort to combine bsd.(files|incs|confs).mk and move
some of its logic out of bsd.subdir.mk, as attempted in r289282 and reverted in
r289331. This commit fixes the problems found there which was mostly double
recursing during 'includes' which would recurse on itself and 'buildincludes'
and 'installincludes', all in parallel. The logic is still in bsd.subdir.mk
for now.
I've been cautious about this commit but have experienced no breakage on the
tree except for the 'par-all' case which was already a hack. If something foo
is depending on something bar that should recurse, it is very likely that the
foo target is being recursed on already meaning that bar will still effectively
recurse once sub-directories call foo.
Discussed on: arch@
MFC after: never
Sponsored by: EMC / Isilon Storage Division
2015-12-02 01:50:22 +00:00
|
|
|
|
2015-12-04 07:54:19 +00:00
|
|
|
# SUBDIR recursing may be disabled for MK_DIRDEPS_BUILD
|
|
|
|
.if !target(_SUBDIR)
|
|
|
|
|
2020-03-17 18:17:32 +00:00
|
|
|
.if defined(SUBDIR) || defined(SUBDIR.yes) || defined(SUBDIR.yes.yes)
|
|
|
|
SUBDIR:=${SUBDIR} ${SUBDIR.yes} ${SUBDIR.yes.yes}
|
2015-12-04 07:54:19 +00:00
|
|
|
SUBDIR:=${SUBDIR:u}
|
|
|
|
.endif
|
|
|
|
|
2020-11-16 19:15:11 +00:00
|
|
|
.if defined(SUBDIR.)
|
|
|
|
.error ${.CURDIR}: Found variable SUBDIR. with value "${SUBDIR.}". This was \
|
|
|
|
probably caused by using SUBDIR.$${MK_FOO} without including \
|
|
|
|
<src.opts.mk> or by using an invalid $${MK_FOO} option.
|
|
|
|
.endif
|
|
|
|
|
2015-10-19 23:34:35 +00:00
|
|
|
# Subdir code shared among 'make <subdir>', 'make <target>' and SUBDIR_PARALLEL.
|
|
|
|
_SUBDIR_SH= \
|
|
|
|
if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \
|
|
|
|
dir=$${dir}.${MACHINE_ARCH}; \
|
|
|
|
fi; \
|
|
|
|
${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \
|
|
|
|
cd ${.CURDIR}/$${dir}; \
|
|
|
|
${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/
|
|
|
|
|
2016-08-22 22:51:01 +00:00
|
|
|
# This is kept for compatibility only. The normal handling of attaching to
|
|
|
|
# SUBDIR_TARGETS will create a target for each directory.
|
2015-10-21 16:24:44 +00:00
|
|
|
_SUBDIR: .USEBEFORE
|
Moved the `distribute' target from bsd.obj.mk to bsd.subdir.mk,
to make it call `install' in the bsd.subdir.mk-driven makefiles
too. (share/examples/Makefile,v 1.29 changed the bsd.prog.mk
to bsd.subdir.mk and many stuff was lost during "make release".
I then merged this change in rev. 1.28.2.2 to work around the
namespace pollution (FILES) in this makefile.)
There was an added complexity here. Both the `distribute' and
`install' targets are recursive (they propagate to SUBDIRs).
So `distribute' first calls `install' in the ${.CURDIR}, then
calls `distribute' in each SUBDIR, etc. The problem is that
`install' (being also recursive) causes the stuff from SUBDIR
to be installed twice, first time thru `install' in ${.CURDIR}
triggered by `distribute', second time by `distribute' run in
the SUBDIR. This problem is not new, but it became apparent
only after I moved the `distribute' target from bsd.obj.mk to
bsd.subdir.mk. My first attempt testing the fix failed due to
this, because the whole world was distributed twice, causing
all the imaginable mess (kerberos5 stuff was installed into both
"base" and "krb5" dists, there was /sbin/init.bak, etc.)
I say the problem is not new because bsd.prog.mk and bsd.lib.mk
makefiles with SUBDIR (even without this fix) had this problem
for years. Try e.g. running ``make distribute DISTDIR=/foo''
from usr.bin/bzip2 or from lib/libcom_err (without the fix) and
watch the output.
So the solution was to make `install' behave non-recursive when
executed by `distribute'. My first attempt in passing SUBDIR=
to the `install' in the `distribute' body failed because of the
way how src/Makefile and src/Makefile.inc1 communicate with each
other. SUBDIR='s assignment precedence on the "make install
SUBDIR=" command line is lowered after src/Makefile wrapper calls
"make ... -f ${.CURDIR}/Makefile.inc1 install" because SUBDIR=
is moved into environment, and Makefile.inc1's assignments now
take higher precedence. This may be fixed someday when we merge
Makefile with Makefile.inc1. For now, this is implemented as a
NO_SUBDIR knob.
Spotted by: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
Prodded by: des
MFC after: 3 days
2002-07-12 15:09:35 +00:00
|
|
|
.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
|
2015-12-04 07:54:13 +00:00
|
|
|
@${_+_}target=${.TARGET:realinstall=install}; \
|
2015-10-29 00:41:03 +00:00
|
|
|
for dir in ${SUBDIR:N.WAIT}; do ( ${_SUBDIR_SH} ); done
|
2002-04-23 09:03:56 +00:00
|
|
|
.endif
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2016-08-22 22:51:07 +00:00
|
|
|
# Create 'make subdir' targets to run the real 'all' target.
|
|
|
|
.for __dir in ${SUBDIR:N.WAIT}
|
|
|
|
${__dir}: all_subdir_${DIRPRFX}${__dir} .PHONY
|
|
|
|
.endfor
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2016-01-19 22:42:07 +00:00
|
|
|
.for __target in ${SUBDIR_TARGETS}
|
2015-10-23 21:30:27 +00:00
|
|
|
# Can ordering be skipped for this and SUBDIR_PARALLEL forced?
|
2015-12-04 07:54:04 +00:00
|
|
|
.if ${STANDALONE_SUBDIR_TARGETS:M${__target}}
|
2015-10-23 21:30:27 +00:00
|
|
|
_is_standalone_target= 1
|
2016-09-09 18:49:45 +00:00
|
|
|
_subdir_filter= N.WAIT
|
2015-10-23 21:30:27 +00:00
|
|
|
.else
|
|
|
|
_is_standalone_target= 0
|
2016-09-09 18:49:45 +00:00
|
|
|
_subdir_filter=
|
2015-10-23 21:30:27 +00:00
|
|
|
.endif
|
2014-04-23 12:52:11 +00:00
|
|
|
__subdir_targets=
|
2016-09-09 18:49:45 +00:00
|
|
|
.for __dir in ${SUBDIR:${_subdir_filter}}
|
2015-12-04 07:54:16 +00:00
|
|
|
.if ${__dir} == .WAIT
|
2014-04-23 12:52:11 +00:00
|
|
|
__subdir_targets+= .WAIT
|
|
|
|
.else
|
2014-06-15 13:45:37 +00:00
|
|
|
__deps=
|
2015-10-23 21:30:27 +00:00
|
|
|
.if ${_is_standalone_target} == 0
|
2016-08-22 22:51:01 +00:00
|
|
|
.if defined(SUBDIR_PARALLEL)
|
|
|
|
# Apply SUBDIR_DEPEND dependencies for SUBDIR_PARALLEL.
|
2014-06-15 13:45:37 +00:00
|
|
|
.for __dep in ${SUBDIR_DEPEND_${__dir}}
|
2016-02-24 17:20:31 +00:00
|
|
|
__deps+= ${__target}_subdir_${DIRPRFX}${__dep}
|
2014-06-15 13:45:37 +00:00
|
|
|
.endfor
|
2016-08-22 22:51:01 +00:00
|
|
|
.else
|
|
|
|
# For non-parallel builds, directories depend on all targets before them.
|
|
|
|
__deps:= ${__subdir_targets}
|
|
|
|
.endif # defined(SUBDIR_PARALLEL)
|
|
|
|
.endif # ${_is_standalone_target} == 0
|
2016-02-25 21:04:52 +00:00
|
|
|
${__target}_subdir_${DIRPRFX}${__dir}: .PHONY .MAKE .SILENT ${__deps}
|
2015-12-04 07:54:13 +00:00
|
|
|
@${_+_}target=${__target:realinstall=install}; \
|
2015-10-19 23:34:35 +00:00
|
|
|
dir=${__dir}; \
|
|
|
|
${_SUBDIR_SH};
|
2016-08-22 22:51:01 +00:00
|
|
|
__subdir_targets+= ${__target}_subdir_${DIRPRFX}${__dir}
|
|
|
|
.endif # ${__dir} == .WAIT
|
2015-10-23 21:30:27 +00:00
|
|
|
.endfor # __dir in ${SUBDIR}
|
2016-08-22 22:51:04 +00:00
|
|
|
|
|
|
|
# Attach the subdir targets to the real target.
|
|
|
|
# Only recurse on directly-called targets. I.e., don't recurse on dependencies
|
|
|
|
# such as 'install' becoming {before,real,after}install, just recurse
|
|
|
|
# 'install'. Despite that, 'realinstall' is special due to ordering issues
|
|
|
|
# with 'afterinstall'.
|
|
|
|
.if !defined(NO_SUBDIR) && (make(${__target}) || \
|
|
|
|
(${__target} == realinstall && make(install)))
|
2016-06-15 23:58:09 +00:00
|
|
|
${__target}: ${__subdir_targets} .PHONY
|
bsd.subdir.mk: Only recurse on called targets, rather than dependencies.
This is to fix 'make all' causing it to recurse on both 'all' and 'buildconfig'
due to 'buildconfig' being in ALL_SUBDIR_TARGETS and being a dependency of
'all'.
This now adds all of the '*includes', '*files' targets as subdir targets,
allowing them to recurse.
This also removes the need for some 'realinstall' hacks in bsd.subdir.mk since
it no longer recurses; only 'install' will recurse and call the proper
'beforeinstall', 'realinstall', and 'afterinstall' in each sub-directory.
This fixes 'make includes' and 'make files' to not be a rerolled ${MAKE}
sub-shell but to rather just recurse on 'inclues' and 'files'. This avoids
various issues such as the one fixed in r289462. As such revert Makefile.inc1
back to using 'includes' which avoids an extra tree walk and parallelizes
the includes phases better.
Makefile.inc1 includes a guard so that 'make all' will not use SUBDIR_PARALLEL,
added in r289438. This is so users do not get a probably broken build if they
run 'make all' from the top-level. Before the change in this commit, the
workaround for 'make everything' was 'par-all' which would depend on 'all' and
cause a proper parallel recursion. Now that will not work so a new
_PARALLEL_SUBUDIR_OK is used to allow it.
This is still part of an effort to combine bsd.(files|incs|confs).mk and move
some of its logic out of bsd.subdir.mk, as attempted in r289282 and reverted in
r289331. This commit fixes the problems found there which was mostly double
recursing during 'includes' which would recurse on itself and 'buildincludes'
and 'installincludes', all in parallel. The logic is still in bsd.subdir.mk
for now.
I've been cautious about this commit but have experienced no breakage on the
tree except for the 'par-all' case which was already a hack. If something foo
is depending on something bar that should recurse, it is very likely that the
foo target is being recursed on already meaning that bar will still effectively
recurse once sub-directories call foo.
Discussed on: arch@
MFC after: never
Sponsored by: EMC / Isilon Storage Division
2015-12-02 01:50:22 +00:00
|
|
|
.endif # make(${__target})
|
2016-01-19 22:42:07 +00:00
|
|
|
.endfor # __target in ${SUBDIR_TARGETS}
|
1994-11-13 21:05:28 +00:00
|
|
|
|
bsd.subdir.mk: Only recurse on called targets, rather than dependencies.
This is to fix 'make all' causing it to recurse on both 'all' and 'buildconfig'
due to 'buildconfig' being in ALL_SUBDIR_TARGETS and being a dependency of
'all'.
This now adds all of the '*includes', '*files' targets as subdir targets,
allowing them to recurse.
This also removes the need for some 'realinstall' hacks in bsd.subdir.mk since
it no longer recurses; only 'install' will recurse and call the proper
'beforeinstall', 'realinstall', and 'afterinstall' in each sub-directory.
This fixes 'make includes' and 'make files' to not be a rerolled ${MAKE}
sub-shell but to rather just recurse on 'inclues' and 'files'. This avoids
various issues such as the one fixed in r289462. As such revert Makefile.inc1
back to using 'includes' which avoids an extra tree walk and parallelizes
the includes phases better.
Makefile.inc1 includes a guard so that 'make all' will not use SUBDIR_PARALLEL,
added in r289438. This is so users do not get a probably broken build if they
run 'make all' from the top-level. Before the change in this commit, the
workaround for 'make everything' was 'par-all' which would depend on 'all' and
cause a proper parallel recursion. Now that will not work so a new
_PARALLEL_SUBUDIR_OK is used to allow it.
This is still part of an effort to combine bsd.(files|incs|confs).mk and move
some of its logic out of bsd.subdir.mk, as attempted in r289282 and reverted in
r289331. This commit fixes the problems found there which was mostly double
recursing during 'includes' which would recurse on itself and 'buildincludes'
and 'installincludes', all in parallel. The logic is still in bsd.subdir.mk
for now.
I've been cautious about this commit but have experienced no breakage on the
tree except for the 'par-all' case which was already a hack. If something foo
is depending on something bar that should recurse, it is very likely that the
foo target is being recursed on already meaning that bar will still effectively
recurse once sub-directories call foo.
Discussed on: arch@
MFC after: never
Sponsored by: EMC / Isilon Storage Division
2015-12-02 01:50:22 +00:00
|
|
|
.endif # !target(_SUBDIR)
|
2012-11-07 22:02:02 +00:00
|
|
|
|
2015-12-04 07:54:19 +00:00
|
|
|
# Ensure all targets exist
|
2016-01-19 22:42:07 +00:00
|
|
|
.for __target in ${SUBDIR_TARGETS}
|
2015-12-04 07:54:19 +00:00
|
|
|
.if !target(${__target})
|
|
|
|
${__target}:
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
2012-11-07 22:02:02 +00:00
|
|
|
.endif
|