Makefile revision 142644
172172Sphantom# 272172Sphantom# $FreeBSD: head/Makefile 142644 2005-02-27 12:11:35Z ru $ 3136487Sru# 4118459Smtm# The user-driven targets are: 5123682Sache# 6123682Sache# universe - *Really* build *everything* (buildworld and 7123682Sache# all kernels on all architectures). 8127474Stjr# buildworld - Rebuild *everything*, including glue to help do 986072Sache# upgrades. 10127474Stjr# installworld - Install everything built by "buildworld". 11108428Sache# world - buildworld + installworld. 1277982Sache# buildkernel - Rebuild the kernel and the kernel-modules. 13127474Stjr# installkernel - Install the kernel and the kernel-modules. 1477982Sache# installkernel.debug 1577982Sache# reinstallkernel - Reinstall the kernel and the kernel-modules. 1688479Sphantom# reinstallkernel.debug 1777982Sache# kernel - buildkernel + installkernel. 1877982Sache# update - Convenient way to update your source tree (cvs). 1977982Sache# 2077982Sache# This makefile is simple by design. The FreeBSD make automatically reads 2177982Sache# the /usr/share/mk/sys.mk unless the -m argument is specified on the 22127474Stjr# command line. By keeping this makefile simple, it doesn't matter too 23127474Stjr# much how different the installed mk files are from those in the source 2477982Sache# tree. This makefile executes a child make process, forcing it to use 2577982Sache# the mk files from the source tree which are supposed to DTRT. 2677982Sache# 2777982Sache# The user-driven targets (as listed above) are implemented in Makefile.inc1. 2877982Sache# 2990583Sphantom# If you want to build your system from source be sure that /usr/obj has 3088473Sphantom# at least 400MB of diskspace available. 3177982Sache# 32128526Stjr# For individuals wanting to build from the sources currently on their 3387043Sache# system, the simple instructions are: 3477982Sache# 3577982Sache# 1. `cd /usr/src' (or to the directory containing your source tree). 36117259Sache# 2. `make world' 37127474Stjr# 3877982Sache# For individuals wanting to upgrade their sources (even if only a 3977982Sache# delta of a few days): 4088473Sphantom# 41127547Stjr# 1. `cd /usr/src' (or to the directory containing your source tree). 42125208Sache# 2. `make buildworld' 43127474Stjr# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4488473Sphantom# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 45127549Stjr# 5. `reboot' (in single user mode: boot -s from the loader prompt). 46105965Sache# 6. `mergemaster -p' 47196812Sache# 7. `make installworld' 48162940Sache# 8. `mergemaster' 4990587Sphantom# 9. `reboot' 5077982Sache# 5177982Sache# See src/UPDATING `COMMON ITEMS' for more complete information. 5277982Sache# 53127474Stjr# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 5493885Sphantom# cross build world for other architectures using the buildworld target, 5577982Sache# and once the world is built you can cross build a kernel using the 56193962Sedwin# buildkernel target. 57193962Sedwin# 5889077Sache# Define the user-driven targets. These are listed here in alphabetical 59115924Sache# order, but that's not important. 6072707Sphantom# 6177982Sache# Targets that begin with underscore are internal targets intended for 6272208Sasmodai# developer convenience only. They are intentionally not documented and 63127474Stjr# completely subject to change without notice. 6477982Sache# 6577982SacheTGTS= all all-man buildenv buildkernel buildworld checkdpadd clean \ 66105445Sache cleandepend cleandir depend distribute distributeworld \ 67105445Sache distribution everything \ 68127474Stjr hierarchy install installcheck installkernel installkernel.debug\ 6977982Sache reinstallkernel reinstallkernel.debug installworld \ 7077982Sache kernel-toolchain libraries lint maninstall \ 71143126Sru obj objlink regress rerelease tags toolchain update \ 7288314Sache _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 7372565Sache _build-tools _cross-tools _includes _libraries _depend \ 74127474Stjr build32 install32 7588473Sphantom 76118174SacheBITGTS= files includes 77122151SdavidxuBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 78127474StjrTGTS+= ${BITGTS} 79127474Stjr 8088473Sphantom.ORDER: buildworld installworld 8172172Sphantom.ORDER: buildworld distributeworld 82136487Sru.ORDER: buildworld buildkernel 8372172Sphantom.ORDER: buildkernel installkernel 8472172Sphantom.ORDER: buildkernel installkernel.debug 8572172Sphantom.ORDER: buildkernel reinstallkernel 8672172Sphantom.ORDER: buildkernel reinstallkernel.debug 8772172Sphantom 8872172SphantomPATH= /sbin:/bin:/usr/sbin:/usr/bin 89136487SruMAKEOBJDIRPREFIX?= /usr/obj 90136487Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 9172172Sphantom ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \ 9272260Swollman -f /dev/null -V MAKEOBJDIRPREFIX dummy 93136487Sru.if !empty(_MAKEOBJDIRPREFIX) 9472260Swollman.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 95136487Sru (in /etc/make.conf) or command-line variable. 96136487Sru.endif 97136487SruMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 98136487SruBINMAKE= \ 99136487Sru `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 100136487Sru -m ${.CURDIR}/share/mk 101136487Sru_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 102136487Sru 103136487Sru# 104136487Sru# Make sure we have an up-to-date make(1). Only world and buildworld 105136487Sru# should do this as those are the initial targets used for upgrades. 106193908Sedwin# The user can define ALWAYS_CHECK_MAKE to have this check performed 107193908Sedwin# for all targets. 108193908Sedwin# 109193908Sedwin.if defined(ALWAYS_CHECK_MAKE) 110193908Sedwin${TGTS}: upgrade_checks 111193962Sedwin.else 112136487Srubuildworld: upgrade_checks 113193908Sedwin.endif 114193908Sedwin 115193908Sedwin# 116193962Sedwin# This 'cleanworld' target is not included in TGTS, because it is not a 117136487Sru# recursive target. All of the work for it is done right here. It is 118136487Sru# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 119136487Sru# created by bsd.obj.mk, except that we don't want to .include that file 120136487Sru# in this makefile. 121196812Sache# 122136487Sru# In the following, the first 'rm' in a series will usually remove all 123136487Sru# files and directories. If it does not, then there are probably some 124136487Sru# files with chflags set, so this unsets them and tries the 'rm' a 125193908Sedwin# second time. There are situations where this target will be cleaning 126193908Sedwin# some directories via more than one method, but that duplication is 127136487Sru# needed to correctly handle all the possible situations. 128136487Sru# 129136487SruBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 130136487Srucleanworld: 131136487Sru.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 132136487Sru.if exists(${BW_CANONICALOBJDIR}/) 133136487Sru -rm -rf ${BW_CANONICALOBJDIR}/* 13478010Sache chflags -R 0 ${BW_CANONICALOBJDIR} 13578008Sache rm -rf ${BW_CANONICALOBJDIR}/* 13690579Sphantom.endif 137127474Stjr # To be safe in this case, fall back to a 'make cleandir' 13872172Sphantom ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 139.else 140 -rm -rf ${.OBJDIR}/* 141 chflags -R 0 ${.OBJDIR} 142 rm -rf ${.OBJDIR}/* 143.endif 144 145# 146# Handle the user-driven targets, using the source relative mk files. 147# 148 149${TGTS}: 150 ${_+_}@cd ${.CURDIR}; \ 151 ${_MAKE} ${.TARGET} 152 153# Set a reasonable default 154.MAIN: all 155 156STARTTIME!= LC_ALL=C date 157 158.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 159# 160# world 161# 162# Attempt to rebuild and reinstall everything. This target is not to be 163# used for upgrading an existing FreeBSD system, because the kernel is 164# not included. One can argue that this target doesn't build everything 165# then. 166# 167world: upgrade_checks 168 @echo "--------------------------------------------------------------" 169 @echo ">>> make world started on ${STARTTIME}" 170 @echo "--------------------------------------------------------------" 171.if target(pre-world) 172 @echo 173 @echo "--------------------------------------------------------------" 174 @echo ">>> Making 'pre-world' target" 175 @echo "--------------------------------------------------------------" 176 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 177.endif 178 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 179 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 180.if target(post-world) 181 @echo 182 @echo "--------------------------------------------------------------" 183 @echo ">>> Making 'post-world' target" 184 @echo "--------------------------------------------------------------" 185 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 186.endif 187 @echo 188 @echo "--------------------------------------------------------------" 189 @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/regression/usr.bin/make && \ 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