kernel/usb4bsd: Add usbdevs.h to a few Makefile which need it.
[dragonfly.git] / Makefile.inc1
index c26166b..8ab7470 100644 (file)
 # realquickworld - skip the glue and depend stages and just build the meat
 # crossworld  - only build the glue (particularly the cross-build environment)
 # installworld- install everything built by "buildworld"
+# backupworld - copies /bin /sbin /usr/bin /usr/sbin /usr/lib /usr/libexec
+#               to manual backup dir
+# restoreworld- installs binaries from manual backup dir to world
+# restoreworld-auto - installs binaries from auto-backup dir to world
 # most        - build user commands, no libraries or include files
 # installmost - install user commands, no libraries or include files
+# backup-clean - delete backup from manual backup dir
+# backup-auto-clean - delete backup from auto-backup dir
 #
 # Standard targets (not defined here) are documented in the makefiles in
 # /usr/share/mk.  These include:
@@ -112,27 +118,21 @@ OBJTREE?=         ${MAKEOBJDIRPREFIX}
 
 # Used for stage installs and pathing
 #
-DESTDIRBASE?=          ${OBJTREE}${.CURDIR}
+DESTDIRBASE:=          ${OBJTREE}${.CURDIR}
 
 # Remove DESTDIR from MAKEFLAGS.  It is present in the environment
 # anyhow, and we need to be able to override it for stage installs
 .MAKEFLAGS:=   ${.MAKEFLAGS:NDESTDIR=*}
 
 # This section sets the tools used to build the world/kernel
-WORLD_CCVER?=          gcc44
+WORLD_CCVER?=          gcc47
 WORLD_LDVER?=          ld.bfd
-WORLD_BINUTILSVER?=    binutils222
+WORLD_BINUTILSVER?=    binutils224
 
-# temporary until everybody has converted to x86_64
-.if ${MACHINE_ARCH} == "amd64"
-MACHINE_ARCH=  x86_64
-.if defined(.PARSEDIR)
-.export MACHINE_ARCH
-.else
-# LEGACY MAKE - REMOVE FOR DFLY 3.6
-.makeenv MACHINE_ARCH
-.endif
-.endif
+# Set the backup parameters if they are not already defined
+#
+WORLD_BACKUP?=         /var/backups/world_backup
+AUTO_BACKUP?=          ${OBJTREE}/world_backup/${DESTDIR}
 
 TARGET_ARCH?=  ${MACHINE_ARCH}
 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
@@ -211,16 +211,11 @@ BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTO
 # The strict temporary command path contains all binaries required
 # by the buildworld system after the cross-tools stage.
 #
-STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games:/usr/pkg/bin
+STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games:/usr/local/bin:/usr/pkg/bin
 
 TMPDIR?=       /tmp
 TMPPID!=       echo $$$$
 
-# Only use the host system make to bootstrap tools, including make itself
-# Use the bootstrap make for the rest of the world
-BTOOLMAKE=     ${BTOOLSDEST}/usr/bin/make
-BTOOLCONFIG=   ${BTOOLSDEST}/usr/sbin/config
-
 #
 # Building a world goes through the following stages
 #
@@ -241,6 +236,16 @@ BTOOLCONFIG=       ${BTOOLSDEST}/usr/sbin/config
 # 5. install stage (optional) [IMAKE]
 #      This stage installs a previously built world.
 #
+# In all cases we must carefully adjust the environment so the proper
+# tools and header files are used.
+#
+# NOTE: The M4 environment variable is used by the [f]lex binary to
+#      override the location of the 'm4' binary.  The override is
+#      needed for certain buildworld version transitions, specifically
+#      past a certain point in 3.3 because the older /usr/bin/m4 will
+#      generate output that will blow up the newer [f]lex/yacc/bison
+#      utilities.
+#
 
 # bootstrap-tool stage
 #
@@ -248,9 +253,10 @@ BMAKEENV=  MAKEOBJDIRPREFIX=${BTOOLSDEST} \
                OBJTREE=${OBJTREE} \
                DESTDIR=${BTOOLSDEST} \
                PATH=${BTOOLSPATH}:${PATH} \
+               M4=${BTOOLSDEST}/usr/bin/m4 \
                INSTALL="sh ${.CURDIR}/tools/install.sh"
 
