Makefile revision 227769
1# 2# $FreeBSD: head/Makefile 227769 2011-11-20 19:05:32Z gjb $ 3# 4# The user-driven targets are: 5# 6# universe - *Really* build *everything* (buildworld and 7# all kernels on all architectures). 8# tinderbox - Same as universe, but presents a list of failed build 9# targets and exits with an error if there were any. 10# buildworld - Rebuild *everything*, including glue to help do 11# upgrades. 12# installworld - Install everything built by "buildworld". 13# world - buildworld + installworld, no kernel. 14# buildkernel - Rebuild the kernel and the kernel-modules. 15# installkernel - Install the kernel and the kernel-modules. 16# installkernel.debug 17# reinstallkernel - Reinstall the kernel and the kernel-modules. 18# reinstallkernel.debug 19# kernel - buildkernel + installkernel. 20# kernel-toolchain - Builds the subset of world necessary to build a kernel 21# doxygen - Build API documentation of the kernel, needs doxygen. 22# update - Convenient way to update your source tree(s). 23# check-old - List obsolete directories/files/libraries. 24# check-old-dirs - List obsolete directories. 25# check-old-files - List obsolete files. 26# check-old-libs - List obsolete libraries. 27# delete-old - Delete obsolete directories/files/libraries. 28# delete-old-dirs - Delete obsolete directories. 29# delete-old-files - Delete obsolete files. 30# delete-old-libs - Delete obsolete libraries. 31# targets - Print a list of supported TARGET/TARGET_ARCH pairs 32# for world and kernel targets. 33# toolchains - Build a toolchain for all world and kernel targets. 34# 35# This makefile is simple by design. The FreeBSD make automatically reads 36# the /usr/share/mk/sys.mk unless the -m argument is specified on the 37# command line. By keeping this makefile simple, it doesn't matter too 38# much how different the installed mk files are from those in the source 39# tree. This makefile executes a child make process, forcing it to use 40# the mk files from the source tree which are supposed to DTRT. 41# 42# Most of the user-driven targets (as listed above) are implemented in 43# Makefile.inc1. The exceptions are universe, tinderbox and targets. 44# 45# If you want to build your system from source be sure that /usr/obj has 46# at least 1GB of diskspace available. A complete 'universe' build requires 47# about 15GB of space. 48# 49# For individuals wanting to build from the sources currently on their 50# system, the simple instructions are: 51# 52# 1. `cd /usr/src' (or to the directory containing your source tree). 53# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 54# 3. `make world' 55# 56# For individuals wanting to upgrade their sources (even if only a 57# delta of a few days): 58# 59# 1. `cd /usr/src' (or to the directory containing your source tree). 60# 2. `make buildworld' 61# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 62# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 63# [steps 3. & 4. can be combined by using the "kernel" target] 64# 5. `reboot' (in single user mode: boot -s from the loader prompt). 65# 6. `mergemaster -p' 66# 7. `make installworld' 67# 8. `make delete-old' 68# 9. `mergemaster' (you may wish to use -i, along with -U or -F). 69# 10. `reboot' 70# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 71# 72# See src/UPDATING `COMMON ITEMS' for more complete information. 73# 74# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 75# cross build world for other machine types using the buildworld target, 76# and once the world is built you can cross build a kernel using the 77# buildkernel target. 78# 79# Define the user-driven targets. These are listed here in alphabetical 80# order, but that's not important. 81# 82# Targets that begin with underscore are internal targets intended for 83# developer convenience only. They are intentionally not documented and 84# completely subject to change without notice. 85# 86# For more information, see the build(7) manual page. 87# 88TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 89 check-old check-old-dirs check-old-files check-old-libs \ 90 checkdpadd clean cleandepend cleandir \ 91 delete-old delete-old-dirs delete-old-files delete-old-libs \ 92 depend distribute distributekernel distributekernel.debug \ 93 distributeworld distrib-dirs distribution doxygen \ 94 everything hierarchy install installcheck installkernel \ 95 installkernel.debug packagekernel packageworld \ 96 reinstallkernel reinstallkernel.debug \ 97 installworld kernel-toolchain libraries lint maninstall \ 98 obj objlink regress rerelease showconfig tags toolchain update \ 99 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 100 _build-tools _cross-tools _includes _libraries _depend \ 101 build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ 102 103TGTS+= ${SUBDIR_TARGETS} 104 105BITGTS= files includes 106BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 107TGTS+= ${BITGTS} 108 109.ORDER: buildworld installworld 110.ORDER: buildworld distributeworld 111.ORDER: buildworld buildkernel 112.ORDER: buildkernel installkernel 113.ORDER: buildkernel installkernel.debug 114.ORDER: buildkernel reinstallkernel 115.ORDER: buildkernel reinstallkernel.debug 116 117PATH= /sbin:/bin:/usr/sbin:/usr/bin 118MAKEOBJDIRPREFIX?= /usr/obj 119_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 120 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 121 -f /dev/null -V MAKEOBJDIRPREFIX dummy 122.if !empty(_MAKEOBJDIRPREFIX) 123.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 124 (in make.conf(5)) or command-line variable. 125.endif 126MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 127BINMAKE= \ 128 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 129 -m ${.CURDIR}/share/mk 130_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} 131 132# Guess machine architecture from machine type, and vice versa. 133.if !defined(TARGET_ARCH) && defined(TARGET) 134_TARGET_ARCH= ${TARGET:S/pc98/i386/:S/mips/mipsel/} 135.elif !defined(TARGET) && defined(TARGET_ARCH) && \ 136 ${TARGET_ARCH} != ${MACHINE_ARCH} 137_TARGET= ${TARGET_ARCH:C/mips.*e[lb]/mips/:C/armeb/arm/} 138.endif 139# Legacy names, for a transition period mips:mips -> mipsel:mips 140.if defined(TARGET) && defined(TARGET_ARCH) && \ 141 ${TARGET_ARCH} == "mips" && ${TARGET} == "mips" 142.warning "TARGET_ARCH of mips is deprecated in favor of mipsel or mipseb" 143.if defined(TARGET_BIG_ENDIAN) 144_TARGET_ARCH=mipseb 145.else 146_TARGET_ARCH=mipsel 147.endif 148.endif 149# arm with TARGET_BIG_ENDIAN -> armeb 150.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN) 151.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated. use armeb" 152_TARGET_ARCH=armeb 153.endif 154.if defined(TARGET) && !defined(_TARGET) 155_TARGET=${TARGET} 156.endif 157.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH) 158_TARGET_ARCH=${TARGET_ARCH} 159.endif 160# Otherwise, default to current machine type and architecture. 161_TARGET?= ${MACHINE} 162_TARGET_ARCH?= ${MACHINE_ARCH} 163 164# 165# Make sure we have an up-to-date make(1). Only world and buildworld 166# should do this as those are the initial targets used for upgrades. 167# The user can define ALWAYS_CHECK_MAKE to have this check performed 168# for all targets. 169# 170.if defined(ALWAYS_CHECK_MAKE) 171${TGTS}: upgrade_checks 172.else 173buildworld: upgrade_checks 174.endif 175 176# 177# This 'cleanworld' target is not included in TGTS, because it is not a 178# recursive target. All of the work for it is done right here. It is 179# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 180# created by bsd.obj.mk, except that we don't want to .include that file 181# in this makefile. 182# 183# In the following, the first 'rm' in a series will usually remove all 184# files and directories. If it does not, then there are probably some 185# files with chflags set, so this unsets them and tries the 'rm' a 186# second time. There are situations where this target will be cleaning 187# some directories via more than one method, but that duplication is 188# needed to correctly handle all the possible situations. Removing all 189# files without the immutable flag set in the first 'rm' instance saves 190# time, because 'chflags' will need to operate on fewer files (with the 191# immutable flag set) afterwards. 192# 193BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 194cleanworld: 195.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 196.if exists(${BW_CANONICALOBJDIR}/) 197 -rm -rf ${BW_CANONICALOBJDIR}/* 198 -chflags -R 0 ${BW_CANONICALOBJDIR} 199 rm -rf ${BW_CANONICALOBJDIR}/* 200.endif 201 # To be safe in this case, fall back to a 'make cleandir' 202 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 203.else 204 -rm -rf ${.OBJDIR}/* 205 -chflags -R 0 ${.OBJDIR} 206 rm -rf ${.OBJDIR}/* 207.endif 208 209# 210# Handle the user-driven targets, using the source relative mk files. 211# 212 213${TGTS}: 214 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET} 215 216# Set a reasonable default 217.MAIN: all 218 219STARTTIME!= LC_ALL=C date 220CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s 221.if !empty(CHECK_TIME) 222.error check your date/time: ${STARTTIME} 223.endif 224 225.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 226# 227# world 228# 229# Attempt to rebuild and reinstall everything. This target is not to be 230# used for upgrading an existing FreeBSD system, because the kernel is 231# not included. One can argue that this target doesn't build everything 232# then. 233# 234world: upgrade_checks 235 @echo "--------------------------------------------------------------" 236 @echo ">>> make world started on ${STARTTIME}" 237 @echo "--------------------------------------------------------------" 238.if target(pre-world) 239 @echo 240 @echo "--------------------------------------------------------------" 241 @echo ">>> Making 'pre-world' target" 242 @echo "--------------------------------------------------------------" 243 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 244.endif 245 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 246 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 247.if target(post-world) 248 @echo 249 @echo "--------------------------------------------------------------" 250 @echo ">>> Making 'post-world' target" 251 @echo "--------------------------------------------------------------" 252 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 253.endif 254 @echo 255 @echo "--------------------------------------------------------------" 256 @echo ">>> make world completed on `LC_ALL=C date`" 257 @echo " (started ${STARTTIME})" 258 @echo "--------------------------------------------------------------" 259.else 260world: 261 @echo "WARNING: make world will overwrite your existing FreeBSD" 262 @echo "installation without also building and installing a new" 263 @echo "kernel. This can be dangerous. Please read the handbook," 264 @echo "'Rebuilding world', for how to upgrade your system." 265 @echo "Define DESTDIR to where you want to install FreeBSD," 266 @echo "including /, to override this warning and proceed as usual." 267 @echo "" 268 @echo "Bailing out now..." 269 @false 270.endif 271 272# 273# kernel 274# 275# Short hand for `make buildkernel installkernel' 276# 277kernel: buildkernel installkernel 278 279# 280# Perform a few tests to determine if the installed tools are adequate 281# for building the world. 282# 283upgrade_checks: 284 @if ! (cd ${.CURDIR}/tools/build/make_check && \ 285 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 286 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 287 then \ 288 (cd ${.CURDIR} && ${MAKE} make); \ 289 fi 290 291# 292# Upgrade make(1) to the current version using the installed 293# headers, libraries and tools. Also, allow the location of 294# the system bsdmake-like utility to be overridden. 295# 296MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 297 DESTDIR= \ 298 INSTALL="sh ${.CURDIR}/tools/install.sh" 299MMAKE= ${MMAKEENV} ${MAKE} \ 300 -D_UPGRADING \ 301 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 302 -DNO_CPU_CFLAGS -DNO_WERROR 303 304make: .PHONY 305 @echo 306 @echo "--------------------------------------------------------------" 307 @echo ">>> Building an up-to-date make(1)" 308 @echo "--------------------------------------------------------------" 309 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 310 ${MMAKE} obj && \ 311 ${MMAKE} depend && \ 312 ${MMAKE} all && \ 313 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 314 315tinderbox: 316 @cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe 317 318toolchains: 319 @cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe 320 321# 322# universe 323# 324# Attempt to rebuild *everything* for all supported architectures, 325# with a reasonable chance of success, regardless of how old your 326# existing system is. 327# 328.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets) 329TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 330TARGET_ARCHES_arm?= arm armeb 331TARGET_ARCHES_mips?= mipsel mipseb mips64el mips64eb mipsn32eb 332TARGET_ARCHES_powerpc?= powerpc powerpc64 333TARGET_ARCHES_pc98?= i386 334.for target in ${TARGETS} 335TARGET_ARCHES_${target}?= ${target} 336.endfor 337 338.if defined(UNIVERSE_TARGET) 339MAKE_JUST_WORLDS= YES 340.else 341UNIVERSE_TARGET?= buildworld 342.endif 343KERNSRCDIR?= ${.CURDIR}/sys 344 345targets: 346 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets" 347.for target in ${TARGETS} 348.for target_arch in ${TARGET_ARCHES_${target}} 349 @echo " ${target}/${target_arch}" 350.endfor 351.endfor 352 353.if defined(DOING_TINDERBOX) 354FAILFILE=${.CURDIR}/_.tinderbox.failed 355MAKEFAIL=tee -a ${FAILFILE} 356.else 357MAKEFAIL=cat 358.endif 359 360universe: universe_prologue 361universe_prologue: 362 @echo "--------------------------------------------------------------" 363 @echo ">>> make universe started on ${STARTTIME}" 364 @echo "--------------------------------------------------------------" 365.if defined(DOING_TINDERBOX) 366 @rm -f ${FAILFILE} 367.endif 368.for target in ${TARGETS} 369universe: universe_${target} 370.ORDER: universe_prologue universe_${target} universe_epilogue 371universe_${target}: universe_${target}_prologue 372universe_${target}_prologue: 373 @echo ">> ${target} started on `LC_ALL=C date`" 374.if !defined(MAKE_JUST_KERNELS) 375.for target_arch in ${TARGET_ARCHES_${target}} 376universe_${target}: universe_${target}_${target_arch} 377universe_${target}_${target_arch}: universe_${target}_prologue 378 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`" 379 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 380 ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \ 381 TARGET=${target} \ 382 TARGET_ARCH=${target_arch} \ 383 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \ 384 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \ 385 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \ 386 ${MAKEFAIL})) 387 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`" 388.endfor 389.endif 390.if !defined(MAKE_JUST_WORLDS) 391.if exists(${KERNSRCDIR}/${target}/conf/NOTES) 392 @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \ 393 ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ 394 (echo "${target} 'make LINT' failed," \ 395 "check _.${target}.makeLINT for details"| ${MAKEFAIL})) 396.endif 397 @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \ 398 universe_kernels 399.endif 400 @echo ">> ${target} completed on `LC_ALL=C date`" 401.endfor 402universe_kernels: universe_kernconfs 403.if !defined(TARGET) 404TARGET!= uname -m 405.endif 406KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \ 407 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \ 408 ! -name DEFAULTS ! -name NOTES 409universe_kernconfs: 410.for kernel in ${KERNCONFS} 411TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \ 412 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \ 413 grep -v WARNING: | cut -f 2 414.if empty(TARGET_ARCH_${kernel}) 415.error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old." 416.endif 417universe_kernconfs: universe_kernconf_${TARGET}_${kernel} 418universe_kernconf_${TARGET}_${kernel}: 419 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 420 ${MAKE} ${JFLAG} buildkernel \ 421 TARGET=${TARGET} \ 422 TARGET_ARCH=${TARGET_ARCH_${kernel}} \ 423 KERNCONF=${kernel} \ 424 > _.${TARGET}.${kernel} 2>&1 || \ 425 (echo "${TARGET} ${kernel} kernel failed," \ 426 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL})) 427.endfor 428universe: universe_epilogue 429universe_epilogue: 430 @echo "--------------------------------------------------------------" 431 @echo ">>> make universe completed on `LC_ALL=C date`" 432 @echo " (started ${STARTTIME})" 433 @echo "--------------------------------------------------------------" 434.if defined(DOING_TINDERBOX) 435 @if [ -e ${FAILFILE} ] ; then \ 436 echo "Tinderbox failed:" ;\ 437 cat ${FAILFILE} ;\ 438 exit 1 ;\ 439 fi 440.endif 441.endif 442