Makefile revision 156145
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 156145 2006-03-01 13:07:17Z yar $ 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 \ 76127360Sru obj objlink regress rerelease tags toolchain update \ 77123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 78137288Speter _build-tools _cross-tools _includes _libraries _depend \ 79147425Sru build32 distribute32 install32 802061Sjkh 8197769SruBITGTS= files includes 8297252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 83119579SruTGTS+= ${BITGTS} 8497252Sru 8595730Sru.ORDER: buildworld installworld 8695793Sru.ORDER: buildworld distributeworld 87111617Sru.ORDER: buildworld buildkernel 8895730Sru.ORDER: buildkernel installkernel 89116679Ssimokawa.ORDER: buildkernel installkernel.debug 9095730Sru.ORDER: buildkernel reinstallkernel 91116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 9295730Sru 93110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 94107516SruMAKEOBJDIRPREFIX?= /usr/obj 95138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 96156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 97138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 98133942Sru.if !empty(_MAKEOBJDIRPREFIX) 99133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 100156145Syar (in make.conf(5)) or command-line variable. 101133942Sru.endif 102110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 103117234SruBINMAKE= \ 104110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 105117229Sru -m ${.CURDIR}/share/mk 106117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 10754324Smarcel 10817308Speter# 109119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 110119519Smarcel# should do this as those are the initial targets used for upgrades. 111119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 112119519Smarcel# for all targets. 113119519Smarcel# 114119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 115119579Sru${TGTS}: upgrade_checks 116119519Smarcel.else 117119519Smarcelbuildworld: upgrade_checks 118119519Smarcel.endif 119119519Smarcel 120119519Smarcel# 121126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 122126024Sgad# recursive target. All of the work for it is done right here. It is 123126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 124126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 125126024Sgad# in this makefile. 126126024Sgad# 127126024Sgad# In the following, the first 'rm' in a series will usually remove all 128126024Sgad# files and directories. If it does not, then there are probably some 129126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 130126024Sgad# second time. There are situations where this target will be cleaning 131126024Sgad# some directories via more than one method, but that duplication is 132126024Sgad# needed to correctly handle all the possible situations. 133126024Sgad# 134126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 135126031Sgadcleanworld: 136126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 137126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 138126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 139126024Sgad chflags -R 0 ${BW_CANONICALOBJDIR} 140126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 141126024Sgad.endif 142126024Sgad # To be safe in this case, fall back to a 'make cleandir' 143133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 144126024Sgad.else 145126024Sgad -rm -rf ${.OBJDIR}/* 146126024Sgad chflags -R 0 ${.OBJDIR} 147126024Sgad rm -rf ${.OBJDIR}/* 148126024Sgad.endif 149125885Sgad 150125885Sgad# 15138666Sjb# Handle the user-driven targets, using the source relative mk files. 15217308Speter# 153119519Smarcel 154119579Sru${TGTS}: 155133376Sharti ${_+_}@cd ${.CURDIR}; \ 156110035Sru ${_MAKE} ${.TARGET} 1572302Spaul 15839206Sjkh# Set a reasonable default 15939206Sjkh.MAIN: all 16039206Sjkh 161133945SruSTARTTIME!= LC_ALL=C date 162133945Sru 163132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 16417308Speter# 16554324Smarcel# world 16654324Smarcel# 167132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 168132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 169132234Smarcel# not included. One can argue that this target doesn't build everything 170132234Smarcel# then. 17154324Smarcel# 17254324Smarcelworld: upgrade_checks 17354324Smarcel @echo "--------------------------------------------------------------" 174118531Sru @echo ">>> make world started on ${STARTTIME}" 17554324Smarcel @echo "--------------------------------------------------------------" 17654324Smarcel.if target(pre-world) 17754324Smarcel @echo 17854324Smarcel @echo "--------------------------------------------------------------" 17954324Smarcel @echo ">>> Making 'pre-world' target" 18054324Smarcel @echo "--------------------------------------------------------------" 181133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 18254324Smarcel.endif 183133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 184133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 18554324Smarcel.if target(post-world) 18654324Smarcel @echo 18754324Smarcel @echo "--------------------------------------------------------------" 18854324Smarcel @echo ">>> Making 'post-world' target" 18954324Smarcel @echo "--------------------------------------------------------------" 190133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 19154324Smarcel.endif 19254324Smarcel @echo 19354324Smarcel @echo "--------------------------------------------------------------" 194118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 195118531Sru @echo " (started ${STARTTIME})" 19654324Smarcel @echo "--------------------------------------------------------------" 197132234Smarcel.else 198132234Smarcelworld: 199132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 200132234Smarcel @echo "installation without also building and installing a new" 201132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 202132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 203132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 204132234Smarcel @echo "including /, to override this warning and proceed as usual." 205132358Smarkm @echo "You may get the historical 'make world' behavior by defining" 206132358Smarkm @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 207132358Smarkm @echo "before doing this." 208132358Smarkm @echo "" 209132234Smarcel @echo "Bailing out now..." 210132234Smarcel @false 211132234Smarcel.endif 21254324Smarcel 21354324Smarcel# 21495730Sru# kernel 21595730Sru# 21695730Sru# Short hand for `make buildkernel installkernel' 21795730Sru# 21895730Srukernel: buildkernel installkernel 21995730Sru 22095730Sru# 22138666Sjb# Perform a few tests to determine if the installed tools are adequate 222107374Sru# for building the world. 22317308Speter# 22455678Smarcelupgrade_checks: 225143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 226138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 227117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 228110035Sru then \ 229110035Sru (cd ${.CURDIR} && make make); \ 230110035Sru fi 2312061Sjkh 23217308Speter# 233107516Sru# Upgrade make(1) to the current version using the installed 234107374Sru# headers, libraries and tools. 23555678Smarcel# 236107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 237107516Sru DESTDIR= \ 238107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 239107516SruMMAKE= ${MMAKEENV} make \ 240107516Sru -D_UPGRADING \ 241139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 242107516Sru -DNO_CPU_CFLAGS -DNO_WERROR 243107516Sru 244122204Skrismake: .PHONY 24555678Smarcel @echo 24655678Smarcel @echo "--------------------------------------------------------------" 247116696Sru @echo ">>> Building an up-to-date make(1)" 24855678Smarcel @echo "--------------------------------------------------------------" 249133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 250107516Sru ${MMAKE} obj && \ 251107516Sru ${MMAKE} depend && \ 252107516Sru ${MMAKE} all && \ 253107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 25455678Smarcel 25555678Smarcel# 256111131Sru# universe 257111131Sru# 258111131Sru# Attempt to rebuild *everything* for all supported architectures, 259133945Sru# with a reasonable chance of success, regardless of how old your 260111131Sru# existing system is. 261111131Sru# 262148154Sru.if make(universe) 263133945Sruuniverse: universe_prologue 264133945Sruuniverse_prologue: 265103985Sphk @echo "--------------------------------------------------------------" 266103985Sphk @echo ">>> make universe started on ${STARTTIME}" 267103985Sphk @echo "--------------------------------------------------------------" 268133945Sru.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 269133945Sru.for arch in ${target:C/:.*$//} 270133945Sru.for mach in ${target:C/^.*://} 271148154SruKERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 272152879Sru find [A-Z]*[A-Z] -type f -maxdepth 0 \ 273152880Sru ! -name DEFAULTS ! -name LINT 274148154SruKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 275133945Sruuniverse: universe_${mach} 276133945Sru.ORDER: universe_prologue universe_${mach} universe_epilogue 277133945Sruuniverse_${mach}: 278111131Sru @echo ">> ${mach} started on `LC_ALL=C date`" 279131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 280111131Sru TARGET_ARCH=${arch} TARGET=${mach} \ 281111131Sru __MAKE_CONF=/dev/null \ 282111131Sru > _.${mach}.buildworld 2>&1 283111131Sru @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 284111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 285111131Sru -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 286111133Sru > ${.CURDIR}/_.${mach}.makeLINT 2>&1 287103985Sphk.endif 288148154Sru.for kernel in ${KERNCONFS} 289148154Sru -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 290148154Sru TARGET_ARCH=${arch} TARGET=${mach} \ 291148154Sru KERNCONF=${kernel} \ 292148154Sru __MAKE_CONF=/dev/null \ 293148154Sru > _.${mach}.${kernel} 2>&1 294148154Sru.endfor 295111131Sru @echo ">> ${mach} completed on `LC_ALL=C date`" 296103985Sphk.endfor 297111131Sru.endfor 298133945Sru.endfor 299133945Sruuniverse: universe_epilogue 300133945Sruuniverse_epilogue: 301103985Sphk @echo "--------------------------------------------------------------" 302118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 303118531Sru @echo " (started ${STARTTIME})" 304103985Sphk @echo "--------------------------------------------------------------" 305133945Sru.endif 306