Makefile revision 216934
1255570Strasz# 2255570Strasz# $FreeBSD: head/Makefile 216934 2011-01-03 22:48:01Z imp $ 3255570Strasz# 4255570Strasz# The user-driven targets are: 5255570Strasz# 6255570Strasz# universe - *Really* build *everything* (buildworld and 7255570Strasz# all kernels on all architectures). 8255570Strasz# buildworld - Rebuild *everything*, including glue to help do 9255570Strasz# upgrades. 10255570Strasz# installworld - Install everything built by "buildworld". 11255570Strasz# world - buildworld + installworld, no kernel. 12255570Strasz# buildkernel - Rebuild the kernel and the kernel-modules. 13255570Strasz# installkernel - Install the kernel and the kernel-modules. 14255570Strasz# installkernel.debug 15255570Strasz# reinstallkernel - Reinstall the kernel and the kernel-modules. 16255570Strasz# reinstallkernel.debug 17255570Strasz# kernel - buildkernel + installkernel. 18255570Strasz# kernel-toolchain - Builds the subset of world necessary to build a kernel 19255570Strasz# doxygen - Build API documentation of the kernel, needs doxygen. 20255570Strasz# update - Convenient way to update your source tree (cvs). 21255570Strasz# check-old - List obsolete directories/files/libraries. 22255570Strasz# check-old-dirs - List obsolete directories. 23255570Strasz# check-old-files - List obsolete files. 24255570Strasz# check-old-libs - List obsolete libraries. 25255570Strasz# delete-old - Delete obsolete directories/files/libraries. 26255570Strasz# delete-old-dirs - Delete obsolete directories. 27255570Strasz# delete-old-files - Delete obsolete files. 28255570Strasz# delete-old-libs - Delete obsolete libraries. 29255570Strasz# 30255570Strasz# This makefile is simple by design. The FreeBSD make automatically reads 31255570Strasz# the /usr/share/mk/sys.mk unless the -m argument is specified on the 32255570Strasz# command line. By keeping this makefile simple, it doesn't matter too 33255570Strasz# much how different the installed mk files are from those in the source 34255570Strasz# tree. This makefile executes a child make process, forcing it to use 35255570Strasz# the mk files from the source tree which are supposed to DTRT. 36255570Strasz# 37255570Strasz# The user-driven targets (as listed above) are implemented in Makefile.inc1. 38255570Strasz# 39255570Strasz# If you want to build your system from source be sure that /usr/obj has 40255570Strasz# at least 800MB of diskspace available. 41255570Strasz# 42255570Strasz# For individuals wanting to build from the sources currently on their 43255570Strasz# system, the simple instructions are: 44255570Strasz# 45255570Strasz# 1. `cd /usr/src' (or to the directory containing your source tree). 46255678Strasz# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 47255570Strasz# 3. `make world' 48255570Strasz# 49255570Strasz# For individuals wanting to upgrade their sources (even if only a 50255570Strasz# delta of a few days): 51255570Strasz# 52255570Strasz# 1. `cd /usr/src' (or to the directory containing your source tree). 53255570Strasz# 2. `make buildworld' 54255570Strasz# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 55255570Strasz# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 56255570Strasz# [steps 3. & 4. can be combined by using the "kernel" target] 57255570Strasz# 5. `reboot' (in single user mode: boot -s from the loader prompt). 58255570Strasz# 6. `mergemaster -p' 59255570Strasz# 7. `make installworld' 60255570Strasz# 8. `make delete-old' 61255570Strasz# 9. `mergemaster' (you may wish to use -U or -ai). 62255570Strasz# 10. `reboot' 63255570Strasz# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 64255570Strasz# 65255570Strasz# See src/UPDATING `COMMON ITEMS' for more complete information. 66255570Strasz# 67255570Strasz# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 68255570Strasz# cross build world for other machine types using the buildworld target, 69255570Strasz# and once the world is built you can cross build a kernel using the 70255570Strasz# buildkernel target. 71255570Strasz# 72255570Strasz# Define the user-driven targets. These are listed here in alphabetical 73255570Strasz# order, but that's not important. 74255570Strasz# 75255570Strasz# Targets that begin with underscore are internal targets intended for 76255570Strasz# developer convenience only. They are intentionally not documented and 77255570Strasz# completely subject to change without notice. 78255570Strasz# 79255570Strasz# For more information, see the build(7) manual page. 80255570Strasz# 81255570StraszTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 82255570Strasz check-old check-old-dirs check-old-files check-old-libs \ 83255570Strasz checkdpadd clean cleandepend cleandir \ 84255570Strasz delete-old delete-old-dirs delete-old-files delete-old-libs \ 85255570Strasz depend distribute distributeworld distrib-dirs distribution doxygen \ 86255570Strasz everything hierarchy install installcheck installkernel \ 87255570Strasz installkernel.debug reinstallkernel reinstallkernel.debug \ 88255570Strasz installworld kernel-toolchain libraries lint maninstall \ 89255570Strasz obj objlink regress rerelease showconfig tags toolchain update \ 90255570Strasz _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 91255570Strasz _build-tools _cross-tools _includes _libraries _depend \ 92255570Strasz build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ 93255570Strasz 94268703SmavTGTS+= ${SUBDIR_TARGETS} 95268703Smav 96255739StraszBITGTS= files includes 97255570StraszBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 98255570StraszTGTS+= ${BITGTS} 99255570Strasz 100255570Strasz.ORDER: buildworld installworld 101255570Strasz.ORDER: buildworld distributeworld 102255570Strasz.ORDER: buildworld buildkernel 103255570Strasz.ORDER: buildkernel installkernel 104268703Smav.ORDER: buildkernel installkernel.debug 105268703Smav.ORDER: buildkernel reinstallkernel 106268703Smav.ORDER: buildkernel reinstallkernel.debug 107255570Strasz 108255570StraszPATH= /sbin:/bin:/usr/sbin:/usr/bin 109255570StraszMAKEOBJDIRPREFIX?= /usr/obj 110255570Strasz_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 111255570Strasz ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 112255570Strasz -f /dev/null -V MAKEOBJDIRPREFIX dummy 113255570Strasz.if !empty(_MAKEOBJDIRPREFIX) 114255570Strasz.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 115255739Strasz (in make.conf(5)) or command-line variable. 116255570Strasz.endif 117255570StraszMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 118255570StraszBINMAKE= \ 119255570Strasz `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 120255570Strasz -m ${.CURDIR}/share/mk 121255739Strasz_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 122255570Strasz 123255570Strasz# 124255570Strasz# Make sure we have an up-to-date make(1). Only world and buildworld 125255570Strasz# should do this as those are the initial targets used for upgrades. 126255570Strasz# The user can define ALWAYS_CHECK_MAKE to have this check performed 127255570Strasz# for all targets. 128255570Strasz# 129255570Strasz.if defined(ALWAYS_CHECK_MAKE) 130255570Strasz${TGTS}: upgrade_checks 131255570Strasz.else 132265526Straszbuildworld: upgrade_checks 133265526Strasz.endif 134265526Strasz 135255570Strasz# 136255570Strasz# This 'cleanworld' target is not included in TGTS, because it is not a 137255570Strasz# recursive target. All of the work for it is done right here. It is 138255570Strasz# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 139255570Strasz# created by bsd.obj.mk, except that we don't want to .include that file 140255570Strasz# in this makefile. 141255570Strasz# 142255570Strasz# In the following, the first 'rm' in a series will usually remove all 143255570Strasz# files and directories. If it does not, then there are probably some 144255570Strasz# files with chflags set, so this unsets them and tries the 'rm' a 145255570Strasz# second time. There are situations where this target will be cleaning 146255570Strasz# some directories via more than one method, but that duplication is 147255570Strasz# needed to correctly handle all the possible situations. 148255570Strasz# 149255570StraszBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 150255570Straszcleanworld: 151255570Strasz.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 152255570Strasz.if exists(${BW_CANONICALOBJDIR}/) 153255570Strasz -rm -rf ${BW_CANONICALOBJDIR}/* 154255570Strasz -chflags -R 0 ${BW_CANONICALOBJDIR} 155255739Strasz rm -rf ${BW_CANONICALOBJDIR}/* 156255570Strasz.endif 157255570Strasz # To be safe in this case, fall back to a 'make cleandir' 158255570Strasz ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 159255570Strasz.else 160255570Strasz -rm -rf ${.OBJDIR}/* 161255570Strasz -chflags -R 0 ${.OBJDIR} 162255570Strasz rm -rf ${.OBJDIR}/* 163255570Strasz.endif 164255570Strasz 165265526Strasz# 166255570Strasz# Handle the user-driven targets, using the source relative mk files. 167255570Strasz# 168255570Strasz 169255570Strasz${TGTS}: 170255570Strasz ${_+_}@cd ${.CURDIR}; \ 171255570Strasz ${_MAKE} ${.TARGET} 172255570Strasz 173255570Strasz# Set a reasonable default 174255570Strasz.MAIN: all 175265526Strasz 176255570StraszSTARTTIME!= LC_ALL=C date 177255570StraszCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0 178255570Strasz.if !empty(CHECK_TIME) 179255570Strasz.error check your date/time: ${STARTTIME} 180255570Strasz.endif 181255570Strasz 182255570Strasz.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 183255570Strasz# 184255570Strasz# world 185255570Strasz# 186255570Strasz# Attempt to rebuild and reinstall everything. This target is not to be 187255570Strasz# used for upgrading an existing FreeBSD system, because the kernel is 188255570Strasz# not included. One can argue that this target doesn't build everything 189255570Strasz# then. 190255739Strasz# 191255570Straszworld: upgrade_checks 192255570Strasz @echo "--------------------------------------------------------------" 193255570Strasz @echo ">>> make world started on ${STARTTIME}" 194255570Strasz @echo "--------------------------------------------------------------" 195255570Strasz.if target(pre-world) 196255739Strasz @echo 197255570Strasz @echo "--------------------------------------------------------------" 198255570Strasz @echo ">>> Making 'pre-world' target" 199255570Strasz @echo "--------------------------------------------------------------" 200255570Strasz ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 201255570Strasz.endif 202255739Strasz ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 203255570Strasz ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 204255570Strasz.if target(post-world) 205269065Smav @echo 206269065Smav @echo "--------------------------------------------------------------" 207269065Smav @echo ">>> Making 'post-world' target" 208269065Smav @echo "--------------------------------------------------------------" 209269065Smav ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 210269065Smav.endif 211255570Strasz @echo 212255570Strasz @echo "--------------------------------------------------------------" 213255570Strasz @echo ">>> make world completed on `LC_ALL=C date`" 214269065Smav @echo " (started ${STARTTIME})" 215255570Strasz @echo "--------------------------------------------------------------" 216255570Strasz.else 217world: 218 @echo "WARNING: make world will overwrite your existing FreeBSD" 219 @echo "installation without also building and installing a new" 220 @echo "kernel. This can be dangerous. Please read the handbook," 221 @echo "'Rebuilding world', for how to upgrade your system." 222 @echo "Define DESTDIR to where you want to install FreeBSD," 223 @echo "including /, to override this warning and proceed as usual." 224 @echo "" 225 @echo "Bailing out now..." 226 @false 227.endif 228 229# 230# kernel 231# 232# Short hand for `make buildkernel installkernel' 233# 234kernel: buildkernel installkernel 235 236# 237# Perform a few tests to determine if the installed tools are adequate 238# for building the world. 239# 240upgrade_checks: 241 @if ! (cd ${.CURDIR}/tools/build/make_check && \ 242 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 243 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 244 then \ 245 (cd ${.CURDIR} && ${MAKE} make); \ 246 fi 247 248# 249# Upgrade make(1) to the current version using the installed 250# headers, libraries and tools. Also, allow the location of 251# the system bsdmake-like utility to be overridden. 252# 253MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 254 DESTDIR= \ 255 INSTALL="sh ${.CURDIR}/tools/install.sh" 256MMAKE= ${MMAKEENV} ${MAKE} \ 257 -D_UPGRADING \ 258 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 259 -DNO_CPU_CFLAGS -DNO_WERROR 260 261make: .PHONY 262 @echo 263 @echo "--------------------------------------------------------------" 264 @echo ">>> Building an up-to-date make(1)" 265 @echo "--------------------------------------------------------------" 266 ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 267 ${MMAKE} obj && \ 268 ${MMAKE} depend && \ 269 ${MMAKE} all && \ 270 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 271 272tinderbox: 273 cd ${.CURDIR} && \ 274 DOING_TINDERBOX=YES ${MAKE} JFLAG=${JFLAG} universe 275 276# 277# universe 278# 279# Attempt to rebuild *everything* for all supported architectures, 280# with a reasonable chance of success, regardless of how old your 281# existing system is. 282# 283.if make(universe) || make(universe_kernels) || make(tinderbox) 284TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 sun4v 285TARGET_ARCHES_arm?= arm armeb 286TARGET_ARCHES_mips?= mipsel mipseb 287TARGET_ARCHES_powerpc?= powerpc powerpc64 288TARGET_ARCHES_pc98?= i386 289TARGET_ARCHES_sun4v?= sparc64 290.for target in ${TARGETS} 291TARGET_ARCHES_${target}?= ${target} 292.endfor 293 294.if defined(DOING_TINDERBOX) 295FAILFILE=tinderbox.failed 296MAKEFAIL=tee -a ${FAILFILE} 297.else 298MAKEFAIL=cat 299.endif 300 301universe: universe_prologue 302universe_prologue: 303 @echo "--------------------------------------------------------------" 304 @echo ">>> make universe started on ${STARTTIME}" 305 @echo "--------------------------------------------------------------" 306.if defined(DOING_TINDERBOX) 307 rm -f ${FAILFILE} 308.endif 309.for target in ${TARGETS} 310universe: universe_${target} 311.ORDER: universe_prologue universe_${target} universe_epilogue 312universe_${target}: universe_${target}_prologue 313universe_${target}_prologue: 314 @echo ">> ${target} started on `LC_ALL=C date`" 315.if !defined(MAKE_JUST_KERNELS) 316.for target_arch in ${TARGET_ARCHES_${target}} 317universe_${target}: universe_${target}_${target_arch} 318universe_${target}_${target_arch}: universe_${target}_prologue 319 @echo ">> ${target}.${target_arch} buildworld started on `LC_ALL=C date`" 320 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 321 ${MAKE} ${JFLAG} buildworld \ 322 TARGET=${target} \ 323 TARGET_ARCH=${target_arch} \ 324 > _.${target}.${target_arch}.buildworld 2>&1 || \ 325 (echo "${target}.${target_arch} world failed," \ 326 "check _.${target}.${target_arch}.buildworld for details" | \ 327 ${MAKEFAIL})) 328 @echo ">> ${target}.${target_arch} buildworld completed on `LC_ALL=C date`" 329.endfor 330.endif 331.if !defined(MAKE_JUST_WORLDS) 332.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 333 @(cd ${.CURDIR}/sys/${target}/conf && env __MAKE_CONF=/dev/null \ 334 ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ 335 (echo "${target} 'make LINT' failed," \ 336 "check _.${target}.makeLINT for details"| ${MAKEFAIL})) 337.endif 338 @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \ 339 universe_kernels 340.endif 341 @echo ">> ${target} completed on `LC_ALL=C date`" 342.endfor 343universe_kernels: universe_kernconfs 344.if !defined(TARGET) 345TARGET!= uname -m 346.endif 347KERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 348 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \ 349 ! -name DEFAULTS ! -name NOTES 350universe_kernconfs: 351.for kernel in ${KERNCONFS} 352TARGET_ARCH_${kernel}!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 353 config -m ${.CURDIR}/sys/${TARGET}/conf/${kernel} 2> /dev/null | \ 354 grep -v WARNING: | cut -f 2 355.if empty(TARGET_ARCH_${kernel}) 356.error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old." 357.endif 358universe_kernconfs: universe_kernconf_${TARGET}_${kernel} 359universe_kernconf_${TARGET}_${kernel}: 360 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ 361 ${MAKE} ${JFLAG} buildkernel \ 362 TARGET=${TARGET} \ 363 TARGET_ARCH=${TARGET_ARCH_${kernel}} \ 364 KERNCONF=${kernel} \ 365 > _.${TARGET}.${kernel} 2>&1 || \ 366 (echo "${TARGET} ${kernel} kernel failed," \ 367 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL})) 368.endfor 369universe: universe_epilogue 370universe_epilogue: 371 @echo "--------------------------------------------------------------" 372 @echo ">>> make universe completed on `LC_ALL=C date`" 373 @echo " (started ${STARTTIME})" 374 @echo "--------------------------------------------------------------" 375.if defined(DOING_TINDERBOX) 376 @if [ -e ${FAILFILE} ] ; then \ 377 echo "Tinderbox failed:" ;\ 378 cat ${FAILFILE} ;\ 379 exit 1 ;\ 380 fi 381.endif 382.endif 383