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