Makefile revision 174564
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 174564 2007-12-13 00:08:02Z 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. 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 3996205Sjwd# at least 400MB 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' 60148330Snetchild# 9. `mergemaster' 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# 78169597SdesTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 79169597Sdes check-old check-old-dirs check-old-files check-old-libs \ 80169597Sdes checkdpadd clean cleandepend cleandir \ 81169597Sdes delete-old delete-old-dirs delete-old-files delete-old-libs \ 82159349Simp depend distribute distributeworld distrib-dirs distribution doxygen \ 83158962Snetchild everything hierarchy install installcheck installkernel \ 84158962Snetchild installkernel.debug reinstallkernel reinstallkernel.debug \ 85158962Snetchild installworld kernel-toolchain libraries lint maninstall \ 86156840Sru obj objlink regress rerelease showconfig tags toolchain update \ 87123311Speter _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 88137288Speter _build-tools _cross-tools _includes _libraries _depend \ 89147425Sru build32 distribute32 install32 90156740SruTGTS+= ${SUBDIR_TARGETS} 912061Sjkh 9297769SruBITGTS= files includes 9397252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 94119579SruTGTS+= ${BITGTS} 9597252Sru 9695730Sru.ORDER: buildworld installworld 9795793Sru.ORDER: buildworld distributeworld 98111617Sru.ORDER: buildworld buildkernel 9995730Sru.ORDER: buildkernel installkernel 100116679Ssimokawa.ORDER: buildkernel installkernel.debug 10195730Sru.ORDER: buildkernel reinstallkernel 102116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug 10395730Sru 104110035SruPATH= /sbin:/bin:/usr/sbin:/usr/bin 105107516SruMAKEOBJDIRPREFIX?= /usr/obj 106138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 107156145Syar ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 108138921Sru -f /dev/null -V MAKEOBJDIRPREFIX dummy 109133942Sru.if !empty(_MAKEOBJDIRPREFIX) 110133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 111156145Syar (in make.conf(5)) or command-line variable. 112133942Sru.endif 113110035SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 114117234SruBINMAKE= \ 115110035Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 116117229Sru -m ${.CURDIR}/share/mk 117117234Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 11854324Smarcel 11917308Speter# 120119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld 121119519Smarcel# should do this as those are the initial targets used for upgrades. 122119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 123119519Smarcel# for all targets. 124119519Smarcel# 125119519Smarcel.if defined(ALWAYS_CHECK_MAKE) 126119579Sru${TGTS}: upgrade_checks 127119519Smarcel.else 128119519Smarcelbuildworld: upgrade_checks 129119519Smarcel.endif 130119519Smarcel 131119519Smarcel# 132126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a 133126024Sgad# recursive target. All of the work for it is done right here. It is 134126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 135126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file 136126024Sgad# in this makefile. 137126024Sgad# 138126024Sgad# In the following, the first 'rm' in a series will usually remove all 139126024Sgad# files and directories. If it does not, then there are probably some 140126024Sgad# files with chflags set, so this unsets them and tries the 'rm' a 141126024Sgad# second time. There are situations where this target will be cleaning 142126024Sgad# some directories via more than one method, but that duplication is 143126024Sgad# needed to correctly handle all the possible situations. 144126024Sgad# 145126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 146126031Sgadcleanworld: 147126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 148126024Sgad.if exists(${BW_CANONICALOBJDIR}/) 149126024Sgad -rm -rf ${BW_CANONICALOBJDIR}/* 150172744Sdelphij -chflags -R 0 ${BW_CANONICALOBJDIR} 151126024Sgad rm -rf ${BW_CANONICALOBJDIR}/* 152126024Sgad.endif 153126024Sgad # To be safe in this case, fall back to a 'make cleandir' 154133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 155126024Sgad.else 156126024Sgad -rm -rf ${.OBJDIR}/* 157172744Sdelphij -chflags -R 0 ${.OBJDIR} 158126024Sgad rm -rf ${.OBJDIR}/* 159126024Sgad.endif 160125885Sgad 161125885Sgad# 16238666Sjb# Handle the user-driven targets, using the source relative mk files. 16317308Speter# 164119519Smarcel 165119579Sru${TGTS}: 166133376Sharti ${_+_}@cd ${.CURDIR}; \ 167110035Sru ${_MAKE} ${.TARGET} 1682302Spaul 16939206Sjkh# Set a reasonable default 17039206Sjkh.MAIN: all 17139206Sjkh 172133945SruSTARTTIME!= LC_ALL=C date 173133945Sru 174132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 17517308Speter# 17654324Smarcel# world 17754324Smarcel# 178132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 179132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 180132234Smarcel# not included. One can argue that this target doesn't build everything 181132234Smarcel# then. 18254324Smarcel# 18354324Smarcelworld: upgrade_checks 18454324Smarcel @echo "--------------------------------------------------------------" 185118531Sru @echo ">>> make world started on ${STARTTIME}" 18654324Smarcel @echo "--------------------------------------------------------------" 18754324Smarcel.if target(pre-world) 18854324Smarcel @echo 18954324Smarcel @echo "--------------------------------------------------------------" 19054324Smarcel @echo ">>> Making 'pre-world' target" 19154324Smarcel @echo "--------------------------------------------------------------" 192133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 19354324Smarcel.endif 194133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 195133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 19654324Smarcel.if target(post-world) 19754324Smarcel @echo 19854324Smarcel @echo "--------------------------------------------------------------" 19954324Smarcel @echo ">>> Making 'post-world' target" 20054324Smarcel @echo "--------------------------------------------------------------" 201133376Sharti ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 20254324Smarcel.endif 20354324Smarcel @echo 20454324Smarcel @echo "--------------------------------------------------------------" 205118531Sru @echo ">>> make world completed on `LC_ALL=C date`" 206118531Sru @echo " (started ${STARTTIME})" 20754324Smarcel @echo "--------------------------------------------------------------" 208132234Smarcel.else 209132234Smarcelworld: 210132234Smarcel @echo "WARNING: make world will overwrite your existing FreeBSD" 211132234Smarcel @echo "installation without also building and installing a new" 212132234Smarcel @echo "kernel. This can be dangerous. Please read the handbook," 213132588Skensmith @echo "'Rebuilding world', for how to upgrade your system." 214132358Smarkm @echo "Define DESTDIR to where you want to install FreeBSD," 215132234Smarcel @echo "including /, to override this warning and proceed as usual." 216132358Smarkm @echo "" 217132234Smarcel @echo "Bailing out now..." 218132234Smarcel @false 219132234Smarcel.endif 22054324Smarcel 22154324Smarcel# 22295730Sru# kernel 22395730Sru# 22495730Sru# Short hand for `make buildkernel installkernel' 22595730Sru# 22695730Srukernel: buildkernel installkernel 22795730Sru 22895730Sru# 22938666Sjb# Perform a few tests to determine if the installed tools are adequate 230107374Sru# for building the world. 23117308Speter# 23255678Smarcelupgrade_checks: 233143032Sharti @if ! (cd ${.CURDIR}/tools/build/make_check && \ 234138515Sharti PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 235117793Sru PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 236110035Sru then \ 237174564Simp (cd ${.CURDIR} && ${MAKE} make); \ 238110035Sru fi 2392061Sjkh 24017308Speter# 241107516Sru# Upgrade make(1) to the current version using the installed 242174539Simp# headers, libraries and tools. Also, allow the location of 243174539Simp# the system bsdmake-like utility to be overridden. 24455678Smarcel# 245107516SruMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 246107516Sru DESTDIR= \ 247107516Sru INSTALL="sh ${.CURDIR}/tools/install.sh" 248174564SimpMMAKE= ${MMAKEENV} ${MAKE} \ 249107516Sru -D_UPGRADING \ 250139112Sru -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 251164470Sjb -DNO_CPU_CFLAGS -DNO_WERROR 252107516Sru 253122204Skrismake: .PHONY 25455678Smarcel @echo 25555678Smarcel @echo "--------------------------------------------------------------" 256116696Sru @echo ">>> Building an up-to-date make(1)" 25755678Smarcel @echo "--------------------------------------------------------------" 258133376Sharti ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 259107516Sru ${MMAKE} obj && \ 260107516Sru ${MMAKE} depend && \ 261107516Sru ${MMAKE} all && \ 262107516Sru ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 26355678Smarcel 26455678Smarcel# 265111131Sru# universe 266111131Sru# 267111131Sru# Attempt to rebuild *everything* for all supported architectures, 268133945Sru# with a reasonable chance of success, regardless of how old your 269111131Sru# existing system is. 270111131Sru# 271148154Sru.if make(universe) 272168280SmarcelTARGETS?=amd64 arm i386 ia64 pc98 powerpc sparc64 sun4v 273168280Smarcel 274133945Sruuniverse: universe_prologue 275133945Sruuniverse_prologue: 276103985Sphk @echo "--------------------------------------------------------------" 277103985Sphk @echo ">>> make universe started on ${STARTTIME}" 278103985Sphk @echo "--------------------------------------------------------------" 279168280Smarcel.for target in ${TARGETS} 280162147SruKERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ 281152879Sru find [A-Z]*[A-Z] -type f -maxdepth 0 \ 282152880Sru ! -name DEFAULTS ! -name LINT 283148154SruKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 284162147Sruuniverse: universe_${target} 285162147Sru.ORDER: universe_prologue universe_${target} universe_epilogue 286162147Sruuniverse_${target}: 287162147Sru @echo ">> ${target} started on `LC_ALL=C date`" 288131876Sphk -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 289162147Sru TARGET=${target} \ 290111131Sru __MAKE_CONF=/dev/null \ 291162147Sru > _.${target}.buildworld 2>&1 292162147Sru @echo ">> ${target} buildworld completed on `LC_ALL=C date`" 293162147Sru.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 294162147Sru -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ 295162147Sru > ${.CURDIR}/_.${target}.makeLINT 2>&1 296103985Sphk.endif 297148154Sru.for kernel in ${KERNCONFS} 298148154Sru -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 299162147Sru TARGET=${target} \ 300148154Sru KERNCONF=${kernel} \ 301148154Sru __MAKE_CONF=/dev/null \ 302162147Sru > _.${target}.${kernel} 2>&1 303148154Sru.endfor 304162147Sru @echo ">> ${target} completed on `LC_ALL=C date`" 305103985Sphk.endfor 306133945Sruuniverse: universe_epilogue 307133945Sruuniverse_epilogue: 308103985Sphk @echo "--------------------------------------------------------------" 309118531Sru @echo ">>> make universe completed on `LC_ALL=C date`" 310118531Sru @echo " (started ${STARTTIME})" 311103985Sphk @echo "--------------------------------------------------------------" 312133945Sru.endif 313