Makefile revision 159831
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 159831 2006-06-21 09:53:42Z obrien $ 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". 11159363Strhodes# world - buildworld + installworld, no kernel. 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). 40159363Strhodes# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 41159363Strhodes# 3. `make world' 4217308Speter# 4396205Sjwd# For individuals wanting to upgrade their sources (even if only a 4496205Sjwd# delta of a few days): 4517308Speter# 46148330Snetchild# 1. `cd /usr/src' (or to the directory containing your source tree). 47148330Snetchild# 2. `make buildworld' 48148330Snetchild# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 49148330Snetchild# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 50159831Sobrien# [steps 3. & 4. can be combined by using the "kernel" target] 51148330Snetchild# 5. `reboot' (in single user mode: boot -s from the loader prompt). 52148330Snetchild# 6. `mergemaster -p' 53148330Snetchild# 7. `make installworld' 54148330Snetchild# 8. `make delete-old' 55148330Snetchild# 9. `mergemaster' 56148330Snetchild# 10. `reboot' 57148330Snetchild# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 5896205Sjwd# 5996205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 6096205Sjwd# 6198775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 6298723Sdillon# cross build world for other architectures using the buildworld target, 6398723Sdillon# and once the world is built you can cross build a kernel using the 6498723Sdillon# buildkernel target. 6598723Sdillon# 6638666Sjb# Define the user-driven targets. These are listed here in alphabetical 6738666Sjb# order, but that's not important. 6817308Speter# 69123311Speter# Targets that begin with underscore are internal targets intended for 70123311Speter# developer convenience only. They are intentionally not documented and 71123311Speter# completely subject to change without notice. 72123311Speter# 73159349SimpTGTS= all all-man buildenv buildenvvars buildkernel buildworld check-old \ 74159349Simp checkdpadd clean cleandepend cleandir delete-old delete-old-libs \ 75159349Simp depend distribute distributeworld distrib-dirs distribution doxygen \ 76158962Snetchild everything hierarchy install installcheck installkernel \ 77158962Snetchild installkernel.debug reinstallkernel reinstallkernel.debug \ 78158962Snetchild installworld kernel-toolchain libraries lint maninstall \ 79156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 80123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 81137288Speter _build-tools _cross-tools _includes _libraries _depend \ 82147425Sru build32 distribute32 install32 83156740SruTGTS+= ${SUBDIR_TARGETS} 842061Sjkh 8597769SruBITGTS= files includes 8697252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 87119579SruTGTS+= ${BITGTS} 8897252Sru 8995730Sru.ORDER: buildworld installworld 9095793Sru.ORDER: buildworld distributeworld 91111617Sru.ORDER: buildworld buildkernel 9295730Sru.ORDER: buildkernel installkernel 93116679Ssimokawa.ORDER: buildkernel installkernel.debug 9495730Sru.ORDER: buildkernel reinstallkernel 95116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 9695730Sru 97110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 98107516SruMAKEOBJDIRPREFIX?= /usr/obj 99138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 100156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 101138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 102133942Sru.if !empty(_MAKEOBJDIRPREFIX) 103133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 104156145Syar (in make.conf(5)) or command-line variable. 105133942Sru.endif 106110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 107117234SruBINMAKE= \ 108110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 109117229Sru -m ${.CURDIR}/share/mk 110117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 11154324Smarcel 11217308Speter# 113119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 114119519Smarcel# should do this as those are the initial targets used for upgrades. 115119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 116119519Smarcel# for all targets. 117119519Smarcel# 118119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 119119579Sru${TGTS}: upgrade_checks 120119519Smarcel.else 121119519Smarcelbuildworld: upgrade_checks 122119519Smarcel.endif 123119519Smarcel 124119519Smarcel# 125126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 126126024Sgad# recursive target. All of the work for it is done right here. It is 127126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 128126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 129126024Sgad# in this makefile. 130126024Sgad# 131126024Sgad# In the following, the first 'rm' in a series will usually remove all 132126024Sgad# files and directories. If it does not, then there are probably some 133126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 134126024Sgad# second time. There are situations where this target will be cleaning 135126024Sgad# some directories via more than one method, but that duplication is 136126024Sgad# needed to correctly handle all the possible situations. 137126024Sgad# 138126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 139126031Sgadcleanworld: 140126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 141126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 142126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 143126024Sgad chflags -R 0 ${BW_CANONICALOBJDIR} 144126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 145126024Sgad.endif 146126024Sgad # To be safe in this case, fall back to a 'make cleandir' 147133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 148126024Sgad.else 149126024Sgad -rm -rf ${.OBJDIR}/* 150126024Sgad chflags -R 0 ${.OBJDIR} 151126024Sgad rm -rf ${.OBJDIR}/* 152126024Sgad.endif 153125885Sgad 154125885Sgad# 15538666Sjb# Handle the user-driven targets, using the source relative mk files. 15617308Speter# 157119519Smarcel 158119579Sru${TGTS}: 159133376Sharti ${_+_}@cd ${.CURDIR}; \ 160110035Sru ${_MAKE} ${.TARGET} 1612302Spaul 16239206Sjkh# Set a reasonable default 16339206Sjkh.MAIN: all 16439206Sjkh 165133945SruSTARTTIME!= LC_ALL=C date 166133945Sru 167132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 16817308Speter# 16954324Smarcel# world 17054324Smarcel# 171132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 172132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 173132234Smarcel# not included. One can argue that this target doesn't build everything 174132234Smarcel# then. 17554324Smarcel# 17654324Smarcelworld: upgrade_checks 17754324Smarcel @echo "--------------------------------------------------------------" 178118531Sru @echo ">>> make world started on ${STARTTIME}" 17954324Smarcel @echo "--------------------------------------------------------------" 18054324Smarcel.if target(pre-world) 18154324Smarcel @echo 18254324Smarcel @echo "--------------------------------------------------------------" 18354324Smarcel @echo ">>> Making 'pre-world' target" 18454324Smarcel @echo "--------------------------------------------------------------" 185133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 18654324Smarcel.endif 187133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 188133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 18954324Smarcel.if target(post-world) 19054324Smarcel @echo 19154324Smarcel @echo "--------------------------------------------------------------" 19254324Smarcel @echo ">>> Making 'post-world' target" 19354324Smarcel @echo "--------------------------------------------------------------" 194133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 19554324Smarcel.endif 19654324Smarcel @echo 19754324Smarcel @echo "--------------------------------------------------------------" 198118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 199118531Sru @echo " (started ${STARTTIME})" 20054324Smarcel @echo "--------------------------------------------------------------" 201132234Smarcel.else 202132234Smarcelworld: 203132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 204132234Smarcel @echo "installation without also building and installing a new" 205132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 206132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 207132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 208132234Smarcel @echo "including /, to override this warning and proceed as usual." 209132358Smarkm @echo "You may get the historical 'make world' behavior by defining" 210132358Smarkm @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 211132358Smarkm @echo "before doing this." 212132358Smarkm @echo "" 213132234Smarcel @echo "Bailing out now..." 214132234Smarcel @false 215132234Smarcel.endif 21654324Smarcel 21754324Smarcel# 21895730Sru# kernel 21995730Sru# 22095730Sru# Short hand for `make buildkernel installkernel' 22195730Sru# 22295730Srukernel: buildkernel installkernel 22395730Sru 22495730Sru# 22538666Sjb# Perform a few tests to determine if the installed tools are adequate 226107374Sru# for building the world. 22717308Speter# 22855678Smarcelupgrade_checks: 229143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 230138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 231117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 232110035Sru then \ 233110035Sru (cd ${.CURDIR} && make make); \ 234110035Sru fi 2352061Sjkh 23617308Speter# 237107516Sru# Upgrade make(1) to the current version using the installed 238107374Sru# headers, libraries and tools. 23955678Smarcel# 240107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 241107516Sru DESTDIR= \ 242107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 243107516SruMMAKE= ${MMAKEENV} make \ 244107516Sru -D_UPGRADING \ 245139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 246107516Sru -DNO_CPU_CFLAGS -DNO_WERROR 247107516Sru 248122204Skrismake: .PHONY 24955678Smarcel @echo 25055678Smarcel @echo "--------------------------------------------------------------" 251116696Sru @echo ">>> Building an up-to-date make(1)" 25255678Smarcel @echo "--------------------------------------------------------------" 253133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 254107516Sru ${MMAKE} obj && \ 255107516Sru ${MMAKE} depend && \ 256107516Sru ${MMAKE} all && \ 257107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 25855678Smarcel 25955678Smarcel# 260111131Sru# universe 261111131Sru# 262111131Sru# Attempt to rebuild *everything* for all supported architectures, 263133945Sru# with a reasonable chance of success, regardless of how old your 264111131Sru# existing system is. 265111131Sru# 266148154Sru.if make(universe) 267133945Sruuniverse: universe_prologue 268133945Sruuniverse_prologue: 269103985Sphk @echo "--------------------------------------------------------------" 270103985Sphk @echo ">>> make universe started on ${STARTTIME}" 271103985Sphk @echo "--------------------------------------------------------------" 272158453Sjhb.for target in i386 i386:pc98 sparc64 ia64 amd64 273133945Sru.for arch in ${target:C/:.*$//} 274133945Sru.for mach in ${target:C/^.*://} 275148154SruKERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \ 276152879Sru find [A-Z]*[A-Z] -type f -maxdepth 0 \ 277152880Sru ! -name DEFAULTS ! -name LINT 278148154SruKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 279133945Sruuniverse: universe_${mach} 280133945Sru.ORDER: universe_prologue universe_${mach} universe_epilogue 281133945Sruuniverse_${mach}: 282111131Sru @echo ">> ${mach} started on `LC_ALL=C date`" 283131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 284111131Sru TARGET_ARCH=${arch} TARGET=${mach} \ 285111131Sru __MAKE_CONF=/dev/null \ 286111131Sru > _.${mach}.buildworld 2>&1 287111131Sru @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 288111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 289111131Sru -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 290111133Sru > ${.CURDIR}/_.${mach}.makeLINT 2>&1 291103985Sphk.endif 292148154Sru.for kernel in ${KERNCONFS} 293148154Sru -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 294148154Sru TARGET_ARCH=${arch} TARGET=${mach} \ 295148154Sru KERNCONF=${kernel} \ 296148154Sru __MAKE_CONF=/dev/null \ 297148154Sru > _.${mach}.${kernel} 2>&1 298148154Sru.endfor 299111131Sru @echo ">> ${mach} completed on `LC_ALL=C date`" 300103985Sphk.endfor 301111131Sru.endfor 302133945Sru.endfor 303133945Sruuniverse: universe_epilogue 304133945Sruuniverse_epilogue: 305103985Sphk @echo "--------------------------------------------------------------" 306118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 307118531Sru @echo " (started ${STARTTIME})" 308103985Sphk @echo "--------------------------------------------------------------" 309133945Sru.endif 310