Makefile revision 223148
1249259Sdim# 2249259Sdim# $FreeBSD: head/Makefile 223148 2011-06-16 12:28:37Z ru $ 3249259Sdim# 4249259Sdim# The user-driven targets are: 5249259Sdim# 6249259Sdim# universe - *Really* build *everything* (buildworld and 7249259Sdim# all kernels on all architectures). 8249259Sdim# tinderbox - Same as universe, but presents a list of failed build 9249259Sdim# targets and exits with an error if there were any. 10249259Sdim# buildworld - Rebuild *everything*, including glue to help do 11249259Sdim# upgrades. 12249259Sdim# installworld - Install everything built by "buildworld". 13249259Sdim# world - buildworld + installworld, no kernel. 14249259Sdim# buildkernel - Rebuild the kernel and the kernel-modules. 15249259Sdim# installkernel - Install the kernel and the kernel-modules. 16249259Sdim# installkernel.debug 17249259Sdim# reinstallkernel - Reinstall the kernel and the kernel-modules. 18249259Sdim# reinstallkernel.debug 19249259Sdim# kernel - buildkernel + installkernel. 20249259Sdim# kernel-toolchain - Builds the subset of world necessary to build a kernel 21249259Sdim# doxygen - Build API documentation of the kernel, needs doxygen. 22249259Sdim# update - Convenient way to update your source tree(s). 23249259Sdim# check-old - List obsolete directories/files/libraries. 24249259Sdim# check-old-dirs - List obsolete directories. 25276479Sdim# check-old-files - List obsolete files. 26249259Sdim# check-old-libs - List obsolete libraries. 27249259Sdim# delete-old - Delete obsolete directories/files/libraries. 28249259Sdim# delete-old-dirs - Delete obsolete directories. 29249259Sdim# delete-old-files - Delete obsolete files. 30249259Sdim# delete-old-libs - Delete obsolete libraries. 31249259Sdim# targets - Print a list of supported TARGET/TARGET_ARCH pairs 32249259Sdim# for world and kernel targets. 33249259Sdim# toolchains - Build a toolchain for all world and kernel targets. 34249259Sdim# 35276479Sdim# This makefile is simple by design. The FreeBSD make automatically reads 36249259Sdim# the /usr/share/mk/sys.mk unless the -m argument is specified on the 37249259Sdim# command line. By keeping this makefile simple, it doesn't matter too 38249259Sdim# much how different the installed mk files are from those in the source 39249259Sdim# tree. This makefile executes a child make process, forcing it to use 40249259Sdim# the mk files from the source tree which are supposed to DTRT. 41249259Sdim# 42249259Sdim# Most of the user-driven targets (as listed above) are implemented in 43249259Sdim# Makefile.inc1. The exceptions are universe, tinderbox and targets. 44249259Sdim# 45249259Sdim# If you want to build your system from source be sure that /usr/obj has 46249259Sdim# at least 1GB of diskspace available. A complete 'universe' build requires 47249259Sdim# about 15GB of space. 48249259Sdim# 49249259Sdim# For individuals wanting to build from the sources currently on their 50249259Sdim# system, the simple instructions are: 51249259Sdim# 52249259Sdim# 1. `cd /usr/src' (or to the directory containing your source tree). 53249259Sdim# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 54249259Sdim# 3. `make world' 55249259Sdim# 56249259Sdim# For individuals wanting to upgrade their sources (even if only a 57249259Sdim# delta of a few days): 58276479Sdim# 59249259Sdim# 1. `cd /usr/src' (or to the directory containing your source tree). 60249259Sdim# 2. `make buildworld' 61249259Sdim# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 62249259Sdim# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 63249259Sdim# [steps 3. & 4. can be combined by using the "kernel" target] 64249259Sdim# 5. `reboot' (in single user mode: boot -s from the loader prompt). 65276479Sdim# 6. `mergemaster -p' 66249259Sdim# 7. `make installworld' 67249259Sdim# 8. `make delete-old' 68249259Sdim# 9. `mergemaster' (you may wish to use -i, along with -U or -F). 69249259Sdim# 10. `reboot' 70249259Sdim# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 71249259Sdim# 72249259Sdim# See src/UPDATING `COMMON ITEMS' for more complete information. 73249259Sdim# 74249259Sdim# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 75249259Sdim# cross build world for other machine types using the buildworld target, 76261991Sdim# and once the world is built you can cross build a kernel using the 77249259Sdim# buildkernel target. 78249259Sdim# 79249259Sdim# Define the user-driven targets. These are listed here in alphabetical 80249259Sdim# order, but that's not important. 81249259Sdim# 82249259Sdim# Targets that begin with underscore are internal targets intended for 83249259Sdim# developer convenience only. They are intentionally not documented and 84249259Sdim# completely subject to change without notice. 85249259Sdim# 86249259Sdim# For more information, see the build(7) manual page. 87249259Sdim# 88249259SdimTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 89249259Sdim check-old check-old-dirs check-old-files check-old-libs \ 90249259Sdim checkdpadd clean cleandepend cleandir \ 91249259Sdim delete-old delete-old-dirs delete-old-files delete-old-libs \ 92249259Sdim depend distribute distributekernel distributekernel.debug \ 93249259Sdim distributeworld distrib-dirs distribution doxygen \ 94249259Sdim everything hierarchy install installcheck installkernel \ 95249259Sdim installkernel.debug packagekernel packageworld \ 96249259Sdim reinstallkernel reinstallkernel.debug \ 97249259Sdim installworld kernel-toolchain libraries lint maninstall \ 98249259Sdim obj objlink regress rerelease showconfig tags toolchain update \ 99249259Sdim _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 100249259Sdim _build-tools _cross-tools _includes _libraries _depend \ 101249259Sdim build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ 102249259Sdim 103249259SdimTGTS+= ${SUBDIR_TARGETS} 104249259Sdim 105249259SdimBITGTS= files includes 106249259SdimBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 107249259SdimTGTS+= ${BITGTS} 108249259Sdim 109249259Sdim.ORDER: buildworld installworld 110249259Sdim.ORDER: buildworld distributeworld 111249259Sdim.ORDER: buildworld buildkernel 112249259Sdim.ORDER: buildkernel installkernel 113249259Sdim.ORDER: buildkernel installkernel.debug 114249259Sdim.ORDER: buildkernel reinstallkernel 115249259Sdim.ORDER: buildkernel reinstallkernel.debug 116249259Sdim 117249259SdimPATH= /sbin:/bin:/usr/sbin:/usr/bin 118249259SdimMAKEOBJDIRPREFIX?= /usr/obj 119249259Sdim_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 120249259Sdim ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 121249259Sdim -f /dev/null -V MAKEOBJDIRPREFIX dummy 122249259Sdim.if !empty(_MAKEOBJDIRPREFIX) 123249259Sdim.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 124249259Sdim (in make.conf(5)) or command-line variable. 125249259Sdim.endif 126249259SdimMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 127249259SdimBINMAKE= \ 128249259Sdim `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 129249259Sdim -m ${.CURDIR}/share/mk 130249259Sdim_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} 131249259Sdim 132249259Sdim# Guess machine architecture from machine type, and vice versa. 133249259Sdim.if !defined(TARGET_ARCH) && defined(TARGET) 134249259Sdim_TARGET_ARCH= ${TARGET:S/pc98/i386/:S/mips/mipsel/} 135249259Sdim.elif !defined(TARGET) && defined(TARGET_ARCH) && \ 136249259Sdim ${TARGET_ARCH} != ${MACHINE_ARCH} 137249259Sdim_TARGET= ${TARGET_ARCH:C/mips.*e[lb]/mips/:C/armeb/arm/} 138249259Sdim.endif 139249259Sdim# Legacy names, for a transition period mips:mips -> mipsel:mips 140249259Sdim.if defined(TARGET) && defined(TARGET_ARCH) && \ 141249259Sdim ${TARGET_ARCH} == "mips" && ${TARGET} == "mips" 142249259Sdim.warning "TARGET_ARCH of mips is deprecated in favor of mipsel or mipseb" 143249259Sdim.if defined(TARGET_BIG_ENDIAN) 144249259Sdim_TARGET_ARCH=mipseb 145249259Sdim.else 146249259Sdim_TARGET_ARCH=mipsel 147249259Sdim.endif 148249259Sdim.endif 149249259Sdim# arm with TARGET_BIG_ENDIAN -> armeb 150249259Sdim.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN) 151249259Sdim.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated. use armeb" 152249259Sdim_TARGET_ARCH=armeb 153249259Sdim.endif 154249259Sdim.if defined(TARGET) && !defined(_TARGET) 155249259Sdim_TARGET=${TARGET} 156276479Sdim.endif 157249259Sdim.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH) 158249259Sdim_TARGET_ARCH=${TARGET_ARCH} 159249259Sdim.endif 160249259Sdim# Otherwise, default to current machine type and architecture. 161276479Sdim_TARGET?= ${MACHINE} 162249259Sdim_TARGET_ARCH?= ${MACHINE_ARCH} 163249259Sdim 164249259Sdim# 165249259Sdim# Make sure we have an up-to-date make(1). Only world and buildworld 166276479Sdim# should do this as those are the initial targets used for upgrades. 167249259Sdim# The user can define ALWAYS_CHECK_MAKE to have this check performed 168249259Sdim# for all targets. 169249259Sdim# 170276479Sdim.if defined(ALWAYS_CHECK_MAKE) 171249259Sdim${TGTS}: upgrade_checks 172249259Sdim.else 173249259Sdimbuildworld: upgrade_checks 174249259Sdim.endif 175249259Sdim 176249259Sdim# 177249259Sdim# This 'cleanworld' target is not included in TGTS, because it is not a 178249259Sdim# recursive target. All of the work for it is done right here. It is 179249259Sdim# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 180249259Sdim# created by bsd.obj.mk, except that we don't want to .include that file 181249259Sdim# in this makefile. 182249259Sdim# 183249259Sdim# In the following, the first 'rm' in a series will usually remove all 184249259Sdim# files and directories. If it does not, then there are probably some 185249259Sdim# files with chflags set, so this unsets them and tries the 'rm' a 186249259Sdim# second time. There are situations where this target will be cleaning 187249259Sdim# some directories via more than one method, but that duplication is 188# needed to correctly handle all the possible situations. 189# 190BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 191cleanworld: 192.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 193.if exists(${BW_CANONICALOBJDIR}/) 194 -rm -rf ${BW_CANONICALOBJDIR}/* 195 -chflags -R 0 ${BW_CANONICALOBJDIR} 196 rm -rf ${BW_CANONICALOBJDIR}/* 197.endif 198 # To be safe in this case, fall back to a 'make cleandir' 199 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 200.else 201 -rm -rf ${.OBJDIR}/* 202 -chflags -R 0 ${.OBJDIR} 203 rm -rf ${.OBJDIR}/* 204.endif 205 206# 207# Handle the user-driven targets, using the source relative mk files. 208# 209 210${TGTS}: 211 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET} 212 213# Set a reasonable default 214.MAIN: all 215 216STARTTIME!= LC_ALL=C date 217CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s 218.if !empty(CHECK_TIME) 219.error check your date/time: ${STARTTIME} 220.endif 221 222.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 223# 224# world 225# 226# Attempt to rebuild and reinstall everything. This target is not to be 227# used for upgrading an existing FreeBSD system, because the kernel is 228# not included. One can argue that this target doesn't build everything 229# then. 230# 231world: upgrade_checks 232 @echo "--------------------------------------------------------------" 233 @echo ">>> make world started on ${STARTTIME}" 234 @echo "--------------------------------------------------------------" 235.if target(pre-world) 236 @echo 237 @echo "--------------------------------------------------------------" 238 @echo ">>> Making 'pre-world' target" 239 @echo "--------------------------------------------------------------" 240 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 241.endif 242 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 243 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 244.if target(post-world) 245 @echo 246 @echo "--------------------------------------------------------------" 247 @echo ">>> Making 'post-world' target" 248 @echo "--------------------------------------------------------------" 249 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 250.endif 251 @echo 252 @echo "--------------------------------------------------------------" 253 @echo ">>> make world completed on `LC_ALL=C date`" 254 @echo " (started ${STARTTIME})" 255 @echo "--------------------------------------------------------------" 256.else 257world: 258 @echo "WARNING: make world will overwrite your existing FreeBSD" 259 @echo "installation without also building and installing a new" 260 @echo "kernel. This can be dangerous. Please read the handbook," 261 @echo "'Rebuilding world', for how to upgrade your system." 262 @echo "Define DESTDIR to where you want to install FreeBSD," 263 @echo "including /, to override this warning and proceed as usual." 264 @echo "" 265 @echo "Bailing out now..." 266 @false 267.endif 268 269# 270# kernel 271# 272# Short hand for `make buildkernel installkernel' 273# 274kernel: buildkernel installkernel 275 276# 277# Perform a few tests to determine if the installed tools are adequate 278# for building the world. 279# 280upgrade_checks: 281 @if ! (cd ${.CURDIR}/tools/build/make_check && \ 282 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 283 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 284 then \ 285 (cd ${.CURDIR} && ${MAKE} make); \ 286 fi 287 288# 289# Upgrade make(1) to the current version using the installed 290# headers, libraries and tools. Also, allow the location of 291# the system bsdmake-like utility to be overridden. 292# 293MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 294 DESTDIR= \ 295 INSTALL="sh ${.CURDIR}/tools/install.sh" 296MMAKE= ${MMAKEENV} ${MAKE} \ 297 -D_UPGRADING \ 298 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 299 -DNO_CPU_CFLAGS -DNO_WERROR 300 301make: .PHONY 302 @echo 303 @echo "--------------------------------------------------------------" 304 @echo ">>> Building an up-to-date make(1)" 305 @echo "--------------------------------------------------------------" 306 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 307 ${MMAKE} obj && \ 308 ${MMAKE} depend && \ 309 ${MMAKE} all && \ 310 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 311 312tinderbox: 313 @cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe 314 315toolchains: 316 @cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe 317 318# 319# universe 320# 321# Attempt to rebuild *everything* for all supported architectures, 322# with a reasonable chance of success, regardless of how old your 323# existing system is. 324# 325.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets) 326TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 327TARGET_ARCHES_arm?= arm armeb 328TARGET_ARCHES_mips?= mipsel mipseb mips64el mips64eb mipsn32eb 329TARGET_ARCHES_powerpc?= powerpc powerpc64 330TARGET_ARCHES_pc98?= i386 331.for target in ${TARGETS} 332TARGET_ARCHES_${target}?= ${target} 333.endfor 334 335.if defined(UNIVERSE_TARGET) 336MAKE_JUST_WORLDS= YES 337.else 338UNIVERSE_TARGET?= buildworld 339.endif 340KERNSRCDIR?= ${.CURDIR}/sys 341 342targets: 343 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets" 344.for target in ${TARGETS} 345.for target_arch in ${TARGET_ARCHES_${target}} 346 @echo " ${target}/${target_arch}" 347.endfor 348.endfor 349 350.if defined(DOING_TINDERBOX) 351FAILFILE=${.CURDIR}/_.tinderbox.failed 352MAKEFAIL=tee -a ${FAILFILE} 353.else 354MAKEFAIL=cat 355.endif 356 357universe: universe_prologue 358universe_prologue: 359 @echo "--------------------------------------------------------------" 360 @echo ">>> make universe started on ${STARTTIME}" 361 @echo "--------------------------------------------------------------" 362.if defined(DOING_TINDERBOX) 363 @rm -f ${FAILFILE} 364.endif 365.for target in ${TARGETS} 366universe: universe_${target} 367.ORDER: universe_prologue universe_${target} universe_epilogue 368universe_${target}: universe_${target}_prologue 369universe_${target}_prologue: 370 @echo ">> ${target} started on `LC_ALL=C date`" 371.if !defined(MAKE_JUST_KERNELS) 372.for target_arch in ${TARGET_ARCHES_${target}} 373universe_${target}: universe_${target}_${target_arch} 374universe_${target}_${target_arch}: universe_${target}_prologue 375 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`" 376 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 377 ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \ 378 TARGET=${target} \ 379 TARGET_ARCH=${target_arch} \ 380 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \ 381 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \ 382 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \ 383 ${MAKEFAIL})) 384 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`" 385.endfor 386.endif 387.if !defined(MAKE_JUST_WORLDS) 388.if exists(${KERNSRCDIR}/${target}/conf/NOTES) 389 @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \ 390 ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ 391 (echo "${target} 'make LINT' failed," \ 392 "check _.${target}.makeLINT for details"| ${MAKEFAIL})) 393.endif 394 @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \ 395 universe_kernels 396.endif 397 @echo ">> ${target} completed on `LC_ALL=C date`" 398.endfor 399universe_kernels: universe_kernconfs 400.if !defined(TARGET) 401TARGET!= uname -m 402.endif 403KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \ 404 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \ 405 ! -name DEFAULTS ! -name NOTES 406universe_kernconfs: 407.for kernel in ${KERNCONFS} 408TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \ 409 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \ 410 grep -v WARNING: | cut -f 2 411.if empty(TARGET_ARCH_${kernel}) 412.error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old." 413.endif 414universe_kernconfs: universe_kernconf_${TARGET}_${kernel} 415universe_kernconf_${TARGET}_${kernel}: 416 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 417 ${MAKE} ${JFLAG} buildkernel \ 418 TARGET=${TARGET} \ 419 TARGET_ARCH=${TARGET_ARCH_${kernel}} \ 420 KERNCONF=${kernel} \ 421 > _.${TARGET}.${kernel} 2>&1 || \ 422 (echo "${TARGET} ${kernel} kernel failed," \ 423 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL})) 424.endfor 425universe: universe_epilogue 426universe_epilogue: 427 @echo "--------------------------------------------------------------" 428 @echo ">>> make universe completed on `LC_ALL=C date`" 429 @echo " (started ${STARTTIME})" 430 @echo "--------------------------------------------------------------" 431.if defined(DOING_TINDERBOX) 432 @if [ -e ${FAILFILE} ] ; then \ 433 echo "Tinderbox failed:" ;\ 434 cat ${FAILFILE} ;\ 435 exit 1 ;\ 436 fi 437.endif 438.endif 439