Makefile revision 147425
12061Sjkh# 250479Speter# $FreeBSD: head/Makefile 147425 2005-06-16 18:16:14Z ru $ 32061Sjkh# 438666Sjb# The user-driven targets are: 532427Sjb# 638666Sjb# universe - *Really* build *everything* (buildworld and 738666Sjb# all kernels on all architectures). 838666Sjb# buildworld - Rebuild *everything*, including glue to help do 938666Sjb# upgrades. 1064049Salex# installworld - Install everything built by "buildworld". 1164049Salex# world - buildworld + installworld. 1266071Smarkm# buildkernel - Rebuild the kernel and the kernel-modules. 1373504Sobrien# installkernel - Install the kernel and the kernel-modules. 1438666Sjb# installkernel.debug 1544918Sjkh# reinstallkernel - Reinstall the kernel and the kernel-modules. 1638666Sjb# reinstallkernel.debug 1738666Sjb# kernel - buildkernel + installkernel. 1838666Sjb# update - Convenient way to update your source tree (cvs). 1938666Sjb# 2038666Sjb# This makefile is simple by design. The FreeBSD make automatically reads 2138666Sjb# the /usr/share/mk/sys.mk unless the -m argument is specified on the 2238666Sjb# command line. By keeping this makefile simple, it doesn't matter too 2338978Sjb# much how different the installed mk files are from those in the source 2438978Sjb# tree. This makefile executes a child make process, forcing it to use 2532427Sjb# the mk files from the source tree which are supposed to DTRT. 2638666Sjb# 2738666Sjb# The user-driven targets (as listed above) are implemented in Makefile.inc1. 2838666Sjb# 2938666Sjb# If you want to build your system from source be sure that /usr/obj has 3038666Sjb# at least 400MB of diskspace available. 3138666Sjb# 3217308Speter# For individuals wanting to build from the sources currently on their 3391606Skeramida# system, the simple instructions are: 3419175Sbde# 3538666Sjb# 1. `cd /usr/src' (or to the directory containing your source tree). 3638666Sjb# 2. `make world' 3738042Sbde# 3839726Sjb# For individuals wanting to upgrade their sources (even if only a 3938666Sjb# delta of a few days): 4038666Sjb# 4138042Sbde# 1. `cd /usr/src' (or to the directory containing your source tree). 4238666Sjb# 2. `make buildworld' 4349315Shoek# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4417308Speter# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4538666Sjb# 5. `reboot' (in single user mode: boot -s from the loader prompt). 4638666Sjb# 6. `mergemaster -p' 4738666Sjb# 7. `make installworld' 4838666Sjb# 8. `mergemaster' 4917308Speter# 9. `reboot' 5045108Sobrien# 5142128Speter# See src/UPDATING `COMMON ITEMS' for more complete information. 5242128Speter# 5338666Sjb# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 5451361Sjb# cross build world for other architectures using the buildworld target, 5538666Sjb# and once the world is built you can cross build a kernel using the 5617308Speter# buildkernel target. 5738666Sjb# 5817308Speter# Define the user-driven targets. These are listed here in alphabetical 5938666Sjb# order, but that's not important. 6017308Speter# 6127910Sasami# Targets that begin with underscore are internal targets intended for 6243226Sjkh# developer convenience only. They are intentionally not documented and 6343226Sjkh# completely subject to change without notice. 6443226Sjkh# 6538666SjbTGTS= all all-man buildenv buildkernel buildworld checkdpadd clean \ 6627910Sasami cleandepend cleandir depend distribute distributeworld \ 6738666Sjb distribution everything \ 6838666Sjb hierarchy install installcheck installkernel installkernel.debug\ 6938666Sjb reinstallkernel reinstallkernel.debug installworld \ 7027910Sasami kernel-toolchain libraries lint maninstall \ 7138666Sjb obj objlink regress rerelease tags toolchain update \ 7238666Sjb _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 7343226Sjkh _build-tools _cross-tools _includes _libraries _depend \ 7443226Sjkh build32 distribute32 install32 7527910Sasami 7638666SjbBITGTS= files includes 7738666SjbBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 7827910SasamiTGTS+= ${BITGTS} 7938666Sjb 8027910Sasami.ORDER: buildworld installworld 8117308Speter.ORDER: buildworld distributeworld 8238666Sjb.ORDER: buildworld buildkernel 8338666Sjb.ORDER: buildkernel installkernel 8417308Speter.ORDER: buildkernel installkernel.debug 8574842Sru.ORDER: buildkernel reinstallkernel 8668987Smarcel.ORDER: buildkernel reinstallkernel.debug 8795146Sgshapiro 8895146SgshapiroPATH= /sbin:/bin:/usr/sbin:/usr/bin 8995146SgshapiroMAKEOBJDIRPREFIX?= /usr/obj 902061Sjkh_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 9155026Smarcel ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \ 9255026Smarcel -f /dev/null -V MAKEOBJDIRPREFIX dummy 9354324Smarcel.if !empty(_MAKEOBJDIRPREFIX) 9417308Speter.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 9538666Sjb (in /etc/make.conf) or command-line variable. 9617308Speter.endif 9755678SmarcelMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 9838666SjbBINMAKE= \ 9954324Smarcel `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 1002302Spaul -m ${.CURDIR}/share/mk 10139206Sjkh_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 10239206Sjkh 10339206Sjkh# 10473349Sru# Make sure we have an up-to-date make(1). Only world and buildworld 10517308Speter# should do this as those are the initial targets used for upgrades. 10654324Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed 10754324Smarcel# for all targets. 10854324Smarcel# 10954324Smarcel.if defined(ALWAYS_CHECK_MAKE) 11054324Smarcel${TGTS}: upgrade_checks 11154324Smarcel.else 11254324Smarcelbuildworld: upgrade_checks 11369659Sobrien.endif 11454324Smarcel 11554324Smarcel# 11654324Smarcel# This 'cleanworld' target is not included in TGTS, because it is not a 11754324Smarcel# recursive target. All of the work for it is done right here. It is 11854324Smarcel# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 11954324Smarcel# created by bsd.obj.mk, except that we don't want to .include that file 12054324Smarcel# in this makefile. 12154324Smarcel# 12254324Smarcel# In the following, the first 'rm' in a series will usually remove all 12354324Smarcel# files and directories. If it does not, then there are probably some 12454324Smarcel# files with chflags set, so this unsets them and tries the 'rm' a 12554324Smarcel# second time. There are situations where this target will be cleaning 12654324Smarcel# some directories via more than one method, but that duplication is 12754324Smarcel# needed to correctly handle all the possible situations. 12854324Smarcel# 12954324SmarcelBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 13054324Smarcelcleanworld: 13154324Smarcel.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 13254324Smarcel.if exists(${BW_CANONICALOBJDIR}/) 13373504Sobrien -rm -rf ${BW_CANONICALOBJDIR}/* 13454324Smarcel chflags -R 0 ${BW_CANONICALOBJDIR} 13554324Smarcel rm -rf ${BW_CANONICALOBJDIR}/* 13654324Smarcel.endif 13738666Sjb # To be safe in this case, fall back to a 'make cleandir' 13838666Sjb ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 13917308Speter.else 14038666Sjb -rm -rf ${.OBJDIR}/* 14138666Sjb chflags -R 0 ${.OBJDIR} 14238666Sjb rm -rf ${.OBJDIR}/* 14317308Speter.endif 14455678Smarcel 14555678Smarcel# 14655678Smarcel# Handle the user-driven targets, using the source relative mk files. 14755678Smarcel# 14855678Smarcel 14990395Sru${TGTS}: 15090395Sru ${_+_}@cd ${.CURDIR}; \ 15190395Sru ${_MAKE} ${.TARGET} 15290395Sru 15390395Sru# Set a reasonable default 1542061Sjkh.MAIN: all 15517308Speter 15638666SjbSTARTTIME!= LC_ALL=C date 15738666Sjb 15817308Speter.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 15955678Smarcel# 1603626Swollman# world 16117308Speter# 16255678Smarcel# Attempt to rebuild and reinstall everything. This target is not to be 16355678Smarcel# used for upgrading an existing FreeBSD system, because the kernel is 16455678Smarcel# not included. One can argue that this target doesn't build everything 16555678Smarcel# then. 16655678Smarcel# 16755678Smarcelworld: upgrade_checks 16855678Smarcel @echo "--------------------------------------------------------------" 16955678Smarcel @echo ">>> make world started on ${STARTTIME}" 17055678Smarcel @echo "--------------------------------------------------------------" 17155678Smarcel.if target(pre-world) 17255678Smarcel @echo 17355678Smarcel @echo "--------------------------------------------------------------" 17455678Smarcel @echo ">>> Making 'pre-world' target" 17538666Sjb @echo "--------------------------------------------------------------" 17638666Sjb ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 17717308Speter.endif 17855678Smarcel ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 17938978Sjb ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 1803626Swollman.if target(post-world) 18117308Speter @echo 18238666Sjb @echo "--------------------------------------------------------------" 18317308Speter @echo ">>> Making 'post-world' target" 18443226Sjkh @echo "--------------------------------------------------------------" 18543226Sjkh ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 18643226Sjkh.endif 18738666Sjb @echo 18838666Sjb @echo "--------------------------------------------------------------" 18944103Smsmith @echo ">>> make world completed on `LC_ALL=C date`" 190 @echo " (started ${STARTTIME})" 191 @echo "--------------------------------------------------------------" 192.else 193world: 194 @echo "WARNING: make world will overwrite your existing FreeBSD" 195 @echo "installation without also building and installing a new" 196 @echo "kernel. This can be dangerous. Please read the handbook," 197 @echo "'Rebuilding world', for how to upgrade your system." 198 @echo "Define DESTDIR to where you want to install FreeBSD," 199 @echo "including /, to override this warning and proceed as usual." 200 @echo "You may get the historical 'make world' behavior by defining" 201 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 202 @echo "before doing this." 203 @echo "" 204 @echo "Bailing out now..." 205 @false 206.endif 207 208# 209# kernel 210# 211# Short hand for `make buildkernel installkernel' 212# 213kernel: buildkernel installkernel 214 215# 216# Perform a few tests to determine if the installed tools are adequate 217# for building the world. 218# 219upgrade_checks: 220 @if ! (cd ${.CURDIR}/tools/build/make_check && \ 221 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 222 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 223 then \ 224 (cd ${.CURDIR} && make make); \ 225 fi 226 227# 228# Upgrade make(1) to the current version using the installed 229# headers, libraries and tools. 230# 231MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 232 DESTDIR= \ 233 INSTALL="sh ${.CURDIR}/tools/install.sh" 234MMAKE= ${MMAKEENV} make \ 235 -D_UPGRADING \ 236 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 237 -DNO_CPU_CFLAGS -DNO_WERROR 238 239make: .PHONY 240 @echo 241 @echo "--------------------------------------------------------------" 242 @echo ">>> Building an up-to-date make(1)" 243 @echo "--------------------------------------------------------------" 244 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 245 ${MMAKE} obj && \ 246 ${MMAKE} depend && \ 247 ${MMAKE} all && \ 248 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 249 250# 251# universe 252# 253# Attempt to rebuild *everything* for all supported architectures, 254# with a reasonable chance of success, regardless of how old your 255# existing system is. 256# 257universe: universe_prologue 258universe_prologue: 259 @echo "--------------------------------------------------------------" 260 @echo ">>> make universe started on ${STARTTIME}" 261 @echo "--------------------------------------------------------------" 262.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 263.for arch in ${target:C/:.*$//} 264.for mach in ${target:C/^.*://} 265universe: universe_${mach} 266.ORDER: universe_prologue universe_${mach} universe_epilogue 267universe_${mach}: 268 @echo ">> ${mach} started on `LC_ALL=C date`" 269 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 270 TARGET_ARCH=${arch} TARGET=${mach} \ 271 __MAKE_CONF=/dev/null \ 272 > _.${mach}.buildworld 2>&1 273 @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 274.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 275 -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 276 > ${.CURDIR}/_.${mach}.makeLINT 2>&1 277.endif 278 cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 279 @echo ">> ${mach} completed on `LC_ALL=C date`" 280.endfor 281.endfor 282.endfor 283universe: universe_epilogue 284universe_epilogue: 285 @echo "--------------------------------------------------------------" 286 @echo ">>> make universe completed on `LC_ALL=C date`" 287 @echo " (started ${STARTTIME})" 288 @echo "--------------------------------------------------------------" 289 290.if make(buildkernels) 291KERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 292 find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 293buildkernels: 294.for kernel in ${KERNCONFS} 295 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 296 KERNCONF=${kernel} \ 297 __MAKE_CONF=/dev/null \ 298 > _.${TARGET}.${kernel} 2>&1 299.endfor 300.endif 301