Makefile revision 132234
1168404Spjd# 2168404Spjd# $FreeBSD: head/Makefile 132234 2004-07-16 02:51:28Z marcel $ 3168404Spjd# 4168404Spjd# The user-driven targets are: 5168404Spjd# 6168404Spjd# universe - *Really* build *everything* (buildworld and 7168404Spjd# all kernels on all architectures). 8168404Spjd# buildworld - Rebuild *everything*, including glue to help do 9168404Spjd# upgrades. 10168404Spjd# installworld - Install everything built by "buildworld". 11168404Spjd# world - buildworld + installworld. 12168404Spjd# buildkernel - Rebuild the kernel and the kernel-modules. 13168404Spjd# installkernel - Install the kernel and the kernel-modules. 14168404Spjd# installkernel.debug 15168404Spjd# reinstallkernel - Reinstall the kernel and the kernel-modules. 16168404Spjd# reinstallkernel.debug 17168404Spjd# kernel - buildkernel + installkernel. 18168404Spjd# update - Convenient way to update your source tree (cvs). 19168404Spjd# 20168404Spjd# This makefile is simple by design. The FreeBSD make automatically reads 21263405Sdelphij# the /usr/share/mk/sys.mk unless the -m argument is specified on the 22168404Spjd# command line. By keeping this makefile simple, it doesn't matter too 23219089Spjd# much how different the installed mk files are from those in the source 24307053Smav# tree. This makefile executes a child make process, forcing it to use 25263405Sdelphij# the mk files from the source tree which are supposed to DTRT. 26263407Sdelphij# 27168404Spjd# The user-driven targets (as listed above) are implemented in Makefile.inc1. 28168404Spjd# 29168404Spjd# If you want to build your system from source be sure that /usr/obj has 30168404Spjd# at least 400MB of diskspace available. 31168404Spjd# 32168404Spjd# For individuals wanting to build from the sources currently on their 33168404Spjd# system, the simple instructions are: 34168404Spjd# 35168404Spjd# 1. `cd /usr/src' (or to the directory containing your source tree). 36168404Spjd# 2. `make world' 37168404Spjd# 38168404Spjd# For individuals wanting to upgrade their sources (even if only a 39168404Spjd# delta of a few days): 40168404Spjd# 41168404Spjd# 1. `cd /usr/src' (or to the directory containing your source tree). 42168404Spjd# 2. `make buildworld' 43168404Spjd# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 44168404Spjd# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 45168404Spjd# 5. `reboot' (in single user mode: boot -s from the loader prompt). 46168404Spjd# 6. `mergemaster -p' 47168404Spjd# 7. `make installworld' 48168404Spjd# 8. `mergemaster' 49168404Spjd# 9. `reboot' 50168404Spjd# 51168404Spjd# See src/UPDATING `COMMON ITEMS' for more complete information. 52168404Spjd# 53168404Spjd# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 54168404Spjd# cross build world for other architectures using the buildworld target, 55168404Spjd# and once the world is built you can cross build a kernel using the 56168404Spjd# buildkernel target. 57168404Spjd# 58168404Spjd# Define the user-driven targets. These are listed here in alphabetical 59205199Sdelphij# order, but that's not important. 60205199Sdelphij# 61205199Sdelphij# Targets that begin with underscore are internal targets intended for 62205199Sdelphij# developer convenience only. They are intentionally not documented and 63205199Sdelphij# completely subject to change without notice. 64205199Sdelphij# 65205199SdelphijTGTS= all all-man buildkernel buildworld checkdpadd clean \ 66205199Sdelphij cleandepend cleandir depend distribute distributeworld everything \ 67168404Spjd hierarchy install installcheck installkernel installkernel.debug\ 68168404Spjd reinstallkernel reinstallkernel.debug installworld \ 69168404Spjd kernel-toolchain libraries lint maninstall \ 70168404Spjd obj objlink regress rerelease tags toolchain update \ 71168404Spjd _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 72185029Spjd _build-tools _cross-tools _includes _libraries _depend 73185029Spjd 74185029SpjdBITGTS= files includes 75263407SdelphijBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 76185029SpjdTGTS+= ${BITGTS} 77185029Spjd 78185029Spjd.ORDER: buildworld installworld 79185029Spjd.ORDER: buildworld distributeworld 80185029Spjd.ORDER: buildworld buildkernel 81185029Spjd.ORDER: buildkernel installkernel 82185029Spjd.ORDER: buildkernel installkernel.debug 83185029Spjd.ORDER: buildkernel reinstallkernel 84185029Spjd.ORDER: buildkernel reinstallkernel.debug 85185029Spjd 86185029SpjdPATH= /sbin:/bin:/usr/sbin:/usr/bin 87185029SpjdMAKEOBJDIRPREFIX?= /usr/obj 88185029SpjdMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 89168404SpjdBINMAKE= \ 90168404Spjd `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 91185029Spjd -m ${.CURDIR}/share/mk 92168404Spjd_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 93168404Spjd 94168404Spjd# 95297117Smav# Make sure we have an up-to-date make(1). Only world and buildworld 96263407Sdelphij# should do this as those are the initial targets used for upgrades. 97263407Sdelphij# The user can define ALWAYS_CHECK_MAKE to have this check performed 98168404Spjd# for all targets. 99185029Spjd# 100185029Spjd.if defined(ALWAYS_CHECK_MAKE) 101168404Spjd${TGTS}: upgrade_checks 102168404Spjd.else 103168404Spjdbuildworld: upgrade_checks 104168404Spjd.endif 105168404Spjd 106168404Spjd# 107168404Spjd# This 'cleanworld' target is not included in TGTS, because it is not a 108205198Sdelphij# recursive target. All of the work for it is done right here. It is 109205198Sdelphij# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 110205198Sdelphij# created by bsd.obj.mk, except that we don't want to .include that file 111205198Sdelphij# in this makefile. 112205198Sdelphij# 113205198Sdelphij# In the following, the first 'rm' in a series will usually remove all 114219089Spjd# files and directories. If it does not, then there are probably some 115263405Sdelphij# files with chflags set, so this unsets them and tries the 'rm' a 116263405Sdelphij# second time. There are situations where this target will be cleaning 117205198Sdelphij# some directories via more than one method, but that duplication is 118205198Sdelphij# needed to correctly handle all the possible situations. 119205198Sdelphij# 120205198SdelphijBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 121168404Spjdcleanworld: 122168404Spjd.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 123297117Smav.if exists(${BW_CANONICALOBJDIR}/) 124168404Spjd -rm -rf ${BW_CANONICALOBJDIR}/* 125168404Spjd chflags -R 0 ${BW_CANONICALOBJDIR} 126168404Spjd rm -rf ${BW_CANONICALOBJDIR}/* 127168404Spjd.endif 128168404Spjd # To be safe in this case, fall back to a 'make cleandir' 129168404Spjd @cd ${.CURDIR}; ${_MAKE} cleandir 130168404Spjd.else 131168404Spjd -rm -rf ${.OBJDIR}/* 132205199Sdelphij chflags -R 0 ${.OBJDIR} 133205199Sdelphij rm -rf ${.OBJDIR}/* 134205199Sdelphij.endif 135205199Sdelphij 136185029Spjd# 137185029Spjd# Handle the user-driven targets, using the source relative mk files. 138263407Sdelphij# 139263407Sdelphij 140230438Spjd${TGTS}: 141230438Spjd @cd ${.CURDIR}; \ 142230438Spjd ${_MAKE} ${.TARGET} 143263407Sdelphij 144263407Sdelphij# Set a reasonable default 145263407Sdelphij.MAIN: all 146205199Sdelphij 147185029Spjd.if defined(DESTDIR) 148168404Spjd.if make(world) 149297117SmavSTARTTIME!= LC_ALL=C date 150168404Spjd.endif 151168404Spjd# 152168404Spjd# world 153168404Spjd# 154168404Spjd# Attempt to rebuild and reinstall everything. This target is not to be 155168404Spjd# used for upgrading an existing FreeBSD system, because the kernel is 156168404Spjd# not included. One can argue that this target doesn't build everything 157168404Spjd# then. 158168404Spjd# 159168404Spjdworld: upgrade_checks 160168404Spjd @echo "--------------------------------------------------------------" 161168404Spjd @echo ">>> make world started on ${STARTTIME}" 162185029Spjd @echo "--------------------------------------------------------------" 163168404Spjd.if target(pre-world) 164168404Spjd @echo 165168404Spjd @echo "--------------------------------------------------------------" 166168404Spjd @echo ">>> Making 'pre-world' target" 167168404Spjd @echo "--------------------------------------------------------------" 168168404Spjd @cd ${.CURDIR}; ${_MAKE} pre-world 169168404Spjd.endif 170185029Spjd @cd ${.CURDIR}; ${_MAKE} buildworld 171168404Spjd @cd ${.CURDIR}; ${_MAKE} -B installworld 172168404Spjd.if target(post-world) 173168404Spjd @echo 174168404Spjd @echo "--------------------------------------------------------------" 175168404Spjd @echo ">>> Making 'post-world' target" 176168404Spjd @echo "--------------------------------------------------------------" 177168404Spjd @cd ${.CURDIR}; ${_MAKE} post-world 178168404Spjd.endif 179168404Spjd @echo 180168404Spjd @echo "--------------------------------------------------------------" 181168404Spjd @echo ">>> make world completed on `LC_ALL=C date`" 182168404Spjd @echo " (started ${STARTTIME})" 183168404Spjd @echo "--------------------------------------------------------------" 184168404Spjd.else 185168404Spjdworld: 186168404Spjd @echo "WARNING: make world will overwrite your existing FreeBSD" 187168404Spjd @echo "installation without also building and installing a new" 188168404Spjd @echo "kernel. This can be dangerous. Please read the handbook," 189168404Spjd @echo "'Using make world', for how to upgrade your system." 190168404Spjd @echo "Define DESTDIR to the where you want to install FreeBSD, 191168404Spjd @echo "including /, to override this warning and proceed as usual." 192168404Spjd @echo "Bailing out now..." 193168404Spjd @false 194168404Spjd.endif 195168404Spjd 196168404Spjd# 197168404Spjd# kernel 198168404Spjd# 199230438Spjd# Short hand for `make buildkernel installkernel' 200230438Spjd# 201230438Spjdkernel: buildkernel installkernel 202230438Spjd 203230438Spjd# 204230438Spjd# Perform a few tests to determine if the installed tools are adequate 205230438Spjd# for building the world. 206230438Spjd# 207168404Spjdupgrade_checks: 208168404Spjd @if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \ 209168404Spjd PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 210168404Spjd then \ 211168404Spjd (cd ${.CURDIR} && make make); \ 212168404Spjd fi 213168404Spjd 214168404Spjd# 215168404Spjd# Upgrade make(1) to the current version using the installed 216168404Spjd# headers, libraries and tools. 217168404Spjd# 218168404SpjdMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 219168404Spjd DESTDIR= \ 220168404Spjd INSTALL="sh ${.CURDIR}/tools/install.sh" 221168404SpjdMMAKE= ${MMAKEENV} make \ 222168404Spjd -D_UPGRADING \ 223168404Spjd -DNOMAN -DNOSHARED \ 224168404Spjd -DNO_CPU_CFLAGS -DNO_WERROR 225168404Spjd 226168404Spjdmake: .PHONY 227168404Spjd @echo 228168404Spjd @echo "--------------------------------------------------------------" 229168404Spjd @echo ">>> Building an up-to-date make(1)" 230168404Spjd @echo "--------------------------------------------------------------" 231168404Spjd @cd ${.CURDIR}/usr.bin/make; \ 232168404Spjd ${MMAKE} obj && \ 233168404Spjd ${MMAKE} depend && \ 234168404Spjd ${MMAKE} all && \ 235168404Spjd ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 236168404Spjd 237168404Spjd# 238168404Spjd# universe 239168404Spjd# 240168404Spjd# Attempt to rebuild *everything* for all supported architectures, 241168404Spjd# with reasonable chance of success, regardless of how old your 242168404Spjd# existing system is. 243168404Spjd# 244168404Spjdi386_mach= pc98 245168404Spjduniverse: 246168404Spjd @echo "--------------------------------------------------------------" 247230438Spjd @echo ">>> make universe started on ${STARTTIME}" 248230438Spjd @echo "--------------------------------------------------------------" 249230438Spjd.for arch in i386 sparc64 alpha ia64 amd64 250230438Spjd.for mach in ${arch} ${${arch}_mach} 251230438Spjd @echo ">> ${mach} started on `LC_ALL=C date`" 252230438Spjd -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 253230438Spjd TARGET_ARCH=${arch} TARGET=${mach} \ 254168404Spjd __MAKE_CONF=/dev/null \ 255168404Spjd > _.${mach}.buildworld 2>&1 256168404Spjd @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 257168404Spjd.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 258168404Spjd -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 259168404Spjd > ${.CURDIR}/_.${mach}.makeLINT 2>&1 260168404Spjd.endif 261168404Spjd cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 262168404Spjd @echo ">> ${mach} completed on `LC_ALL=C date`" 263168404Spjd.endfor 264168404Spjd.endfor 265168404Spjd @echo "--------------------------------------------------------------" 266168404Spjd @echo ">>> make universe completed on `LC_ALL=C date`" 267168404Spjd @echo " (started ${STARTTIME})" 268168404Spjd @echo "--------------------------------------------------------------" 269168404Spjd 270168404Spjd.if make(buildkernels) 271168404SpjdKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 272168404Spjd find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 273168404Spjd.endif 274168404Spjd 275168404Spjdbuildkernels: 276168404Spjd.for kernel in ${KERNCONFS} 277168404Spjd -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 278168404Spjd KERNCONF=${kernel} \ 279168404Spjd __MAKE_CONF=/dev/null \ 280168404Spjd > _.${TARGET}.${kernel} 2>&1 281168404Spjd.endfor 282168404Spjd