Makefile revision 158962
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 158962 2006-05-26 18:10:06Z netchild $ 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. 18158962Snetchild# doxygen - Build API documentation of the kernel, needs doxygen. 1938666Sjb# update - Convenient way to update your source tree (cvs). 20148330Snetchild# check-old - Print a list of old files/directories in the system. 21148330Snetchild# delete-old - Delete obsolete files and directories interactively. 22148330Snetchild# delete-old-libs - Delete obsolete libraries interactively. 2332427Sjb# 2438666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 25108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the 2638666Sjb# command line. By keeping this makefile simple, it doesn't matter too 2738666Sjb# much how different the installed mk files are from those in the source 2838666Sjb# tree. This makefile executes a child make process, forcing it to use 2938666Sjb# the mk files from the source tree which are supposed to DTRT. 3017308Speter# 3191606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1. 3219175Sbde# 3396205Sjwd# If you want to build your system from source be sure that /usr/obj has 3496205Sjwd# at least 400MB of diskspace available. 3538042Sbde# 3696205Sjwd# For individuals wanting to build from the sources currently on their 3796205Sjwd# system, the simple instructions are: 3838042Sbde# 3996205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 4096205Sjwd# 2. `make world' 4117308Speter# 4296205Sjwd# For individuals wanting to upgrade their sources (even if only a 4396205Sjwd# delta of a few days): 4417308Speter# 45148330Snetchild# 1. `cd /usr/src' (or to the directory containing your source tree). 46148330Snetchild# 2. `make buildworld' 47148330Snetchild# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 48148330Snetchild# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 49148330Snetchild# 5. `reboot' (in single user mode: boot -s from the loader prompt). 50148330Snetchild# 6. `mergemaster -p' 51148330Snetchild# 7. `make installworld' 52148330Snetchild# 8. `make delete-old' 53148330Snetchild# 9. `mergemaster' 54148330Snetchild# 10. `reboot' 55148330Snetchild# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 5696205Sjwd# 5796205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 5896205Sjwd# 5998775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 6098723Sdillon# cross build world for other architectures using the buildworld target, 6198723Sdillon# and once the world is built you can cross build a kernel using the 6298723Sdillon# buildkernel target. 6398723Sdillon# 6438666Sjb# Define the user-driven targets. These are listed here in alphabetical 6538666Sjb# order, but that's not important. 6617308Speter# 67123311Speter# Targets that begin with underscore are internal targets intended for 68123311Speter# developer convenience only. They are intentionally not documented and 69123311Speter# completely subject to change without notice. 70123311Speter# 71148330SnetchildTGTS= all all-man buildenv buildkernel buildworld check-old checkdpadd \ 72148330Snetchild clean cleandepend cleandir delete-old delete-old-libs depend \ 73158962Snetchild distribute distributeworld distrib-dirs distribution doxygen \ 74158962Snetchild everything hierarchy install installcheck installkernel \ 75158962Snetchild installkernel.debug reinstallkernel reinstallkernel.debug \ 76158962Snetchild installworld kernel-toolchain libraries lint maninstall \ 77156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 78123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 79137288Speter _build-tools _cross-tools _includes _libraries _depend \ 80147425Sru build32 distribute32 install32 81156740SruTGTS+= ${SUBDIR_TARGETS} 822061Sjkh 8397769SruBITGTS= files includes 8497252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 85119579SruTGTS+= ${BITGTS} 8697252Sru 8795730Sru.ORDER: buildworld installworld 8895793Sru.ORDER: buildworld distributeworld 89111617Sru.ORDER: buildworld buildkernel 9095730Sru.ORDER: buildkernel installkernel 91116679Ssimokawa.ORDER: buildkernel installkernel.debug 9295730Sru.ORDER: buildkernel reinstallkernel 93116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 9495730Sru 95110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 96107516SruMAKEOBJDIRPREFIX?= /usr/obj 97138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 98156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 99138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 100133942Sru.if !empty(_MAKEOBJDIRPREFIX) 101133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 102156145Syar (in make.conf(5)) or command-line variable. 103133942Sru.endif 104110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 105117234SruBINMAKE= \ 106110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 107117229Sru -m ${.CURDIR}/share/mk 108117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 10954324Smarcel 11017308Speter# 111119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 112119519Smarcel# should do this as those are the initial targets used for upgrades. 113119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 114119519Smarcel# for all targets. 115119519Smarcel# 116119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 117119579Sru${TGTS}: upgrade_checks 118119519Smarcel.else 119119519Smarcelbuildworld: upgrade_checks 120119519Smarcel.endif 121119519Smarcel 122119519Smarcel# 123126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 124126024Sgad# recursive target. All of the work for it is done right here. It is 125126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 126126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 127126024Sgad# in this makefile. 128126024Sgad# 129126024Sgad# In the following, the first 'rm' in a series will usually remove all 130126024Sgad# files and directories. If it does not, then there are probably some 131126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 132126024Sgad# second time. There are situations where this target will be cleaning 133126024Sgad# some directories via more than one method, but that duplication is 134126024Sgad# needed to correctly handle all the possible situations. 135126024Sgad# 136126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 137126031Sgadcleanworld: 138126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 139126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 140126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 141126024Sgad chflags -R 0 ${BW_CANONICALOBJDIR} 142126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 143126024Sgad.endif 144126024Sgad # To be safe in this case, fall back to a 'make cleandir' 145133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 146126024Sgad.else 147126024Sgad -rm -rf ${.OBJDIR}/* 148126024Sgad chflags -R 0 ${.OBJDIR} 149126024Sgad rm -rf ${.OBJDIR}/* 150126024Sgad.endif 151125885Sgad 152125885Sgad# 15338666Sjb# Handle the user-driven targets, using the source relative mk files. 15417308Speter# 155119519Smarcel 156119579Sru${TGTS}: 157133376Sharti ${_+_}@cd ${.CURDIR}; \ 158110035Sru ${_MAKE} ${.TARGET} 1592302Spaul 16039206Sjkh# Set a reasonable default 16139206Sjkh.MAIN: all 16239206Sjkh 163133945SruSTARTTIME!= LC_ALL=C date 164133945Sru 165132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 16617308Speter# 16754324Smarcel# world 16854324Smarcel# 169132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 170132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 171132234Smarcel# not included. One can argue that this target doesn't build everything 172132234Smarcel# then. 17354324Smarcel# 17454324Smarcelworld: upgrade_checks 17554324Smarcel @echo "--------------------------------------------------------------" 176118531Sru @echo ">>> make world started on ${STARTTIME}" 17754324Smarcel @echo "--------------------------------------------------------------" 17854324Smarcel.if target(pre-world) 17954324Smarcel @echo 18054324Smarcel @echo "--------------------------------------------------------------" 18154324Smarcel @echo ">>> Making 'pre-world' target" 18254324Smarcel @echo "--------------------------------------------------------------" 183133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 18454324Smarcel.endif 185133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 186133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 18754324Smarcel.if target(post-world) 18854324Smarcel @echo 18954324Smarcel @echo "--------------------------------------------------------------" 19054324Smarcel @echo ">>> Making 'post-world' target" 19154324Smarcel @echo "--------------------------------------------------------------" 192133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 19354324Smarcel.endif 19454324Smarcel @echo 19554324Smarcel @echo "--------------------------------------------------------------" 196118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 197118531Sru @echo " (started ${STARTTIME})" 19854324Smarcel @echo "--------------------------------------------------------------" 199132234Smarcel.else 200132234Smarcelworld: 201132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 202132234Smarcel @echo "installation without also building and installing a new" 203132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 204132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 205132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 206132234Smarcel @echo "including /, to override this warning and proceed as usual." 207132358Smarkm @echo "You may get the historical 'make world' behavior by defining" 208132358Smarkm @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 209132358Smarkm @echo "before doing this." 210132358Smarkm @echo "" 211132234Smarcel @echo "Bailing out now..." 212132234Smarcel @false 213132234Smarcel.endif 21454324Smarcel 21554324Smarcel# 21695730Sru# kernel 21795730Sru# 21895730Sru# Short hand for `make buildkernel installkernel' 21995730Sru# 22095730Srukernel: buildkernel installkernel 22195730Sru 22295730Sru# 22338666Sjb# Perform a few tests to determine if the installed tools are adequate 224107374Sru# for building the world. 22517308Speter# 22655678Smarcelupgrade_checks: 227143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 228138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 229117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 230110035Sru then \ 231110035Sru (cd ${.CURDIR} && make make); \ 232110035Sru fi 2332061Sjkh 23417308Speter# 235107516Sru# Upgrade make(1) to the current version using the installed 236107374Sru# headers, libraries and tools. 23755678Smarcel# 238107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 239107516Sru DESTDIR= \ 240107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 241107516SruMMAKE= ${MMAKEENV} make \ 242107516Sru -D_UPGRADING \ 243139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 244107516Sru -DNO_CPU_CFLAGS -DNO_WERROR 245107516Sru 246122204Skrismake: .PHONY 24755678Smarcel @echo 24855678Smarcel @echo "--------------------------------------------------------------" 249116696Sru @echo ">>> Building an up-to-date make(1)" 25055678Smarcel @echo "--------------------------------------------------------------" 251133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 252107516Sru ${MMAKE} obj && \ 253107516Sru ${MMAKE} depend && \ 254107516Sru ${MMAKE} all && \ 255107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 25655678Smarcel 25755678Smarcel# 258111131Sru# universe 259111131Sru# 260111131Sru# Attempt to rebuild *everything* for all supported architectures, 261133945Sru# with a reasonable chance of success, regardless of how old your 262111131Sru# existing system is. 263111131Sru# 264148154Sru.if make(universe) 265133945Sruuniverse: universe_prologue 266133945Sruuniverse_prologue: 267103985Sphk @echo "--------------------------------------------------------------" 268103985Sphk @echo ">>> make universe started on ${STARTTIME}" 269103985Sphk @echo "--------------------------------------------------------------" 270158453Sjhb.for target in i386 i386:pc98 sparc64 ia64 amd64 271133945Sru.for arch in ${target:C/:.*$//} 272133945Sru.for mach in ${target:C/^.*://} 273148154SruKERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 274152879Sru find [A-Z]*[A-Z] -type f -maxdepth 0 \ 275152880Sru ! -name DEFAULTS ! -name LINT 276148154SruKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 277133945Sruuniverse: universe_${mach} 278133945Sru.ORDER: universe_prologue universe_${mach} universe_epilogue 279133945Sruuniverse_${mach}: 280111131Sru @echo ">> ${mach} started on `LC_ALL=C date`" 281131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 282111131Sru TARGET_ARCH=${arch} TARGET=${mach} \ 283111131Sru __MAKE_CONF=/dev/null \ 284111131Sru > _.${mach}.buildworld 2>&1 285111131Sru @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 286111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 287111131Sru -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 288111133Sru > ${.CURDIR}/_.${mach}.makeLINT 2>&1 289103985Sphk.endif 290148154Sru.for kernel in ${KERNCONFS} 291148154Sru -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 292148154Sru TARGET_ARCH=${arch} TARGET=${mach} \ 293148154Sru KERNCONF=${kernel} \ 294148154Sru __MAKE_CONF=/dev/null \ 295148154Sru > _.${mach}.${kernel} 2>&1 296148154Sru.endfor 297111131Sru @echo ">> ${mach} completed on `LC_ALL=C date`" 298103985Sphk.endfor 299111131Sru.endfor 300133945Sru.endfor 301133945Sruuniverse: universe_epilogue 302133945Sruuniverse_epilogue: 303103985Sphk @echo "--------------------------------------------------------------" 304118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 305118531Sru @echo " (started ${STARTTIME})" 306103985Sphk @echo "--------------------------------------------------------------" 307133945Sru.endif 308