Makefile revision 143032
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 143032 2005-03-02 12:33:23Z harti $ 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). 1932427Sjb# 2038666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 21108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the 2238666Sjb# command line. By keeping this makefile simple, it doesn't matter too 2338666Sjb# much how different the installed mk files are from those in the source 2438666Sjb# tree. This makefile executes a child make process, forcing it to use 2538666Sjb# the mk files from the source tree which are supposed to DTRT. 2617308Speter# 2791606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1. 2819175Sbde# 2996205Sjwd# If you want to build your system from source be sure that /usr/obj has 3096205Sjwd# at least 400MB of diskspace available. 3138042Sbde# 3296205Sjwd# For individuals wanting to build from the sources currently on their 3396205Sjwd# system, the simple instructions are: 3438042Sbde# 3596205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 3696205Sjwd# 2. `make world' 3717308Speter# 3896205Sjwd# For individuals wanting to upgrade their sources (even if only a 3996205Sjwd# delta of a few days): 4017308Speter# 4196205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 4296205Sjwd# 2. `make buildworld' 4396205Sjwd# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4496205Sjwd# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4596205Sjwd# 5. `reboot' (in single user mode: boot -s from the loader prompt). 4696205Sjwd# 6. `mergemaster -p' 4796205Sjwd# 7. `make installworld' 4896205Sjwd# 8. `mergemaster' 4996205Sjwd# 9. `reboot' 5096205Sjwd# 5196205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 5296205Sjwd# 5398775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 5498723Sdillon# cross build world for other architectures using the buildworld target, 5598723Sdillon# and once the world is built you can cross build a kernel using the 5698723Sdillon# buildkernel target. 5798723Sdillon# 5838666Sjb# Define the user-driven targets. These are listed here in alphabetical 5938666Sjb# order, but that's not important. 6017308Speter# 61123311Speter# Targets that begin with underscore are internal targets intended for 62123311Speter# developer convenience only. They are intentionally not documented and 63123311Speter# completely subject to change without notice. 64123311Speter# 65142585SruTGTS= all all-man buildenv buildkernel buildworld checkdpadd clean \ 66142644Sru cleandepend cleandir depend distribute distributeworld \ 67142644Sru distribution everything \ 68116679Ssimokawa hierarchy install installcheck installkernel installkernel.debug\ 69120760Sru reinstallkernel reinstallkernel.debug installworld \ 70128189Sdes kernel-toolchain libraries lint maninstall \ 71127360Sru obj objlink regress rerelease tags toolchain update \ 72123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 73137288Speter _build-tools _cross-tools _includes _libraries _depend \ 74137288Speter build32 install32 752061Sjkh 7697769SruBITGTS= files includes 7797252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 78119579SruTGTS+= ${BITGTS} 7997252Sru 8095730Sru.ORDER: buildworld installworld 8195793Sru.ORDER: buildworld distributeworld 82111617Sru.ORDER: buildworld buildkernel 8395730Sru.ORDER: buildkernel installkernel 84116679Ssimokawa.ORDER: buildkernel installkernel.debug 8595730Sru.ORDER: buildkernel reinstallkernel 86116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 8795730Sru 88110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 89107516SruMAKEOBJDIRPREFIX?= /usr/obj 90138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 91138921Sru ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \ 92138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 93133942Sru.if !empty(_MAKEOBJDIRPREFIX) 94133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 95133942Sru (in /etc/make.conf) or command-line variable. 96133942Sru.endif 97110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 98117234SruBINMAKE= \ 99110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 100117229Sru -m ${.CURDIR}/share/mk 101117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 10254324Smarcel 10317308Speter# 104119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 105119519Smarcel# should do this as those are the initial targets used for upgrades. 106119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 107119519Smarcel# for all targets. 108119519Smarcel# 109119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 110119579Sru${TGTS}: upgrade_checks 111119519Smarcel.else 112119519Smarcelbuildworld: upgrade_checks 113119519Smarcel.endif 114119519Smarcel 115119519Smarcel# 116126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 117126024Sgad# recursive target. All of the work for it is done right here. It is 118126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 119126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 120126024Sgad# in this makefile. 121126024Sgad# 122126024Sgad# In the following, the first 'rm' in a series will usually remove all 123126024Sgad# files and directories. If it does not, then there are probably some 124126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 125126024Sgad# second time. There are situations where this target will be cleaning 126126024Sgad# some directories via more than one method, but that duplication is 127126024Sgad# needed to correctly handle all the possible situations. 128126024Sgad# 129126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 130126031Sgadcleanworld: 131126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 132126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 133126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 134126024Sgad chflags -R 0 ${BW_CANONICALOBJDIR} 135126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 136126024Sgad.endif 137126024Sgad # To be safe in this case, fall back to a 'make cleandir' 138133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 139126024Sgad.else 140126024Sgad -rm -rf ${.OBJDIR}/* 141126024Sgad chflags -R 0 ${.OBJDIR} 142126024Sgad rm -rf ${.OBJDIR}/* 143126024Sgad.endif 144125885Sgad 145125885Sgad# 14638666Sjb# Handle the user-driven targets, using the source relative mk files. 14717308Speter# 148119519Smarcel 149119579Sru${TGTS}: 150133376Sharti ${_+_}@cd ${.CURDIR}; \ 151110035Sru ${_MAKE} ${.TARGET} 1522302Spaul 15339206Sjkh# Set a reasonable default 15439206Sjkh.MAIN: all 15539206Sjkh 156133945SruSTARTTIME!= LC_ALL=C date 157133945Sru 158132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 15917308Speter# 16054324Smarcel# world 16154324Smarcel# 162132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 163132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 164132234Smarcel# not included. One can argue that this target doesn't build everything 165132234Smarcel# then. 16654324Smarcel# 16754324Smarcelworld: upgrade_checks 16854324Smarcel @echo "--------------------------------------------------------------" 169118531Sru @echo ">>> make world started on ${STARTTIME}" 17054324Smarcel @echo "--------------------------------------------------------------" 17154324Smarcel.if target(pre-world) 17254324Smarcel @echo 17354324Smarcel @echo "--------------------------------------------------------------" 17454324Smarcel @echo ">>> Making 'pre-world' target" 17554324Smarcel @echo "--------------------------------------------------------------" 176133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 17754324Smarcel.endif 178133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 179133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 18054324Smarcel.if target(post-world) 18154324Smarcel @echo 18254324Smarcel @echo "--------------------------------------------------------------" 18354324Smarcel @echo ">>> Making 'post-world' target" 18454324Smarcel @echo "--------------------------------------------------------------" 185133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 18654324Smarcel.endif 18754324Smarcel @echo 18854324Smarcel @echo "--------------------------------------------------------------" 189118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 190118531Sru @echo " (started ${STARTTIME})" 19154324Smarcel @echo "--------------------------------------------------------------" 192132234Smarcel.else 193132234Smarcelworld: 194132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 195132234Smarcel @echo "installation without also building and installing a new" 196132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 197132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 198132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 199132234Smarcel @echo "including /, to override this warning and proceed as usual." 200132358Smarkm @echo "You may get the historical 'make world' behavior by defining" 201132358Smarkm @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 202132358Smarkm @echo "before doing this." 203132358Smarkm @echo "" 204132234Smarcel @echo "Bailing out now..." 205132234Smarcel @false 206132234Smarcel.endif 20754324Smarcel 20854324Smarcel# 20995730Sru# kernel 21095730Sru# 21195730Sru# Short hand for `make buildkernel installkernel' 21295730Sru# 21395730Srukernel: buildkernel installkernel 21495730Sru 21595730Sru# 21638666Sjb# Perform a few tests to determine if the installed tools are adequate 217107374Sru# for building the world. 21817308Speter# 21955678Smarcelupgrade_checks: 220143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 221138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 222117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 223110035Sru then \ 224110035Sru (cd ${.CURDIR} && make make); \ 225110035Sru fi 2262061Sjkh 22717308Speter# 228107516Sru# Upgrade make(1) to the current version using the installed 229107374Sru# headers, libraries and tools. 23055678Smarcel# 231107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 232107516Sru DESTDIR= \ 233107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 234107516SruMMAKE= ${MMAKEENV} make \ 235107516Sru -D_UPGRADING \ 236139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 237107516Sru -DNO_CPU_CFLAGS -DNO_WERROR 238107516Sru 239122204Skrismake: .PHONY 24055678Smarcel @echo 24155678Smarcel @echo "--------------------------------------------------------------" 242116696Sru @echo ">>> Building an up-to-date make(1)" 24355678Smarcel @echo "--------------------------------------------------------------" 244133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 245107516Sru ${MMAKE} obj && \ 246107516Sru ${MMAKE} depend && \ 247107516Sru ${MMAKE} all && \ 248107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 24955678Smarcel 25055678Smarcel# 251111131Sru# universe 252111131Sru# 253111131Sru# Attempt to rebuild *everything* for all supported architectures, 254133945Sru# with a reasonable chance of success, regardless of how old your 255111131Sru# existing system is. 256111131Sru# 257133945Sruuniverse: universe_prologue 258133945Sruuniverse_prologue: 259103985Sphk @echo "--------------------------------------------------------------" 260103985Sphk @echo ">>> make universe started on ${STARTTIME}" 261103985Sphk @echo "--------------------------------------------------------------" 262133945Sru.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 263133945Sru.for arch in ${target:C/:.*$//} 264133945Sru.for mach in ${target:C/^.*://} 265133945Sruuniverse: universe_${mach} 266133945Sru.ORDER: universe_prologue universe_${mach} universe_epilogue 267133945Sruuniverse_${mach}: 268111131Sru @echo ">> ${mach} started on `LC_ALL=C date`" 269131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 270111131Sru TARGET_ARCH=${arch} TARGET=${mach} \ 271111131Sru __MAKE_CONF=/dev/null \ 272111131Sru > _.${mach}.buildworld 2>&1 273111131Sru @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 274111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 275111131Sru -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 276111133Sru > ${.CURDIR}/_.${mach}.makeLINT 2>&1 277103985Sphk.endif 278133945Sru cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 279111131Sru @echo ">> ${mach} completed on `LC_ALL=C date`" 280103985Sphk.endfor 281111131Sru.endfor 282133945Sru.endfor 283133945Sruuniverse: universe_epilogue 284133945Sruuniverse_epilogue: 285103985Sphk @echo "--------------------------------------------------------------" 286118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 287118531Sru @echo " (started ${STARTTIME})" 288103985Sphk @echo "--------------------------------------------------------------" 289103985Sphk 290126485Sru.if make(buildkernels) 291111131SruKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 292111131Sru find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 293103985Sphkbuildkernels: 294111131Sru.for kernel in ${KERNCONFS} 295131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 296111131Sru KERNCONF=${kernel} \ 297111131Sru __MAKE_CONF=/dev/null \ 298111131Sru > _.${TARGET}.${kernel} 2>&1 299103985Sphk.endfor 300133945Sru.endif 301