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