Makefile revision 164470
1103285Sikob# 2103285Sikob# $FreeBSD: head/Makefile 164470 2006-11-21 08:25:28Z jb $ 3103285Sikob# 4103285Sikob# The user-driven targets are: 5103285Sikob# 6103285Sikob# universe - *Really* build *everything* (buildworld and 7103285Sikob# all kernels on all architectures). 8103285Sikob# buildworld - Rebuild *everything*, including glue to help do 9103285Sikob# upgrades. 10103285Sikob# installworld - Install everything built by "buildworld". 11103285Sikob# world - buildworld + installworld, no kernel. 12103285Sikob# buildkernel - Rebuild the kernel and the kernel-modules. 13103285Sikob# installkernel - Install the kernel and the kernel-modules. 14103285Sikob# installkernel.debug 15103285Sikob# reinstallkernel - Reinstall the kernel and the kernel-modules. 16103285Sikob# reinstallkernel.debug 17103285Sikob# kernel - buildkernel + installkernel. 18103285Sikob# doxygen - Build API documentation of the kernel, needs doxygen. 19103285Sikob# update - Convenient way to update your source tree (cvs). 20103285Sikob# check-old - Print a list of old files/directories in the system. 21103285Sikob# delete-old - Delete obsolete files and directories interactively. 22103285Sikob# delete-old-libs - Delete obsolete libraries interactively. 23103285Sikob# 24103285Sikob# This makefile is simple by design. The FreeBSD make automatically reads 25103285Sikob# the /usr/share/mk/sys.mk unless the -m argument is specified on the 26103285Sikob# command line. By keeping this makefile simple, it doesn't matter too 27103285Sikob# much how different the installed mk files are from those in the source 28103285Sikob# tree. This makefile executes a child make process, forcing it to use 29103285Sikob# the mk files from the source tree which are supposed to DTRT. 30103285Sikob# 31107728Sru# The user-driven targets (as listed above) are implemented in Makefile.inc1. 32103285Sikob# 33103285Sikob# If you want to build your system from source be sure that /usr/obj has 34231244Sgjb# at least 400MB of diskspace available. 35103285Sikob# 36103285Sikob# For individuals wanting to build from the sources currently on their 37103285Sikob# system, the simple instructions are: 38103285Sikob# 39103285Sikob# 1. `cd /usr/src' (or to the directory containing your source tree). 40103285Sikob# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 41110752Ssimokawa# 3. `make world' 42110752Ssimokawa# 43110752Ssimokawa# For individuals wanting to upgrade their sources (even if only a 44110752Ssimokawa# delta of a few days): 45110752Ssimokawa# 46110752Ssimokawa# 1. `cd /usr/src' (or to the directory containing your source tree). 47103285Sikob# 2. `make buildworld' 48109816Ssimokawa# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 49109816Ssimokawa# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 50109816Ssimokawa# [steps 3. & 4. can be combined by using the "kernel" target] 51109816Ssimokawa# 5. `reboot' (in single user mode: boot -s from the loader prompt). 52109816Ssimokawa# 6. `mergemaster -p' 53103285Sikob# 7. `make installworld' 54103285Sikob# 8. `make delete-old' 55103285Sikob# 9. `mergemaster' 56116991Ssimokawa# 10. `reboot' 57109816Ssimokawa# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 58123591Sbrueffer# 59123591Sbrueffer# See src/UPDATING `COMMON ITEMS' for more complete information. 60103285Sikob# 61111447Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 62110782Ssimokawa# cross build world for other machine types using the buildworld target, 63111447Sru# and once the world is built you can cross build a kernel using the 64111447Sru# buildkernel target. 65111447Sru# 66111447Sru# Define the user-driven targets. These are listed here in alphabetical 67111447Sru# order, but that's not important. 68123591Sbrueffer# 69110782Ssimokawa# Targets that begin with underscore are internal targets intended for 70111447Sru# developer convenience only. They are intentionally not documented and 71111447Sru# completely subject to change without notice. 72111447Sru# 73167603SsimokawaTGTS= all all-man buildenv buildenvvars buildkernel buildworld check-old \ 74231244Sgjb checkdpadd clean cleandepend cleandir delete-old delete-old-libs \ 75117782Ssimokawa depend distribute distributeworld distrib-dirs distribution doxygen \ 76130582Sru everything hierarchy install installcheck installkernel \ 77130582Sru installkernel.debug reinstallkernel reinstallkernel.debug \ 78117782Ssimokawa installworld kernel-toolchain libraries lint maninstall \ 79117782Ssimokawa obj objlink regress rerelease showconfig tags toolchain update \ 80109816Ssimokawa _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 81116991Ssimokawa _build-tools _cross-tools _includes _libraries _depend \ 82111447Sru build32 distribute32 install32 83109816SsimokawaTGTS+= ${SUBDIR_TARGETS} 84110363Ssimokawa 85110752SsimokawaBITGTS= files includes 86110363SsimokawaBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 87103285SikobTGTS+= ${BITGTS} 88103285Sikob 89103285Sikob.ORDER: buildworld installworld 90103285Sikob.ORDER: buildworld distributeworld 91103285Sikob.ORDER: buildworld buildkernel 92103285Sikob.ORDER: buildkernel installkernel 93103285Sikob.ORDER: buildkernel installkernel.debug 94103285Sikob.ORDER: buildkernel reinstallkernel 95103285Sikob.ORDER: buildkernel reinstallkernel.debug 96103285Sikob 97103285SikobPATH= /sbin:/bin:/usr/sbin:/usr/bin 98MAKEOBJDIRPREFIX?= /usr/obj 99_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 100 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 101 -f /dev/null -V MAKEOBJDIRPREFIX dummy 102.if !empty(_MAKEOBJDIRPREFIX) 103.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 104 (in make.conf(5)) or command-line variable. 105.endif 106MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 107BINMAKE= \ 108 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 109 -m ${.CURDIR}/share/mk 110_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 111 112# 113# Make sure we have an up-to-date make(1). Only world and buildworld 114# should do this as those are the initial targets used for upgrades. 115# The user can define ALWAYS_CHECK_MAKE to have this check performed 116# for all targets. 117# 118.if defined(ALWAYS_CHECK_MAKE) 119${TGTS}: upgrade_checks 120.else 121buildworld: upgrade_checks 122.endif 123 124# 125# This 'cleanworld' target is not included in TGTS, because it is not a 126# recursive target. All of the work for it is done right here. It is 127# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 128# created by bsd.obj.mk, except that we don't want to .include that file 129# in this makefile. 130# 131# In the following, the first 'rm' in a series will usually remove all 132# files and directories. If it does not, then there are probably some 133# files with chflags set, so this unsets them and tries the 'rm' a 134# second time. There are situations where this target will be cleaning 135# some directories via more than one method, but that duplication is 136# needed to correctly handle all the possible situations. 137# 138BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 139cleanworld: 140.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 141.if exists(${BW_CANONICALOBJDIR}/) 142 -rm -rf ${BW_CANONICALOBJDIR}/* 143 chflags -R 0 ${BW_CANONICALOBJDIR} 144 rm -rf ${BW_CANONICALOBJDIR}/* 145.endif 146 # To be safe in this case, fall back to a 'make cleandir' 147 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 148.else 149 -rm -rf ${.OBJDIR}/* 150 chflags -R 0 ${.OBJDIR} 151 rm -rf ${.OBJDIR}/* 152.endif 153 154# 155# Handle the user-driven targets, using the source relative mk files. 156# 157 158${TGTS}: 159 ${_+_}@cd ${.CURDIR}; \ 160 ${_MAKE} ${.TARGET} 161 162# Set a reasonable default 163.MAIN: all 164 165STARTTIME!= LC_ALL=C date 166 167.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 168# 169# world 170# 171# Attempt to rebuild and reinstall everything. This target is not to be 172# used for upgrading an existing FreeBSD system, because the kernel is 173# not included. One can argue that this target doesn't build everything 174# then. 175# 176world: upgrade_checks 177 @echo "--------------------------------------------------------------" 178 @echo ">>> make world started on ${STARTTIME}" 179 @echo "--------------------------------------------------------------" 180.if target(pre-world) 181 @echo 182 @echo "--------------------------------------------------------------" 183 @echo ">>> Making 'pre-world' target" 184 @echo "--------------------------------------------------------------" 185 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 186.endif 187 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 188 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 189.if target(post-world) 190 @echo 191 @echo "--------------------------------------------------------------" 192 @echo ">>> Making 'post-world' target" 193 @echo "--------------------------------------------------------------" 194 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 195.endif 196 @echo 197 @echo "--------------------------------------------------------------" 198 @echo ">>> make world completed on `LC_ALL=C date`" 199 @echo " (started ${STARTTIME})" 200 @echo "--------------------------------------------------------------" 201.else 202world: 203 @echo "WARNING: make world will overwrite your existing FreeBSD" 204 @echo "installation without also building and installing a new" 205 @echo "kernel. This can be dangerous. Please read the handbook," 206 @echo "'Rebuilding world', for how to upgrade your system." 207 @echo "Define DESTDIR to where you want to install FreeBSD," 208 @echo "including /, to override this warning and proceed as usual." 209 @echo "" 210 @echo "Bailing out now..." 211 @false 212.endif 213 214# 215# kernel 216# 217# Short hand for `make buildkernel installkernel' 218# 219kernel: buildkernel installkernel 220 221# 222# Perform a few tests to determine if the installed tools are adequate 223# for building the world. 224# 225upgrade_checks: 226 @if ! (cd ${.CURDIR}/tools/build/make_check && \ 227 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 228 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 229 then \ 230 (cd ${.CURDIR} && make make); \ 231 fi 232 233# 234# Upgrade make(1) to the current version using the installed 235# headers, libraries and tools. 236# 237MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 238 DESTDIR= \ 239 INSTALL="sh ${.CURDIR}/tools/install.sh" 240MMAKE= ${MMAKEENV} make \ 241 -D_UPGRADING \ 242 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 243 -DNO_CPU_CFLAGS -DNO_WERROR 244 245make: .PHONY 246 @echo 247 @echo "--------------------------------------------------------------" 248 @echo ">>> Building an up-to-date make(1)" 249 @echo "--------------------------------------------------------------" 250 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 251 ${MMAKE} obj && \ 252 ${MMAKE} depend && \ 253 ${MMAKE} all && \ 254 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 255 256# 257# universe 258# 259# Attempt to rebuild *everything* for all supported architectures, 260# with a reasonable chance of success, regardless of how old your 261# existing system is. 262# 263.if make(universe) 264universe: universe_prologue 265universe_prologue: 266 @echo "--------------------------------------------------------------" 267 @echo ">>> make universe started on ${STARTTIME}" 268 @echo "--------------------------------------------------------------" 269.for target in amd64 i386 ia64 pc98 sparc64 sun4v 270KERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ 271 find [A-Z]*[A-Z] -type f -maxdepth 0 \ 272 ! -name DEFAULTS ! -name LINT 273KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 274universe: universe_${target} 275.ORDER: universe_prologue universe_${target} universe_epilogue 276universe_${target}: 277 @echo ">> ${target} started on `LC_ALL=C date`" 278 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 279 TARGET=${target} \ 280 __MAKE_CONF=/dev/null \ 281 > _.${target}.buildworld 2>&1 282 @echo ">> ${target} buildworld completed on `LC_ALL=C date`" 283.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 284 -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ 285 > ${.CURDIR}/_.${target}.makeLINT 2>&1 286.endif 287.for kernel in ${KERNCONFS} 288 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 289 TARGET=${target} \ 290 KERNCONF=${kernel} \ 291 __MAKE_CONF=/dev/null \ 292 > _.${target}.${kernel} 2>&1 293.endfor 294 @echo ">> ${target} completed on `LC_ALL=C date`" 295.endfor 296universe: universe_epilogue 297universe_epilogue: 298 @echo "--------------------------------------------------------------" 299 @echo ">>> make universe completed on `LC_ALL=C date`" 300 @echo " (started ${STARTTIME})" 301 @echo "--------------------------------------------------------------" 302.endif 303