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
|
2015-08-27 01:55:00 +00:00
|
|
|
# subdirectories. SUBDIR.yes is automatically appeneded
|
|
|
|
# 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".
|
|
|
|
#
|
2015-10-13 19:42:57 +00:00
|
|
|
# See ALL_SUBDIR_TARGETS for list of targets that will recurse.
|
|
|
|
# Custom targets can be added to SUBDIR_TARGETS in 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>__:
|
|
|
|
|
2015-10-14 20:30:32 +00:00
|
|
|
ALL_SUBDIR_TARGETS= all all-man buildconfig checkdpadd clean cleandepend \
|
|
|
|
cleandir cleanilinks cleanobj depend distribute \
|
|
|
|
installconfig lint maninstall manlint obj objlink \
|
|
|
|
realinstall regress tags \
|
2015-10-14 20:28:15 +00:00
|
|
|
${SUBDIR_TARGETS}
|
2015-10-13 19:42:57 +00:00
|
|
|
|
2002-04-17 13:49:29 +00:00
|
|
|
.include <bsd.init.mk>
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2015-06-10 18:14:38 +00:00
|
|
|
.if !defined(NEED_SUBDIR)
|
2015-05-26 21:52:57 +00:00
|
|
|
.if ${.MAKE.LEVEL} == 0 && ${MK_META_MODE} == "yes" && !empty(SUBDIR) && !(make(clean*) || make(destroy*))
|
2012-08-22 19:25:57 +00:00
|
|
|
.include <meta.subdir.mk>
|
|
|
|
# ignore this
|
|
|
|
_SUBDIR:
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.if !target(_SUBDIR)
|
|
|
|
|
2015-08-27 01:55:00 +00:00
|
|
|
.if defined(SUBDIR)
|
|
|
|
SUBDIR:=${SUBDIR} ${SUBDIR.yes}
|
|
|
|
SUBDIR:=${SUBDIR:u}
|
|
|
|
.endif
|
|
|
|
|
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}; \
|
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
|
|
|
${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
|
|
|
|
.endfor
|
|
|
|
.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}/
|
|
|
|
|
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-10-21 16:24:44 +00:00
|
|
|
@${_+_}target=${.TARGET:S,realinstall,install,}; \
|
2015-10-19 23:34:35 +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
|
|
|
|
2014-04-23 12:52:11 +00:00
|
|
|
${SUBDIR:N.WAIT}: .PHONY .MAKE
|
2015-10-19 23:34:35 +00:00
|
|
|
${_+_}@target=all; \
|
|
|
|
dir=${.TARGET}; \
|
|
|
|
${_SUBDIR_SH};
|
1994-05-30 19:09:18 +00:00
|
|
|
|
2014-04-23 12:52:11 +00:00
|
|
|
# Work around parsing of .if nested in .for by putting .WAIT string into a var.
|
|
|
|
__wait= .WAIT
|
2015-10-13 19:42:57 +00:00
|
|
|
.for __target in ${ALL_SUBDIR_TARGETS}
|
2014-03-26 22:30:38 +00:00
|
|
|
.ifdef SUBDIR_PARALLEL
|
2014-04-23 12:52:11 +00:00
|
|
|
__subdir_targets=
|
2014-03-26 22:30:38 +00:00
|
|
|
.for __dir in ${SUBDIR}
|
2014-04-23 12:52:11 +00:00
|
|
|
.if ${__wait} == ${__dir}
|
|
|
|
__subdir_targets+= .WAIT
|
|
|
|
.else
|
|
|
|
__subdir_targets+= ${__target}_subdir_${__dir}
|
2014-06-15 13:45:37 +00:00
|
|
|
__deps=
|
|
|
|
.for __dep in ${SUBDIR_DEPEND_${__dir}}
|
|
|
|
__deps+= ${__target}_subdir_${__dep}
|
|
|
|
.endfor
|
2015-10-19 22:27:32 +00:00
|
|
|
${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps}
|
2014-06-10 17:04:30 +00:00
|
|
|
.if !defined(NO_SUBDIR)
|
2015-10-19 23:34:35 +00:00
|
|
|
@${_+_}target=${__target:realinstall=install}; \
|
|
|
|
dir=${__dir}; \
|
|
|
|
${_SUBDIR_SH};
|
2014-04-23 12:52:11 +00:00
|
|
|
.endif
|
2014-06-10 17:04:30 +00:00
|
|
|
.endif
|
2014-03-26 22:30:38 +00:00
|
|
|
.endfor
|
2014-04-23 12:52:11 +00:00
|
|
|
${__target}: ${__subdir_targets}
|
2014-03-26 22:30:38 +00:00
|
|
|
.else
|
2015-10-21 16:24:44 +00:00
|
|
|
${__target}: _SUBDIR
|
2014-03-26 22:30:38 +00:00
|
|
|
.endif
|
1996-04-05 22:22:44 +00:00
|
|
|
.endfor
|
1994-11-13 21:05:28 +00:00
|
|
|
|
2015-10-14 19:30:04 +00:00
|
|
|
# This is to support 'make includes' calling 'make buildincludes' and
|
|
|
|
# 'make installincludes' in the proper order, and to support these
|
|
|
|
# targets as SUBDIR_TARGETS.
|
2015-10-14 20:30:32 +00:00
|
|
|
.for __target in files includes
|
2015-10-14 19:30:04 +00:00
|
|
|
.for __stage in build install
|
|
|
|
${__stage}${__target}:
|
|
|
|
.if make(${__stage}${__target})
|
2015-10-21 16:24:44 +00:00
|
|
|
${__stage}${__target}: _SUBDIR
|
2015-10-14 19:30:04 +00:00
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.if !target(${__target})
|
|
|
|
${__target}: .MAKE
|
|
|
|
${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
1994-05-30 19:09:18 +00:00
|
|
|
.if !target(install)
|
|
|
|
.if !target(beforeinstall)
|
|
|
|
beforeinstall:
|
|
|
|
.endif
|
|
|
|
.if !target(afterinstall)
|
|
|
|
afterinstall:
|
|
|
|
.endif
|
2002-07-01 14:49:16 +00:00
|
|
|
install: beforeinstall realinstall afterinstall
|
|
|
|
.ORDER: beforeinstall realinstall afterinstall
|
1994-05-30 19:09:18 +00:00
|
|
|
.endif
|
2012-11-07 22:02:02 +00:00
|
|
|
|
|
|
|
.endif
|