Makefile revision 152879
1218887Sdim# 2218887Sdim# $FreeBSD: head/Makefile 152879 2005-11-28 11:03:59Z ru $ 3218887Sdim# 4218887Sdim# The user-driven targets are: 5218887Sdim# 6218887Sdim# universe - *Really* build *everything* (buildworld and 7218887Sdim# all kernels on all architectures). 8218887Sdim# buildworld - Rebuild *everything*, including glue to help do 9218887Sdim# upgrades. 10224145Sdim# installworld - Install everything built by "buildworld". 11218887Sdim# world - buildworld + installworld. 12218887Sdim# buildkernel - Rebuild the kernel and the kernel-modules. 13218887Sdim# installkernel - Install the kernel and the kernel-modules. 14218887Sdim# installkernel.debug 15218887Sdim# reinstallkernel - Reinstall the kernel and the kernel-modules. 16218887Sdim# reinstallkernel.debug 17249423Sdim# kernel - buildkernel + installkernel. 18249423Sdim# update - Convenient way to update your source tree (cvs). 19218887Sdim# check-old - Print a list of old files/directories in the system. 20221345Sdim# delete-old - Delete obsolete files and directories interactively. 21239462Sdim# delete-old-libs - Delete obsolete libraries interactively. 22218887Sdim# 23218887Sdim# This makefile is simple by design. The FreeBSD make automatically reads 24218887Sdim# the /usr/share/mk/sys.mk unless the -m argument is specified on the 25226633Sdim# command line. By keeping this makefile simple, it doesn't matter too 26226633Sdim# much how different the installed mk files are from those in the source 27218887Sdim# tree. This makefile executes a child make process, forcing it to use 28218887Sdim# the mk files from the source tree which are supposed to DTRT. 29226633Sdim# 30218887Sdim# The user-driven targets (as listed above) are implemented in Makefile.inc1. 31218887Sdim# 32234353Sdim# If you want to build your system from source be sure that /usr/obj has 33234353Sdim# at least 400MB of diskspace available. 34234353Sdim# 35218887Sdim# For individuals wanting to build from the sources currently on their 36218887Sdim# system, the simple instructions are: 37218887Sdim# 38218887Sdim# 1. `cd /usr/src' (or to the directory containing your source tree). 39218887Sdim# 2. `make world' 40218887Sdim# 41218887Sdim# For individuals wanting to upgrade their sources (even if only a 42218887Sdim# delta of a few days): 43218887Sdim# 44218887Sdim# 1. `cd /usr/src' (or to the directory containing your source tree). 45218887Sdim# 2. `make buildworld' 46218887Sdim# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 47218887Sdim# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 48218887Sdim# 5. `reboot' (in single user mode: boot -s from the loader prompt). 49218887Sdim# 6. `mergemaster -p' 50224145Sdim# 7. `make installworld' 51224145Sdim# 8. `make delete-old' 52224145Sdim# 9. `mergemaster' 53224145Sdim# 10. `reboot' 54224145Sdim# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 55224145Sdim# 56218887Sdim# See src/UPDATING `COMMON ITEMS' for more complete information. 57218887Sdim# 58218887Sdim# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 59218887Sdim# cross build world for other architectures using the buildworld target, 60218887Sdim# and once the world is built you can cross build a kernel using the 61218887Sdim# buildkernel target. 62218887Sdim# 63218887Sdim# Define the user-driven targets. These are listed here in alphabetical 64218887Sdim# order, but that's not important. 65218887Sdim# 66218887Sdim# Targets that begin with underscore are internal targets intended for 67218887Sdim# developer convenience only. They are intentionally not documented and 68218887Sdim# completely subject to change without notice. 69218887Sdim# 70218887SdimTGTS= all all-man buildenv buildkernel buildworld check-old checkdpadd \ 71218887Sdim clean cleandepend cleandir delete-old delete-old-libs depend \ 72218887Sdim distribute distributeworld distrib-dirs distribution everything \ 73218887Sdim hierarchy install installcheck installkernel installkernel.debug\ 74218887Sdim reinstallkernel reinstallkernel.debug installworld \ 75218887Sdim kernel-toolchain libraries lint maninstall \ 76218887Sdim obj objlink regress rerelease tags toolchain update \ 77218887Sdim _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 78218887Sdim _build-tools _cross-tools _includes _libraries _depend \ 79218887Sdim build32 distribute32 install32 80218887Sdim 81234353SdimBITGTS= files includes 82218887SdimBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 83218887SdimTGTS+= ${BITGTS} 84218887Sdim 85218887Sdim.ORDER: buildworld installworld 86218887Sdim.ORDER: buildworld distributeworld 87218887Sdim.ORDER: buildworld buildkernel 88218887Sdim.ORDER: buildkernel installkernel 89218887Sdim.ORDER: buildkernel installkernel.debug 90224145Sdim.ORDER: buildkernel reinstallkernel 91226633Sdim.ORDER: buildkernel reinstallkernel.debug 92226633Sdim 93226633SdimPATH= /sbin:/bin:/usr/sbin:/usr/bin 94226633SdimMAKEOBJDIRPREFIX?= /usr/obj 95226633Sdim_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 96226633Sdim ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \ 97226633Sdim -f /dev/null -V MAKEOBJDIRPREFIX dummy 98226633Sdim.if !empty(_MAKEOBJDIRPREFIX) 99226633Sdim.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 100226633Sdim (in /etc/make.conf) or command-line variable. 101224145Sdim.endif 102224145SdimMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 103224145SdimBINMAKE= \ 104224145Sdim `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 105224145Sdim -m ${.CURDIR}/share/mk 106224145Sdim_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 107224145Sdim 108226633Sdim# 109249423Sdim# Make sure we have an up-to-date make(1). Only world and buildworld 110226633Sdim# should do this as those are the initial targets used for upgrades. 111226633Sdim# The user can define ALWAYS_CHECK_MAKE to have this check performed 112224145Sdim# for all targets. 113224145Sdim# 114224145Sdim.if defined(ALWAYS_CHECK_MAKE) 115224145Sdim${TGTS}: upgrade_checks 116224145Sdim.else 117224145Sdimbuildworld: upgrade_checks 118224145Sdim.endif 119224145Sdim 120224145Sdim# 121224145Sdim# This 'cleanworld' target is not included in TGTS, because it is not a 122224145Sdim# recursive target. All of the work for it is done right here. It is 123226633Sdim# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 124224145Sdim# created by bsd.obj.mk, except that we don't want to .include that file 125224145Sdim# in this makefile. 126224145Sdim# 127224145Sdim# In the following, the first 'rm' in a series will usually remove all 128224145Sdim# files and directories. If it does not, then there are probably some 129226633Sdim# files with chflags set, so this unsets them and tries the 'rm' a 130224145Sdim# second time. There are situations where this target will be cleaning 131224145Sdim# some directories via more than one method, but that duplication is 132224145Sdim# needed to correctly handle all the possible situations. 133224145Sdim# 134249423SdimBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 135224145Sdimcleanworld: 136224145Sdim.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 137224145Sdim.if exists(${BW_CANONICALOBJDIR}/) 138224145Sdim -rm -rf ${BW_CANONICALOBJDIR}/* 139224145Sdim chflags -R 0 ${BW_CANONICALOBJDIR} 140224145Sdim rm -rf ${BW_CANONICALOBJDIR}/* 141.endif 142 # To be safe in this case, fall back to a 'make cleandir' 143 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 144.else 145 -rm -rf ${.OBJDIR}/* 146 chflags -R 0 ${.OBJDIR} 147 rm -rf ${.OBJDIR}/* 148.endif 149 150# 151# Handle the user-driven targets, using the source relative mk files. 152# 153 154${TGTS}: 155 ${_+_}@cd ${.CURDIR}; \ 156 ${_MAKE} ${.TARGET} 157 158# Set a reasonable default 159.MAIN: all 160 161STARTTIME!= LC_ALL=C date 162 163.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 164# 165# world 166# 167# Attempt to rebuild and reinstall everything. This target is not to be 168# used for upgrading an existing FreeBSD system, because the kernel is 169# not included. One can argue that this target doesn't build everything 170# then. 171# 172world: upgrade_checks 173 @echo "--------------------------------------------------------------" 174 @echo ">>> make world started on ${STARTTIME}" 175 @echo "--------------------------------------------------------------" 176.if target(pre-world) 177 @echo 178 @echo "--------------------------------------------------------------" 179 @echo ">>> Making 'pre-world' target" 180 @echo "--------------------------------------------------------------" 181 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 182.endif 183 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 184 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 185.if target(post-world) 186 @echo 187 @echo "--------------------------------------------------------------" 188 @echo ">>> Making 'post-world' target" 189 @echo "--------------------------------------------------------------" 190 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 191.endif 192 @echo 193 @echo "--------------------------------------------------------------" 194 @echo ">>> make world completed on `LC_ALL=C date`" 195 @echo " (started ${STARTTIME})" 196 @echo "--------------------------------------------------------------" 197.else 198world: 199 @echo "WARNING: make world will overwrite your existing FreeBSD" 200 @echo "installation without also building and installing a new" 201 @echo "kernel. This can be dangerous. Please read the handbook," 202 @echo "'Rebuilding world', for how to upgrade your system." 203 @echo "Define DESTDIR to where you want to install FreeBSD," 204 @echo "including /, to override this warning and proceed as usual." 205 @echo "You may get the historical 'make world' behavior by defining" 206 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 207 @echo "before doing this." 208 @echo "" 209 @echo "Bailing out now..." 210 @false 211.endif 212 213# 214# kernel 215# 216# Short hand for `make buildkernel installkernel' 217# 218kernel: buildkernel installkernel 219 220# 221# Perform a few tests to determine if the installed tools are adequate 222# for building the world. 223# 224upgrade_checks: 225 @if ! (cd ${.CURDIR}/tools/build/make_check && \ 226 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 227 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 228 then \ 229 (cd ${.CURDIR} && make make); \ 230 fi 231 232# 233# Upgrade make(1) to the current version using the installed 234# headers, libraries and tools. 235# 236MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 237 DESTDIR= \ 238 INSTALL="sh ${.CURDIR}/tools/install.sh" 239MMAKE= ${MMAKEENV} make \ 240 -D_UPGRADING \ 241 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 242 -DNO_CPU_CFLAGS -DNO_WERROR 243 244make: .PHONY 245 @echo 246 @echo "--------------------------------------------------------------" 247 @echo ">>> Building an up-to-date make(1)" 248 @echo "--------------------------------------------------------------" 249 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 250 ${MMAKE} obj && \ 251 ${MMAKE} depend && \ 252 ${MMAKE} all && \ 253 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 254 255# 256# universe 257# 258# Attempt to rebuild *everything* for all supported architectures, 259# with a reasonable chance of success, regardless of how old your 260# existing system is. 261# 262.if make(universe) 263universe: universe_prologue 264universe_prologue: 265 @echo "--------------------------------------------------------------" 266 @echo ">>> make universe started on ${STARTTIME}" 267 @echo "--------------------------------------------------------------" 268.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 269.for arch in ${target:C/:.*$//} 270.for mach in ${target:C/^.*://} 271KERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 272 find [A-Z]*[A-Z] -type f -maxdepth 0 \ 273 ! -name DEFAULTS ! -name NOTES 274KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 275universe: universe_${mach} 276.ORDER: universe_prologue universe_${mach} universe_epilogue 277universe_${mach}: 278 @echo ">> ${mach} started on `LC_ALL=C date`" 279 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 280 TARGET_ARCH=${arch} TARGET=${mach} \ 281 __MAKE_CONF=/dev/null \ 282 > _.${mach}.buildworld 2>&1 283 @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 284.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 285 -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 286 > ${.CURDIR}/_.${mach}.makeLINT 2>&1 287.endif 288.for kernel in ${KERNCONFS} 289 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 290 TARGET_ARCH=${arch} TARGET=${mach} \ 291 KERNCONF=${kernel} \ 292 __MAKE_CONF=/dev/null \ 293 > _.${mach}.${kernel} 2>&1 294.endfor 295 @echo ">> ${mach} completed on `LC_ALL=C date`" 296.endfor 297.endfor 298.endfor 299universe: universe_epilogue 300universe_epilogue: 301 @echo "--------------------------------------------------------------" 302 @echo ">>> make universe completed on `LC_ALL=C date`" 303 @echo " (started ${STARTTIME})" 304 @echo "--------------------------------------------------------------" 305.endif 306