1# 2# $FreeBSD$ 3# 4# The user-driven targets are: 5# 6# universe - *Really* build *everything* (buildworld and 7# all kernels on all architectures). 8# buildworld - Rebuild *everything*, including glue to help do 9# upgrades. 10# installworld - Install everything built by "buildworld". 11# world - buildworld + installworld. 12# buildkernel - Rebuild the kernel and the kernel-modules. 13# installkernel - Install the kernel and the kernel-modules. 14# installkernel.debug 15# reinstallkernel - Reinstall the kernel and the kernel-modules. 16# reinstallkernel.debug 17# kernel - buildkernel + installkernel. 18# update - Convenient way to update your source tree (cvs). 19# 20# This makefile is simple by design. The FreeBSD make automatically reads 21# the /usr/share/mk/sys.mk unless the -m argument is specified on the 22# command line. By keeping this makefile simple, it doesn't matter too 23# much how different the installed mk files are from those in the source 24# tree. This makefile executes a child make process, forcing it to use 25# the mk files from the source tree which are supposed to DTRT. 26# 27# The user-driven targets (as listed above) are implemented in Makefile.inc1. 28# 29# If you want to build your system from source be sure that /usr/obj has 30# at least 400MB of diskspace available. 31# 32# For individuals wanting to build from the sources currently on their 33# system, the simple instructions are: 34# 35# 1. `cd /usr/src' (or to the directory containing your source tree). 36# 2. `make world' 37# 38# For individuals wanting to upgrade their sources (even if only a 39# delta of a few days): 40# 41# 1. `cd /usr/src' (or to the directory containing your source tree). 42# 2. `make buildworld' 43# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 44# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 45# 5. `reboot' (in single user mode: boot -s from the loader prompt). 46# 6. `mergemaster -p' 47# 7. `make installworld' 48# 8. `mergemaster' 49# 9. `reboot' 50# 51# See src/UPDATING `COMMON ITEMS' for more complete information. 52# 53# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 54# cross build world for other architectures using the buildworld target, 55# and once the world is built you can cross build a kernel using the 56# buildkernel target. 57# 58# Define the user-driven targets. These are listed here in alphabetical 59# order, but that's not important. 60# 61# Targets that begin with underscore are internal targets intended for 62# developer convenience only. They are intentionally not documented and 63# completely subject to change without notice. 64# 65TGTS= all all-man buildkernel buildworld checkdpadd clean \ 66 cleandepend cleandir depend distribute distributeworld everything \ 67 hierarchy install installcheck installkernel installkernel.debug\ 68 reinstallkernel reinstallkernel.debug installworld \ 69 kernel-toolchain libraries lint maninstall \ 70 obj objlink regress rerelease tags toolchain update \ 71 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 72 _build-tools _cross-tools _includes _libraries _depend \ 73 build32 install32 74 75BITGTS= files includes 76BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 77TGTS+= ${BITGTS} 78 79.ORDER: buildworld installworld 80.ORDER: buildworld distributeworld 81.ORDER: buildworld buildkernel 82.ORDER: buildkernel installkernel 83.ORDER: buildkernel installkernel.debug 84.ORDER: buildkernel reinstallkernel 85.ORDER: buildkernel reinstallkernel.debug 86 87PATH= /sbin:/bin:/usr/sbin:/usr/bin 88MAKEOBJDIRPREFIX?= /usr/obj 89_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 90 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \ 91 -f /dev/null -V MAKEOBJDIRPREFIX dummy 92.if !empty(_MAKEOBJDIRPREFIX) 93.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 94 (in /etc/make.conf) or command-line variable. 95.endif 96MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 97BINMAKE= \ 98 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 99 -m ${.CURDIR}/share/mk 100_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 101 102# 103# Make sure we have an up-to-date make(1). Only world and buildworld 104# should do this as those are the initial targets used for upgrades. 105# The user can define ALWAYS_CHECK_MAKE to have this check performed 106# for all targets. 107# 108.if defined(ALWAYS_CHECK_MAKE) 109${TGTS}: upgrade_checks 110.else 111buildworld: upgrade_checks 112.endif 113 114# 115# This 'cleanworld' target is not included in TGTS, because it is not a 116# recursive target. All of the work for it is done right here. It is 117# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 118# created by bsd.obj.mk, except that we don't want to .include that file 119# in this makefile. 120# 121# In the following, the first 'rm' in a series will usually remove all 122# files and directories. If it does not, then there are probably some 123# files with chflags set, so this unsets them and tries the 'rm' a 124# second time. There are situations where this target will be cleaning 125# some directories via more than one method, but that duplication is 126# needed to correctly handle all the possible situations. 127# 128BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 129cleanworld: 130.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 131.if exists(${BW_CANONICALOBJDIR}/) 132 -rm -rf ${BW_CANONICALOBJDIR}/* 133 chflags -R 0 ${BW_CANONICALOBJDIR} 134 rm -rf ${BW_CANONICALOBJDIR}/* 135.endif 136 # To be safe in this case, fall back to a 'make cleandir' 137 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 138.else 139 -rm -rf ${.OBJDIR}/* 140 chflags -R 0 ${.OBJDIR} 141 rm -rf ${.OBJDIR}/* 142.endif 143 144# 145# Handle the user-driven targets, using the source relative mk files. 146# 147 148${TGTS}: 149 ${_+_}@cd ${.CURDIR}; \ 150 ${_MAKE} ${.TARGET} 151 152# Set a reasonable default 153.MAIN: all 154 155STARTTIME!= LC_ALL=C date 156 157.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 158# 159# world 160# 161# Attempt to rebuild and reinstall everything. This target is not to be 162# used for upgrading an existing FreeBSD system, because the kernel is 163# not included. One can argue that this target doesn't build everything 164# then. 165# 166world: upgrade_checks 167 @echo "--------------------------------------------------------------" 168 @echo ">>> make world started on ${STARTTIME}" 169 @echo "--------------------------------------------------------------" 170.if target(pre-world) 171 @echo 172 @echo "--------------------------------------------------------------" 173 @echo ">>> Making 'pre-world' target" 174 @echo "--------------------------------------------------------------" 175 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 176.endif 177 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 178 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 179.if target(post-world) 180 @echo 181 @echo "--------------------------------------------------------------" 182 @echo ">>> Making 'post-world' target" 183 @echo "--------------------------------------------------------------" 184 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 185.endif 186 @echo 187 @echo "--------------------------------------------------------------" 188 @echo ">>> make world completed on `LC_ALL=C date`" 189 @echo " (started ${STARTTIME})" 190 @echo "--------------------------------------------------------------" 191.else 192world: 193 @echo "WARNING: make world will overwrite your existing FreeBSD" 194 @echo "installation without also building and installing a new" 195 @echo "kernel. This can be dangerous. Please read the handbook," 196 @echo "'Rebuilding world', for how to upgrade your system." 197 @echo "Define DESTDIR to where you want to install FreeBSD," 198 @echo "including /, to override this warning and proceed as usual." 199 @echo "You may get the historical 'make world' behavior by defining" 200 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 201 @echo "before doing this." 202 @echo "" 203 @echo "Bailing out now..." 204 @false 205.endif 206 207# 208# kernel 209# 210# Short hand for `make buildkernel installkernel' 211# 212kernel: buildkernel installkernel 213 214# 215# Perform a few tests to determine if the installed tools are adequate 216# for building the world. 217# 218upgrade_checks: 219 @if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \ 220 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 221 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 222 then \ 223 (cd ${.CURDIR} && make make); \ 224 fi 225 226# 227# Upgrade make(1) to the current version using the installed 228# headers, libraries and tools. 229# 230MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 231 DESTDIR= \ 232 INSTALL="sh ${.CURDIR}/tools/install.sh" 233MMAKE= ${MMAKEENV} make \ 234 -D_UPGRADING \ 235 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 236 -DNO_CPU_CFLAGS -DNO_WERROR 237 238make: .PHONY 239 @echo 240 @echo "--------------------------------------------------------------" 241 @echo ">>> Building an up-to-date make(1)" 242 @echo "--------------------------------------------------------------" 243 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 244 ${MMAKE} obj && \ 245 ${MMAKE} depend && \ 246 ${MMAKE} all && \ 247 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 248 249# 250# universe 251# 252# Attempt to rebuild *everything* for all supported architectures, 253# with a reasonable chance of success, regardless of how old your 254# existing system is. 255# 256universe: universe_prologue 257universe_prologue: 258 @echo "--------------------------------------------------------------" 259 @echo ">>> make universe started on ${STARTTIME}" 260 @echo "--------------------------------------------------------------" 261.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 262.for arch in ${target:C/:.*$//} 263.for mach in ${target:C/^.*://} 264universe: universe_${mach} 265.ORDER: universe_prologue universe_${mach} universe_epilogue 266universe_${mach}: 267 @echo ">> ${mach} started on `LC_ALL=C date`" 268 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 269 TARGET_ARCH=${arch} TARGET=${mach} \ 270 __MAKE_CONF=/dev/null \ 271 > _.${mach}.buildworld 2>&1 272 @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 273.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 274 -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 275 > ${.CURDIR}/_.${mach}.makeLINT 2>&1 276.endif 277 cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 278 @echo ">> ${mach} completed on `LC_ALL=C date`" 279.endfor 280.endfor 281.endfor 282universe: universe_epilogue 283universe_epilogue: 284 @echo "--------------------------------------------------------------" 285 @echo ">>> make universe completed on `LC_ALL=C date`" 286 @echo " (started ${STARTTIME})" 287 @echo "--------------------------------------------------------------" 288 289.if make(buildkernels) 290KERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 291 find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 292buildkernels: 293.for kernel in ${KERNCONFS} 294 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 295 KERNCONF=${kernel} \ 296 __MAKE_CONF=/dev/null \ 297 > _.${TARGET}.${kernel} 2>&1 298.endfor 299.endif 300