Makefile revision 158453
1185573Srwatson# 2191270Srwatson# $FreeBSD: head/Makefile 158453 2006-05-11 18:54:16Z jhb $ 3146759Srwatson# 4146759Srwatson# The user-driven targets are: 5146759Srwatson# 6146759Srwatson# universe - *Really* build *everything* (buildworld and 7146759Srwatson# all kernels on all architectures). 8146759Srwatson# buildworld - Rebuild *everything*, including glue to help do 9155191Srwatson# upgrades. 10155191Srwatson# installworld - Install everything built by "buildworld". 11155191Srwatson# world - buildworld + installworld. 12155191Srwatson# buildkernel - Rebuild the kernel and the kernel-modules. 13155191Srwatson# installkernel - Install the kernel and the kernel-modules. 14181053Srwatson# installkernel.debug 15155191Srwatson# reinstallkernel - Reinstall the kernel and the kernel-modules. 16155191Srwatson# reinstallkernel.debug 17146759Srwatson# kernel - buildkernel + installkernel. 18155191Srwatson# update - Convenient way to update your source tree (cvs). 19155191Srwatson# check-old - Print a list of old files/directories in the system. 20155191Srwatson# delete-old - Delete obsolete files and directories interactively. 21155191Srwatson# delete-old-libs - Delete obsolete libraries interactively. 22155191Srwatson# 23155191Srwatson# This makefile is simple by design. The FreeBSD make automatically reads 24155191Srwatson# the /usr/share/mk/sys.mk unless the -m argument is specified on the 25155191Srwatson# command line. By keeping this makefile simple, it doesn't matter too 26155191Srwatson# much how different the installed mk files are from those in the source 27155191Srwatson# tree. This makefile executes a child make process, forcing it to use 28155191Srwatson# the mk files from the source tree which are supposed to DTRT. 29195740Srwatson# 30146759Srwatson# The user-driven targets (as listed above) are implemented in Makefile.inc1. 31146759Srwatson# 32146759Srwatson# If you want to build your system from source be sure that /usr/obj has 33191270Srwatson# at least 400MB of diskspace available. 34155191Srwatson# 35146759Srwatson# For individuals wanting to build from the sources currently on their 36191270Srwatson# system, the simple instructions are: 37186647Srwatson# 38155191Srwatson# 1. `cd /usr/src' (or to the directory containing your source tree). 39155191Srwatson# 2. `make world' 40155191Srwatson# 41161635Srwatson# For individuals wanting to upgrade their sources (even if only a 42161635Srwatson# delta of a few days): 43155191Srwatson# 44155191Srwatson# 1. `cd /usr/src' (or to the directory containing your source tree). 45146759Srwatson# 2. `make buildworld' 46155191Srwatson# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 47155191Srwatson# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 48155191Srwatson# 5. `reboot' (in single user mode: boot -s from the loader prompt). 49155191Srwatson# 6. `mergemaster -p' 50146759Srwatson# 7. `make installworld' 51155191Srwatson# 8. `make delete-old' 52155191Srwatson# 9. `mergemaster' 53155191Srwatson# 10. `reboot' 54161635Srwatson# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 55155191Srwatson# 56155191Srwatson# See src/UPDATING `COMMON ITEMS' for more complete information. 57162508Srwatson# 58162508Srwatson# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 59162508Srwatson# cross build world for other architectures using the buildworld target, 60162508Srwatson# and once the world is built you can cross build a kernel using the 61162508Srwatson# buildkernel target. 62186647Srwatson# 63189279Srwatson# Define the user-driven targets. These are listed here in alphabetical 64189279Srwatson# order, but that's not important. 65189279Srwatson# 66155191Srwatson# Targets that begin with underscore are internal targets intended for 67155191Srwatson# developer convenience only. They are intentionally not documented and 68162508Srwatson# completely subject to change without notice. 69155191Srwatson# 70155191SrwatsonTGTS= all all-man buildenv buildkernel buildworld check-old checkdpadd \ 71162508Srwatson clean cleandepend cleandir delete-old delete-old-libs depend \ 72155191Srwatson distribute distributeworld distrib-dirs distribution everything \ 73155191Srwatson hierarchy install installcheck installkernel installkernel.debug\ 74155191Srwatson reinstallkernel reinstallkernel.debug installworld \ 75155191Srwatson kernel-toolchain libraries lint maninstall \ 76186647Srwatson obj objlink regress rerelease showconfig tags toolchain update \ 77186647Srwatson _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 78186647Srwatson _build-tools _cross-tools _includes _libraries _depend \ 79155191Srwatson build32 distribute32 install32 80155191SrwatsonTGTS+= ${SUBDIR_TARGETS} 81161635Srwatson 82155191SrwatsonBITGTS= files includes 83155191SrwatsonBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 84155191SrwatsonTGTS+= ${BITGTS} 85155191Srwatson 86155191Srwatson.ORDER: buildworld installworld 87155191Srwatson.ORDER: buildworld distributeworld 88155191Srwatson.ORDER: buildworld buildkernel 89155191Srwatson.ORDER: buildkernel installkernel 90155191Srwatson.ORDER: buildkernel installkernel.debug 91155191Srwatson.ORDER: buildkernel reinstallkernel 92155191Srwatson.ORDER: buildkernel reinstallkernel.debug 93155191Srwatson 94155191SrwatsonPATH= /sbin:/bin:/usr/sbin:/usr/bin 95155191SrwatsonMAKEOBJDIRPREFIX?= /usr/obj 96155191Srwatson_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 97155191Srwatson ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 98191270Srwatson -f /dev/null -V MAKEOBJDIRPREFIX dummy 99191270Srwatson.if !empty(_MAKEOBJDIRPREFIX) 100155191Srwatson.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 101155191Srwatson (in make.conf(5)) or command-line variable. 102191270Srwatson.endif 103191270SrwatsonMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 104155191SrwatsonBINMAKE= \ 105155191Srwatson `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 106155191Srwatson -m ${.CURDIR}/share/mk 107155191Srwatson_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 108155191Srwatson 109155191Srwatson# 110191270Srwatson# Make sure we have an up-to-date make(1). Only world and buildworld 111191270Srwatson# should do this as those are the initial targets used for upgrades. 112155191Srwatson# The user can define ALWAYS_CHECK_MAKE to have this check performed 113155191Srwatson# for all targets. 114155191Srwatson# 115155191Srwatson.if defined(ALWAYS_CHECK_MAKE) 116155191Srwatson${TGTS}: upgrade_checks 117155191Srwatson.else 118155191Srwatsonbuildworld: upgrade_checks 119155191Srwatson.endif 120155191Srwatson 121155191Srwatson# 122186647Srwatson# This 'cleanworld' target is not included in TGTS, because it is not a 123191270Srwatson# recursive target. All of the work for it is done right here. It is 124191270Srwatson# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 125191270Srwatson# created by bsd.obj.mk, except that we don't want to .include that file 126191270Srwatson# in this makefile. 127191270Srwatson# 128191270Srwatson# In the following, the first 'rm' in a series will usually remove all 129155191Srwatson# files and directories. If it does not, then there are probably some 130155191Srwatson# files with chflags set, so this unsets them and tries the 'rm' a 131155191Srwatson# second time. There are situations where this target will be cleaning 132155191Srwatson# some directories via more than one method, but that duplication is 133155191Srwatson# needed to correctly handle all the possible situations. 134155191Srwatson# 135155191SrwatsonBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 136155191Srwatsoncleanworld: 137161635Srwatson.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 138161635Srwatson.if exists(${BW_CANONICALOBJDIR}/) 139161635Srwatson -rm -rf ${BW_CANONICALOBJDIR}/* 140161635Srwatson chflags -R 0 ${BW_CANONICALOBJDIR} 141161635Srwatson rm -rf ${BW_CANONICALOBJDIR}/* 142161635Srwatson.endif 143161635Srwatson # To be safe in this case, fall back to a 'make cleandir' 144161635Srwatson ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 145161635Srwatson.else 146161635Srwatson -rm -rf ${.OBJDIR}/* 147155191Srwatson chflags -R 0 ${.OBJDIR} 148155191Srwatson rm -rf ${.OBJDIR}/* 149162508Srwatson.endif 150155191Srwatson 151155191Srwatson# 152155191Srwatson# Handle the user-driven targets, using the source relative mk files. 153155191Srwatson# 154162508Srwatson 155155191Srwatson${TGTS}: 156155191Srwatson ${_+_}@cd ${.CURDIR}; \ 157155191Srwatson ${_MAKE} ${.TARGET} 158155191Srwatson 159155191Srwatson# Set a reasonable default 160155191Srwatson.MAIN: all 161155191Srwatson 162155191SrwatsonSTARTTIME!= LC_ALL=C date 163155191Srwatson 164155191Srwatson.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 165155191Srwatson# 166155191Srwatson# world 167155191Srwatson# 168155191Srwatson# Attempt to rebuild and reinstall everything. This target is not to be 169155191Srwatson# used for upgrading an existing FreeBSD system, because the kernel is 170155191Srwatson# not included. One can argue that this target doesn't build everything 171155191Srwatson# then. 172155191Srwatson# 173146759Srwatsonworld: upgrade_checks 174155191Srwatson @echo "--------------------------------------------------------------" 175155191Srwatson @echo ">>> make world started on ${STARTTIME}" 176195740Srwatson @echo "--------------------------------------------------------------" 177146759Srwatson.if target(pre-world) 178155191Srwatson @echo 179155191Srwatson @echo "--------------------------------------------------------------" 180155191Srwatson @echo ">>> Making 'pre-world' target" 181155191Srwatson @echo "--------------------------------------------------------------" 182155191Srwatson ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 183155191Srwatson.endif 184155191Srwatson ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 185155191Srwatson ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 186155191Srwatson.if target(post-world) 187155191Srwatson @echo 188155191Srwatson @echo "--------------------------------------------------------------" 189155191Srwatson @echo ">>> Making 'post-world' target" 190155191Srwatson @echo "--------------------------------------------------------------" 191155191Srwatson ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 192155191Srwatson.endif 193155191Srwatson @echo 194155191Srwatson @echo "--------------------------------------------------------------" 195155191Srwatson @echo ">>> make world completed on `LC_ALL=C date`" 196155191Srwatson @echo " (started ${STARTTIME})" 197155191Srwatson @echo "--------------------------------------------------------------" 198155191Srwatson.else 199155191Srwatsonworld: 200155191Srwatson @echo "WARNING: make world will overwrite your existing FreeBSD" 201155191Srwatson @echo "installation without also building and installing a new" 202155191Srwatson @echo "kernel. This can be dangerous. Please read the handbook," 203155191Srwatson @echo "'Rebuilding world', for how to upgrade your system." 204155191Srwatson @echo "Define DESTDIR to where you want to install FreeBSD," 205155191Srwatson @echo "including /, to override this warning and proceed as usual." 206155191Srwatson @echo "You may get the historical 'make world' behavior by defining" 207155191Srwatson @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 208155191Srwatson @echo "before doing this." 209155191Srwatson @echo "" 210195740Srwatson @echo "Bailing out now..." 211155191Srwatson @false 212155191Srwatson.endif 213155191Srwatson 214155191Srwatson# 215155191Srwatson# kernel 216155191Srwatson# 217155191Srwatson# Short hand for `make buildkernel installkernel' 218155191Srwatson# 219155191Srwatsonkernel: buildkernel installkernel 220155191Srwatson 221155191Srwatson# 222155191Srwatson# Perform a few tests to determine if the installed tools are adequate 223155191Srwatson# for building the world. 224155191Srwatson# 225155191Srwatsonupgrade_checks: 226155191Srwatson @if ! (cd ${.CURDIR}/tools/build/make_check && \ 227155191Srwatson PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 228155191Srwatson PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 229195740Srwatson then \ 230155191Srwatson (cd ${.CURDIR} && make make); \ 231155191Srwatson fi 232155191Srwatson 233186647Srwatson# 234186647Srwatson# Upgrade make(1) to the current version using the installed 235186647Srwatson# headers, libraries and tools. 236186647Srwatson# 237186647SrwatsonMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 238186647Srwatson DESTDIR= \ 239156289Srwatson INSTALL="sh ${.CURDIR}/tools/install.sh" 240156289SrwatsonMMAKE= ${MMAKEENV} make \ 241156289Srwatson -D_UPGRADING \ 242155191Srwatson -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 243155191Srwatson -DNO_CPU_CFLAGS -DNO_WERROR 244155191Srwatson 245191270Srwatsonmake: .PHONY 246191270Srwatson @echo 247191270Srwatson @echo "--------------------------------------------------------------" 248191270Srwatson @echo ">>> Building an up-to-date make(1)" 249191270Srwatson @echo "--------------------------------------------------------------" 250191270Srwatson ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 251155191Srwatson ${MMAKE} obj && \ 252155191Srwatson ${MMAKE} depend && \ 253191270Srwatson ${MMAKE} all && \ 254191270Srwatson ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 255191270Srwatson 256191270Srwatson# 257191270Srwatson# universe 258191270Srwatson# 259191270Srwatson# Attempt to rebuild *everything* for all supported architectures, 260191270Srwatson# with a reasonable chance of success, regardless of how old your 261155191Srwatson# existing system is. 262155191Srwatson# 263155191Srwatson.if make(universe) 264155191Srwatsonuniverse: universe_prologue 265155191Srwatsonuniverse_prologue: 266155191Srwatson @echo "--------------------------------------------------------------" 267155191Srwatson @echo ">>> make universe started on ${STARTTIME}" 268155191Srwatson @echo "--------------------------------------------------------------" 269155191Srwatson.for target in i386 i386:pc98 sparc64 ia64 amd64 270155191Srwatson.for arch in ${target:C/:.*$//} 271155191Srwatson.for mach in ${target:C/^.*://} 272159256SrwatsonKERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 273155191Srwatson find [A-Z]*[A-Z] -type f -maxdepth 0 \ 274155191Srwatson ! -name DEFAULTS ! -name LINT 275155191SrwatsonKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 276159256Srwatsonuniverse: universe_${mach} 277155191Srwatson.ORDER: universe_prologue universe_${mach} universe_epilogue 278155191Srwatsonuniverse_${mach}: 279155191Srwatson @echo ">> ${mach} started on `LC_ALL=C date`" 280155191Srwatson -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 281155191Srwatson TARGET_ARCH=${arch} TARGET=${mach} \ 282155191Srwatson __MAKE_CONF=/dev/null \ 283155191Srwatson > _.${mach}.buildworld 2>&1 284155191Srwatson @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 285155191Srwatson.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 286155191Srwatson -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 287155191Srwatson > ${.CURDIR}/_.${mach}.makeLINT 2>&1 288155191Srwatson.endif 289155191Srwatson.for kernel in ${KERNCONFS} 290187214Srwatson -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 291187214Srwatson TARGET_ARCH=${arch} TARGET=${mach} \ 292155191Srwatson KERNCONF=${kernel} \ 293155191Srwatson __MAKE_CONF=/dev/null \ 294155191Srwatson > _.${mach}.${kernel} 2>&1 295155191Srwatson.endfor 296155191Srwatson @echo ">> ${mach} completed on `LC_ALL=C date`" 297155191Srwatson.endfor 298155191Srwatson.endfor 299155191Srwatson.endfor 300155191Srwatsonuniverse: universe_epilogue 301155191Srwatsonuniverse_epilogue: 302155191Srwatson @echo "--------------------------------------------------------------" 303155191Srwatson @echo ">>> make universe completed on `LC_ALL=C date`" 304156289Srwatson @echo " (started ${STARTTIME})" 305156289Srwatson @echo "--------------------------------------------------------------" 306156289Srwatson.endif 307155191Srwatson