Makefile revision 217754
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 217754 2011-01-23 16:28:44Z bz $ 32061Sjkh# 438666Sjb# The user-driven targets are: 532427Sjb# 6111131Sru# universe - *Really* build *everything* (buildworld and 7111131Sru# all kernels on all architectures). 8217733Sbz# tinderbox - Same as universe, but presents a list of failed build 9217733Sbz# targets and exits with an error if there were any. 1038666Sjb# buildworld - Rebuild *everything*, including glue to help do 1138666Sjb# upgrades. 1238666Sjb# installworld - Install everything built by "buildworld". 13159363Strhodes# world - buildworld + installworld, no kernel. 1464049Salex# buildkernel - Rebuild the kernel and the kernel-modules. 1564049Salex# installkernel - Install the kernel and the kernel-modules. 16116679Ssimokawa# installkernel.debug 1766071Smarkm# reinstallkernel - Reinstall the kernel and the kernel-modules. 18116679Ssimokawa# reinstallkernel.debug 1973504Sobrien# kernel - buildkernel + installkernel. 20204661Simp# kernel-toolchain - Builds the subset of world necessary to build a kernel 21158962Snetchild# doxygen - Build API documentation of the kernel, needs doxygen. 2238666Sjb# update - Convenient way to update your source tree (cvs). 23169597Sdes# check-old - List obsolete directories/files/libraries. 24169597Sdes# check-old-dirs - List obsolete directories. 25169597Sdes# check-old-files - List obsolete files. 26169597Sdes# check-old-libs - List obsolete libraries. 27169597Sdes# delete-old - Delete obsolete directories/files/libraries. 28169597Sdes# delete-old-dirs - Delete obsolete directories. 29169597Sdes# delete-old-files - Delete obsolete files. 30169597Sdes# delete-old-libs - Delete obsolete libraries. 31217125Simp# targets - Print a list of supported TARGET/TARGET_ARCH pairs. 3232427Sjb# 3338666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 34108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the 3538666Sjb# command line. By keeping this makefile simple, it doesn't matter too 3638666Sjb# much how different the installed mk files are from those in the source 3738666Sjb# tree. This makefile executes a child make process, forcing it to use 3838666Sjb# the mk files from the source tree which are supposed to DTRT. 3917308Speter# 40217273Simp# Most of the user-driven targets (as listed above) are implemented in 41217294Simp# Makefile.inc1. The exceptions are universe, tinderbox and targets. 4219175Sbde# 4396205Sjwd# If you want to build your system from source be sure that /usr/obj has 44217297Simp# at least 1GB of diskspace available. A complete 'universe' build requires 45217297Simp# about 15GB of space. 4638042Sbde# 4796205Sjwd# For individuals wanting to build from the sources currently on their 4896205Sjwd# system, the simple instructions are: 4938042Sbde# 5096205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 51159363Strhodes# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 52159363Strhodes# 3. `make world' 5317308Speter# 5496205Sjwd# For individuals wanting to upgrade their sources (even if only a 5596205Sjwd# delta of a few days): 5617308Speter# 57148330Snetchild# 1. `cd /usr/src' (or to the directory containing your source tree). 58148330Snetchild# 2. `make buildworld' 59148330Snetchild# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 60148330Snetchild# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 61159831Sobrien# [steps 3. & 4. can be combined by using the "kernel" target] 62148330Snetchild# 5. `reboot' (in single user mode: boot -s from the loader prompt). 63148330Snetchild# 6. `mergemaster -p' 64148330Snetchild# 7. `make installworld' 65148330Snetchild# 8. `make delete-old' 66178653Srwatson# 9. `mergemaster' (you may wish to use -U or -ai). 67148330Snetchild# 10. `reboot' 68148330Snetchild# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 6996205Sjwd# 7096205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 7196205Sjwd# 72162147Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 73162147Sru# cross build world for other machine types using the buildworld target, 7498723Sdillon# and once the world is built you can cross build a kernel using the 7598723Sdillon# buildkernel target. 7698723Sdillon# 7738666Sjb# Define the user-driven targets. These are listed here in alphabetical 7838666Sjb# order, but that's not important. 7917308Speter# 80123311Speter# Targets that begin with underscore are internal targets intended for 81123311Speter# developer convenience only. They are intentionally not documented and 82123311Speter# completely subject to change without notice. 83123311Speter# 84175833Sjhb# For more information, see the build(7) manual page. 85175833Sjhb# 86169597SdesTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 87169597Sdes check-old check-old-dirs check-old-files check-old-libs \ 88169597Sdes checkdpadd clean cleandepend cleandir \ 89169597Sdes delete-old delete-old-dirs delete-old-files delete-old-libs \ 90159349Simp depend distribute distributeworld distrib-dirs distribution doxygen \ 91158962Snetchild everything hierarchy install installcheck installkernel \ 92158962Snetchild installkernel.debug reinstallkernel reinstallkernel.debug \ 93158962Snetchild installworld kernel-toolchain libraries lint maninstall \ 94156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 95123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 96137288Speter _build-tools _cross-tools _includes _libraries _depend \ 97209128Sraj build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ 98209128Sraj 99156740SruTGTS+= ${SUBDIR_TARGETS} 1002061Sjkh 10197769SruBITGTS= files includes 10297252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 103119579SruTGTS+= ${BITGTS} 10497252Sru 10595730Sru.ORDER: buildworld installworld 10695793Sru.ORDER: buildworld distributeworld 107111617Sru.ORDER: buildworld buildkernel 10895730Sru.ORDER: buildkernel installkernel 109116679Ssimokawa.ORDER: buildkernel installkernel.debug 11095730Sru.ORDER: buildkernel reinstallkernel 111116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 11295730Sru 113110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 114107516SruMAKEOBJDIRPREFIX?= /usr/obj 115138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 116156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 117138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 118133942Sru.if !empty(_MAKEOBJDIRPREFIX) 119133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 120156145Syar (in make.conf(5)) or command-line variable. 121133942Sru.endif 122110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 123117234SruBINMAKE= \ 124110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 125117229Sru -m ${.CURDIR}/share/mk 126117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 12754324Smarcel 12817308Speter# 129119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 130119519Smarcel# should do this as those are the initial targets used for upgrades. 131119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 132119519Smarcel# for all targets. 133119519Smarcel# 134119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 135119579Sru${TGTS}: upgrade_checks 136119519Smarcel.else 137119519Smarcelbuildworld: upgrade_checks 138119519Smarcel.endif 139119519Smarcel 140119519Smarcel# 141126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 142126024Sgad# recursive target. All of the work for it is done right here. It is 143126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 144126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 145126024Sgad# in this makefile. 146126024Sgad# 147126024Sgad# In the following, the first 'rm' in a series will usually remove all 148126024Sgad# files and directories. If it does not, then there are probably some 149126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 150126024Sgad# second time. There are situations where this target will be cleaning 151126024Sgad# some directories via more than one method, but that duplication is 152126024Sgad# needed to correctly handle all the possible situations. 153126024Sgad# 154126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 155126031Sgadcleanworld: 156126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 157126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 158126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 159172744Sdelphij -chflags -R 0 ${BW_CANONICALOBJDIR} 160126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 161126024Sgad.endif 162126024Sgad # To be safe in this case, fall back to a 'make cleandir' 163133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 164126024Sgad.else 165126024Sgad -rm -rf ${.OBJDIR}/* 166172744Sdelphij -chflags -R 0 ${.OBJDIR} 167126024Sgad rm -rf ${.OBJDIR}/* 168126024Sgad.endif 169125885Sgad 170125885Sgad# 17138666Sjb# Handle the user-driven targets, using the source relative mk files. 17217308Speter# 173119519Smarcel 174119579Sru${TGTS}: 175133376Sharti ${_+_}@cd ${.CURDIR}; \ 176110035Sru ${_MAKE} ${.TARGET} 1772302Spaul 17839206Sjkh# Set a reasonable default 17939206Sjkh.MAIN: all 18039206Sjkh 181133945SruSTARTTIME!= LC_ALL=C date 182177609SruCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0 183177609Sru.if !empty(CHECK_TIME) 184177609Sru.error check your date/time: ${STARTTIME} 185177609Sru.endif 186133945Sru 187132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 18817308Speter# 18954324Smarcel# world 19054324Smarcel# 191132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 192132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 193132234Smarcel# not included. One can argue that this target doesn't build everything 194132234Smarcel# then. 19554324Smarcel# 19654324Smarcelworld: upgrade_checks 19754324Smarcel @echo "--------------------------------------------------------------" 198118531Sru @echo ">>> make world started on ${STARTTIME}" 19954324Smarcel @echo "--------------------------------------------------------------" 20054324Smarcel.if target(pre-world) 20154324Smarcel @echo 20254324Smarcel @echo "--------------------------------------------------------------" 20354324Smarcel @echo ">>> Making 'pre-world' target" 20454324Smarcel @echo "--------------------------------------------------------------" 205133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 20654324Smarcel.endif 207133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 208133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 20954324Smarcel.if target(post-world) 21054324Smarcel @echo 21154324Smarcel @echo "--------------------------------------------------------------" 21254324Smarcel @echo ">>> Making 'post-world' target" 21354324Smarcel @echo "--------------------------------------------------------------" 214133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 21554324Smarcel.endif 21654324Smarcel @echo 21754324Smarcel @echo "--------------------------------------------------------------" 218118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 219118531Sru @echo " (started ${STARTTIME})" 22054324Smarcel @echo "--------------------------------------------------------------" 221132234Smarcel.else 222132234Smarcelworld: 223132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 224132234Smarcel @echo "installation without also building and installing a new" 225132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 226132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 227132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 228132234Smarcel @echo "including /, to override this warning and proceed as usual." 229132358Smarkm @echo "" 230132234Smarcel @echo "Bailing out now..." 231132234Smarcel @false 232132234Smarcel.endif 23354324Smarcel 23454324Smarcel# 23595730Sru# kernel 23695730Sru# 23795730Sru# Short hand for `make buildkernel installkernel' 23895730Sru# 23995730Srukernel: buildkernel installkernel 24095730Sru 24195730Sru# 24238666Sjb# Perform a few tests to determine if the installed tools are adequate 243107374Sru# for building the world. 24417308Speter# 24555678Smarcelupgrade_checks: 246143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 247138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 248117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 249110035Sru then \ 250174564Simp (cd ${.CURDIR} && ${MAKE} make); \ 251110035Sru fi 2522061Sjkh 25317308Speter# 254107516Sru# Upgrade make(1) to the current version using the installed 255174539Simp# headers, libraries and tools. Also, allow the location of 256174539Simp# the system bsdmake-like utility to be overridden. 25755678Smarcel# 258107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 259107516Sru DESTDIR= \ 260107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 261174564SimpMMAKE= ${MMAKEENV} ${MAKE} \ 262107516Sru -D_UPGRADING \ 263139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 264164470Sjb -DNO_CPU_CFLAGS -DNO_WERROR 265107516Sru 266122204Skrismake: .PHONY 26755678Smarcel @echo 26855678Smarcel @echo "--------------------------------------------------------------" 269116696Sru @echo ">>> Building an up-to-date make(1)" 27055678Smarcel @echo "--------------------------------------------------------------" 271133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 272107516Sru ${MMAKE} obj && \ 273107516Sru ${MMAKE} depend && \ 274107516Sru ${MMAKE} all && \ 275107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 27655678Smarcel 277185499Salfredtinderbox: 278217754Sbz @cd ${.CURDIR} && \ 279216487Sjhb DOING_TINDERBOX=YES ${MAKE} JFLAG=${JFLAG} universe 280185499Salfred 28155678Smarcel# 282111131Sru# universe 283111131Sru# 284111131Sru# Attempt to rebuild *everything* for all supported architectures, 285133945Sru# with a reasonable chance of success, regardless of how old your 286111131Sru# existing system is. 287111131Sru# 288217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets) 289216520SnwhitehornTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 sun4v 290216520SnwhitehornTARGET_ARCHES_arm?= arm armeb 291217123SimpTARGET_ARCHES_mips?= mipsel mipseb mips64el mips64eb 292216520SnwhitehornTARGET_ARCHES_powerpc?= powerpc powerpc64 293216520SnwhitehornTARGET_ARCHES_pc98?= i386 294216520SnwhitehornTARGET_ARCHES_sun4v?= sparc64 295216520Snwhitehorn.for target in ${TARGETS} 296216520SnwhitehornTARGET_ARCHES_${target}?= ${target} 297216520Snwhitehorn.endfor 298168280Smarcel 299217125Simptargets: 300217734Sbz @echo "Supported TARGETS/TARGET_ARCH pairs" 301217125Simp.for target in ${TARGETS} 302217125Simp.for target_arch in ${TARGET_ARCHES_${target}} 303217125Simp @echo " ${target}/${target_arch}" 304217125Simp.endfor 305217125Simp.endfor 306217125Simp 307185499Salfred.if defined(DOING_TINDERBOX) 308217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed 309185499SalfredMAKEFAIL=tee -a ${FAILFILE} 310185499Salfred.else 311185499SalfredMAKEFAIL=cat 312185499Salfred.endif 313185499Salfred 314133945Sruuniverse: universe_prologue 315133945Sruuniverse_prologue: 316103985Sphk @echo "--------------------------------------------------------------" 317103985Sphk @echo ">>> make universe started on ${STARTTIME}" 318103985Sphk @echo "--------------------------------------------------------------" 319185499Salfred.if defined(DOING_TINDERBOX) 320217754Sbz @rm -f ${FAILFILE} 321185499Salfred.endif 322168280Smarcel.for target in ${TARGETS} 323162147Sruuniverse: universe_${target} 324162147Sru.ORDER: universe_prologue universe_${target} universe_epilogue 325216520Snwhitehornuniverse_${target}: universe_${target}_prologue 326216520Snwhitehornuniverse_${target}_prologue: 327216520Snwhitehorn @echo ">> ${target} started on `LC_ALL=C date`" 328179232Sjb.if !defined(MAKE_JUST_KERNELS) 329216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}} 330216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch} 331216520Snwhitehornuniverse_${target}_${target_arch}: universe_${target}_prologue 332216520Snwhitehorn @echo ">> ${target}.${target_arch} buildworld started on `LC_ALL=C date`" 333185250Sdes @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 334202629Sed ${MAKE} ${JFLAG} buildworld \ 335162147Sru TARGET=${target} \ 336216520Snwhitehorn TARGET_ARCH=${target_arch} \ 337216520Snwhitehorn > _.${target}.${target_arch}.buildworld 2>&1 || \ 338216520Snwhitehorn (echo "${target}.${target_arch} world failed," \ 339216520Snwhitehorn "check _.${target}.${target_arch}.buildworld for details" | \ 340216520Snwhitehorn ${MAKEFAIL})) 341216520Snwhitehorn @echo ">> ${target}.${target_arch} buildworld completed on `LC_ALL=C date`" 342216520Snwhitehorn.endfor 343179232Sjb.endif 344205290Sdougb.if !defined(MAKE_JUST_WORLDS) 345162147Sru.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 346185250Sdes @(cd ${.CURDIR}/sys/${target}/conf && env __MAKE_CONF=/dev/null \ 347185250Sdes ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ 348185499Salfred (echo "${target} 'make LINT' failed," \ 349185499Salfred "check _.${target}.makeLINT for details"| ${MAKEFAIL})) 350103985Sphk.endif 351201815Sbz @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \ 352201815Sbz universe_kernels 353205290Sdougb.endif 354201815Sbz @echo ">> ${target} completed on `LC_ALL=C date`" 355201815Sbz.endfor 356201815Sbzuniverse_kernels: universe_kernconfs 357202095Sbz.if !defined(TARGET) 358202095SbzTARGET!= uname -m 359202095Sbz.endif 360201815SbzKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 361201815Sbz find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \ 362201815Sbz ! -name DEFAULTS ! -name NOTES 363201815Sbzuniverse_kernconfs: 364148154Sru.for kernel in ${KERNCONFS} 365216520SnwhitehornTARGET_ARCH_${kernel}!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 366216685Simp config -m ${.CURDIR}/sys/${TARGET}/conf/${kernel} 2> /dev/null | \ 367216934Simp grep -v WARNING: | cut -f 2 368216934Simp.if empty(TARGET_ARCH_${kernel}) 369216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old." 370216934Simp.endif 371216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel} 372216520Snwhitehornuniverse_kernconf_${TARGET}_${kernel}: 373185250Sdes @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 374185250Sdes ${MAKE} ${JFLAG} buildkernel \ 375201815Sbz TARGET=${TARGET} \ 376216520Snwhitehorn TARGET_ARCH=${TARGET_ARCH_${kernel}} \ 377148154Sru KERNCONF=${kernel} \ 378201815Sbz > _.${TARGET}.${kernel} 2>&1 || \ 379201815Sbz (echo "${TARGET} ${kernel} kernel failed," \ 380201815Sbz "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL})) 381148154Sru.endfor 382133945Sruuniverse: universe_epilogue 383133945Sruuniverse_epilogue: 384103985Sphk @echo "--------------------------------------------------------------" 385118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 386118531Sru @echo " (started ${STARTTIME})" 387103985Sphk @echo "--------------------------------------------------------------" 388185499Salfred.if defined(DOING_TINDERBOX) 389185499Salfred @if [ -e ${FAILFILE} ] ; then \ 390185499Salfred echo "Tinderbox failed:" ;\ 391185499Salfred cat ${FAILFILE} ;\ 392185499Salfred exit 1 ;\ 393185499Salfred fi 394133945Sru.endif 395185499Salfred.endif 396