Makefile revision 204661
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 204661 2010-03-03 21:08:44Z imp $ 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. 18204661Simp# kernel-toolchain - Builds the subset of world necessary to build a kernel 19158962Snetchild# doxygen - Build API documentation of the kernel, needs doxygen. 2038666Sjb# update - Convenient way to update your source tree (cvs). 21169597Sdes# check-old - List obsolete directories/files/libraries. 22169597Sdes# check-old-dirs - List obsolete directories. 23169597Sdes# check-old-files - List obsolete files. 24169597Sdes# check-old-libs - List obsolete libraries. 25169597Sdes# delete-old - Delete obsolete directories/files/libraries. 26169597Sdes# delete-old-dirs - Delete obsolete directories. 27169597Sdes# delete-old-files - Delete obsolete files. 28169597Sdes# delete-old-libs - Delete obsolete libraries. 2932427Sjb# 3038666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 31108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the 3238666Sjb# command line. By keeping this makefile simple, it doesn't matter too 3338666Sjb# much how different the installed mk files are from those in the source 3438666Sjb# tree. This makefile executes a child make process, forcing it to use 3538666Sjb# the mk files from the source tree which are supposed to DTRT. 3617308Speter# 3791606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1. 3819175Sbde# 3996205Sjwd# If you want to build your system from source be sure that /usr/obj has 40177794Spav# at least 800MB of diskspace available. 4138042Sbde# 4296205Sjwd# For individuals wanting to build from the sources currently on their 4396205Sjwd# system, the simple instructions are: 4438042Sbde# 4596205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 46159363Strhodes# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 47159363Strhodes# 3. `make world' 4817308Speter# 4996205Sjwd# For individuals wanting to upgrade their sources (even if only a 5096205Sjwd# delta of a few days): 5117308Speter# 52148330Snetchild# 1. `cd /usr/src' (or to the directory containing your source tree). 53148330Snetchild# 2. `make buildworld' 54148330Snetchild# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 55148330Snetchild# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 56159831Sobrien# [steps 3. & 4. can be combined by using the "kernel" target] 57148330Snetchild# 5. `reboot' (in single user mode: boot -s from the loader prompt). 58148330Snetchild# 6. `mergemaster -p' 59148330Snetchild# 7. `make installworld' 60148330Snetchild# 8. `make delete-old' 61178653Srwatson# 9. `mergemaster' (you may wish to use -U or -ai). 62148330Snetchild# 10. `reboot' 63148330Snetchild# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 6496205Sjwd# 6596205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 6696205Sjwd# 67162147Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 68162147Sru# cross build world for other machine types using the buildworld target, 6998723Sdillon# and once the world is built you can cross build a kernel using the 7098723Sdillon# buildkernel target. 7198723Sdillon# 7238666Sjb# Define the user-driven targets. These are listed here in alphabetical 7338666Sjb# order, but that's not important. 7417308Speter# 75123311Speter# Targets that begin with underscore are internal targets intended for 76123311Speter# developer convenience only. They are intentionally not documented and 77123311Speter# completely subject to change without notice. 78123311Speter# 79175833Sjhb# For more information, see the build(7) manual page. 80175833Sjhb# 81169597SdesTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 82169597Sdes check-old check-old-dirs check-old-files check-old-libs \ 83169597Sdes checkdpadd clean cleandepend cleandir \ 84169597Sdes delete-old delete-old-dirs delete-old-files delete-old-libs \ 85159349Simp depend distribute distributeworld distrib-dirs distribution doxygen \ 86158962Snetchild everything hierarchy install installcheck installkernel \ 87158962Snetchild installkernel.debug reinstallkernel reinstallkernel.debug \ 88158962Snetchild installworld kernel-toolchain libraries lint maninstall \ 89156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 90123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 91137288Speter _build-tools _cross-tools _includes _libraries _depend \ 92189760Simp build32 distribute32 install32 xdev xdev-build xdev-install 93156740SruTGTS+= ${SUBDIR_TARGETS} 942061Sjkh 9597769SruBITGTS= files includes 9697252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 97119579SruTGTS+= ${BITGTS} 9897252Sru 9995730Sru.ORDER: buildworld installworld 10095793Sru.ORDER: buildworld distributeworld 101111617Sru.ORDER: buildworld buildkernel 10295730Sru.ORDER: buildkernel installkernel 103116679Ssimokawa.ORDER: buildkernel installkernel.debug 10495730Sru.ORDER: buildkernel reinstallkernel 105116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 10695730Sru 107110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 108107516SruMAKEOBJDIRPREFIX?= /usr/obj 109138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 110156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 111138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 112133942Sru.if !empty(_MAKEOBJDIRPREFIX) 113133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 114156145Syar (in make.conf(5)) or command-line variable. 115133942Sru.endif 116110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 117117234SruBINMAKE= \ 118110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 119117229Sru -m ${.CURDIR}/share/mk 120117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 12154324Smarcel 12217308Speter# 123119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 124119519Smarcel# should do this as those are the initial targets used for upgrades. 125119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 126119519Smarcel# for all targets. 127119519Smarcel# 128119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 129119579Sru${TGTS}: upgrade_checks 130119519Smarcel.else 131119519Smarcelbuildworld: upgrade_checks 132119519Smarcel.endif 133119519Smarcel 134119519Smarcel# 135126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 136126024Sgad# recursive target. All of the work for it is done right here. It is 137126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 138126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 139126024Sgad# in this makefile. 140126024Sgad# 141126024Sgad# In the following, the first 'rm' in a series will usually remove all 142126024Sgad# files and directories. If it does not, then there are probably some 143126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 144126024Sgad# second time. There are situations where this target will be cleaning 145126024Sgad# some directories via more than one method, but that duplication is 146126024Sgad# needed to correctly handle all the possible situations. 147126024Sgad# 148126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 149126031Sgadcleanworld: 150126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 151126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 152126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 153172744Sdelphij -chflags -R 0 ${BW_CANONICALOBJDIR} 154126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 155126024Sgad.endif 156126024Sgad # To be safe in this case, fall back to a 'make cleandir' 157133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 158126024Sgad.else 159126024Sgad -rm -rf ${.OBJDIR}/* 160172744Sdelphij -chflags -R 0 ${.OBJDIR} 161126024Sgad rm -rf ${.OBJDIR}/* 162126024Sgad.endif 163125885Sgad 164125885Sgad# 16538666Sjb# Handle the user-driven targets, using the source relative mk files. 16617308Speter# 167119519Smarcel 168119579Sru${TGTS}: 169133376Sharti ${_+_}@cd ${.CURDIR}; \ 170110035Sru ${_MAKE} ${.TARGET} 1712302Spaul 17239206Sjkh# Set a reasonable default 17339206Sjkh.MAIN: all 17439206Sjkh 175133945SruSTARTTIME!= LC_ALL=C date 176177609SruCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0 177177609Sru.if !empty(CHECK_TIME) 178177609Sru.error check your date/time: ${STARTTIME} 179177609Sru.endif 180133945Sru 181132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 18217308Speter# 18354324Smarcel# world 18454324Smarcel# 185132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 186132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 187132234Smarcel# not included. One can argue that this target doesn't build everything 188132234Smarcel# then. 18954324Smarcel# 19054324Smarcelworld: upgrade_checks 19154324Smarcel @echo "--------------------------------------------------------------" 192118531Sru @echo ">>> make world started on ${STARTTIME}" 19354324Smarcel @echo "--------------------------------------------------------------" 19454324Smarcel.if target(pre-world) 19554324Smarcel @echo 19654324Smarcel @echo "--------------------------------------------------------------" 19754324Smarcel @echo ">>> Making 'pre-world' target" 19854324Smarcel @echo "--------------------------------------------------------------" 199133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 20054324Smarcel.endif 201133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 202133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 20354324Smarcel.if target(post-world) 20454324Smarcel @echo 20554324Smarcel @echo "--------------------------------------------------------------" 20654324Smarcel @echo ">>> Making 'post-world' target" 20754324Smarcel @echo "--------------------------------------------------------------" 208133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 20954324Smarcel.endif 21054324Smarcel @echo 21154324Smarcel @echo "--------------------------------------------------------------" 212118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 213118531Sru @echo " (started ${STARTTIME})" 21454324Smarcel @echo "--------------------------------------------------------------" 215132234Smarcel.else 216132234Smarcelworld: 217132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 218132234Smarcel @echo "installation without also building and installing a new" 219132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 220132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 221132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 222132234Smarcel @echo "including /, to override this warning and proceed as usual." 223132358Smarkm @echo "" 224132234Smarcel @echo "Bailing out now..." 225132234Smarcel @false 226132234Smarcel.endif 22754324Smarcel 22854324Smarcel# 22995730Sru# kernel 23095730Sru# 23195730Sru# Short hand for `make buildkernel installkernel' 23295730Sru# 23395730Srukernel: buildkernel installkernel 23495730Sru 23595730Sru# 23638666Sjb# Perform a few tests to determine if the installed tools are adequate 237107374Sru# for building the world. 23817308Speter# 23955678Smarcelupgrade_checks: 240143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 241138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 242117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 243110035Sru then \ 244174564Simp (cd ${.CURDIR} && ${MAKE} make); \ 245110035Sru fi 2462061Sjkh 24717308Speter# 248107516Sru# Upgrade make(1) to the current version using the installed 249174539Simp# headers, libraries and tools. Also, allow the location of 250174539Simp# the system bsdmake-like utility to be overridden. 25155678Smarcel# 252107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 253107516Sru DESTDIR= \ 254107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 255174564SimpMMAKE= ${MMAKEENV} ${MAKE} \ 256107516Sru -D_UPGRADING \ 257139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 258164470Sjb -DNO_CPU_CFLAGS -DNO_WERROR 259107516Sru 260122204Skrismake: .PHONY 26155678Smarcel @echo 26255678Smarcel @echo "--------------------------------------------------------------" 263116696Sru @echo ">>> Building an up-to-date make(1)" 26455678Smarcel @echo "--------------------------------------------------------------" 265133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 266107516Sru ${MMAKE} obj && \ 267107516Sru ${MMAKE} depend && \ 268107516Sru ${MMAKE} all && \ 269107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 27055678Smarcel 271185499Salfredtinderbox: 272185499Salfred cd ${.CURDIR} && \ 273185499Salfred DOING_TINDERBOX=YES ${MAKE} ${JFLAG} universe 274185499Salfred 27555678Smarcel# 276111131Sru# universe 277111131Sru# 278111131Sru# Attempt to rebuild *everything* for all supported architectures, 279133945Sru# with a reasonable chance of success, regardless of how old your 280111131Sru# existing system is. 281111131Sru# 282201815Sbz.if make(universe) || make(universe_kernels) || make(tinderbox) 283190628SbzTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 sun4v 284168280Smarcel 285185499Salfred.if defined(DOING_TINDERBOX) 286185499SalfredFAILFILE=tinderbox.failed 287185499SalfredMAKEFAIL=tee -a ${FAILFILE} 288185499Salfred.else 289185499SalfredMAKEFAIL=cat 290185499Salfred.endif 291185499Salfred 292133945Sruuniverse: universe_prologue 293133945Sruuniverse_prologue: 294103985Sphk @echo "--------------------------------------------------------------" 295103985Sphk @echo ">>> make universe started on ${STARTTIME}" 296103985Sphk @echo "--------------------------------------------------------------" 297185499Salfred.if defined(DOING_TINDERBOX) 298185499Salfred rm -f ${FAILFILE} 299185499Salfred.endif 300168280Smarcel.for target in ${TARGETS} 301162147Sruuniverse: universe_${target} 302162147Sru.ORDER: universe_prologue universe_${target} universe_epilogue 303162147Sruuniverse_${target}: 304179232Sjb.if !defined(MAKE_JUST_KERNELS) 305162147Sru @echo ">> ${target} started on `LC_ALL=C date`" 306185250Sdes @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 307202629Sed ${MAKE} ${JFLAG} buildworld \ 308162147Sru TARGET=${target} \ 309185250Sdes > _.${target}.buildworld 2>&1 || \ 310185499Salfred (echo "${target} world failed," \ 311185499Salfred "check _.${target}.buildworld for details" | ${MAKEFAIL})) 312162147Sru @echo ">> ${target} buildworld completed on `LC_ALL=C date`" 313179232Sjb.endif 314162147Sru.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 315185250Sdes @(cd ${.CURDIR}/sys/${target}/conf && env __MAKE_CONF=/dev/null \ 316185250Sdes ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ 317185499Salfred (echo "${target} 'make LINT' failed," \ 318185499Salfred "check _.${target}.makeLINT for details"| ${MAKEFAIL})) 319103985Sphk.endif 320201815Sbz @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \ 321201815Sbz universe_kernels 322201815Sbz @echo ">> ${target} completed on `LC_ALL=C date`" 323201815Sbz.endfor 324201815Sbzuniverse_kernels: universe_kernconfs 325202095Sbz.if !defined(TARGET) 326202095SbzTARGET!= uname -m 327202095Sbz.endif 328201815SbzKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 329201815Sbz find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \ 330201815Sbz ! -name DEFAULTS ! -name NOTES 331201815Sbzuniverse_kernconfs: 332148154Sru.for kernel in ${KERNCONFS} 333185250Sdes @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 334185250Sdes ${MAKE} ${JFLAG} buildkernel \ 335201815Sbz TARGET=${TARGET} \ 336148154Sru KERNCONF=${kernel} \ 337201815Sbz > _.${TARGET}.${kernel} 2>&1 || \ 338201815Sbz (echo "${TARGET} ${kernel} kernel failed," \ 339201815Sbz "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL})) 340148154Sru.endfor 341133945Sruuniverse: universe_epilogue 342133945Sruuniverse_epilogue: 343103985Sphk @echo "--------------------------------------------------------------" 344118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 345118531Sru @echo " (started ${STARTTIME})" 346103985Sphk @echo "--------------------------------------------------------------" 347185499Salfred.if defined(DOING_TINDERBOX) 348185499Salfred @if [ -e ${FAILFILE} ] ; then \ 349185499Salfred echo "Tinderbox failed:" ;\ 350185499Salfred cat ${FAILFILE} ;\ 351185499Salfred exit 1 ;\ 352185499Salfred fi 353133945Sru.endif 354185499Salfred.endif 355