Makefile revision 1.331
11.331Skamil#	$NetBSD: Makefile,v 1.331 2019/08/27 22:48:54 kamil Exp $
21.95Scjs
31.193Slukem#
41.95Scjs# This is the top-level makefile for building NetBSD. For an outline of
51.95Scjs# how to build a snapshot or release, as well as other release engineering
61.221Ssalo# information, see http://www.NetBSD.org/developers/releng/index.html
71.95Scjs#
81.95Scjs# Not everything you can set or do is documented in this makefile. In
91.95Scjs# particular, you should review the files in /usr/share/mk (especially
101.95Scjs# bsd.README) for general information on building programs and writing
111.95Scjs# Makefiles within this structure, and see the comments in src/etc/Makefile
121.95Scjs# for further information on installation and release set options.
131.95Scjs#
141.95Scjs# Variables listed below can be set on the make command line (highest
151.95Scjs# priority), in /etc/mk.conf (middle priority), or in the environment
161.95Scjs# (lowest priority).
171.95Scjs#
181.95Scjs# Variables:
191.101Ssommerfe#   DESTDIR is the target directory for installation of the compiled
201.101Ssommerfe#	software. It defaults to /. Note that programs are built against
211.101Ssommerfe#	libraries installed in DESTDIR.
221.214Slukem#   MKMAN, if `no', will prevent building of manual pages.
231.214Slukem#   MKOBJDIRS, if not `no', will build object directories at
241.101Ssommerfe#	an appropriate point in a build.
251.214Slukem#   MKSHARE, if `no', will prevent building and installing
261.95Scjs#	anything in /usr/share.
271.214Slukem#   MKUPDATE, if not `no', will avoid a `make cleandir' at the start of
281.178Senami#	`make build', as well as having the effects listed in
291.178Senami#	/usr/share/mk/bsd.README.
301.125Smrg#   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
311.178Senami#	of the `make build'.
321.119Stoddpw#   NOINCLUDES will avoid the `make includes' usually done by `make build'.
331.319Schristos#   NOBINARIES will not build binaries, only includes and libraries
341.95Scjs#
351.214Slukem#   See mk.conf(5) for more details.
361.214Slukem#
371.214Slukem#
381.95Scjs# Targets:
391.137Stv#   build:
401.196Slukem#	Builds a full release of NetBSD in DESTDIR, except for the
411.196Slukem#	/etc configuration files.
421.196Slukem#	If BUILD_DONE is set, this is an empty target.
431.196Slukem#   distribution:
441.196Slukem#	Builds a full release of NetBSD in DESTDIR, including the /etc
451.196Slukem#	configuration files.
461.196Slukem#   buildworld:
471.196Slukem#	As per `make distribution', except that it ensures that DESTDIR
481.196Slukem#	is not the root directory.
491.196Slukem#   installworld:
501.196Slukem#	Install the distribution from DESTDIR to INSTALLWORLDDIR (which
511.196Slukem#	defaults to the root directory).  Ensures that INSTALLWORLDDIR
521.291Sabs#	is not the root directory if cross compiling.
531.137Stv#   release:
541.240Slukem#	Does a `make distribution', and then tars up the DESTDIR files
551.252Slukem#	into ${RELEASEDIR}/${RELEASEMACHINEDIR}, in release(7) format.
561.196Slukem#	(See etc/Makefile for more information on this.)
571.137Stv#   regression-tests:
581.137Stv#	Runs the regression tests in "regress" on this host.
591.206Slukem#   sets:
601.252Slukem#	Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
611.252Slukem#	from ${DESTDIR}
621.206Slukem#   sourcesets:
631.206Slukem#	Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR}
641.241Sapb#   syspkgs:
651.252Slukem#	Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
661.252Slukem#	from ${DESTDIR}
671.243Sapb#   iso-image:
681.311Ssnj#	Create CD-ROM image in RELEASEDIR/images.
691.243Sapb#	RELEASEDIR must already have been populated by `make release'
701.243Sapb#	or equivalent.
711.248Sjnemeth#   iso-image-source:
721.311Ssnj#	Create CD-ROM image with source in RELEASEDIR/images.
731.248Sjnemeth#	RELEASEDIR must already have been populated by
741.248Sjnemeth#	`make release sourcesets' or equivalent.
751.290Stsutsui#   live-image:
761.290Stsutsui#	Create bootable live image for emulators or USB stick etc.
771.290Stsutsui#	in RELEASEDIR/liveimage.
781.290Stsutsui#	RELEASEDIR must already have been populated by `make release'
791.290Stsutsui#	or equivalent.
801.290Stsutsui#   install-image:
811.290Stsutsui#	Create bootable installation image for USB stick etc.
821.290Stsutsui#	in RELEASEDIR/installimage.
831.290Stsutsui#	RELEASEDIR must already have been populated by `make release'
841.290Stsutsui#	or equivalent.
851.123Smrg#
861.137Stv# Targets invoked by `make build,' in order:
871.155Stv#   cleandir:        cleans the tree.
881.261Sapb#   do-top-obj:      creates the top level object directory.
891.260Sapb#   do-tools-obj:    creates object directories for the host toolchain.
901.260Sapb#   do-tools:        builds host toolchain.
911.300Sapb#   params:          record the values of variables that might affect the
921.300Sapb#                    build.
931.137Stv#   obj:             creates object directories.
941.208Slukem#   do-distrib-dirs: creates the distribution directories.
951.208Slukem#   includes:        installs include files.
961.326Smartin#   do-lib:          builds and installs prerequisites from lib.
971.299Sjoerg#   do-compat-lib:   builds and installs prerequisites from compat/lib
981.262Smrg#                    if ${MKCOMPAT} != "no".
991.320Suwe#   do-x11:          builds and installs X11 tools and libraries
1001.320Suwe#                    from src/external/mit/xorg if ${MKX11} != "no".
1011.137Stv#   do-build:        builds and installs the entire system.
1021.275Suebayasi#   do-extsrc:       builds and installs extsrc if ${MKEXTSRC} != "no".
1031.222Slukem#   do-obsolete:     installs the obsolete sets (for the postinstall-* targets).
1041.193Slukem#
1051.32Scgd
1061.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
1071.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk
1081.146Stv.endif
1091.163Stv
1101.193Slukem#
1111.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
1121.163Stv# not be the top level objdir, because "make obj" can happen in the *middle*
1131.163Stv# of "make build" (long after <bsd.own.mk> is calculated it).  So, pre-set
1141.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
1151.193Slukem#
1161.163Stv_SRC_TOP_OBJ_=
1171.148Sjmc
1181.146Stv.include <bsd.own.mk>
1191.4Scgd
1201.193Slukem#
1211.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously
1221.137Stv# with a standard recursive target.
1231.193Slukem#
1241.137Stv
1251.137Stv.if make(build) || make(release) || make(snapshot)
1261.137Stv.for targ in ${TARGETS:Nobj:Ncleandir}
1271.137Stv.if make(${targ}) && !target(.BEGIN)
1281.137Stv.BEGIN:
1291.137Stv	@echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
1301.137Stv	@false
1311.137Stv.endif
1321.137Stv.endfor
1331.137Stv.endif
1341.58Stv
1351.261Sapb#
1361.261Sapb# _SUBDIR is used to set SUBDIR, after removing directories that have
1371.261Sapb# BUILD_${dir}=no, or that have no ${dir}/Makefile.
1381.261Sapb#
1391.329Skamil_SUBDIR=	tools .WAIT lib
1401.329Skamil.if ${MKLLVM} != "no"
1411.329Skamil_SUBDIR+=	external/bsd/compiler_rt
1421.329Skamil.endif
1431.329Skamil_SUBDIR+=	 include external crypto/external bin
1441.325Smaya_SUBDIR+=	games libexec sbin usr.bin
1451.303Sjoerg_SUBDIR+=	usr.sbin share sys etc tests compat
1461.303Sjoerg_SUBDIR+=	.WAIT rescue .WAIT distrib regress
1471.105Sassar
1481.137Stv.for dir in ${_SUBDIR}
1491.261Sapb.if "${dir}" == ".WAIT" \
1501.261Sapb	|| (${BUILD_${dir}:Uyes} != "no" && exists(${dir}/Makefile))
1511.137StvSUBDIR+=	${dir}
1521.36Sexplorer.endif
1531.137Stv.endfor
1541.21Scgd
1551.13Sbrezak.if exists(regress)
1561.242Sdslregression-tests: .PHONY .MAKE
1571.10Scgd	@echo Running regression tests...
1581.232Slukem	${MAKEDIRTARGET} regress regress
1591.13Sbrezak.endif
1601.20Scgd
1611.214Slukem.if ${MKUNPRIVED} != "no"
1621.179SthorpejNOPOSTINSTALL=	# defined
1631.179Sthorpej.endif
1641.179Sthorpej
1651.242Sdslafterinstall: .PHONY .MAKE
1661.137Stv.if ${MKMAN} != "no"
1671.232Slukem	${MAKEDIRTARGET} share/man makedb
1681.137Stv.endif
1691.214Slukem.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no")
1701.317Schristos	${MAKEDIRTARGET} external/gpl2/texinfo/bin/install-info infodir-meta
1711.176Slukem.endif
1721.179Sthorpej.if !defined(NOPOSTINSTALL)
1731.232Slukem	${MAKEDIRTARGET} . postinstall-check
1741.159Sperry.endif
1751.170Slukem
1761.327Smartin_POSTINSTALL=	${:!cd ${.CURDIR}/usr.sbin/postinstall && \
1771.327Smartin			${MAKE} print-objdir!}/postinstall  \
1781.308Sapb		-m ${MACHINE} -a ${MACHINE_ARCH}
1791.295Sapb_POSTINSTALL_ENV= \
1801.295Sapb	AWK=${TOOL_AWK:Q}		\
1811.295Sapb	DB=${TOOL_DB:Q}			\
1821.298Sapb	HOST_SH=${HOST_SH:Q}		\
1831.295Sapb	MAKE=${MAKE:Q}			\
1841.297Sapb	PWD_MKDB=${TOOL_PWD_MKDB:Q}	\
1851.307Sapb	SED=${TOOL_SED:Q}		\
1861.297Sapb	STAT=${TOOL_STAT:Q}
1871.239Slukem
1881.313Smartin.if ${MKX11} != "no"
1891.313Smartin_POSTINSTALL_X11=-x ${X11SRCDIR:Q}
1901.313Smartin.endif
1911.313Smartin
1921.228Slukempostinstall-check: .PHONY
1931.169Slukem	@echo "   === Post installation checks ==="
1941.313Smartin	${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} ${_POSTINSTALL_X11} -d ${DESTDIR}/ check; if [ $$? -gt 1 ]; then exit 1; fi
1951.171Slukem	@echo "   ================================"
1961.171Slukem
1971.228Slukempostinstall-fix: .NOTMAIN .PHONY
1981.171Slukem	@echo "   === Post installation fixes ==="
1991.313Smartin	${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} ${_POSTINSTALL_X11} -d ${DESTDIR}/ fix
2001.212Slukem	@echo "   ==============================="
2011.212Slukem
2021.228Slukempostinstall-fix-obsolete: .NOTMAIN .PHONY
2031.212Slukem	@echo "   === Removing obsolete files ==="
2041.313Smartin	${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} ${_POSTINSTALL_X11} -d ${DESTDIR}/ fix obsolete
2051.212Slukem	@echo "   ==============================="
2061.169Slukem
2071.309Sapbpostinstall-fix-obsolete_stand: .NOTMAIN .PHONY
2081.309Sapb	@echo "   === Removing obsolete files ==="
2091.313Smartin	${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} ${_POSTINSTALL_X11} -d ${DESTDIR}/ fix obsolete_stand
2101.309Sapb	@echo "   ==============================="
2111.309Sapb
2121.108Serh
2131.193Slukem#
2141.137Stv# Targets (in order!) called by "make build".
2151.193Slukem#
2161.156StvBUILDTARGETS+=	check-tools
2171.214Slukem.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR)
2181.155StvBUILDTARGETS+=	cleandir
2191.155Stv.endif
2201.261Sapb.if ${MKOBJDIRS} != "no"
2211.261SapbBUILDTARGETS+=	do-top-obj
2221.261Sapb.endif
2231.261Sapb.if ${USETOOLS} == "yes"	# {
2241.149Stv.if ${MKOBJDIRS} != "no"
2251.260SapbBUILDTARGETS+=	do-tools-obj
2261.123Smrg.endif
2271.152StvBUILDTARGETS+=	do-tools
2281.261Sapb.endif # USETOOLS		# }
2291.300SapbBUILDTARGETS+=	params
2301.260Sapb.if ${MKOBJDIRS} != "no"
2311.260SapbBUILDTARGETS+=	obj
2321.260Sapb.endif
2331.270SapbBUILDTARGETS+=	clean_METALOG
2341.137Stv.if !defined(NODISTRIBDIRS)
2351.137StvBUILDTARGETS+=	do-distrib-dirs
2361.131Stv.endif
2371.137Stv.if !defined(NOINCLUDES)
2381.137StvBUILDTARGETS+=	includes
2391.131Stv.endif
2401.281SplunkyBUILDTARGETS+=	do-lib
2411.299SjoergBUILDTARGETS+=	do-compat-lib
2421.328Skamil.if ${MKLLVM} != "no"
2431.329SkamilBUILDTARGETS+=	do-sanitizer
2441.328Skamil.if ${MKSANITIZER:Uno} == "yes"
2451.328SkamilBUILDTARGETS+=	do-sanitizer-tools
2461.328Skamil.endif
2471.328Skamil.endif
2481.263Smrg.if ${MKX11} != "no"
2491.227SlukemBUILDTARGETS+=	do-x11
2501.227Slukem.endif
2511.321Suwe.if !defined(NOBINARIES)
2521.312SjoergBUILDTARGETS+=	do-build
2531.275Suebayasi.if ${MKEXTSRC} != "no"
2541.275SuebayasiBUILDTARGETS+=	do-extsrc
2551.275Suebayasi.endif
2561.200SlukemBUILDTARGETS+=	do-obsolete
2571.319Schristos.endif
2581.131Stv
2591.193Slukem#
2601.137Stv# Enforce proper ordering of some rules.
2611.193Slukem#
2621.123Smrg
2631.137Stv.ORDER:		${BUILDTARGETS}
2641.228Slukemincludes-lib:	.PHONY includes-include includes-sys
2651.123Smrg
2661.193Slukem#
2671.300Sapb# Record the values of variables that might affect the build.
2681.300Sapb# If no values have changed, avoid updating the timestamp
2691.300Sapb# of the params file.
2701.300Sapb#
2711.300Sapb# This is referenced by _NETBSD_VERSION_DEPENDS in <bsd.own.mk>.
2721.300Sapb#
2731.302Sapb.include "${NETBSDSRCDIR}/etc/Makefile.params"
2741.300SapbCLEANDIRFILES+= params
2751.300Sapbparams: .EXEC
2761.300Sapb	${_MKMSG_CREATE} params
2771.302Sapb	@${PRINT_PARAMS} >${.TARGET}.new
2781.300Sapb	@if cmp -s ${.TARGET}.new ${.TARGET} > /dev/null 2>&1; then \
2791.300Sapb		: "params is unchanged" ; \
2801.300Sapb		rm ${.TARGET}.new ; \
2811.300Sapb	else \
2821.300Sapb		: "params has changed or is new" ; \
2831.300Sapb		mv ${.TARGET}.new ${.TARGET} ; \
2841.300Sapb	fi
2851.300Sapb
2861.300Sapb#
2871.302Sapb# Display current make(1) parameters
2881.302Sapb#
2891.302Sapbshow-params: .PHONY .MAKE
2901.302Sapb	@${PRINT_PARAMS}
2911.302Sapb
2921.302Sapb#
2931.137Stv# Build the system and install into DESTDIR.
2941.193Slukem#
2951.123Smrg
2961.191SlukemSTART_TIME!=	date
2971.191Slukem
2981.242Sdslbuild: .PHONY .MAKE
2991.137Stv.if defined(BUILD_DONE)
3001.137Stv	@echo "Build already installed into ${DESTDIR}"
3011.137Stv.else
3021.191Slukem	@echo "Build started at: ${START_TIME}"
3031.145Stv.for tgt in ${BUILDTARGETS}
3041.232Slukem	${MAKEDIRTARGET} . ${tgt}
3051.145Stv.endfor
3061.232Slukem	${MAKEDIRTARGET} etc install-etc-release
3071.191Slukem	@echo   "Build started at:  ${START_TIME}"
3081.172Sbjh21	@printf "Build finished at: " && date
3091.71Smycroft.endif
3101.160Sthorpej
3111.193Slukem#
3121.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into
3131.193Slukem# ${RELEASEDIR}).  "buildworld" enforces a build to ${DESTDIR} != /
3141.193Slukem#
3151.160Sthorpej
3161.242Sdsldistribution buildworld: .PHONY .MAKE
3171.194Slukem.if make(buildworld) && \
3181.194Slukem    (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
3191.193Slukem	@echo "Won't make ${.TARGET} with DESTDIR=/"
3201.193Slukem	@false
3211.193Slukem.endif
3221.232Slukem	${MAKEDIRTARGET} . build NOPOSTINSTALL=1
3231.232Slukem	${MAKEDIRTARGET} etc distribution INSTALL_DONE=1
3241.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/"
3251.232Slukem	${MAKEDIRTARGET} . postinstall-fix-obsolete
3261.309Sapb	${MAKEDIRTARGET} . postinstall-fix-obsolete_stand
3271.232Slukem	${MAKEDIRTARGET} distrib/sets checkflist
3281.181Sthorpej.endif
3291.192Slukem	@echo   "make ${.TARGET} started at:  ${START_TIME}"
3301.185Slukem	@printf "make ${.TARGET} finished at: " && date
3311.123Smrg
3321.193Slukem#
3331.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/')
3341.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and
3351.193Slukem# the host's `uname -m` == ${MACHINE}.
3361.193Slukem#
3371.193Slukem
3381.193SlukemHOST_UNAME_S!=	uname -s
3391.193SlukemHOST_UNAME_M!=	uname -m
3401.193Slukem
3411.242Sdslinstallworld: .PHONY .MAKE
3421.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
3431.193Slukem	@echo "Can't make ${.TARGET} to DESTDIR=/"
3441.193Slukem	@false
3451.193Slukem.endif
3461.193Slukem.if !defined(INSTALLWORLDDIR) || \
3471.193Slukem    ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/"
3481.193Slukem.if (${HOST_UNAME_S} != "NetBSD")
3491.193Slukem	@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/"
3501.193Slukem	@false
3511.193Slukem.endif
3521.193Slukem.if (${HOST_UNAME_M} != ${MACHINE})
3531.193Slukem	@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/"
3541.193Slukem	@false
3551.193Slukem.endif
3561.193Slukem.endif
3571.232Slukem	${MAKEDIRTARGET} distrib/sets installsets \
3581.282Sjym		INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS=${INSTALLSETS:Q}
3591.232Slukem	${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR}
3601.193Slukem	@echo   "make ${.TARGET} started at:  ${START_TIME}"
3611.193Slukem	@printf "make ${.TARGET} finished at: " && date
3621.199Slukem
3631.199Slukem#
3641.287Sjmcneill# Install modules from $DESTDIR to $INSTALLMODULESDIR
3651.287Sjmcneill#
3661.287Sjmcneillinstallmodules: .PHONY .MAKE
3671.287Sjmcneill.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
3681.287Sjmcneill	@echo "Can't make ${.TARGET} to DESTDIR=/"
3691.287Sjmcneill	@false
3701.287Sjmcneill.endif
3711.287Sjmcneill.if !defined(INSTALLMODULESDIR) || \
3721.287Sjmcneill    ${INSTALLMODULESDIR} == "" || ${INSTALLMODULESDIR} == "/"
3731.287Sjmcneill.if (${HOST_UNAME_S} != "NetBSD")
3741.287Sjmcneill	@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLMODULESDIR=/"
3751.287Sjmcneill	@false
3761.287Sjmcneill.endif
3771.287Sjmcneill.if (${HOST_UNAME_M} != ${MACHINE})
3781.287Sjmcneill	@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLMODULESDIR=/"
3791.287Sjmcneill	@false
3801.287Sjmcneill.endif
3811.287Sjmcneill.endif
3821.288Sjmcneill	${MAKEDIRTARGET} sys/modules install DESTDIR=${INSTALLMODULESDIR:U/}
3831.287Sjmcneill	@echo   "make ${.TARGET} started at:  ${START_TIME}"
3841.287Sjmcneill	@printf "make ${.TARGET} finished at: " && date
3851.287Sjmcneill
3861.287Sjmcneill#
3871.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR
3881.199Slukem#
3891.199Slukem
3901.241Sapb.for tgt in sets sourcesets syspkgs
3911.242Sdsl${tgt}: .PHONY .MAKE
3921.232Slukem	${MAKEDIRTARGET} distrib/sets ${tgt}
3931.206Slukem.endfor
3941.193Slukem
3951.193Slukem#
3961.240Slukem# Build a release or snapshot (implies "make distribution").  Note that
3971.181Sthorpej# in this case, the set lists will be checked before the tar files
3981.181Sthorpej# are made.
3991.193Slukem#
4001.123Smrg
4011.242Sdslrelease snapshot: .PHONY .MAKE
4021.240Slukem	${MAKEDIRTARGET} . distribution
4031.240Slukem	${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1
4041.192Slukem	@echo   "make ${.TARGET} started at:  ${START_TIME}"
4051.185Slukem	@printf "make ${.TARGET} finished at: " && date
4061.123Smrg
4071.193Slukem#
4081.243Sapb# Create a CD-ROM image.
4091.243Sapb#
4101.243Sapb
4111.243Sapbiso-image: .PHONY
4121.247Sbouyer	${MAKEDIRTARGET} distrib iso_image
4131.243Sapb	${MAKEDIRTARGET} etc iso-image
4141.243Sapb	@echo   "make ${.TARGET} started at:  ${START_TIME}"
4151.243Sapb	@printf "make ${.TARGET} finished at: " && date
4161.243Sapb
4171.248Sjnemethiso-image-source: .PHONY
4181.248Sjnemeth	${MAKEDIRTARGET} distrib iso_image CDSOURCE=true
4191.248Sjnemeth	${MAKEDIRTARGET} etc iso-image
4201.248Sjnemeth	@echo   "make ${.TARGET} started at:  ${START_TIME}"
4211.248Sjnemeth	@printf "make ${.TARGET} finished at: " && date
4221.248Sjnemeth
4231.243Sapb#
4241.290Stsutsui# Create bootable live images.
4251.290Stsutsui#
4261.290Stsutsui
4271.290Stsutsuilive-image: .PHONY
4281.290Stsutsui	${MAKEDIRTARGET} etc live-image
4291.290Stsutsui	@echo   "make ${.TARGET} started at:  ${START_TIME}"
4301.290Stsutsui	@printf "make ${.TARGET} finished at: " && date
4311.290Stsutsui
4321.290Stsutsui#
4331.290Stsutsui# Create bootable installation images.
4341.290Stsutsui#
4351.290Stsutsui
4361.290Stsutsuiinstall-image: .PHONY
4371.290Stsutsui	${MAKEDIRTARGET} etc install-image
4381.290Stsutsui	@echo   "make ${.TARGET} started at:  ${START_TIME}"
4391.290Stsutsui	@printf "make ${.TARGET} finished at: " && date
4401.290Stsutsui
4411.290Stsutsui#
4421.137Stv# Special components of the "make build" process.
4431.193Slukem#
4441.156Stv
4451.228Slukemcheck-tools: .PHONY
4461.223Slukem.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN)
4471.187Sthorpej	@echo '*** WARNING:  Building on MACHINE=${MACHINE} with missing toolchain.'
4481.187Sthorpej	@echo '*** May result in a failed build or corrupt binaries!'
4491.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN)
4501.187Sthorpej	@echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.'
4511.156Stv.endif
4521.173Ssommerfe.if defined(NBUILDJOBS)
4531.173Ssommerfe	@echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
4541.173Ssommerfe.endif
4551.123Smrg
4561.270Sapb# Delete or sanitise a leftover METALOG from a previous build.
4571.270Sapbclean_METALOG: .PHONY .MAKE
4581.270Sapb.if ${MKUPDATE} != "no"
4591.270Sapb	${MAKEDIRTARGET} distrib/sets clean_METALOG
4601.270Sapb.endif
4611.270Sapb
4621.242Sdsldo-distrib-dirs: .PHONY .MAKE
4631.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == ""
4641.232Slukem	${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/
4651.147Sjmc.else
4661.232Slukem	${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR}
4671.147Sjmc.endif
4681.190Slukem
4691.190Slukem.for targ in cleandir obj includes
4701.228Slukemdo-${targ}: .PHONY ${targ}
4711.190Slukem	@true
4721.190Slukem.endfor
4731.123Smrg
4741.301Sjoergdo-tools: .PHONY .MAKE
4751.301Sjoerg	${MAKEDIRTARGET} tools build_install
4761.184Slukem
4771.299Sjoergdo-lib: .PHONY .MAKE
4781.299Sjoerg	${MAKEDIRTARGET} lib build_install
4791.299Sjoerg
4801.299Sjoergdo-compat-lib: .PHONY .MAKE
4811.299Sjoerg	${MAKEDIRTARGET} compat build_install BOOTSTRAP_SUBDIRS="../../../lib"
4821.276Smrg
4831.329Skamildo-sanitizer: .PHONY .MAKE
4841.331Skamil	${MAKEDIRTARGET} external/bsd/compiler_rt build_install
4851.328Skamil
4861.328Skamildo-sanitizer-tools: .PHONY .MAKE
4871.329Skamil.if !exists(${TOOLDIR}/lib/clang) && ${HAVE_LLVM:Uno} == "yes"
4881.328Skamil	mkdir -p ${TOOLDIR}/lib/clang
4891.328Skamil	cd ${DESTDIR}/usr/lib/clang && \
4901.328Skamil		${TOOL_PAX} -rw . ${TOOLDIR}/lib/clang
4911.328Skamil.endif
4921.328Skamil
4931.261Sapbdo-top-obj: .PHONY .MAKE
4941.261Sapb	${MAKEDIRTARGET} . obj NOSUBDIR=
4951.261Sapb
4961.260Sapbdo-tools-obj: .PHONY .MAKE
4971.260Sapb	${MAKEDIRTARGET} tools obj
4981.260Sapb
4991.242Sdsldo-build: .PHONY .MAKE
5001.154Stv.for targ in dependall install
5011.232Slukem	${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no
5021.154Stv.endfor
5031.200Slukem
5041.242Sdsldo-x11: .PHONY .MAKE
5051.263Smrg.if ${MKX11} != "no"
5061.312Sjoerg	${MAKEDIRTARGET} external/mit/xorg/tools all
5071.312Sjoerg	${MAKEDIRTARGET} external/mit/xorg/lib build_install
5081.315Smatt.if ${MKCOMPATX11} != "no"
5091.314Smatt	${MAKEDIRTARGET} compat build_install BOOTSTRAP_SUBDIRS="../../../external/mit/xorg/lib"
5101.314Smatt.endif
5111.263Smrg.else
5121.263Smrg	@echo "MKX11 is not enabled"
5131.257Slukem	@false
5141.254Smrg.endif
5151.227Slukem
5161.275Suebayasido-extsrc: .PHONY .MAKE
5171.275Suebayasi.if ${MKEXTSRC} != "no"
5181.275Suebayasi	${MAKEDIRTARGET} extsrc build
5191.275Suebayasi.else
5201.275Suebayasi	@echo "MKEXTSRC is not enabled"
5211.275Suebayasi	@false
5221.275Suebayasi.endif
5231.275Suebayasi
5241.242Sdsldo-obsolete: .PHONY .MAKE
5251.232Slukem	${MAKEDIRTARGET} etc install-obsolete-lists
5261.87Scjs
5271.193Slukem#
5281.137Stv# Speedup stubs for some subtrees that don't need to run these rules.
5291.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.)
5301.193Slukem#
5311.129Stv
5321.292Sveego.for dir in bin etc distrib games libexec regress sbin usr.bin usr.sbin tools
5331.228Slukemincludes-${dir}: .PHONY
5341.152Stv	@true
5351.152Stv.endfor
5361.152Stv.for dir in etc distrib regress
5371.228Slukeminstall-${dir}: .PHONY
5381.152Stv	@true
5391.152Stv.endfor
5401.152Stv
5411.193Slukem#
5421.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant
5431.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first...
5441.193Slukem#
5451.228Slukemdependall-distrib depend-distrib all-distrib: .PHONY
5461.136Snathanw	@true
5471.130Stv
5481.151Stv.include <bsd.obj.mk>
5491.209Slukem.include <bsd.kernobj.mk>
5501.146Stv.include <bsd.subdir.mk>
5511.322Smrg.include <bsd.clean.mk>
552