Makefile revision 159363
1290001Sglebius# 2290001Sglebius# $FreeBSD: head/Makefile 159363 2006-06-07 03:33:48Z trhodes $ 3290001Sglebius# 4290001Sglebius# The user-driven targets are: 5290001Sglebius# 6290001Sglebius# universe - *Really* build *everything* (buildworld and 7290001Sglebius# all kernels on all architectures). 8290001Sglebius# buildworld - Rebuild *everything*, including glue to help do 9290001Sglebius# upgrades. 10290001Sglebius# installworld - Install everything built by "buildworld". 11290001Sglebius# world - buildworld + installworld, no kernel. 12290001Sglebius# buildkernel - Rebuild the kernel and the kernel-modules. 13290001Sglebius# installkernel - Install the kernel and the kernel-modules. 14290001Sglebius# installkernel.debug 15290001Sglebius# reinstallkernel - Reinstall the kernel and the kernel-modules. 16290001Sglebius# reinstallkernel.debug 17290001Sglebius# kernel - buildkernel + installkernel. 18290001Sglebius# doxygen - Build API documentation of the kernel, needs doxygen. 19290001Sglebius# update - Convenient way to update your source tree (cvs). 20290001Sglebius# check-old - Print a list of old files/directories in the system. 21290001Sglebius# delete-old - Delete obsolete files and directories interactively. 22290001Sglebius# delete-old-libs - Delete obsolete libraries interactively. 23290001Sglebius# 24290001Sglebius# This makefile is simple by design. The FreeBSD make automatically reads 25290001Sglebius# the /usr/share/mk/sys.mk unless the -m argument is specified on the 26290001Sglebius# command line. By keeping this makefile simple, it doesn't matter too 27290001Sglebius# much how different the installed mk files are from those in the source 28290001Sglebius# tree. This makefile executes a child make process, forcing it to use 29290001Sglebius# the mk files from the source tree which are supposed to DTRT. 30290001Sglebius# 31290001Sglebius# The user-driven targets (as listed above) are implemented in Makefile.inc1. 32290001Sglebius# 33290001Sglebius# If you want to build your system from source be sure that /usr/obj has 34290001Sglebius# at least 400MB of diskspace available. 35290001Sglebius# 36290001Sglebius# For individuals wanting to build from the sources currently on their 37290001Sglebius# system, the simple instructions are: 38290001Sglebius# 39290001Sglebius# 1. `cd /usr/src' (or to the directory containing your source tree). 40290001Sglebius# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 41290001Sglebius# 3. `make world' 42290001Sglebius# 43290001Sglebius# For individuals wanting to upgrade their sources (even if only a 44290001Sglebius# delta of a few days): 45290001Sglebius# 46290001Sglebius# 1. `cd /usr/src' (or to the directory containing your source tree). 47290001Sglebius# 2. `make buildworld' 48290001Sglebius# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 49290001Sglebius# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 50290001Sglebius# 5. `reboot' (in single user mode: boot -s from the loader prompt). 51290001Sglebius# 6. `mergemaster -p' 52290001Sglebius# 7. `make installworld' 53290001Sglebius# 8. `make delete-old' 54290001Sglebius# 9. `mergemaster' 55290001Sglebius# 10. `reboot' 56290001Sglebius# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 57290001Sglebius# 58290001Sglebius# See src/UPDATING `COMMON ITEMS' for more complete information. 59290001Sglebius# 60290001Sglebius# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 61290001Sglebius# cross build world for other architectures using the buildworld target, 62290001Sglebius# and once the world is built you can cross build a kernel using the 63290001Sglebius# buildkernel target. 64290001Sglebius# 65290001Sglebius# Define the user-driven targets. These are listed here in alphabetical 66290001Sglebius# order, but that's not important. 67290001Sglebius# 68290001Sglebius# Targets that begin with underscore are internal targets intended for 69290001Sglebius# developer convenience only. They are intentionally not documented and 70290001Sglebius# completely subject to change without notice. 71290001Sglebius# 72290001SglebiusTGTS= all all-man buildenv buildenvvars buildkernel buildworld check-old \ 73290001Sglebius checkdpadd clean cleandepend cleandir delete-old delete-old-libs \ 74290001Sglebius depend distribute distributeworld distrib-dirs distribution doxygen \ 75290001Sglebius everything hierarchy install installcheck installkernel \ 76290001Sglebius installkernel.debug reinstallkernel reinstallkernel.debug \ 77290001Sglebius installworld kernel-toolchain libraries lint maninstall \ 78290001Sglebius obj objlink regress rerelease showconfig tags toolchain update \ 79290001Sglebius _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 80290001Sglebius _build-tools _cross-tools _includes _libraries _depend \ 81290001Sglebius build32 distribute32 install32 82290001SglebiusTGTS+= ${SUBDIR_TARGETS} 83290001Sglebius 84290001SglebiusBITGTS= files includes 85290001SglebiusBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 86290001SglebiusTGTS+= ${BITGTS} 87290001Sglebius 88290001Sglebius.ORDER: buildworld installworld 89290001Sglebius.ORDER: buildworld distributeworld 90290001Sglebius.ORDER: buildworld buildkernel 91290001Sglebius.ORDER: buildkernel installkernel 92290001Sglebius.ORDER: buildkernel installkernel.debug 93290001Sglebius.ORDER: buildkernel reinstallkernel 94290001Sglebius.ORDER: buildkernel reinstallkernel.debug 95290001Sglebius 96290001SglebiusPATH= /sbin:/bin:/usr/sbin:/usr/bin 97290001SglebiusMAKEOBJDIRPREFIX?= /usr/obj 98290001Sglebius_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 99290001Sglebius ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 100290001Sglebius -f /dev/null -V MAKEOBJDIRPREFIX dummy 101290001Sglebius.if !empty(_MAKEOBJDIRPREFIX) 102290001Sglebius.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 103290001Sglebius (in make.conf(5)) or command-line variable. 104290001Sglebius.endif 105290001SglebiusMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 106290001SglebiusBINMAKE= \ 107290001Sglebius `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 108290001Sglebius -m ${.CURDIR}/share/mk 109290001Sglebius_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 110290001Sglebius 111290001Sglebius# 112290001Sglebius# Make sure we have an up-to-date make(1). Only world and buildworld 113290001Sglebius# should do this as those are the initial targets used for upgrades. 114290001Sglebius# The user can define ALWAYS_CHECK_MAKE to have this check performed 115290001Sglebius# for all targets. 116290001Sglebius# 117290001Sglebius.if defined(ALWAYS_CHECK_MAKE) 118290001Sglebius${TGTS}: upgrade_checks 119290001Sglebius.else 120290001Sglebiusbuildworld: upgrade_checks 121290001Sglebius.endif 122290001Sglebius 123290001Sglebius# 124290001Sglebius# This 'cleanworld' target is not included in TGTS, because it is not a 125290001Sglebius# recursive target. All of the work for it is done right here. It is 126290001Sglebius# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 127290001Sglebius# created by bsd.obj.mk, except that we don't want to .include that file 128290001Sglebius# in this makefile. 129290001Sglebius# 130290001Sglebius# In the following, the first 'rm' in a series will usually remove all 131290001Sglebius# files and directories. If it does not, then there are probably some 132290001Sglebius# files with chflags set, so this unsets them and tries the 'rm' a 133290001Sglebius# second time. There are situations where this target will be cleaning 134290001Sglebius# some directories via more than one method, but that duplication is 135290001Sglebius# needed to correctly handle all the possible situations. 136290001Sglebius# 137290001SglebiusBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 138290001Sglebiuscleanworld: 139290001Sglebius.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 140290001Sglebius.if exists(${BW_CANONICALOBJDIR}/) 141290001Sglebius -rm -rf ${BW_CANONICALOBJDIR}/* 142290001Sglebius chflags -R 0 ${BW_CANONICALOBJDIR} 143290001Sglebius rm -rf ${BW_CANONICALOBJDIR}/* 144290001Sglebius.endif 145290001Sglebius # To be safe in this case, fall back to a 'make cleandir' 146290001Sglebius ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 147290001Sglebius.else 148290001Sglebius -rm -rf ${.OBJDIR}/* 149290001Sglebius chflags -R 0 ${.OBJDIR} 150290001Sglebius rm -rf ${.OBJDIR}/* 151290001Sglebius.endif 152290001Sglebius 153290001Sglebius# 154290001Sglebius# Handle the user-driven targets, using the source relative mk files. 155290001Sglebius# 156290001Sglebius 157290001Sglebius${TGTS}: 158290001Sglebius ${_+_}@cd ${.CURDIR}; \ 159290001Sglebius ${_MAKE} ${.TARGET} 160290001Sglebius 161290001Sglebius# Set a reasonable default 162290001Sglebius.MAIN: all 163290001Sglebius 164290001SglebiusSTARTTIME!= LC_ALL=C date 165290001Sglebius 166290001Sglebius.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 167290001Sglebius# 168290001Sglebius# world 169290001Sglebius# 170290001Sglebius# Attempt to rebuild and reinstall everything. This target is not to be 171290001Sglebius# used for upgrading an existing FreeBSD system, because the kernel is 172290001Sglebius# not included. One can argue that this target doesn't build everything 173290001Sglebius# then. 174290001Sglebius# 175290001Sglebiusworld: upgrade_checks 176290001Sglebius @echo "--------------------------------------------------------------" 177290001Sglebius @echo ">>> make world started on ${STARTTIME}" 178290001Sglebius @echo "--------------------------------------------------------------" 179290001Sglebius.if target(pre-world) 180290001Sglebius @echo 181290001Sglebius @echo "--------------------------------------------------------------" 182290001Sglebius @echo ">>> Making 'pre-world' target" 183290001Sglebius @echo "--------------------------------------------------------------" 184290001Sglebius ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 185290001Sglebius.endif 186290001Sglebius ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 187290001Sglebius ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 188290001Sglebius.if target(post-world) 189290001Sglebius @echo 190290001Sglebius @echo "--------------------------------------------------------------" 191290001Sglebius @echo ">>> Making 'post-world' target" 192290001Sglebius @echo "--------------------------------------------------------------" 193290001Sglebius ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 194290001Sglebius.endif 195290001Sglebius @echo 196290001Sglebius @echo "--------------------------------------------------------------" 197290001Sglebius @echo ">>> make world completed on `LC_ALL=C date`" 198290001Sglebius @echo " (started ${STARTTIME})" 199290001Sglebius @echo "--------------------------------------------------------------" 200290001Sglebius.else 201290001Sglebiusworld: 202290001Sglebius @echo "WARNING: make world will overwrite your existing FreeBSD" 203290001Sglebius @echo "installation without also building and installing a new" 204290001Sglebius @echo "kernel. This can be dangerous. Please read the handbook," 205290001Sglebius @echo "'Rebuilding world', for how to upgrade your system." 206290001Sglebius @echo "Define DESTDIR to where you want to install FreeBSD," 207290001Sglebius @echo "including /, to override this warning and proceed as usual." 208290001Sglebius @echo "You may get the historical 'make world' behavior by defining" 209290001Sglebius @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 210290001Sglebius @echo "before doing this." 211290001Sglebius @echo "" 212290001Sglebius @echo "Bailing out now..." 213290001Sglebius @false 214290001Sglebius.endif 215290001Sglebius 216290001Sglebius# 217290001Sglebius# kernel 218290001Sglebius# 219290001Sglebius# Short hand for `make buildkernel installkernel' 220290001Sglebius# 221290001Sglebiuskernel: buildkernel installkernel 222290001Sglebius 223290001Sglebius# 224290001Sglebius# Perform a few tests to determine if the installed tools are adequate 225290001Sglebius# for building the world. 226290001Sglebius# 227290001Sglebiusupgrade_checks: 228290001Sglebius @if ! (cd ${.CURDIR}/tools/build/make_check && \ 229290001Sglebius PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 230290001Sglebius PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 231290001Sglebius then \ 232290001Sglebius (cd ${.CURDIR} && make make); \ 233290001Sglebius fi 234290001Sglebius 235290001Sglebius# 236290001Sglebius# Upgrade make(1) to the current version using the installed 237290001Sglebius# headers, libraries and tools. 238290001Sglebius# 239290001SglebiusMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 240290001Sglebius DESTDIR= \ 241290001Sglebius INSTALL="sh ${.CURDIR}/tools/install.sh" 242290001SglebiusMMAKE= ${MMAKEENV} make \ 243290001Sglebius -D_UPGRADING \ 244290001Sglebius -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 245290001Sglebius -DNO_CPU_CFLAGS -DNO_WERROR 246290001Sglebius 247290001Sglebiusmake: .PHONY 248290001Sglebius @echo 249290001Sglebius @echo "--------------------------------------------------------------" 250290001Sglebius @echo ">>> Building an up-to-date make(1)" 251290001Sglebius @echo "--------------------------------------------------------------" 252290001Sglebius ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 253290001Sglebius ${MMAKE} obj && \ 254290001Sglebius ${MMAKE} depend && \ 255290001Sglebius ${MMAKE} all && \ 256290001Sglebius ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 257290001Sglebius 258290001Sglebius# 259290001Sglebius# universe 260290001Sglebius# 261290001Sglebius# Attempt to rebuild *everything* for all supported architectures, 262290001Sglebius# with a reasonable chance of success, regardless of how old your 263290001Sglebius# existing system is. 264290001Sglebius# 265290001Sglebius.if make(universe) 266290001Sglebiusuniverse: universe_prologue 267290001Sglebiusuniverse_prologue: 268290001Sglebius @echo "--------------------------------------------------------------" 269290001Sglebius @echo ">>> make universe started on ${STARTTIME}" 270290001Sglebius @echo "--------------------------------------------------------------" 271290001Sglebius.for target in i386 i386:pc98 sparc64 ia64 amd64 272290001Sglebius.for arch in ${target:C/:.*$//} 273290001Sglebius.for mach in ${target:C/^.*://} 274290001SglebiusKERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 275290001Sglebius find [A-Z]*[A-Z] -type f -maxdepth 0 \ 276290001Sglebius ! -name DEFAULTS ! -name LINT 277290001SglebiusKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 278290001Sglebiusuniverse: universe_${mach} 279290001Sglebius.ORDER: universe_prologue universe_${mach} universe_epilogue 280290001Sglebiusuniverse_${mach}: 281290001Sglebius @echo ">> ${mach} started on `LC_ALL=C date`" 282290001Sglebius -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 283290001Sglebius TARGET_ARCH=${arch} TARGET=${mach} \ 284290001Sglebius __MAKE_CONF=/dev/null \ 285290001Sglebius > _.${mach}.buildworld 2>&1 286290001Sglebius @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 287290001Sglebius.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 288290001Sglebius -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 289290001Sglebius > ${.CURDIR}/_.${mach}.makeLINT 2>&1 290290001Sglebius.endif 291290001Sglebius.for kernel in ${KERNCONFS} 292290001Sglebius -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 293290001Sglebius TARGET_ARCH=${arch} TARGET=${mach} \ 294290001Sglebius KERNCONF=${kernel} \ 295290001Sglebius __MAKE_CONF=/dev/null \ 296290001Sglebius > _.${mach}.${kernel} 2>&1 297290001Sglebius.endfor 298290001Sglebius @echo ">> ${mach} completed on `LC_ALL=C date`" 299290001Sglebius.endfor 300290001Sglebius.endfor 301290001Sglebius.endfor 302290001Sglebiusuniverse: universe_epilogue 303290001Sglebiusuniverse_epilogue: 304290001Sglebius @echo "--------------------------------------------------------------" 305290001Sglebius @echo ">>> make universe completed on `LC_ALL=C date`" 306290001Sglebius @echo " (started ${STARTTIME})" 307290001Sglebius @echo "--------------------------------------------------------------" 308290001Sglebius.endif 309290001Sglebius