-BMAKE=         ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
+BMAKE=         ${BMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
                -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
                -DNO_WERROR -DNO_NLS
 
@@ -260,9 +266,10 @@ TMAKEENV=  MAKEOBJDIRPREFIX=${BTOOLSDEST} \
                OBJTREE=${OBJTREE} \
                DESTDIR= \
                PATH=${BTOOLSPATH}:${PATH} \
+               M4=${BTOOLSDEST}/usr/bin/m4 \
                INSTALL="sh ${.CURDIR}/tools/install.sh"
 
-TMAKE=         ${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
+TMAKE=         ${TMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
                -DNO_FORTRAN -DNOSHARED
 
 # cross-tool stage
@@ -278,9 +285,10 @@ XMAKEENV=  MAKEOBJDIRPREFIX=${CTOOLSDEST} \
                INSTALL="sh ${.CURDIR}/tools/install.sh" \
                TOOLS_PREFIX=${CTOOLSDEST} \
                USRDATA_PREFIX=${WORLDDEST} \
+               M4=${BTOOLSDEST}/usr/bin/m4 \
                PATH=${BTOOLSPATH}:${PATH}
 
-XMAKE=         ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
+XMAKE=         ${XMAKEENV} make -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
                -DBOOTSTRAPPING -DNOSHARED
 
 # world stage, note the strict path and note that TOOLS_PREFIX is left
@@ -304,15 +312,16 @@ CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \
 WMAKEENV=      ${CROSSENV} \
                DESTDIR=${WORLDDEST} \
                INSTALL="sh ${.CURDIR}/tools/install.sh" \
+               M4=${BTOOLSDEST}/usr/bin/m4 \
                PATH=${STRICTTMPPATH}
 
-WMAKE=         ${WMAKEENV} ${BTOOLMAKE} -f Makefile.inc1
+WMAKE=         ${WMAKEENV} make -f Makefile.inc1
 
 # install stage
 #
 IMAKEENV=      ${CROSSENV} \
                PATH=${STRICTTMPPATH}
-IMAKE=         ${IMAKEENV} ${BTOOLMAKE} -f Makefile.inc1
+IMAKE=         ${IMAKEENV} make -f Makefile.inc1
 
 # kernel stage
 #
@@ -437,6 +446,7 @@ crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
 .ORDER: ${WMAKE_TGTS}
 .ORDER: _obj _includes
 .ORDER: _mtreetmp _obj
+.ORDER: installcheck backupworld-auto
 
 #
 # installcheck
@@ -459,7 +469,7 @@ installcheck:
 #
 # Installs everything compiled by a 'buildworld'.
 #
-installworld: installcheck
+installworld: installcheck backupworld-auto
        cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
        ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc ${DESTDIR}/etc/upgrade/
 
@@ -474,12 +484,12 @@ reinstall:
        @echo "--------------------------------------------------------------"
        @echo ">>> Making hierarchy"
        @echo "--------------------------------------------------------------"
-       cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
+       cd ${.CURDIR}; make -f Makefile.inc1 hierarchy
        @echo
        @echo "--------------------------------------------------------------"
        @echo ">>> Installing everything.."
        @echo "--------------------------------------------------------------"
-       cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
+       cd ${.CURDIR}; make -f Makefile.inc1 install
 
 #
 # buildkernel, nativekernel, quickkernel, and installkernel
@@ -600,7 +610,7 @@ buildkernel:        bk_tools bk_build_list bk_kernwarn
 .if !defined(NO_KERNELCONFIG)
        cd ${KRNLCONFDIR}; \
                PATH=${STRICTTMPPATH} \
-                   ${BTOOLCONFIG} ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
+                   config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
                        ${KERNCONFDIR}/${_kernel}
 .endif
 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
@@ -609,10 +619,10 @@ buildkernel:      bk_tools bk_build_list bk_kernwarn
        touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
 .if !defined(NO_KERNELDEPEND)
        cd ${KRNLOBJDIR}/${_kernel}; \
-           ${KMAKEENV} ${BTOOLMAKE} KERNEL=${INSTKERNNAME} depend
+           ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
 .endif
        cd ${KRNLOBJDIR}/${_kernel}; \
-           ${KMAKEENV} ${BTOOLMAKE} KERNEL=${INSTKERNNAME} all
+           ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
        @echo "--------------------------------------------------------------"
        @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
        @echo "--------------------------------------------------------------"
@@ -648,13 +658,13 @@ nativekernel:     bk_build_list bk_kernwarn
        touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
        cd ${KRNLOBJDIR}/${_kernel}; \
            MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
-           ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
+           make -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
 .if !defined(NO_KERNELDEPEND)
        cd ${KRNLOBJDIR}/${_kernel}; \
-           ${MAKE} KERNEL=${INSTKERNNAME} depend
+           make KERNEL=${INSTKERNNAME} depend
 .endif
        cd ${KRNLOBJDIR}/${_kernel}; \
-           ${MAKE} KERNEL=${INSTKERNNAME} all
+           make KERNEL=${INSTKERNNAME} all
        @echo "--------------------------------------------------------------"
        @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
        @echo "--------------------------------------------------------------"
@@ -676,11 +686,11 @@ quickkernel:      maybe_bk_tools bk_build_list bk_kernwarn
 .if !defined(NO_KERNELCONFIG)
        cd ${KRNLCONFDIR}; \
                PATH=${STRICTTMPPATH} \
-                   ${BTOOLCONFIG} ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
+                   config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
                        ${KERNCONFDIR}/${_kernel}
 .endif
        cd ${KRNLOBJDIR}/${_kernel}; \
-           ${KMAKEENV} ${BTOOLMAKE} KERNEL=${INSTKERNNAME} all
+           ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
 .else
 .if !defined(NO_KERNELCONFIG)
        cd ${KRNLCONFDIR}; \
@@ -688,7 +698,7 @@ quickkernel:        maybe_bk_tools bk_build_list bk_kernwarn
                ${KERNCONFDIR}/${_kernel}
 .endif
        cd ${KRNLOBJDIR}/${_kernel}; \
-           ${MAKE} KERNEL=${INSTKERNNAME} all
+           make KERNEL=${INSTKERNNAME} all
 .endif
        @echo "--------------------------------------------------------------"
        @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
@@ -706,10 +716,10 @@ installkernel reinstallkernel:
        @echo "--------------------------------------------------------------"
 .if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run)
        cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
-           ${IMAKEENV} ${BTOOLMAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
+           ${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
 .else
        cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
-           ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
+           make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
 .endif
 
 #
@@ -722,7 +732,7 @@ most:
        @echo ">>> Building programs only"
        @echo "--------------------------------------------------------------"
 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
-       cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ all
+       cd ${.CURDIR}/${_dir};          make DIRPRFX=${_dir}/ all
 .endfor
 
 #
@@ -736,7 +746,7 @@ installmost:
        @echo ">>> Installing programs only"
        @echo "--------------------------------------------------------------"
 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
-       cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ install
+       cd ${.CURDIR}/${_dir};          make DIRPRFX=${_dir}/ install
 .endfor
 
 #
@@ -766,14 +776,25 @@ installmost:
 _strfile=      games/fortune/strfile
 .endif
 
-BSTRAPDIRS= ${_strfile} \
+# BSTRAPDIRS1 - must be built in strict order, no parallelism
+#
+# order is very important. yacc before m4 before flex.  flex exec's m4,
+# m4's parser file needs the latest byacc (insanity!).
+#
+BSTRAPDIRS1= ${_strfile} \
        usr.bin/patch \
        bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \
        bin/test bin/cat bin/ln bin/mv bin/csh bin/expr bin/sh \
        bin/hostname bin/kill \
-       usr.bin/yacc usr.bin/colldef usr.bin/uudecode usr.bin/xinstall \
-       usr.bin/m4 usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
-       usr.bin/find usr.bin/lex usr.bin/sed usr.bin/uname usr.bin/touch \
+       usr.bin/yacc usr.bin/m4 usr.bin/colldef \
+       usr.bin/uudecode usr.bin/xinstall \
+       usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
+       usr.bin/find usr.bin/flex
+
+# BSTRAPDIRS2 - may built in parallel
+#
+BSTRAPDIRS2= \
+       usr.bin/sed usr.bin/uname usr.bin/touch \
        usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
        usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
        usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
@@ -786,24 +807,28 @@ BSTRAPDIRS= ${_strfile} \
        gnu/usr.bin/texinfo gnu/usr.bin/grep usr.bin/sort \
        usr.bin/gzip usr.bin/bzip2 usr.bin/mkcsmapper usr.bin/mkesdb
 
-bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets
+bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
        touch ${BTOOLSDEST}/.bootstrap_done
 
 bootstrap-tools-before:
        ${LN} -fs /bin/date ${BTOOLSDEST}/bin/date
 
-bootstrap-tools-targets: ${BSTRAPDIRS:S/^/bstrap-/}
+bootstrap-tools-targets1: ${BSTRAPDIRS1:S/^/bstrap-/}
+
+bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/}
 
-.ORDER: bootstrap-tools-before bootstrap-tools-targets
+.ORDER: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
 
-.for _tool in ${BSTRAPDIRS}
+.ORDER: ${BSTRAPDIRS1:S/^/bstrap-/}
+
+.for _tool in ${BSTRAPDIRS1} ${BSTRAPDIRS2}
 bstrap-${_tool}!
        ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
                cd ${.CURDIR}/${_tool}; \
-               ${MAKE} DIRPRFX=${_tool}/ obj; \
-               ${MAKE} DIRPRFX=${_tool}/ depend; \
-               ${MAKE} DIRPRFX=${_tool}/ all; \
-               ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
+               make DIRPRFX=${_tool}/ obj; \
+               make DIRPRFX=${_tool}/ depend; \
+               make DIRPRFX=${_tool}/ all; \
+               make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
 .endfor
 
 # build-tools: Build special purpose build tools.
@@ -816,12 +841,12 @@ _share=   share/syscons/scrnmaps
 .endif
 
 _gcc_common_cross= gnu/usr.bin/gmp gnu/usr.bin/mpfr
+.if !defined(NO_GCC44)
 _gcc44_cross= gnu/usr.bin/cc44
 _gcc44_tools= gnu/usr.bin/cc44/cc_prep gnu/usr.bin/cc44/cc_tools
-.if !defined(NO_GCC47)
+.endif
 _gcc47_cross= lib/libz gnu/usr.bin/mpc gnu/usr.bin/cc47
 _gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
-.endif
 _custom_cross= libexec/customcc
 _binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
 
@@ -839,10 +864,10 @@ build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
 btools-${_tool}!
        ${ECHODIR} "===> ${_tool} (build-tools)"; \
                cd ${.CURDIR}/${_tool}; \
-               ${MAKE} DIRPRFX=${_tool}/ obj; \
-               ${MAKE} DIRPRFX=${_tool}/ depend; \
-               ${MAKE} DIRPRFX=${_tool}/ all; \
-               ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
+               make DIRPRFX=${_tool}/ obj; \
+               make DIRPRFX=${_tool}/ depend; \
+               make DIRPRFX=${_tool}/ all; \
+               make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
 .endfor
 
 #
@@ -864,17 +889,17 @@ cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}
 ctools-${_tool}!
        ${ECHODIR} "===> ${_tool} (cross-tools)"; \
                cd ${.CURDIR}/${_tool}; \
-               ${MAKE} DIRPRFX=${_tool}/ obj; \
-               ${MAKE} DIRPRFX=${_tool}/ depend; \
-               ${MAKE} DIRPRFX=${_tool}/ all; \
-               ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
+               make DIRPRFX=${_tool}/ obj; \
+               make DIRPRFX=${_tool}/ depend; \
+               make DIRPRFX=${_tool}/ all; \
+               make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
 .endfor
 
 #
 # hierarchy - ensure that all the needed directories are present
 #
 hierarchy:
-       cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
+       cd ${.CURDIR}/etc;              make distrib-dirs
 
 #
 # libraries - build all libraries, and install them under ${DESTDIR}.
@@ -887,18 +912,18 @@ hierarchy:
 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
 #
 libraries:
-.if !defined(NO_GCC47)
        cd ${.CURDIR}; \
            HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
-               ${BTOOLMAKE} -f Makefile.inc1 _startup_libs47;
-.endif
+               make -f Makefile.inc1 _startup_libs47;
+.if !defined(NO_GCC44)
        cd ${.CURDIR}; \
            HOST_CCVER=${HOST_CCVER} CCVER=gcc44 \
-               ${BTOOLMAKE} -f Makefile.inc1 _startup_libs44;
+               make -f Makefile.inc1 _startup_libs44;
+.endif
        cd ${.CURDIR}; \
-           ${BTOOLMAKE} -f Makefile.inc1 _startup_libs; \
-           ${BTOOLMAKE} -f Makefile.inc1 _prebuild_libs; \
-           ${BTOOLMAKE} -f Makefile.inc1 _generic_libs;
+           make -f Makefile.inc1 _startup_libs; \
+           make -f Makefile.inc1 _prebuild_libs; \
+           make -f Makefile.inc1 _generic_libs;
        touch ${WORLDDEST}/.libraries_done
 
 # These dependencies are not automatically generated:
@@ -925,10 +950,7 @@ _prebuild_libs+=   lib/libutil
 _generic_libs= gnu/lib
 
 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
-               lib/libncurses/libncurses lib/libopie lib/libradius \
-               lib/libsbuf lib/libtacplus lib/libm \
-               lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \
-               lib/libpthread lib/libprop lib/libdevattr
+               lib/libncurses/libncurses lib/libopie
 
 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
 
@@ -945,7 +967,11 @@ secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
 _generic_libs+=        secure/lib
 .endif
 
-_generic_libs+=        usr.bin/lex/lib
+_prebuild_libs+= lib/libradius lib/libsbuf lib/libtacplus lib/libm \
+               lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \
+               lib/libpthread lib/libprop lib/libdevattr
+
+_generic_libs+=        usr.bin/flex/lib
 
 .for _lib in ${_startup_libs44} ${_startup_libs47} \
                ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
@@ -953,9 +979,9 @@ ${_lib}__L: .PHONY
 .if exists(${.CURDIR}/${_lib})
        ${ECHODIR} "===> ${_lib}"; \
                cd ${.CURDIR}/${_lib}; \
-               ${MAKE} DIRPRFX=${_lib}/ depend; \
-               ${MAKE} DIRPRFX=${_lib}/ all; \
-               ${MAKE} DIRPRFX=${_lib}/ install
+               make DIRPRFX=${_lib}/ depend; \
+               make DIRPRFX=${_lib}/ all; \
+               make DIRPRFX=${_lib}/ install
 .endif
 .endfor
 
@@ -986,7 +1012,7 @@ ${entry}.${__target}__D: .PHONY
                edir=${entry}; \
                cd ${.CURDIR}/$${edir}; \
        fi; \
-       ${BTOOLMAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
+       make ${__target} DIRPRFX=${DIRPRFX}$${edir}/
 .endfor
 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
 .ORDER: ${SUBDIR:S/$/.${__target}__D/}
@@ -997,44 +1023,91 @@ par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
 # world build environment.
 #
 wmake:
-       @echo '${WMAKEENV} ${BTOOLMAKE} ${WMAKE_ARGS}'
+       @echo '${WMAKEENV} make ${WMAKE_ARGS}'
 
 wmakeenv:
        @echo '${WMAKEENV} /bin/sh'
 
 bmake:
-       @echo '${BMAKEENV} ${BTOOLMAKE} ${BMAKE_ARGS}'
+       @echo '${BMAKEENV} make ${BMAKE_ARGS}'
 
 bmakeenv:
        @echo '${BMAKEENV} /bin/sh'
 
 tmake:
-       @echo '${TMAKEENV} ${BTOOLMAKE} ${TMAKE_ARGS}'
+       @echo '${TMAKEENV} make ${TMAKE_ARGS}'
 
 tmakeenv:
        @echo '${TMAKEENV} /bin/sh'
 
 xmake:
-       @echo '${XMAKEENV} ${BTOOLMAKE} ${XMAKE_ARGS}'
+       @echo '${XMAKEENV} make ${XMAKE_ARGS}'
 
 xmakeenv:
        @echo '${XMAKEENV} /bin/sh'
 
+backupworld: backup-clean
+       @mkdir -p ${WORLD_BACKUP}
+.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
+     exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
+     exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
+       tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
+               --options gzip:compression-level=1 \
+               sbin bin usr/sbin usr/bin usr/lib usr/libexec
+.endif
+
+backupworld-auto:
+.if !defined(NO_BACKUP)
+       rm -f ${AUTO_BACKUP}/binaries.tar.gz
+       @mkdir -p ${AUTO_BACKUP}
+.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
+     exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
+     exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
+       tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
+               --options gzip:compression-level=1 \
+               sbin bin usr/sbin usr/bin usr/lib usr/libexec
+.endif
+.endif
+
+backup-auto-clean:
+       rm -f ${AUTO_BACKUP}/binaries.tar.gz
+
+backup-clean:
+       rm -f ${WORLD_BACKUP}/binaries.tar.gz
+
+restoreworld:
+.if !exists(${WORLD_BACKUP}/binaries.tar.gz)
+       @echo "There does not seem to be a valid archive present."
+.else
+       @echo "Restoring system binaries from manual backup archive..."
+       @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
+               ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
+               ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
+       tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
+.endif
+
+restoreworld-auto:
+.if !exists(${AUTO_BACKUP}/binaries.tar.gz)
+       @echo "There does not seem to be a valid archive present."
+.else
+       @echo "Restoring system binaries from auto-backup archive..."
+       @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
+               ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
+               ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
+       tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
+.endif
+
 # Take advantage of bmake error response
 #
 MAKE_PRINT_VAR_ON_ERROR= \
        .CURDIR \
        .OBJDIR \
-       .MAKE \
-       MAKE_VERSION \
        LD_LIBRARY_PATH \
        MACHINE_ARCH \
        MACHINE \
        MAKEFILE \
        .TARGETS \
        .ERROR_TARGET \
-       .ERROR_META_FILE \
-       .MAKE.LEVEL \
-       .MAKE.MODE
+       .MAKE.LEVEL
 
 .include <bsd.subdir.mk>