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