Makefile revision 183242
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 179845 2008-06-17 11:08:49Z bz $ 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). 20169597Sdes# check-old - List obsolete directories/files/libraries. 21169597Sdes# check-old-dirs - List obsolete directories. 22169597Sdes# check-old-files - List obsolete files. 23169597Sdes# check-old-libs - List obsolete libraries. 24169597Sdes# delete-old - Delete obsolete directories/files/libraries. 25169597Sdes# delete-old-dirs - Delete obsolete directories. 26169597Sdes# delete-old-files - Delete obsolete files. 27169597Sdes# delete-old-libs - Delete obsolete libraries. 2832427Sjb# 2938666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 30108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the 3138666Sjb# command line. By keeping this makefile simple, it doesn't matter too 3238666Sjb# much how different the installed mk files are from those in the source 3338666Sjb# tree. This makefile executes a child make process, forcing it to use 3438666Sjb# the mk files from the source tree which are supposed to DTRT. 3517308Speter# 3691606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1. 3719175Sbde# 3896205Sjwd# If you want to build your system from source be sure that /usr/obj has 39177794Spav# at least 800MB of diskspace available. 4038042Sbde# 4196205Sjwd# For individuals wanting to build from the sources currently on their 4296205Sjwd# system, the simple instructions are: 4338042Sbde# 4496205Sjwd# 1. `cd /usr/src' (or to the directory containing your source tree). 45159363Strhodes# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 46159363Strhodes# 3. `make world' 4717308Speter# 4896205Sjwd# For individuals wanting to upgrade their sources (even if only a 4996205Sjwd# delta of a few days): 5017308Speter# 51148330Snetchild# 1. `cd /usr/src' (or to the directory containing your source tree). 52148330Snetchild# 2. `make buildworld' 53148330Snetchild# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 54148330Snetchild# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 55159831Sobrien# [steps 3. & 4. can be combined by using the "kernel" target] 56148330Snetchild# 5. `reboot' (in single user mode: boot -s from the loader prompt). 57148330Snetchild# 6. `mergemaster -p' 58148330Snetchild# 7. `make installworld' 59148330Snetchild# 8. `make delete-old' 60178653Srwatson# 9. `mergemaster' (you may wish to use -U or -ai). 61148330Snetchild# 10. `reboot' 62148330Snetchild# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 6396205Sjwd# 6496205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information. 6596205Sjwd# 66162147Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 67162147Sru# cross build world for other machine types using the buildworld target, 6898723Sdillon# and once the world is built you can cross build a kernel using the 6998723Sdillon# buildkernel target. 7098723Sdillon# 7138666Sjb# Define the user-driven targets. These are listed here in alphabetical 7238666Sjb# order, but that's not important. 7317308Speter# 74123311Speter# Targets that begin with underscore are internal targets intended for 75123311Speter# developer convenience only. They are intentionally not documented and 76123311Speter# completely subject to change without notice. 77123311Speter# 78175833Sjhb# For more information, see the build(7) manual page. 79175833Sjhb# 80169597SdesTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 81169597Sdes check-old check-old-dirs check-old-files check-old-libs \ 82169597Sdes checkdpadd clean cleandepend cleandir \ 83169597Sdes delete-old delete-old-dirs delete-old-files delete-old-libs \ 84159349Simp depend distribute distributeworld distrib-dirs distribution doxygen \ 85158962Snetchild everything hierarchy install installcheck installkernel \ 86158962Snetchild installkernel.debug reinstallkernel reinstallkernel.debug \ 87158962Snetchild installworld kernel-toolchain libraries lint maninstall \ 88156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 89123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 90137288Speter _build-tools _cross-tools _includes _libraries _depend \ 91147425Sru build32 distribute32 install32 92156740SruTGTS+= ${SUBDIR_TARGETS} 932061Sjkh 9497769SruBITGTS= files includes 9597252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 96119579SruTGTS+= ${BITGTS} 9797252Sru 9895730Sru.ORDER: buildworld installworld 9995793Sru.ORDER: buildworld distributeworld 100111617Sru.ORDER: buildworld buildkernel 10195730Sru.ORDER: buildkernel installkernel 102116679Ssimokawa.ORDER: buildkernel installkernel.debug 10395730Sru.ORDER: buildkernel reinstallkernel 104116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 10595730Sru 106110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 107107516SruMAKEOBJDIRPREFIX?= /usr/obj 108138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 109156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 110138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 111133942Sru.if !empty(_MAKEOBJDIRPREFIX) 112133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 113156145Syar (in make.conf(5)) or command-line variable. 114133942Sru.endif 115110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 116117234SruBINMAKE= \ 117110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 118117229Sru -m ${.CURDIR}/share/mk 119117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 12054324Smarcel 12117308Speter# 122119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 123119519Smarcel# should do this as those are the initial targets used for upgrades. 124119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 125119519Smarcel# for all targets. 126119519Smarcel# 127119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 128119579Sru${TGTS}: upgrade_checks 129119519Smarcel.else 130119519Smarcelbuildworld: upgrade_checks 131119519Smarcel.endif 132119519Smarcel 133119519Smarcel# 134126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 135126024Sgad# recursive target. All of the work for it is done right here. It is 136126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 137126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 138126024Sgad# in this makefile. 139126024Sgad# 140126024Sgad# In the following, the first 'rm' in a series will usually remove all 141126024Sgad# files and directories. If it does not, then there are probably some 142126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 143126024Sgad# second time. There are situations where this target will be cleaning 144126024Sgad# some directories via more than one method, but that duplication is 145126024Sgad# needed to correctly handle all the possible situations. 146126024Sgad# 147126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 148126031Sgadcleanworld: 149126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 150126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 151126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 152172744Sdelphij -chflags -R 0 ${BW_CANONICALOBJDIR} 153126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 154126024Sgad.endif 155126024Sgad # To be safe in this case, fall back to a 'make cleandir' 156133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 157126024Sgad.else 158126024Sgad -rm -rf ${.OBJDIR}/* 159172744Sdelphij -chflags -R 0 ${.OBJDIR} 160126024Sgad rm -rf ${.OBJDIR}/* 161126024Sgad.endif 162125885Sgad 163125885Sgad# 16438666Sjb# Handle the user-driven targets, using the source relative mk files. 16517308Speter# 166119519Smarcel 167119579Sru${TGTS}: 168133376Sharti ${_+_}@cd ${.CURDIR}; \ 169110035Sru ${_MAKE} ${.TARGET} 1702302Spaul 17139206Sjkh# Set a reasonable default 17239206Sjkh.MAIN: all 17339206Sjkh 174133945SruSTARTTIME!= LC_ALL=C date 175177609SruCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0 176177609Sru.if !empty(CHECK_TIME) 177177609Sru.error check your date/time: ${STARTTIME} 178177609Sru.endif 179133945Sru 180132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 18117308Speter# 18254324Smarcel# world 18354324Smarcel# 184132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 185132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 186132234Smarcel# not included. One can argue that this target doesn't build everything 187132234Smarcel# then. 18854324Smarcel# 18954324Smarcelworld: upgrade_checks 19054324Smarcel @echo "--------------------------------------------------------------" 191118531Sru @echo ">>> make world started on ${STARTTIME}" 19254324Smarcel @echo "--------------------------------------------------------------" 19354324Smarcel.if target(pre-world) 19454324Smarcel @echo 19554324Smarcel @echo "--------------------------------------------------------------" 19654324Smarcel @echo ">>> Making 'pre-world' target" 19754324Smarcel @echo "--------------------------------------------------------------" 198133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 19954324Smarcel.endif 200133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 201133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 20254324Smarcel.if target(post-world) 20354324Smarcel @echo 20454324Smarcel @echo "--------------------------------------------------------------" 20554324Smarcel @echo ">>> Making 'post-world' target" 20654324Smarcel @echo "--------------------------------------------------------------" 207133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 20854324Smarcel.endif 20954324Smarcel @echo 21054324Smarcel @echo "--------------------------------------------------------------" 211118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 212118531Sru @echo " (started ${STARTTIME})" 21354324Smarcel @echo "--------------------------------------------------------------" 214132234Smarcel.else 215132234Smarcelworld: 216132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 217132234Smarcel @echo "installation without also building and installing a new" 218132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 219132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 220132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 221132234Smarcel @echo "including /, to override this warning and proceed as usual." 222132358Smarkm @echo "" 223132234Smarcel @echo "Bailing out now..." 224132234Smarcel @false 225132234Smarcel.endif 22654324Smarcel 22754324Smarcel# 22895730Sru# kernel 22995730Sru# 23095730Sru# Short hand for `make buildkernel installkernel' 23195730Sru# 23295730Srukernel: buildkernel installkernel 23395730Sru 23495730Sru# 23538666Sjb# Perform a few tests to determine if the installed tools are adequate 236107374Sru# for building the world. 23717308Speter# 23855678Smarcelupgrade_checks: 239143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 240138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 241117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 242110035Sru then \ 243174564Simp (cd ${.CURDIR} && ${MAKE} make); \ 244110035Sru fi 2452061Sjkh 24617308Speter# 247107516Sru# Upgrade make(1) to the current version using the installed 248174539Simp# headers, libraries and tools. Also, allow the location of 249174539Simp# the system bsdmake-like utility to be overridden. 25055678Smarcel# 251107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 252107516Sru DESTDIR= \ 253107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 254174564SimpMMAKE= ${MMAKEENV} ${MAKE} \ 255107516Sru -D_UPGRADING \ 256139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 257164470Sjb -DNO_CPU_CFLAGS -DNO_WERROR 258107516Sru 259122204Skrismake: .PHONY 26055678Smarcel @echo 26155678Smarcel @echo "--------------------------------------------------------------" 262116696Sru @echo ">>> Building an up-to-date make(1)" 26355678Smarcel @echo "--------------------------------------------------------------" 264133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 265107516Sru ${MMAKE} obj && \ 266107516Sru ${MMAKE} depend && \ 267107516Sru ${MMAKE} all && \ 268107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 26955678Smarcel 27055678Smarcel# 271111131Sru# universe 272111131Sru# 273111131Sru# Attempt to rebuild *everything* for all supported architectures, 274133945Sru# with a reasonable chance of success, regardless of how old your 275111131Sru# existing system is. 276111131Sru# 277148154Sru.if make(universe) 278179309SjbTARGETS?=amd64 arm i386 ia64 pc98 powerpc sparc64 sun4v 279168280Smarcel 280133945Sruuniverse: universe_prologue 281133945Sruuniverse_prologue: 282103985Sphk @echo "--------------------------------------------------------------" 283103985Sphk @echo ">>> make universe started on ${STARTTIME}" 284103985Sphk @echo "--------------------------------------------------------------" 285168280Smarcel.for target in ${TARGETS} 286162147SruKERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ 287152879Sru find [A-Z]*[A-Z] -type f -maxdepth 0 \ 288152880Sru ! -name DEFAULTS ! -name LINT 289148154SruKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 290162147Sruuniverse: universe_${target} 291162147Sru.ORDER: universe_prologue universe_${target} universe_epilogue 292162147Sruuniverse_${target}: 293179232Sjb.if !defined(MAKE_JUST_KERNELS) 294162147Sru @echo ">> ${target} started on `LC_ALL=C date`" 295131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 296162147Sru TARGET=${target} \ 297179845Sbz __MAKE_CONF=/dev/null \ 298162147Sru > _.${target}.buildworld 2>&1 299162147Sru @echo ">> ${target} buildworld completed on `LC_ALL=C date`" 300179232Sjb.endif 301162147Sru.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 302162147Sru -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ 303162147Sru > ${.CURDIR}/_.${target}.makeLINT 2>&1 304103985Sphk.endif 305148154Sru.for kernel in ${KERNCONFS} 306148154Sru -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 307162147Sru TARGET=${target} \ 308148154Sru KERNCONF=${kernel} \ 309179845Sbz __MAKE_CONF=/dev/null \ 310162147Sru > _.${target}.${kernel} 2>&1 311148154Sru.endfor 312162147Sru @echo ">> ${target} completed on `LC_ALL=C date`" 313103985Sphk.endfor 314133945Sruuniverse: universe_epilogue 315133945Sruuniverse_epilogue: 316103985Sphk @echo "--------------------------------------------------------------" 317118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 318118531Sru @echo " (started ${STARTTIME})" 319103985Sphk @echo "--------------------------------------------------------------" 320133945Sru.endif 321