13540f0e1SJordan K. Hubbard# 297d92980SPeter Wemm# $FreeBSD$ 3cf763a57SJohn Birrell# 411fb97daSJohn Birrell# The user-driven targets are: 5cf763a57SJohn Birrell# 61f4f7670SRuslan Ermilov# universe - *Really* build *everything* (buildworld and 71f4f7670SRuslan Ermilov# all kernels on all architectures). 811fb97daSJohn Birrell# buildworld - Rebuild *everything*, including glue to help do 911fb97daSJohn Birrell# upgrades. 1011fb97daSJohn Birrell# installworld - Install everything built by "buildworld". 11fb55e855STom Rhodes# world - buildworld + installworld, no kernel. 1200eb8cbdSAlexander Langer# buildkernel - Rebuild the kernel and the kernel-modules. 1300eb8cbdSAlexander Langer# installkernel - Install the kernel and the kernel-modules. 140147d2aaSHidetoshi Shimokawa# installkernel.debug 15737ffab7SMark Murray# reinstallkernel - Reinstall the kernel and the kernel-modules. 160147d2aaSHidetoshi Shimokawa# reinstallkernel.debug 17bc4311beSDavid E. O'Brien# kernel - buildkernel + installkernel. 18becc5c62SAlexander Leidinger# doxygen - Build API documentation of the kernel, needs doxygen. 1911fb97daSJohn Birrell# update - Convenient way to update your source tree (cvs). 2032cd239bSDag-Erling Smørgrav# check-old - List obsolete directories/files/libraries. 2132cd239bSDag-Erling Smørgrav# check-old-dirs - List obsolete directories. 2232cd239bSDag-Erling Smørgrav# check-old-files - List obsolete files. 2332cd239bSDag-Erling Smørgrav# check-old-libs - List obsolete libraries. 2432cd239bSDag-Erling Smørgrav# delete-old - Delete obsolete directories/files/libraries. 2532cd239bSDag-Erling Smørgrav# delete-old-dirs - Delete obsolete directories. 2632cd239bSDag-Erling Smørgrav# delete-old-files - Delete obsolete files. 2732cd239bSDag-Erling Smørgrav# delete-old-libs - Delete obsolete libraries. 283540f0e1SJordan K. Hubbard# 2911fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads 3011fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the 3111fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too 3211fb97daSJohn Birrell# much how different the installed mk files are from those in the source 3311fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use 3411fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT. 3511fb97daSJohn Birrell# 36912422f0SGiorgos Keramidas# The user-driven targets (as listed above) are implemented in Makefile.inc1. 3711fb97daSJohn Birrell# 3876fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has 3976fdd728SJohn W. De Boskey# at least 400MB of diskspace available. 4011fb97daSJohn Birrell# 4176fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their 4276fdd728SJohn W. De Boskey# system, the simple instructions are: 4311fb97daSJohn Birrell# 4476fdd728SJohn W. De Boskey# 1. `cd /usr/src' (or to the directory containing your source tree). 45fb55e855STom Rhodes# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 46fb55e855STom Rhodes# 3. `make world' 4711fb97daSJohn Birrell# 4876fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a 4976fdd728SJohn W. De Boskey# delta of a few days): 5076fdd728SJohn W. De Boskey# 5176fdd728SJohn W. De Boskey# 1. `cd /usr/src' (or to the directory containing your source tree). 5276fdd728SJohn W. De Boskey# 2. `make buildworld' 5376fdd728SJohn W. De Boskey# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 5476fdd728SJohn W. De Boskey# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 552c5e89c2SDavid E. O'Brien# [steps 3. & 4. can be combined by using the "kernel" target] 5676fdd728SJohn W. De Boskey# 5. `reboot' (in single user mode: boot -s from the loader prompt). 5776fdd728SJohn W. De Boskey# 6. `mergemaster -p' 5876fdd728SJohn W. De Boskey# 7. `make installworld' 59e2a36081SAlexander Leidinger# 8. `make delete-old' 60e2a36081SAlexander Leidinger# 9. `mergemaster' 61e2a36081SAlexander Leidinger# 10. `reboot' 62e2a36081SAlexander Leidinger# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 6376fdd728SJohn W. De Boskey# 6476fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information. 6511fb97daSJohn Birrell# 661fde59f3SRuslan Ermilov# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 671fde59f3SRuslan Ermilov# cross build world for other machine types using the buildworld target, 68dbc3719dSMatthew Dillon# and once the world is built you can cross build a kernel using the 69dbc3719dSMatthew Dillon# buildkernel target. 70dbc3719dSMatthew Dillon# 7111fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical 7211fb97daSJohn Birrell# order, but that's not important. 7311fb97daSJohn Birrell# 74ef7af95aSPeter Wemm# Targets that begin with underscore are internal targets intended for 75ef7af95aSPeter Wemm# developer convenience only. They are intentionally not documented and 76ef7af95aSPeter Wemm# completely subject to change without notice. 77ef7af95aSPeter Wemm# 7832cd239bSDag-Erling SmørgravTGTS= all all-man buildenv buildenvvars buildkernel buildworld \ 7932cd239bSDag-Erling Smørgrav check-old check-old-dirs check-old-files check-old-libs \ 8032cd239bSDag-Erling Smørgrav checkdpadd clean cleandepend cleandir \ 8132cd239bSDag-Erling Smørgrav delete-old delete-old-dirs delete-old-files delete-old-libs \ 82621e4ae1SWarner Losh depend distribute distributeworld distrib-dirs distribution doxygen \ 83becc5c62SAlexander Leidinger everything hierarchy install installcheck installkernel \ 84becc5c62SAlexander Leidinger installkernel.debug reinstallkernel reinstallkernel.debug \ 85becc5c62SAlexander Leidinger installworld kernel-toolchain libraries lint maninstall \ 86c3ed02cfSRuslan Ermilov obj objlink regress rerelease showconfig tags toolchain update \ 87ef7af95aSPeter Wemm _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 881d9468eeSPeter Wemm _build-tools _cross-tools _includes _libraries _depend \ 89ece6831dSRuslan Ermilov build32 distribute32 install32 90902f7c5bSRuslan ErmilovTGTS+= ${SUBDIR_TARGETS} 916e59a256SMarcel Moolenaar 92af2dc868SRuslan ErmilovBITGTS= files includes 9328d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 94b797df80SRuslan ErmilovTGTS+= ${BITGTS} 9528d2080aSRuslan Ermilov 96d672a609SRuslan Ermilov.ORDER: buildworld installworld 978f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld 9820902bd3SRuslan Ermilov.ORDER: buildworld buildkernel 99d672a609SRuslan Ermilov.ORDER: buildkernel installkernel 1000147d2aaSHidetoshi Shimokawa.ORDER: buildkernel installkernel.debug 101d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel 1020147d2aaSHidetoshi Shimokawa.ORDER: buildkernel reinstallkernel.debug 103d672a609SRuslan Ermilov 10476499f15SRuslan ErmilovPATH= /sbin:/bin:/usr/sbin:/usr/bin 1052e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?= /usr/obj 106e9bddef1SRuslan Ermilov_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 107f1fb2096SYaroslav Tykhiy ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 1080ec443a0SRuslan Ermilov -f /dev/null -V MAKEOBJDIRPREFIX dummy 1090ec443a0SRuslan Ermilov.if !empty(_MAKEOBJDIRPREFIX) 1100ec443a0SRuslan Ermilov.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 111f1fb2096SYaroslav Tykhiy (in make.conf(5)) or command-line variable. 1120ec443a0SRuslan Ermilov.endif 11376499f15SRuslan ErmilovMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 114ead4296eSRuslan ErmilovBINMAKE= \ 11576499f15SRuslan Ermilov `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 1165dc63117SRuslan Ermilov -m ${.CURDIR}/share/mk 117ead4296eSRuslan Ermilov_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 118a962de47SPeter Wemm 119a962de47SPeter Wemm# 120d911f786SMarcel Moolenaar# Make sure we have an up-to-date make(1). Only world and buildworld 121d911f786SMarcel Moolenaar# should do this as those are the initial targets used for upgrades. 122d911f786SMarcel Moolenaar# The user can define ALWAYS_CHECK_MAKE to have this check performed 123d911f786SMarcel Moolenaar# for all targets. 124d911f786SMarcel Moolenaar# 125d911f786SMarcel Moolenaar.if defined(ALWAYS_CHECK_MAKE) 126b797df80SRuslan Ermilov${TGTS}: upgrade_checks 127d911f786SMarcel Moolenaar.else 128d911f786SMarcel Moolenaarbuildworld: upgrade_checks 129d911f786SMarcel Moolenaar.endif 130d911f786SMarcel Moolenaar 131d911f786SMarcel Moolenaar# 132224f0698SGarance A Drosehn# This 'cleanworld' target is not included in TGTS, because it is not a 1331a974787SGarance A Drosehn# recursive target. All of the work for it is done right here. It is 1341a974787SGarance A Drosehn# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 1351a974787SGarance A Drosehn# created by bsd.obj.mk, except that we don't want to .include that file 1361a974787SGarance A Drosehn# in this makefile. 1371a974787SGarance A Drosehn# 1381a974787SGarance A Drosehn# In the following, the first 'rm' in a series will usually remove all 1391a974787SGarance A Drosehn# files and directories. If it does not, then there are probably some 1401a974787SGarance A Drosehn# files with chflags set, so this unsets them and tries the 'rm' a 1411a974787SGarance A Drosehn# second time. There are situations where this target will be cleaning 1421a974787SGarance A Drosehn# some directories via more than one method, but that duplication is 1431a974787SGarance A Drosehn# needed to correctly handle all the possible situations. 1441a974787SGarance A Drosehn# 1451a974787SGarance A DrosehnBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 146224f0698SGarance A Drosehncleanworld: 1471a974787SGarance A Drosehn.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 1481a974787SGarance A Drosehn.if exists(${BW_CANONICALOBJDIR}/) 1491a974787SGarance A Drosehn -rm -rf ${BW_CANONICALOBJDIR}/* 15061858771SXin LI -chflags -R 0 ${BW_CANONICALOBJDIR} 1511a974787SGarance A Drosehn rm -rf ${BW_CANONICALOBJDIR}/* 1521a974787SGarance A Drosehn.endif 1531a974787SGarance A Drosehn # To be safe in this case, fall back to a 'make cleandir' 154088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 1551a974787SGarance A Drosehn.else 1561a974787SGarance A Drosehn -rm -rf ${.OBJDIR}/* 15761858771SXin LI -chflags -R 0 ${.OBJDIR} 1581a974787SGarance A Drosehn rm -rf ${.OBJDIR}/* 1591a974787SGarance A Drosehn.endif 1602047c5d3SGarance A Drosehn 1612047c5d3SGarance A Drosehn# 16211fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files. 163f3c4dd0dSBruce Evans# 164d911f786SMarcel Moolenaar 165b797df80SRuslan Ermilov${TGTS}: 166088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; \ 16776499f15SRuslan Ermilov ${_MAKE} ${.TARGET} 168c3d9b0f0SRodney W. Grimes 169ce53af53SJordan K. Hubbard# Set a reasonable default 170ce53af53SJordan K. Hubbard.MAIN: all 171ce53af53SJordan K. Hubbard 172afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date 173d18c9906SRuslan Ermilov 174d18c9906SRuslan Ermilov.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 1756e59a256SMarcel Moolenaar# 1766e59a256SMarcel Moolenaar# world 1776e59a256SMarcel Moolenaar# 1780a945825SMarcel Moolenaar# Attempt to rebuild and reinstall everything. This target is not to be 1790a945825SMarcel Moolenaar# used for upgrading an existing FreeBSD system, because the kernel is 1800a945825SMarcel Moolenaar# not included. One can argue that this target doesn't build everything 1810a945825SMarcel Moolenaar# then. 1826e59a256SMarcel Moolenaar# 1836e59a256SMarcel Moolenaarworld: upgrade_checks 1846e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1855ab77811SRuslan Ermilov @echo ">>> make world started on ${STARTTIME}" 1866e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1876e59a256SMarcel Moolenaar.if target(pre-world) 1886e59a256SMarcel Moolenaar @echo 1896e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1906e59a256SMarcel Moolenaar @echo ">>> Making 'pre-world' target" 1916e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 192088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 1936e59a256SMarcel Moolenaar.endif 194088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 195088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 1966e59a256SMarcel Moolenaar.if target(post-world) 1976e59a256SMarcel Moolenaar @echo 1986e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1996e59a256SMarcel Moolenaar @echo ">>> Making 'post-world' target" 2006e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 201088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 2026e59a256SMarcel Moolenaar.endif 2036e59a256SMarcel Moolenaar @echo 2046e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 2055ab77811SRuslan Ermilov @echo ">>> make world completed on `LC_ALL=C date`" 2065ab77811SRuslan Ermilov @echo " (started ${STARTTIME})" 2076e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 2080a945825SMarcel Moolenaar.else 2090a945825SMarcel Moolenaarworld: 2100a945825SMarcel Moolenaar @echo "WARNING: make world will overwrite your existing FreeBSD" 2110a945825SMarcel Moolenaar @echo "installation without also building and installing a new" 2120a945825SMarcel Moolenaar @echo "kernel. This can be dangerous. Please read the handbook," 2131f6483e4SKen Smith @echo "'Rebuilding world', for how to upgrade your system." 214954c5b43SMark Murray @echo "Define DESTDIR to where you want to install FreeBSD," 2150a945825SMarcel Moolenaar @echo "including /, to override this warning and proceed as usual." 216954c5b43SMark Murray @echo "" 2170a945825SMarcel Moolenaar @echo "Bailing out now..." 2180a945825SMarcel Moolenaar @false 2190a945825SMarcel Moolenaar.endif 2206e59a256SMarcel Moolenaar 221cf94fb21SBruce Evans# 222d672a609SRuslan Ermilov# kernel 223d672a609SRuslan Ermilov# 224d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel' 225d672a609SRuslan Ermilov# 226d672a609SRuslan Ermilovkernel: buildkernel installkernel 227d672a609SRuslan Ermilov 228d672a609SRuslan Ermilov# 22911fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate 230113cf9e6SRuslan Ermilov# for building the world. 23111fb97daSJohn Birrell# 23211fb97daSJohn Birrellupgrade_checks: 233012a8b3fSHartmut Brandt @if ! (cd ${.CURDIR}/tools/build/make_check && \ 23489f087e8SHartmut Brandt PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 235ef2c779bSRuslan Ermilov PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 23676499f15SRuslan Ermilov then \ 237e2be0fd0SWarner Losh (cd ${.CURDIR} && ${MAKE} make); \ 23876499f15SRuslan Ermilov fi 2396a8d432dSMark Murray 240a962de47SPeter Wemm# 2412e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed 2426029ad99SWarner Losh# headers, libraries and tools. Also, allow the location of 2436029ad99SWarner Losh# the system bsdmake-like utility to be overridden. 244549f978aSMarcel Moolenaar# 2452e84ab94SRuslan ErmilovMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 2462e84ab94SRuslan Ermilov DESTDIR= \ 2472e84ab94SRuslan Ermilov INSTALL="sh ${.CURDIR}/tools/install.sh" 248e2be0fd0SWarner LoshMMAKE= ${MMAKEENV} ${MAKE} \ 2492e84ab94SRuslan Ermilov -D_UPGRADING \ 25083c7ade9SRuslan Ermilov -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 251ba70462cSJohn Birrell -DNO_CPU_CFLAGS -DNO_WERROR 2522e84ab94SRuslan Ermilov 2532a6e9f88SKris Kennawaymake: .PHONY 254549f978aSMarcel Moolenaar @echo 255549f978aSMarcel Moolenaar @echo "--------------------------------------------------------------" 256b31745f5SRuslan Ermilov @echo ">>> Building an up-to-date make(1)" 257549f978aSMarcel Moolenaar @echo "--------------------------------------------------------------" 258088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 2592e84ab94SRuslan Ermilov ${MMAKE} obj && \ 2602e84ab94SRuslan Ermilov ${MMAKE} depend && \ 2612e84ab94SRuslan Ermilov ${MMAKE} all && \ 2622e84ab94SRuslan Ermilov ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 263549f978aSMarcel Moolenaar 264549f978aSMarcel Moolenaar# 2651f4f7670SRuslan Ermilov# universe 2661f4f7670SRuslan Ermilov# 2671f4f7670SRuslan Ermilov# Attempt to rebuild *everything* for all supported architectures, 268d18c9906SRuslan Ermilov# with a reasonable chance of success, regardless of how old your 2691f4f7670SRuslan Ermilov# existing system is. 2701f4f7670SRuslan Ermilov# 271dd0f3923SRuslan Ermilov.if make(universe) 2721bdb3fb9SMarcel MoolenaarTARGETS?=amd64 arm i386 ia64 pc98 powerpc sparc64 sun4v 2731bdb3fb9SMarcel Moolenaar 274d18c9906SRuslan Ermilovuniverse: universe_prologue 275d18c9906SRuslan Ermilovuniverse_prologue: 27677c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 27777c1699fSPoul-Henning Kamp @echo ">>> make universe started on ${STARTTIME}" 27877c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 2791bdb3fb9SMarcel Moolenaar.for target in ${TARGETS} 2801fde59f3SRuslan ErmilovKERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ 281d72ae1eaSRuslan Ermilov find [A-Z]*[A-Z] -type f -maxdepth 0 \ 282e9729318SRuslan Ermilov ! -name DEFAULTS ! -name LINT 283dd0f3923SRuslan ErmilovKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 2841fde59f3SRuslan Ermilovuniverse: universe_${target} 2851fde59f3SRuslan Ermilov.ORDER: universe_prologue universe_${target} universe_epilogue 2861fde59f3SRuslan Ermilovuniverse_${target}: 2871fde59f3SRuslan Ermilov @echo ">> ${target} started on `LC_ALL=C date`" 2880d4e175dSPoul-Henning Kamp -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 2891fde59f3SRuslan Ermilov TARGET=${target} \ 29077c1699fSPoul-Henning Kamp __MAKE_CONF=/dev/null \ 2911fde59f3SRuslan Ermilov > _.${target}.buildworld 2>&1 2921fde59f3SRuslan Ermilov @echo ">> ${target} buildworld completed on `LC_ALL=C date`" 2931fde59f3SRuslan Ermilov.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 2941fde59f3SRuslan Ermilov -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ 2951fde59f3SRuslan Ermilov > ${.CURDIR}/_.${target}.makeLINT 2>&1 29677c1699fSPoul-Henning Kamp.endif 297dd0f3923SRuslan Ermilov.for kernel in ${KERNCONFS} 298dd0f3923SRuslan Ermilov -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 2991fde59f3SRuslan Ermilov TARGET=${target} \ 300dd0f3923SRuslan Ermilov KERNCONF=${kernel} \ 301dd0f3923SRuslan Ermilov __MAKE_CONF=/dev/null \ 3021fde59f3SRuslan Ermilov > _.${target}.${kernel} 2>&1 303dd0f3923SRuslan Ermilov.endfor 3041fde59f3SRuslan Ermilov @echo ">> ${target} completed on `LC_ALL=C date`" 305d18c9906SRuslan Ermilov.endfor 306d18c9906SRuslan Ermilovuniverse: universe_epilogue 307d18c9906SRuslan Ermilovuniverse_epilogue: 30877c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 3095ab77811SRuslan Ermilov @echo ">>> make universe completed on `LC_ALL=C date`" 3105ab77811SRuslan Ermilov @echo " (started ${STARTTIME})" 31177c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 312d18c9906SRuslan Ermilov.endif 313