Makefile revision 138515
1138568Ssam# 2186904Ssam# $FreeBSD: head/Makefile 138515 2004-12-07 14:41:16Z harti $ 3138568Ssam# 4138568Ssam# The user-driven targets are: 5138568Ssam# 6138568Ssam# universe - *Really* build *everything* (buildworld and 7138568Ssam# all kernels on all architectures). 8138568Ssam# buildworld - Rebuild *everything*, including glue to help do 9138568Ssam# upgrades. 10138568Ssam# installworld - Install everything built by "buildworld". 11138568Ssam# world - buildworld + installworld. 12138568Ssam# buildkernel - Rebuild the kernel and the kernel-modules. 13138568Ssam# installkernel - Install the kernel and the kernel-modules. 14138568Ssam# installkernel.debug 15138568Ssam# reinstallkernel - Reinstall the kernel and the kernel-modules. 16138568Ssam# reinstallkernel.debug 17138568Ssam# kernel - buildkernel + installkernel. 18138568Ssam# update - Convenient way to update your source tree (cvs). 19138568Ssam# 20138568Ssam# This makefile is simple by design. The FreeBSD make automatically reads 21138568Ssam# the /usr/share/mk/sys.mk unless the -m argument is specified on the 22138568Ssam# command line. By keeping this makefile simple, it doesn't matter too 23138568Ssam# much how different the installed mk files are from those in the source 24138568Ssam# tree. This makefile executes a child make process, forcing it to use 25138568Ssam# the mk files from the source tree which are supposed to DTRT. 26138568Ssam# 27138568Ssam# The user-driven targets (as listed above) are implemented in Makefile.inc1. 28138568Ssam# 29138568Ssam# If you want to build your system from source be sure that /usr/obj has 30138568Ssam# at least 400MB of diskspace available. 31138568Ssam# 32178354Ssam# For individuals wanting to build from the sources currently on their 33178354Ssam# system, the simple instructions are: 34138568Ssam# 35138568Ssam# 1. `cd /usr/src' (or to the directory containing your source tree). 36293470Smelifaro# 2. `make world' 37295126Sglebius# 38138568Ssam# For individuals wanting to upgrade their sources (even if only a 39295126Sglebius# delta of a few days): 40138568Ssam# 41138568Ssam# 1. `cd /usr/src' (or to the directory containing your source tree). 42138568Ssam# 2. `make buildworld' 43138568Ssam# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 44138568Ssam# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 45138568Ssam# 5. `reboot' (in single user mode: boot -s from the loader prompt). 46138568Ssam# 6. `mergemaster -p' 47192468Ssam# 7. `make installworld' 48138568Ssam# 8. `mergemaster' 49257176Sglebius# 9. `reboot' 50190526Ssam# 51178354Ssam# See src/UPDATING `COMMON ITEMS' for more complete information. 52138568Ssam# 53178354Ssam# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 54138568Ssam# cross build world for other architectures using the buildworld target, 55138568Ssam# and once the world is built you can cross build a kernel using the 56196019Srwatson# buildkernel target. 57138568Ssam# 58138568Ssam# Define the user-driven targets. These are listed here in alphabetical 59195757Ssam# order, but that's not important. 60138568Ssam# 61138568Ssam# Targets that begin with underscore are internal targets intended for 62138568Ssam# developer convenience only. They are intentionally not documented and 63138568Ssam# completely subject to change without notice. 64138568Ssam# 65138568SsamTGTS= all all-man buildkernel buildworld checkdpadd clean \ 66138568Ssam cleandepend cleandir depend distribute distributeworld everything \ 67138568Ssam hierarchy install installcheck installkernel installkernel.debug\ 68138568Ssam reinstallkernel reinstallkernel.debug installworld \ 69227293Sed kernel-toolchain libraries lint maninstall \ 70178354Ssam obj objlink regress rerelease tags toolchain update \ 71241610Sglebius _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 72241610Sglebius _build-tools _cross-tools _includes _libraries _depend \ 73241610Sglebius build32 install32 74138568Ssam 75178354SsamBITGTS= files includes 76173273SsamBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 77178354SsamTGTS+= ${BITGTS} 78178354Ssam 79178354Ssam.ORDER: buildworld installworld 80173273Ssam.ORDER: buildworld distributeworld 81173273Ssam.ORDER: buildworld buildkernel 82178354Ssam.ORDER: buildkernel installkernel 83178354Ssam.ORDER: buildkernel installkernel.debug 84178354Ssam.ORDER: buildkernel reinstallkernel 85287197Sglebius.ORDER: buildkernel reinstallkernel.debug 86287197Sglebius 87178354SsamPATH= /sbin:/bin:/usr/sbin:/usr/bin 88178957SsamMAKEOBJDIRPREFIX?= /usr/obj 89287197Sglebius_MAKEOBJDIRPREFIX!= /usr/bin/env -i \ 90287197Sglebius PATH=${PATH} MAKEFLAGS="${.MAKEFLAGS}" ${MAKE} \ 91178354Ssam -f /dev/null -V MAKEOBJDIRPREFIX dummy 92178354Ssam.if !empty(_MAKEOBJDIRPREFIX) 93178957Ssam.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 94287197Sglebius (in /etc/make.conf) or command-line variable. 95178957Ssam.endif 96178957SsamMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 97178957SsamBINMAKE= \ 98186904Ssam `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 99186904Ssam -m ${.CURDIR}/share/mk 100186904Ssam_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 101186904Ssam 102186904Ssam# 103186904Ssam# Make sure we have an up-to-date make(1). Only world and buildworld 104186904Ssam# should do this as those are the initial targets used for upgrades. 105287197Sglebius# The user can define ALWAYS_CHECK_MAKE to have this check performed 106186904Ssam# for all targets. 107186904Ssam# 108241610Sglebius.if defined(ALWAYS_CHECK_MAKE) 109178354Ssam${TGTS}: upgrade_checks 110178354Ssam.else 111287197Sglebiusbuildworld: upgrade_checks 112242154Sadrian.endif 113178354Ssam 114178354Ssam# 115178354Ssam# This 'cleanworld' target is not included in TGTS, because it is not a 116178354Ssam# recursive target. All of the work for it is done right here. It is 117178354Ssam# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 118178354Ssam# created by bsd.obj.mk, except that we don't want to .include that file 119178354Ssam# in this makefile. 120178354Ssam# 121178354Ssam# In the following, the first 'rm' in a series will usually remove all 122178354Ssam# files and directories. If it does not, then there are probably some 123178354Ssam# files with chflags set, so this unsets them and tries the 'rm' a 124178354Ssam# second time. There are situations where this target will be cleaning 125178354Ssam# some directories via more than one method, but that duplication is 126178354Ssam# needed to correctly handle all the possible situations. 127178354Ssam# 128242149SadrianBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 129241610Sglebiuscleanworld: 130242149Sadrian.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 131178354Ssam.if exists(${BW_CANONICALOBJDIR}/) 132178354Ssam -rm -rf ${BW_CANONICALOBJDIR}/* 133192473Ssam chflags -R 0 ${BW_CANONICALOBJDIR} 134178354Ssam rm -rf ${BW_CANONICALOBJDIR}/* 135178354Ssam.endif 136178354Ssam # To be safe in this case, fall back to a 'make cleandir' 137178354Ssam ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 138178354Ssam.else 139178354Ssam -rm -rf ${.OBJDIR}/* 140173273Ssam chflags -R 0 ${.OBJDIR} 141173273Ssam rm -rf ${.OBJDIR}/* 142178354Ssam.endif 143178354Ssam 144173273Ssam# 145173273Ssam# Handle the user-driven targets, using the source relative mk files. 146178354Ssam# 147173273Ssam 148138568Ssam${TGTS}: 149138568Ssam ${_+_}@cd ${.CURDIR}; \ 150138568Ssam ${_MAKE} ${.TARGET} 151138568Ssam 152138568Ssam# Set a reasonable default 153138568Ssam.MAIN: all 154138568Ssam 155138568SsamSTARTTIME!= LC_ALL=C date 156138568Ssam 157138568Ssam.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 158138568Ssam# 159138568Ssam# world 160138568Ssam# 161138568Ssam# Attempt to rebuild and reinstall everything. This target is not to be 162138568Ssam# used for upgrading an existing FreeBSD system, because the kernel is 163138568Ssam# not included. One can argue that this target doesn't build everything 164138568Ssam# then. 165283529Sglebius# 166138568Ssamworld: upgrade_checks 167138568Ssam @echo "--------------------------------------------------------------" 168181194Ssam @echo ">>> make world started on ${STARTTIME}" 169181194Ssam @echo "--------------------------------------------------------------" 170181194Ssam.if target(pre-world) 171181194Ssam @echo 172181194Ssam @echo "--------------------------------------------------------------" 173181194Ssam @echo ">>> Making 'pre-world' target" 174181194Ssam @echo "--------------------------------------------------------------" 175181194Ssam ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 176181194Ssam.endif 177181194Ssam ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 178181194Ssam ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 179181194Ssam.if target(post-world) 180181194Ssam @echo 181181194Ssam @echo "--------------------------------------------------------------" 182181194Ssam @echo ">>> Making 'post-world' target" 183138568Ssam @echo "--------------------------------------------------------------" 184138568Ssam ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 185138568Ssam.endif 186178354Ssam @echo 187178354Ssam @echo "--------------------------------------------------------------" 188178354Ssam @echo ">>> make world completed on `LC_ALL=C date`" 189178354Ssam @echo " (started ${STARTTIME})" 190178354Ssam @echo "--------------------------------------------------------------" 191178354Ssam.else 192178354Ssamworld: 193178354Ssam @echo "WARNING: make world will overwrite your existing FreeBSD" 194178354Ssam @echo "installation without also building and installing a new" 195178354Ssam @echo "kernel. This can be dangerous. Please read the handbook," 196178354Ssam @echo "'Rebuilding world', for how to upgrade your system." 197138568Ssam @echo "Define DESTDIR to where you want to install FreeBSD," 198138568Ssam @echo "including /, to override this warning and proceed as usual." 199138568Ssam @echo "You may get the historical 'make world' behavior by defining" 200138568Ssam @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 201283538Sadrian @echo "before doing this." 202283538Sadrian @echo "" 203138568Ssam @echo "Bailing out now..." 204178354Ssam @false 205138568Ssam.endif 206138568Ssam 207138568Ssam# 208138568Ssam# kernel 209178354Ssam# 210138568Ssam# Short hand for `make buildkernel installkernel' 211138568Ssam# 212138568Ssamkernel: buildkernel installkernel 213217554Smdf 214178354Ssam# 215217322Smdf# Perform a few tests to determine if the installed tools are adequate 216178354Ssam# for building the world. 217178354Ssam# 218138568Ssamupgrade_checks: 219178354Ssam @if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \ 220217322Smdf PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 221178354Ssam PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 222138568Ssam then \ 223138568Ssam (cd ${.CURDIR} && make make); \ 224178354Ssam fi 225178354Ssam 226178354Ssam# 227138568Ssam# Upgrade make(1) to the current version using the installed 228138568Ssam# headers, libraries and tools. 229178354Ssam# 230138568SsamMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 231138568Ssam DESTDIR= \ 232138568Ssam INSTALL="sh ${.CURDIR}/tools/install.sh" 233178354SsamMMAKE= ${MMAKEENV} make \ 234138568Ssam -D_UPGRADING \ 235138568Ssam -DNOMAN -DNOSHARED \ 236138568Ssam -DNO_CPU_CFLAGS -DNO_WERROR 237178354Ssam 238138568Ssammake: .PHONY 239138568Ssam @echo 240138568Ssam @echo "--------------------------------------------------------------" 241178354Ssam @echo ">>> Building an up-to-date make(1)" 242138568Ssam @echo "--------------------------------------------------------------" 243138568Ssam ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 244178354Ssam ${MMAKE} obj && \ 245217322Smdf ${MMAKE} depend && \ 246178354Ssam ${MMAKE} all && \ 247178354Ssam ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 248178354Ssam 249217322Smdf# 250178354Ssam# universe 251178354Ssam# 252178354Ssam# Attempt to rebuild *everything* for all supported architectures, 253217322Smdf# with a reasonable chance of success, regardless of how old your 254178354Ssam# existing system is. 255178354Ssam# 256178354Ssamuniverse: universe_prologue 257217322Smdfuniverse_prologue: 258178354Ssam @echo "--------------------------------------------------------------" 259178354Ssam @echo ">>> make universe started on ${STARTTIME}" 260178354Ssam @echo "--------------------------------------------------------------" 261178354Ssam.for target in i386 i386:pc98 sparc64 alpha ia64 amd64 262181194Ssam.for arch in ${target:C/:.*$//} 263181194Ssam.for mach in ${target:C/^.*://} 264181194Ssamuniverse: universe_${mach} 265193115Ssam.ORDER: universe_prologue universe_${mach} universe_epilogue 266181194Ssamuniverse_${mach}: 267178354Ssam @echo ">> ${mach} started on `LC_ALL=C date`" 268178354Ssam -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 269138568Ssam TARGET_ARCH=${arch} TARGET=${mach} \ 270138568Ssam __MAKE_CONF=/dev/null \ 271138568Ssam > _.${mach}.buildworld 2>&1 272178354Ssam @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 273138568Ssam.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 274138568Ssam -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 275178354Ssam > ${.CURDIR}/_.${mach}.makeLINT 2>&1 276178354Ssam.endif 277283538Sadrian cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 278178354Ssam @echo ">> ${mach} completed on `LC_ALL=C date`" 279138568Ssam.endfor 280138568Ssam.endfor 281138568Ssam.endfor 282138568Ssamuniverse: universe_epilogue 283138568Ssamuniverse_epilogue: 284138568Ssam @echo "--------------------------------------------------------------" 285138568Ssam @echo ">>> make universe completed on `LC_ALL=C date`" 286138568Ssam @echo " (started ${STARTTIME})" 287138568Ssam @echo "--------------------------------------------------------------" 288138568Ssam 289138568Ssam.if make(buildkernels) 290165894SsamKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 291165894Ssam find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 292165894Ssambuildkernels: 293165894Ssam.for kernel in ${KERNCONFS} 294165894Ssam -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 295165894Ssam KERNCONF=${kernel} \ 296165894Ssam __MAKE_CONF=/dev/null \ 297165894Ssam > _.${TARGET}.${kernel} 2>&1 298165894Ssam.endfor 299165894Ssam.endif 300165894Ssam