Makefile revision 156840
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 156840 2006-03-18 14:30:23Z ru $ 32061Sjkh# 438666Sjb# The user-driven targets are: 532427Sjb# 6111131Sru# universe - *Really* build *everything* (buildworld and 7111131Sru# all kernels on all architectures). 838666Sjb# buildworld - Rebuild *everything*, including glue to help do 938666Sjb# upgrades. 1038666Sjb# installworld - Install everything built by "buildworld". 1138666Sjb# world - buildworld + installworld. 1264049Salex# buildkernel - Rebuild the kernel and the kernel-modules. 1364049Salex# installkernel - Install the kernel and the kernel-modules. 14116679Ssimokawa# installkernel.debug 1566071Smarkm# reinstallkernel - Reinstall the kernel and the kernel-modules. 16116679Ssimokawa# reinstallkernel.debug 1773504Sobrien# kernel - buildkernel + installkernel. 1838666Sjb# update - Convenient way to update your source tree (cvs). 19148330Snetchild# check-old - Print a list of old files/directories in the system. 20148330Snetchild# delete-old - Delete obsolete files and directories interactively. 21148330Snetchild# delete-old-libs - Delete obsolete libraries interactively. 2232427Sjb# 2338666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 24108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the 2538666Sjb# command line. By keeping this makefile simple, it doesn't matter too 2638666Sjb# much how different the installed mk files are from those in the source 2738666Sjb# tree. This makefile executes a child make process, forcing it to use 2838666Sjb# the mk files from the source tree which are supposed to DTRT. 2917308Speter# 3091606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1. 3119175Sbde# 3296205Sjwd# If you want to build your system from source be sure that /usr/obj has 3396205Sjwd# at least 400MB of diskspace available. 3438042Sbde# 3596205Sjwd# For individuals wanting to build from the sources currently on their 3696205Sjwd# system, the simple instructions are: 3738042Sbde# 3896205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 3996205Sjwd# 2. `make world' 4017308Speter# 4196205Sjwd# For individuals wanting to upgrade their sources (even if only a 4296205Sjwd# delta of a few days): 4317308Speter# 44148330Snetchild# 1. `cd /usr/src' (or to the directory containing your source tree). 45148330Snetchild# 2. `make buildworld' 46148330Snetchild# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 47148330Snetchild# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 48148330Snetchild# 5. `reboot' (in single user mode: boot -s from the loader prompt). 49148330Snetchild# 6. `mergemaster -p' 50148330Snetchild# 7. `make installworld' 51148330Snetchild# 8. `make delete-old' 52148330Snetchild# 9. `mergemaster' 53148330Snetchild# 10. `reboot' 54148330Snetchild# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 5596205Sjwd# 5696205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 5796205Sjwd# 5898775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 5998723Sdillon# cross build world for other architectures using the buildworld target, 6098723Sdillon# and once the world is built you can cross build a kernel using the 6198723Sdillon# buildkernel target. 6298723Sdillon# 6338666Sjb# Define the user-driven targets. These are listed here in alphabetical 6438666Sjb# order, but that's not important. 6517308Speter# 66123311Speter# Targets that begin with underscore are internal targets intended for 67123311Speter# developer convenience only. They are intentionally not documented and 68123311Speter# completely subject to change without notice. 69123311Speter# 70148330SnetchildTGTS= all all-man buildenv buildkernel buildworld check-old checkdpadd \ 71148330Snetchild clean cleandepend cleandir delete-old delete-old-libs depend \ 72148330Snetchild distribute distributeworld distrib-dirs distribution everything \ 73116679Ssimokawa hierarchy install installcheck installkernel installkernel.debug\ 74120760Sru reinstallkernel reinstallkernel.debug installworld \ 75128189Sdes kernel-toolchain libraries lint maninstall \ 76156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 77123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 78137288Speter _build-tools _cross-tools _includes _libraries _depend \ 79147425Sru build32 distribute32 install32 80156740SruTGTS+= ${SUBDIR_TARGETS} 812061Sjkh 8297769SruBITGTS= files includes 8397252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 84119579SruTGTS+= ${BITGTS} 8597252Sru 8695730Sru.ORDER: buildworld installworld 8795793Sru.ORDER: buildworld distributeworld 88111617Sru.ORDER: buildworld buildkernel 8995730Sru.ORDER: buildkernel installkernel 90116679Ssimokawa.ORDER: buildkernel installkernel.debug 9195730Sru.ORDER: buildkernel reinstallkernel 92116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 9395730Sru 94110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 95107516SruMAKEOBJDIRPREFIX?= /usr/obj 96138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 97156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 98138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 99133942Sru.if !empty(_MAKEOBJDIRPREFIX) 100133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 101156145Syar (in make.conf(5)) or command-line variable. 102133942Sru.endif 103110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 104117234SruBINMAKE= \ 105110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 106117229Sru -m ${.CURDIR}/share/mk 107117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 10854324Smarcel 10917308Speter# 110119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 111119519Smarcel# should do this as those are the initial targets used for upgrades. 112119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 113119519Smarcel# for all targets. 114119519Smarcel# 115119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 116119579Sru${TGTS}: upgrade_checks 117119519Smarcel.else 118119519Smarcelbuildworld: upgrade_checks 119119519Smarcel.endif 120119519Smarcel 121119519Smarcel# 122126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 123126024Sgad# recursive target. All of the work for it is done right here. It is 124126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 125126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 126126024Sgad# in this makefile. 127126024Sgad# 128126024Sgad# In the following, the first 'rm' in a series will usually remove all 129126024Sgad# files and directories. If it does not, then there are probably some 130126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 131126024Sgad# second time. There are situations where this target will be cleaning 132126024Sgad# some directories via more than one method, but that duplication is 133126024Sgad# needed to correctly handle all the possible situations. 134126024Sgad# 135126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 136126031Sgadcleanworld: 137126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 138126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 139126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 140126024Sgad chflags -R 0 ${BW_CANONICALOBJDIR} 141126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 142126024Sgad.endif 143126024Sgad # To be safe in this case, fall back to a 'make cleandir' 144133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 145126024Sgad.else 146126024Sgad -rm -rf ${.OBJDIR}/* 147126024Sgad chflags -R 0 ${.OBJDIR} 148126024Sgad rm -rf ${.OBJDIR}/* 149126024Sgad.endif 150125885Sgad 151125885Sgad# 15238666Sjb# Handle the user-driven targets, using the source relative mk files. 15317308Speter# 154119519Smarcel 155119579Sru${TGTS}: 156133376Sharti ${_+_}@cd ${.CURDIR}; \ 157110035Sru ${_MAKE} ${.TARGET} 1582302Spaul 15939206Sjkh# Set a reasonable default 16039206Sjkh.MAIN: all 16139206Sjkh 162133945SruSTARTTIME!= LC_ALL=C date 163133945Sru 164132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 16517308Speter# 16654324Smarcel# world 16754324Smarcel# 168132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 169132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 170132234Smarcel# not included. One can argue that this target doesn't build everything 171132234Smarcel# then. 17254324Smarcel# 17354324Smarcelworld: upgrade_checks 17454324Smarcel @echo "--------------------------------------------------------------" 175118531Sru @echo ">>> make world started on ${STARTTIME}" 17654324Smarcel @echo "--------------------------------------------------------------" 17754324Smarcel.if target(pre-world) 17854324Smarcel @echo 17954324Smarcel @echo "--------------------------------------------------------------" 18054324Smarcel @echo ">>> Making 'pre-world' target" 18154324Smarcel @echo "--------------------------------------------------------------" 182133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 18354324Smarcel.endif 184133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 185133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 18654324Smarcel.if target(post-world) 18754324Smarcel @echo 18854324Smarcel @echo "--------------------------------------------------------------" 18954324Smarcel @echo ">>> Making 'post-world' target" 19054324Smarcel @echo "--------------------------------------------------------------" 191133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 19254324Smarcel.endif 19354324Smarcel @echo 19454324Smarcel @echo "--------------------------------------------------------------" 195118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 196118531Sru @echo " (started ${STARTTIME})" 19754324Smarcel @echo "--------------------------------------------------------------" 198132234Smarcel.else 199132234Smarcelworld: 200132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 201132234Smarcel @echo "installation without also building and installing a new" 202132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 203132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 204132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 205132234Smarcel @echo "including /, to override this warning and proceed as usual." 206132358Smarkm @echo "You may get the historical 'make world' behavior by defining" 207132358Smarkm @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 208132358Smarkm @echo "before doing this." 209132358Smarkm @echo "" 210132234Smarcel @echo "Bailing out now..." 211132234Smarcel @false 212132234Smarcel.endif 21354324Smarcel 21454324Smarcel# 21595730Sru# kernel 21695730Sru# 21795730Sru# Short hand for `make buildkernel installkernel' 21895730Sru# 21995730Srukernel: buildkernel installkernel 22095730Sru 22195730Sru# 22238666Sjb# Perform a few tests to determine if the installed tools are adequate 223107374Sru# for building the world. 22417308Speter# 22555678Smarcelupgrade_checks: 226143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 227138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 228117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 229110035Sru then \ 230110035Sru (cd ${.CURDIR} && make make); \ 231110035Sru fi 2322061Sjkh 23317308Speter# 234107516Sru# Upgrade make(1) to the current version using the installed 235107374Sru# headers, libraries and tools. 23655678Smarcel# 237107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 238107516Sru DESTDIR= \ 239107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 240107516SruMMAKE= ${MMAKEENV} make \ 241107516Sru -D_UPGRADING \ 242139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 243107516Sru -DNO_CPU_CFLAGS -DNO_WERROR 244107516Sru 245122204Skrismake: .PHONY 24655678Smarcel @echo 24755678Smarcel @echo "--------------------------------------------------------------" 248116696Sru @echo ">>> Building an up-to-date make(1)" 24955678Smarcel @echo "--------------------------------------------------------------" 250133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 251107516Sru ${MMAKE} obj && \ 252107516Sru ${MMAKE} depend && \ 253107516Sru ${MMAKE} all && \ 254107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 25555678Smarcel 25655678Smarcel# 257111131Sru# universe 258111131Sru# 259111131Sru# Attempt to rebuild *everything* for all supported architectures, 260133945Sru# with a reasonable chance of success, regardless of how old your 261111131Sru# existing system is. 262111131Sru# 263148154Sru.if make(universe) 264133945Sruuniverse: universe_prologue 265133945Sruuniverse_prologue: 266103985Sphk @echo "--------------------------------------------------------------" 267103985Sphk @echo ">>> make universe started on ${STARTTIME}" 268103985Sphk @echo "--------------------------------------------------------------" 269133945Sru.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 270133945Sru.for arch in ${target:C/:.*$//} 271133945Sru.for mach in ${target:C/^.*://} 272148154SruKERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 273152879Sru find [A-Z]*[A-Z] -type f -maxdepth 0 \ 274152880Sru ! -name DEFAULTS ! -name LINT 275148154SruKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 276133945Sruuniverse: universe_${mach} 277133945Sru.ORDER: universe_prologue universe_${mach} universe_epilogue 278133945Sruuniverse_${mach}: 279111131Sru @echo ">> ${mach} started on `LC_ALL=C date`" 280131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 281111131Sru TARGET_ARCH=${arch} TARGET=${mach} \ 282111131Sru __MAKE_CONF=/dev/null \ 283111131Sru > _.${mach}.buildworld 2>&1 284111131Sru @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 285111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 286111131Sru -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 287111133Sru > ${.CURDIR}/_.${mach}.makeLINT 2>&1 288103985Sphk.endif 289148154Sru.for kernel in ${KERNCONFS} 290148154Sru -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 291148154Sru TARGET_ARCH=${arch} TARGET=${mach} \ 292148154Sru KERNCONF=${kernel} \ 293148154Sru __MAKE_CONF=/dev/null \ 294148154Sru > _.${mach}.${kernel} 2>&1 295148154Sru.endfor 296111131Sru @echo ">> ${mach} completed on `LC_ALL=C date`" 297103985Sphk.endfor 298111131Sru.endfor 299133945Sru.endfor 300133945Sruuniverse: universe_epilogue 301133945Sruuniverse_epilogue: 302103985Sphk @echo "--------------------------------------------------------------" 303118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 304118531Sru @echo " (started ${STARTTIME})" 305103985Sphk @echo "--------------------------------------------------------------" 306133945Sru.endif 307