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