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 74BITGTS= files includes 75BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 76TGTS+= ${BITGTS} 77 78.ORDER: buildworld installworld 79.ORDER: buildworld distributeworld 80.ORDER: buildworld buildkernel 81.ORDER: buildkernel installkernel 82.ORDER: buildkernel installkernel.debug 83.ORDER: buildkernel reinstallkernel 84.ORDER: buildkernel reinstallkernel.debug 85 86PATH= /sbin:/bin:/usr/sbin:/usr/bin 87MAKEOBJDIRPREFIX?= /usr/obj 88_MAKEOBJDIRPREFIX!= env -i PATH=${PATH} MAKEFLAGS="${.MAKEFLAGS}" ${MAKE} \ 89 -f /dev/null -V MAKEOBJDIRPREFIX dummy 90.if !empty(_MAKEOBJDIRPREFIX) 91.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 92 (in /etc/make.conf) or command-line variable. 93.endif 94MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 95BINMAKE= \ 96 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 97 -m ${.CURDIR}/share/mk 98_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 99 100# 101# Make sure we have an up-to-date make(1). Only world and buildworld 102# should do this as those are the initial targets used for upgrades. 103# The user can define ALWAYS_CHECK_MAKE to have this check performed 104# for all targets. 105# 106.if defined(ALWAYS_CHECK_MAKE) 107${TGTS}: upgrade_checks 108.else 109buildworld: upgrade_checks 110.endif 111 112# 113# This 'cleanworld' target is not included in TGTS, because it is not a 114# recursive target. All of the work for it is done right here. It is 115# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 116# created by bsd.obj.mk, except that we don't want to .include that file 117# in this makefile. 118# 119# In the following, the first 'rm' in a series will usually remove all 120# files and directories. If it does not, then there are probably some 121# files with chflags set, so this unsets them and tries the 'rm' a 122# second time. There are situations where this target will be cleaning 123# some directories via more than one method, but that duplication is 124# needed to correctly handle all the possible situations. 125# 126BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 127cleanworld: 128.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 129.if exists(${BW_CANONICALOBJDIR}/) 130 -rm -rf ${BW_CANONICALOBJDIR}/* 131 chflags -R 0 ${BW_CANONICALOBJDIR} 132 rm -rf ${BW_CANONICALOBJDIR}/* 133.endif 134 # To be safe in this case, fall back to a 'make cleandir' 135 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 136.else 137 -rm -rf ${.OBJDIR}/* 138 chflags -R 0 ${.OBJDIR} 139 rm -rf ${.OBJDIR}/* 140.endif 141 142# 143# Handle the user-driven targets, using the source relative mk files. 144# 145 146${TGTS}: 147 ${_+_}@cd ${.CURDIR}; \ 148 ${_MAKE} ${.TARGET} 149 150# Set a reasonable default 151.MAIN: all 152 153STARTTIME!= LC_ALL=C date 154 155.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 156# 157# world 158# 159# Attempt to rebuild and reinstall everything. This target is not to be 160# used for upgrading an existing FreeBSD system, because the kernel is 161# not included. One can argue that this target doesn't build everything 162# then. 163# 164world: upgrade_checks 165 @echo "--------------------------------------------------------------" 166 @echo ">>> make world started on ${STARTTIME}" 167 @echo "--------------------------------------------------------------" 168.if target(pre-world) 169 @echo 170 @echo "--------------------------------------------------------------" 171 @echo ">>> Making 'pre-world' target" 172 @echo "--------------------------------------------------------------" 173 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 174.endif 175 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 176 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 177.if target(post-world) 178 @echo 179 @echo "--------------------------------------------------------------" 180 @echo ">>> Making 'post-world' target" 181 @echo "--------------------------------------------------------------" 182 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 183.endif 184 @echo 185 @echo "--------------------------------------------------------------" 186 @echo ">>> make world completed on `LC_ALL=C date`" 187 @echo " (started ${STARTTIME})" 188 @echo "--------------------------------------------------------------" 189.else 190world: 191 @echo "WARNING: make world will overwrite your existing FreeBSD" 192 @echo "installation without also building and installing a new" 193 @echo "kernel. This can be dangerous. Please read the handbook," 194 @echo "'Rebuilding world', for how to upgrade your system." 195 @echo "Define DESTDIR to where you want to install FreeBSD," 196 @echo "including /, to override this warning and proceed as usual." 197 @echo "You may get the historical 'make world' behavior by defining" 198 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 199 @echo "before doing this." 200 @echo "" 201 @echo "Bailing out now..." 202 @false 203.endif 204 205# 206# kernel 207# 208# Short hand for `make buildkernel installkernel' 209# 210kernel: buildkernel installkernel 211 212# 213# Perform a few tests to determine if the installed tools are adequate 214# for building the world. 215# 216upgrade_checks: 217 @if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \ 218 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 219 then \ 220 (cd ${.CURDIR} && make make); \ 221 fi 222 223# 224# Upgrade make(1) to the current version using the installed 225# headers, libraries and tools. 226# 227MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 228 DESTDIR= \ 229 INSTALL="sh ${.CURDIR}/tools/install.sh" 230MMAKE= ${MMAKEENV} make \ 231 -D_UPGRADING \ 232 -DNOMAN -DNOSHARED \ 233 -DNO_CPU_CFLAGS -DNO_WERROR 234 235make: .PHONY 236 @echo 237 @echo "--------------------------------------------------------------" 238 @echo ">>> Building an up-to-date make(1)" 239 @echo "--------------------------------------------------------------" 240 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 241 ${MMAKE} obj && \ 242 ${MMAKE} depend && \ 243 ${MMAKE} all && \ 244 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 245 246# 247# universe 248# 249# Attempt to rebuild *everything* for all supported architectures, 250# with a reasonable chance of success, regardless of how old your 251# existing system is. 252# 253universe: universe_prologue 254universe_prologue: 255 @echo "--------------------------------------------------------------" 256 @echo ">>> make universe started on ${STARTTIME}" 257 @echo "--------------------------------------------------------------" 258.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 259.for arch in ${target:C/:.*$//} 260.for mach in ${target:C/^.*://} 261universe: universe_${mach} 262.ORDER: universe_prologue universe_${mach} universe_epilogue 263universe_${mach}: 264 @echo ">> ${mach} started on `LC_ALL=C date`" 265 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 266 TARGET_ARCH=${arch} TARGET=${mach} \ 267 __MAKE_CONF=/dev/null \ 268 > _.${mach}.buildworld 2>&1 269 @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 270.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 271 -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 272 > ${.CURDIR}/_.${mach}.makeLINT 2>&1 273.endif 274 cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 275 @echo ">> ${mach} completed on `LC_ALL=C date`" 276.endfor 277.endfor 278.endfor 279universe: universe_epilogue 280universe_epilogue: 281 @echo "--------------------------------------------------------------" 282 @echo ">>> make universe completed on `LC_ALL=C date`" 283 @echo " (started ${STARTTIME})" 284 @echo "--------------------------------------------------------------" 285 286.if make(buildkernels) 287KERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 288 find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 289buildkernels: 290.for kernel in ${KERNCONFS} 291 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 292 KERNCONF=${kernel} \ 293 __MAKE_CONF=/dev/null \ 294 > _.${TARGET}.${kernel} 2>&1 295.endfor 296.endif 297