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). 20e2a36081SAlexander Leidinger# check-old - Print a list of old files/directories in the system. 21e2a36081SAlexander Leidinger# delete-old - Delete obsolete files and directories interactively. 22e2a36081SAlexander Leidinger# delete-old-libs - Delete obsolete libraries interactively. 233540f0e1SJordan K. Hubbard# 2411fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads 2511fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the 2611fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too 2711fb97daSJohn Birrell# much how different the installed mk files are from those in the source 2811fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use 2911fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT. 3011fb97daSJohn Birrell# 31912422f0SGiorgos Keramidas# The user-driven targets (as listed above) are implemented in Makefile.inc1. 3211fb97daSJohn Birrell# 3376fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has 3476fdd728SJohn W. De Boskey# at least 400MB of diskspace available. 3511fb97daSJohn Birrell# 3676fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their 3776fdd728SJohn W. De Boskey# system, the simple instructions are: 3811fb97daSJohn Birrell# 3976fdd728SJohn W. De Boskey# 1. `cd /usr/src' (or to the directory containing your source tree). 40fb55e855STom Rhodes# 2. Define `HISTORICAL_MAKE_WORLD' variable (see README). 41fb55e855STom Rhodes# 3. `make world' 4211fb97daSJohn Birrell# 4376fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a 4476fdd728SJohn W. De Boskey# delta of a few days): 4576fdd728SJohn W. De Boskey# 4676fdd728SJohn W. De Boskey# 1. `cd /usr/src' (or to the directory containing your source tree). 4776fdd728SJohn W. De Boskey# 2. `make buildworld' 4876fdd728SJohn W. De Boskey# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4976fdd728SJohn W. De Boskey# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 502c5e89c2SDavid E. O'Brien# [steps 3. & 4. can be combined by using the "kernel" target] 5176fdd728SJohn W. De Boskey# 5. `reboot' (in single user mode: boot -s from the loader prompt). 5276fdd728SJohn W. De Boskey# 6. `mergemaster -p' 5376fdd728SJohn W. De Boskey# 7. `make installworld' 54e2a36081SAlexander Leidinger# 8. `make delete-old' 55e2a36081SAlexander Leidinger# 9. `mergemaster' 56e2a36081SAlexander Leidinger# 10. `reboot' 57e2a36081SAlexander Leidinger# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) 5876fdd728SJohn W. De Boskey# 5976fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information. 6011fb97daSJohn Birrell# 611fde59f3SRuslan Ermilov# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can 621fde59f3SRuslan Ermilov# cross build world for other machine types using the buildworld target, 63dbc3719dSMatthew Dillon# and once the world is built you can cross build a kernel using the 64dbc3719dSMatthew Dillon# buildkernel target. 65dbc3719dSMatthew Dillon# 6611fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical 6711fb97daSJohn Birrell# order, but that's not important. 6811fb97daSJohn Birrell# 69ef7af95aSPeter Wemm# Targets that begin with underscore are internal targets intended for 70ef7af95aSPeter Wemm# developer convenience only. They are intentionally not documented and 71ef7af95aSPeter Wemm# completely subject to change without notice. 72ef7af95aSPeter Wemm# 73621e4ae1SWarner LoshTGTS= all all-man buildenv buildenvvars buildkernel buildworld check-old \ 74621e4ae1SWarner Losh checkdpadd clean cleandepend cleandir delete-old delete-old-libs \ 75621e4ae1SWarner Losh depend distribute distributeworld distrib-dirs distribution doxygen \ 76becc5c62SAlexander Leidinger everything hierarchy install installcheck installkernel \ 77becc5c62SAlexander Leidinger installkernel.debug reinstallkernel reinstallkernel.debug \ 78becc5c62SAlexander Leidinger installworld kernel-toolchain libraries lint maninstall \ 79c3ed02cfSRuslan Ermilov obj objlink regress rerelease showconfig tags toolchain update \ 80ef7af95aSPeter Wemm _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 811d9468eeSPeter Wemm _build-tools _cross-tools _includes _libraries _depend \ 82ece6831dSRuslan Ermilov build32 distribute32 install32 83902f7c5bSRuslan ErmilovTGTS+= ${SUBDIR_TARGETS} 846e59a256SMarcel Moolenaar 85af2dc868SRuslan ErmilovBITGTS= files includes 8628d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 87b797df80SRuslan ErmilovTGTS+= ${BITGTS} 8828d2080aSRuslan Ermilov 89d672a609SRuslan Ermilov.ORDER: buildworld installworld 908f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld 9120902bd3SRuslan Ermilov.ORDER: buildworld buildkernel 92d672a609SRuslan Ermilov.ORDER: buildkernel installkernel 930147d2aaSHidetoshi Shimokawa.ORDER: buildkernel installkernel.debug 94d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel 950147d2aaSHidetoshi Shimokawa.ORDER: buildkernel reinstallkernel.debug 96d672a609SRuslan Ermilov 9776499f15SRuslan ErmilovPATH= /sbin:/bin:/usr/sbin:/usr/bin 982e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?= /usr/obj 99e9bddef1SRuslan Ermilov_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ 100f1fb2096SYaroslav Tykhiy ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ 1010ec443a0SRuslan Ermilov -f /dev/null -V MAKEOBJDIRPREFIX dummy 1020ec443a0SRuslan Ermilov.if !empty(_MAKEOBJDIRPREFIX) 1030ec443a0SRuslan Ermilov.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ 104f1fb2096SYaroslav Tykhiy (in make.conf(5)) or command-line variable. 1050ec443a0SRuslan Ermilov.endif 10676499f15SRuslan ErmilovMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 107ead4296eSRuslan ErmilovBINMAKE= \ 10876499f15SRuslan Ermilov `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 1095dc63117SRuslan Ermilov -m ${.CURDIR}/share/mk 110ead4296eSRuslan Ermilov_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 111a962de47SPeter Wemm 112a962de47SPeter Wemm# 113d911f786SMarcel Moolenaar# Make sure we have an up-to-date make(1). Only world and buildworld 114d911f786SMarcel Moolenaar# should do this as those are the initial targets used for upgrades. 115d911f786SMarcel Moolenaar# The user can define ALWAYS_CHECK_MAKE to have this check performed 116d911f786SMarcel Moolenaar# for all targets. 117d911f786SMarcel Moolenaar# 118d911f786SMarcel Moolenaar.if defined(ALWAYS_CHECK_MAKE) 119b797df80SRuslan Ermilov${TGTS}: upgrade_checks 120d911f786SMarcel Moolenaar.else 121d911f786SMarcel Moolenaarbuildworld: upgrade_checks 122d911f786SMarcel Moolenaar.endif 123d911f786SMarcel Moolenaar 124d911f786SMarcel Moolenaar# 125224f0698SGarance A Drosehn# This 'cleanworld' target is not included in TGTS, because it is not a 1261a974787SGarance A Drosehn# recursive target. All of the work for it is done right here. It is 1271a974787SGarance A Drosehn# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 1281a974787SGarance A Drosehn# created by bsd.obj.mk, except that we don't want to .include that file 1291a974787SGarance A Drosehn# in this makefile. 1301a974787SGarance A Drosehn# 1311a974787SGarance A Drosehn# In the following, the first 'rm' in a series will usually remove all 1321a974787SGarance A Drosehn# files and directories. If it does not, then there are probably some 1331a974787SGarance A Drosehn# files with chflags set, so this unsets them and tries the 'rm' a 1341a974787SGarance A Drosehn# second time. There are situations where this target will be cleaning 1351a974787SGarance A Drosehn# some directories via more than one method, but that duplication is 1361a974787SGarance A Drosehn# needed to correctly handle all the possible situations. 1371a974787SGarance A Drosehn# 1381a974787SGarance A DrosehnBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 139224f0698SGarance A Drosehncleanworld: 1401a974787SGarance A Drosehn.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 1411a974787SGarance A Drosehn.if exists(${BW_CANONICALOBJDIR}/) 1421a974787SGarance A Drosehn -rm -rf ${BW_CANONICALOBJDIR}/* 1431a974787SGarance A Drosehn chflags -R 0 ${BW_CANONICALOBJDIR} 1441a974787SGarance A Drosehn rm -rf ${BW_CANONICALOBJDIR}/* 1451a974787SGarance A Drosehn.endif 1461a974787SGarance A Drosehn # To be safe in this case, fall back to a 'make cleandir' 147088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir 1481a974787SGarance A Drosehn.else 1491a974787SGarance A Drosehn -rm -rf ${.OBJDIR}/* 1501a974787SGarance A Drosehn chflags -R 0 ${.OBJDIR} 1511a974787SGarance A Drosehn rm -rf ${.OBJDIR}/* 1521a974787SGarance A Drosehn.endif 1532047c5d3SGarance A Drosehn 1542047c5d3SGarance A Drosehn# 15511fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files. 156f3c4dd0dSBruce Evans# 157d911f786SMarcel Moolenaar 158b797df80SRuslan Ermilov${TGTS}: 159088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; \ 16076499f15SRuslan Ermilov ${_MAKE} ${.TARGET} 161c3d9b0f0SRodney W. Grimes 162ce53af53SJordan K. Hubbard# Set a reasonable default 163ce53af53SJordan K. Hubbard.MAIN: all 164ce53af53SJordan K. Hubbard 165afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date 166d18c9906SRuslan Ermilov 167d18c9906SRuslan Ermilov.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 1686e59a256SMarcel Moolenaar# 1696e59a256SMarcel Moolenaar# world 1706e59a256SMarcel Moolenaar# 1710a945825SMarcel Moolenaar# Attempt to rebuild and reinstall everything. This target is not to be 1720a945825SMarcel Moolenaar# used for upgrading an existing FreeBSD system, because the kernel is 1730a945825SMarcel Moolenaar# not included. One can argue that this target doesn't build everything 1740a945825SMarcel Moolenaar# then. 1756e59a256SMarcel Moolenaar# 1766e59a256SMarcel Moolenaarworld: upgrade_checks 1776e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1785ab77811SRuslan Ermilov @echo ">>> make world started on ${STARTTIME}" 1796e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1806e59a256SMarcel Moolenaar.if target(pre-world) 1816e59a256SMarcel Moolenaar @echo 1826e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1836e59a256SMarcel Moolenaar @echo ">>> Making 'pre-world' target" 1846e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 185088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world 1866e59a256SMarcel Moolenaar.endif 187088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld 188088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld 1896e59a256SMarcel Moolenaar.if target(post-world) 1906e59a256SMarcel Moolenaar @echo 1916e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1926e59a256SMarcel Moolenaar @echo ">>> Making 'post-world' target" 1936e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 194088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world 1956e59a256SMarcel Moolenaar.endif 1966e59a256SMarcel Moolenaar @echo 1976e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1985ab77811SRuslan Ermilov @echo ">>> make world completed on `LC_ALL=C date`" 1995ab77811SRuslan Ermilov @echo " (started ${STARTTIME})" 2006e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 2010a945825SMarcel Moolenaar.else 2020a945825SMarcel Moolenaarworld: 2030a945825SMarcel Moolenaar @echo "WARNING: make world will overwrite your existing FreeBSD" 2040a945825SMarcel Moolenaar @echo "installation without also building and installing a new" 2050a945825SMarcel Moolenaar @echo "kernel. This can be dangerous. Please read the handbook," 2061f6483e4SKen Smith @echo "'Rebuilding world', for how to upgrade your system." 207954c5b43SMark Murray @echo "Define DESTDIR to where you want to install FreeBSD," 2080a945825SMarcel Moolenaar @echo "including /, to override this warning and proceed as usual." 209954c5b43SMark Murray @echo "" 2100a945825SMarcel Moolenaar @echo "Bailing out now..." 2110a945825SMarcel Moolenaar @false 2120a945825SMarcel Moolenaar.endif 2136e59a256SMarcel Moolenaar 214cf94fb21SBruce Evans# 215d672a609SRuslan Ermilov# kernel 216d672a609SRuslan Ermilov# 217d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel' 218d672a609SRuslan Ermilov# 219d672a609SRuslan Ermilovkernel: buildkernel installkernel 220d672a609SRuslan Ermilov 221d672a609SRuslan Ermilov# 22211fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate 223113cf9e6SRuslan Ermilov# for building the world. 22411fb97daSJohn Birrell# 22511fb97daSJohn Birrellupgrade_checks: 226012a8b3fSHartmut Brandt @if ! (cd ${.CURDIR}/tools/build/make_check && \ 22789f087e8SHartmut Brandt PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ 228ef2c779bSRuslan Ermilov PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 22976499f15SRuslan Ermilov then \ 23076499f15SRuslan Ermilov (cd ${.CURDIR} && make make); \ 23176499f15SRuslan Ermilov fi 2326a8d432dSMark Murray 233a962de47SPeter Wemm# 2342e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed 235113cf9e6SRuslan Ermilov# headers, libraries and tools. 236549f978aSMarcel Moolenaar# 2372e84ab94SRuslan ErmilovMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 2382e84ab94SRuslan Ermilov DESTDIR= \ 2392e84ab94SRuslan Ermilov INSTALL="sh ${.CURDIR}/tools/install.sh" 2402e84ab94SRuslan ErmilovMMAKE= ${MMAKEENV} make \ 2412e84ab94SRuslan Ermilov -D_UPGRADING \ 24283c7ade9SRuslan Ermilov -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ 243ba70462cSJohn Birrell -DNO_CPU_CFLAGS -DNO_WERROR 2442e84ab94SRuslan Ermilov 2452a6e9f88SKris Kennawaymake: .PHONY 246549f978aSMarcel Moolenaar @echo 247549f978aSMarcel Moolenaar @echo "--------------------------------------------------------------" 248b31745f5SRuslan Ermilov @echo ">>> Building an up-to-date make(1)" 249549f978aSMarcel Moolenaar @echo "--------------------------------------------------------------" 250088cf0fbSHartmut Brandt ${_+_}@cd ${.CURDIR}/usr.bin/make; \ 2512e84ab94SRuslan Ermilov ${MMAKE} obj && \ 2522e84ab94SRuslan Ermilov ${MMAKE} depend && \ 2532e84ab94SRuslan Ermilov ${MMAKE} all && \ 2542e84ab94SRuslan Ermilov ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 255549f978aSMarcel Moolenaar 256549f978aSMarcel Moolenaar# 2571f4f7670SRuslan Ermilov# universe 2581f4f7670SRuslan Ermilov# 2591f4f7670SRuslan Ermilov# Attempt to rebuild *everything* for all supported architectures, 260d18c9906SRuslan Ermilov# with a reasonable chance of success, regardless of how old your 2611f4f7670SRuslan Ermilov# existing system is. 2621f4f7670SRuslan Ermilov# 263dd0f3923SRuslan Ermilov.if make(universe) 2641bdb3fb9SMarcel MoolenaarTARGETS?=amd64 arm i386 ia64 pc98 powerpc sparc64 sun4v 2651bdb3fb9SMarcel Moolenaar 266d18c9906SRuslan Ermilovuniverse: universe_prologue 267d18c9906SRuslan Ermilovuniverse_prologue: 26877c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 26977c1699fSPoul-Henning Kamp @echo ">>> make universe started on ${STARTTIME}" 27077c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 2711bdb3fb9SMarcel Moolenaar.for target in ${TARGETS} 2721fde59f3SRuslan ErmilovKERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ 273d72ae1eaSRuslan Ermilov find [A-Z]*[A-Z] -type f -maxdepth 0 \ 274e9729318SRuslan Ermilov ! -name DEFAULTS ! -name LINT 275dd0f3923SRuslan ErmilovKERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} 2761fde59f3SRuslan Ermilovuniverse: universe_${target} 2771fde59f3SRuslan Ermilov.ORDER: universe_prologue universe_${target} universe_epilogue 2781fde59f3SRuslan Ermilovuniverse_${target}: 2791fde59f3SRuslan Ermilov @echo ">> ${target} started on `LC_ALL=C date`" 2800d4e175dSPoul-Henning Kamp -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 2811fde59f3SRuslan Ermilov TARGET=${target} \ 28277c1699fSPoul-Henning Kamp __MAKE_CONF=/dev/null \ 2831fde59f3SRuslan Ermilov > _.${target}.buildworld 2>&1 2841fde59f3SRuslan Ermilov @echo ">> ${target} buildworld completed on `LC_ALL=C date`" 2851fde59f3SRuslan Ermilov.if exists(${.CURDIR}/sys/${target}/conf/NOTES) 2861fde59f3SRuslan Ermilov -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ 2871fde59f3SRuslan Ermilov > ${.CURDIR}/_.${target}.makeLINT 2>&1 28877c1699fSPoul-Henning Kamp.endif 289dd0f3923SRuslan Ermilov.for kernel in ${KERNCONFS} 290dd0f3923SRuslan Ermilov -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 2911fde59f3SRuslan Ermilov TARGET=${target} \ 292dd0f3923SRuslan Ermilov KERNCONF=${kernel} \ 293dd0f3923SRuslan Ermilov __MAKE_CONF=/dev/null \ 2941fde59f3SRuslan Ermilov > _.${target}.${kernel} 2>&1 295dd0f3923SRuslan Ermilov.endfor 2961fde59f3SRuslan Ermilov @echo ">> ${target} completed on `LC_ALL=C date`" 297d18c9906SRuslan Ermilov.endfor 298d18c9906SRuslan Ermilovuniverse: universe_epilogue 299d18c9906SRuslan Ermilovuniverse_epilogue: 30077c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 3015ab77811SRuslan Ermilov @echo ">>> make universe completed on `LC_ALL=C date`" 3025ab77811SRuslan Ermilov @echo " (started ${STARTTIME})" 30377c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 304d18c9906SRuslan Ermilov.endif 305