Makefile revision 147425
1108983Simp# 2108983Simp# $FreeBSD: head/Makefile 147425 2005-06-16 18:16:14Z ru $ 3108983Simp# 4108983Simp# The user-driven targets are: 5108983Simp# 6108983Simp# universe - *Really* build *everything* (buildworld and 7108983Simp# all kernels on all architectures). 8108983Simp# buildworld - Rebuild *everything*, including glue to help do 9108983Simp# upgrades. 10108983Simp# installworld - Install everything built by "buildworld". 11227994Swblock# world - buildworld + installworld. 12227994Swblock# buildkernel - Rebuild the kernel and the kernel-modules. 13227994Swblock# installkernel - Install the kernel and the kernel-modules. 14227994Swblock# installkernel.debug 15108983Simp# reinstallkernel - Reinstall the kernel and the kernel-modules. 16108983Simp# reinstallkernel.debug 17108983Simp# kernel - buildkernel + installkernel. 18108983Simp# update - Convenient way to update your source tree (cvs). 19108983Simp# 20148471Simp# This makefile is simple by design. The FreeBSD make automatically reads 21108983Simp# the /usr/share/mk/sys.mk unless the -m argument is specified on the 22139027Sbrueffer# command line. By keeping this makefile simple, it doesn't matter too 23146969Smarius# much how different the installed mk files are from those in the source 24139027Sbrueffer# tree. This makefile executes a child make process, forcing it to use 25108983Simp# the mk files from the source tree which are supposed to DTRT. 26108983Simp# 27108983Simp# The user-driven targets (as listed above) are implemented in Makefile.inc1. 28108983Simp# 29108983Simp# If you want to build your system from source be sure that /usr/obj has 30108983Simp# at least 400MB of diskspace available. 31159126Sthompsa# 32159126Sthompsa# For individuals wanting to build from the sources currently on their 33108983Simp# system, the simple instructions are: 34187743Ssam# 35227994Swblock# 1. `cd /usr/src' (or to the directory containing your source tree). 36227994Swblock# 2. `make world' 37187743Ssam# 38187743Ssam# For individuals wanting to upgrade their sources (even if only a 39159126Sthompsa# delta of a few days): 40159126Sthompsa# 41247767Shrs# 1. `cd /usr/src' (or to the directory containing your source tree). 42159126Sthompsa# 2. `make buildworld' 43159126Sthompsa# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 44108983Simp# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 45108983Simp# 5. `reboot' (in single user mode: boot -s from the loader prompt). 46147088Sbrooks# 6. `mergemaster -p' 47227994Swblock# 7. `make installworld' 48147088Sbrooks# 8. `mergemaster' 49216983Sjpaetzel# 9. `reboot' 50147088Sbrooks# 51147088Sbrooks# See src/UPDATING `COMMON ITEMS' for more complete information. 52147088Sbrooks# 53147088Sbrooks# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 54147088Sbrooks# cross build world for other architectures using the buildworld target, 55148642Ssam# and once the world is built you can cross build a kernel using the 56175683Smtm# buildkernel target. 57147088Sbrooks# 58147088Sbrooks# Define the user-driven targets. These are listed here in alphabetical 59148642Ssam# order, but that's not important. 60148642Ssam# 61148642Ssam# Targets that begin with underscore are internal targets intended for 62148642Ssam# developer convenience only. They are intentionally not documented and 63148642Ssam# completely subject to change without notice. 64148642Ssam# 65148642SsamTGTS= all all-man buildenv buildkernel buildworld checkdpadd clean \ 66148642Ssam cleandepend cleandir depend distribute distributeworld \ 67148642Ssam distribution everything \ 68148642Ssam hierarchy install installcheck installkernel installkernel.debug\ 69148642Ssam reinstallkernel reinstallkernel.debug installworld \ 70148642Ssam kernel-toolchain libraries lint maninstall \ 71148642Ssam obj objlink regress rerelease tags toolchain update \ 72148642Ssam _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 73148642Ssam _build-tools _cross-tools _includes _libraries _depend \ 74148642Ssam build32 distribute32 install32 75148642Ssam 76175683SmtmBITGTS= files includes 77148642SsamBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 78148642SsamTGTS+= ${BITGTS} 79108983Simp 80108983Simp.ORDER: buildworld installworld 81108983Simp.ORDER: buildworld distributeworld 82139281Sbrueffer.ORDER: buildworld buildkernel 83108983Simp.ORDER: buildkernel installkernel 84108983Simp.ORDER: buildkernel installkernel.debug 85108983Simp.ORDER: buildkernel reinstallkernel 86108983Simp.ORDER: buildkernel reinstallkernel.debug 87108983Simp 88108983SimpPATH= /sbin:/bin:/usr/sbin:/usr/bin 89108983SimpMAKEOBJDIRPREFIX?= /usr/obj 90108983Simp_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 91227994Swblock ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \ 92152326Semax -f /dev/null -V MAKEOBJDIRPREFIX dummy 93152326Semax.if !empty(_MAKEOBJDIRPREFIX) 94175683Smtm.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 95152326Semax (in /etc/make.conf) or command-line variable. 96152326Semax.endif 97152326SemaxMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 98175683SmtmBINMAKE= \ 99152326Semax `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 100152326Semax -m ${.CURDIR}/share/mk 101215195Semax_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 102215195Semax 103215195Semax# 104215195Semax# Make sure we have an up-to-date make(1). Only world and buildworld 105215195Semax# should do this as those are the initial targets used for upgrades. 106215195Semax# The user can define ALWAYS_CHECK_MAKE to have this check performed 107215195Semax# for all targets. 108139281Sbrueffer# 109134584Sbrooks.if defined(ALWAYS_CHECK_MAKE) 110134584Sbrooks${TGTS}: upgrade_checks 111156782Semax.else 112134584Sbrooksbuildworld: upgrade_checks 113134584Sbrooks.endif 114134584Sbrooks 115156331Semax# 116134584Sbrooks# This 'cleanworld' target is not included in TGTS, because it is not a 117134584Sbrooks# recursive target. All of the work for it is done right here. It is 118241084Shselasky# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 119241084Shselasky# created by bsd.obj.mk, except that we don't want to .include that file 120241084Shselasky# in this makefile. 121241084Shselasky# 122261510Shselasky# In the following, the first 'rm' in a series will usually remove all 123261510Shselasky# files and directories. If it does not, then there are probably some 124261510Shselasky# files with chflags set, so this unsets them and tries the 'rm' a 125261510Shselasky# second time. There are situations where this target will be cleaning 126261510Shselasky# some directories via more than one method, but that duplication is 127261510Shselasky# needed to correctly handle all the possible situations. 128261510Shselasky# 129261510ShselaskyBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 130261510Shselaskycleanworld: 131241084Shselasky.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 132241084Shselasky.if exists(${BW_CANONICALOBJDIR}/) 133241084Shselasky -rm -rf ${BW_CANONICALOBJDIR}/* 134138175Siedowse chflags -R 0 ${BW_CANONICALOBJDIR} 135138175Siedowse rm -rf ${BW_CANONICALOBJDIR}/* 136241084Shselasky.endif 137241084Shselasky # To be safe in this case, fall back to a 'make cleandir' 138241084Shselasky ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 139261510Shselasky.else 140261510Shselasky -rm -rf ${.OBJDIR}/* 141261510Shselasky chflags -R 0 ${.OBJDIR} 142261510Shselasky rm -rf ${.OBJDIR}/* 143261510Shselasky.endif 144261510Shselasky 145261510Shselasky# 146261510Shselasky# Handle the user-driven targets, using the source relative mk files. 147261510Shselasky# 148241084Shselasky 149241084Shselasky${TGTS}: 150241084Shselasky ${_+_}@cd ${.CURDIR}; \ 151241084Shselasky ${_MAKE} ${.TARGET} 152208060Sdougb 153179804Skmacy# Set a reasonable default 154153300Siedowse.MAIN: all 155227994Swblock 156153300SiedowseSTARTTIME!= LC_ALL=C date 157153300Siedowse 158153300Siedowse.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 159153300Siedowse# 160153300Siedowse# world 161153300Siedowse# 162153300Siedowse# Attempt to rebuild and reinstall everything. This target is not to be 163153300Siedowse# used for upgrading an existing FreeBSD system, because the kernel is 164153300Siedowse# not included. One can argue that this target doesn't build everything 165153300Siedowse# then. 166153300Siedowse# 167153300Siedowseworld: upgrade_checks 168153300Siedowse @echo "--------------------------------------------------------------" 169192198Smaxim @echo ">>> make world started on ${STARTTIME}" 170153300Siedowse @echo "--------------------------------------------------------------" 171153300Siedowse.if target(pre-world) 172153300Siedowse @echo 173153300Siedowse @echo "--------------------------------------------------------------" 174153300Siedowse @echo ">>> Making 'pre-world' target" 175207020Sthompsa @echo "--------------------------------------------------------------" 176207020Sthompsa ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 177207020Sthompsa.endif 178207020Sthompsa ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 179207020Sthompsa ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 180207020Sthompsa.if target(post-world) 181207020Sthompsa @echo 182207020Sthompsa @echo "--------------------------------------------------------------" 183153300Siedowse @echo ">>> Making 'post-world' target" 184153300Siedowse @echo "--------------------------------------------------------------" 185108983Simp ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 186148471Simp.endif 187148471Simp @echo 188108983Simp @echo "--------------------------------------------------------------" 189108983Simp @echo ">>> make world completed on `LC_ALL=C date`" 190108983Simp @echo " (started ${STARTTIME})" 191131646Simp @echo "--------------------------------------------------------------" 192108983Simp.else 193108983Simpworld: 194108983Simp @echo "WARNING: make world will overwrite your existing FreeBSD" 195114799Simp @echo "installation without also building and installing a new" 196166754Simp @echo "kernel. This can be dangerous. Please read the handbook," 197166754Simp @echo "'Rebuilding world', for how to upgrade your system." 198119254Simp @echo "Define DESTDIR to where you want to install FreeBSD," 199114852Simp @echo "including /, to override this warning and proceed as usual." 200119254Simp @echo "You may get the historical 'make world' behavior by defining" 201108983Simp @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 202166701Sjoerg @echo "before doing this." 203166701Sjoerg @echo "" 204166701Sjoerg @echo "Bailing out now..." 205166701Sjoerg @false 206166701Sjoerg.endif 207166701Sjoerg 208166701Sjoerg# 209166701Sjoerg# kernel 210166701Sjoerg# 211166701Sjoerg# Short hand for `make buildkernel installkernel' 212166701Sjoerg# 213166701Sjoergkernel: buildkernel installkernel 214166701Sjoerg 215166701Sjoerg# 216166701Sjoerg# Perform a few tests to determine if the installed tools are adequate 217166701Sjoerg# for building the world. 218166701Sjoerg# 219166701Sjoergupgrade_checks: 220166701Sjoerg @if ! (cd ${.CURDIR}/tools/build/make_check && \ 221166701Sjoerg PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 222166701Sjoerg PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 223166701Sjoerg then \ 224166701Sjoerg (cd ${.CURDIR} && make make); \ 225166701Sjoerg fi 226166701Sjoerg 227166701Sjoerg# 228166701Sjoerg# Upgrade make(1) to the current version using the installed 229166701Sjoerg# headers, libraries and tools. 230166701Sjoerg# 231166701SjoergMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 232139281Sbrueffer DESTDIR= \ 233123626Snjl INSTALL="sh ${.CURDIR}/tools/install.sh" 234123626SnjlMMAKE= ${MMAKEENV} make \ 235123626Snjl -D_UPGRADING \ 236125366Snjl -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 237123626Snjl -DNO_CPU_CFLAGS -DNO_WERROR 238123626Snjl 239125366Snjlmake: .PHONY 240125366Snjl @echo 241125366Snjl @echo "--------------------------------------------------------------" 242125366Snjl @echo ">>> Building an up-to-date make(1)" 243125366Snjl @echo "--------------------------------------------------------------" 244125366Snjl ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 245125366Snjl ${MMAKE} obj && \ 246125366Snjl ${MMAKE} depend && \ 247125366Snjl ${MMAKE} all && \ 248125366Snjl ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 249168495Spjd 250168495Spjd# 251168495Spjd# universe 252168495Spjd# 253168495Spjd# Attempt to rebuild *everything* for all supported architectures, 254168495Spjd# with a reasonable chance of success, regardless of how old your 255168495Spjd# existing system is. 256168495Spjd# 257168495Spjduniverse: universe_prologue 258168495Spjduniverse_prologue: 259168497Spjd @echo "--------------------------------------------------------------" 260168495Spjd @echo ">>> make universe started on ${STARTTIME}" 261168495Spjd @echo "--------------------------------------------------------------" 262168495Spjd.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 263168495Spjd.for arch in ${target:C/:.*$//} 264168495Spjd.for mach in ${target:C/^.*://} 265168495Spjduniverse: universe_${mach} 266168495Spjd.ORDER: universe_prologue universe_${mach} universe_epilogue 267168495Spjduniverse_${mach}: 268168495Spjd @echo ">> ${mach} started on `LC_ALL=C date`" 269168495Spjd -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 270168495Spjd TARGET_ARCH=${arch} TARGET=${mach} \ 271168495Spjd __MAKE_CONF=/dev/null \ 272168495Spjd > _.${mach}.buildworld 2>&1 273168495Spjd @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 274168495Spjd.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 275168495Spjd -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 276168495Spjd > ${.CURDIR}/_.${mach}.makeLINT 2>&1 277168495Spjd.endif 278168495Spjd cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 279168495Spjd @echo ">> ${mach} completed on `LC_ALL=C date`" 280170976Snjl.endfor 281170976Snjl.endfor 282170976Snjl.endfor 283170976Snjluniverse: universe_epilogue 284170976Snjluniverse_epilogue: 285170976Snjl @echo "--------------------------------------------------------------" 286170976Snjl @echo ">>> make universe completed on `LC_ALL=C date`" 287170976Snjl @echo " (started ${STARTTIME})" 288170976Snjl @echo "--------------------------------------------------------------" 289170976Snjl 290170976Snjl.if make(buildkernels) 291170976SnjlKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 292170976Snjl find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 293108983Simpbuildkernels: 294108983Simp.for kernel in ${KERNCONFS} 295227994Swblock -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 296227994Swblock KERNCONF=${kernel} \ 297227994Swblock __MAKE_CONF=/dev/null \ 298227994Swblock > _.${TARGET}.${kernel} 2>&1 299227994Swblock.endfor 300108983Simp.endif 301108983Simp