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". 1111fb97daSJohn Birrell# world - buildworld + installworld. 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. 1811fb97daSJohn Birrell# update - Convenient way to update your source tree (cvs). 193540f0e1SJordan K. Hubbard# 2011fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads 2111fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the 2211fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too 2311fb97daSJohn Birrell# much how different the installed mk files are from those in the source 2411fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use 2511fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT. 2611fb97daSJohn Birrell# 27912422f0SGiorgos Keramidas# The user-driven targets (as listed above) are implemented in Makefile.inc1. 2811fb97daSJohn Birrell# 2976fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has 3076fdd728SJohn W. De Boskey# at least 400MB of diskspace available. 3111fb97daSJohn Birrell# 3276fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their 3376fdd728SJohn W. De Boskey# system, the simple instructions are: 3411fb97daSJohn Birrell# 3576fdd728SJohn W. De Boskey# 1. `cd /usr/src' (or to the directory containing your source tree). 3676fdd728SJohn W. De Boskey# 2. `make world' 3711fb97daSJohn Birrell# 3876fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a 3976fdd728SJohn W. De Boskey# delta of a few days): 4076fdd728SJohn W. De Boskey# 4176fdd728SJohn W. De Boskey# 1. `cd /usr/src' (or to the directory containing your source tree). 4276fdd728SJohn W. De Boskey# 2. `make buildworld' 4376fdd728SJohn W. De Boskey# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4476fdd728SJohn W. De Boskey# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 4576fdd728SJohn W. De Boskey# 5. `reboot' (in single user mode: boot -s from the loader prompt). 4676fdd728SJohn W. De Boskey# 6. `mergemaster -p' 4776fdd728SJohn W. De Boskey# 7. `make installworld' 4876fdd728SJohn W. De Boskey# 8. `mergemaster' 4976fdd728SJohn W. De Boskey# 9. `reboot' 5076fdd728SJohn W. De Boskey# 5176fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information. 5211fb97daSJohn Birrell# 531b71212bSMatthew Dillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 54dbc3719dSMatthew Dillon# cross build world for other architectures using the buildworld target, 55dbc3719dSMatthew Dillon# and once the world is built you can cross build a kernel using the 56dbc3719dSMatthew Dillon# buildkernel target. 57dbc3719dSMatthew Dillon# 5811fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical 5911fb97daSJohn Birrell# order, but that's not important. 6011fb97daSJohn Birrell# 61ef7af95aSPeter Wemm# Targets that begin with underscore are internal targets intended for 62ef7af95aSPeter Wemm# developer convenience only. They are intentionally not documented and 63ef7af95aSPeter Wemm# completely subject to change without notice. 64ef7af95aSPeter Wemm# 656bde859fSRuslan ErmilovTGTS= all all-man buildkernel buildworld checkdpadd clean \ 668f1f55e9SRuslan Ermilov cleandepend cleandir depend distribute distributeworld everything \ 670147d2aaSHidetoshi Shimokawa hierarchy install installcheck installkernel installkernel.debug\ 68829340b1SRuslan Ermilov reinstallkernel reinstallkernel.debug installworld \ 6943fc6762SDag-Erling Smørgrav kernel-toolchain libraries lint maninstall \ 70839274c7SRuslan Ermilov obj objlink regress rerelease tags toolchain update \ 71ef7af95aSPeter Wemm _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 72ef7af95aSPeter Wemm _build-tools _cross-tools _includes _libraries _depend 736e59a256SMarcel Moolenaar 74af2dc868SRuslan ErmilovBITGTS= files includes 7528d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 76b797df80SRuslan ErmilovTGTS+= ${BITGTS} 7728d2080aSRuslan Ermilov 78d672a609SRuslan Ermilov.ORDER: buildworld installworld 798f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld 8020902bd3SRuslan Ermilov.ORDER: buildworld buildkernel 81d672a609SRuslan Ermilov.ORDER: buildkernel installkernel 820147d2aaSHidetoshi Shimokawa.ORDER: buildkernel installkernel.debug 83d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel 840147d2aaSHidetoshi Shimokawa.ORDER: buildkernel reinstallkernel.debug 85d672a609SRuslan Ermilov 8676499f15SRuslan ErmilovPATH= /sbin:/bin:/usr/sbin:/usr/bin 872e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?= /usr/obj 8876499f15SRuslan ErmilovMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 89ead4296eSRuslan ErmilovBINMAKE= \ 9076499f15SRuslan Ermilov `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 915dc63117SRuslan Ermilov -m ${.CURDIR}/share/mk 92ead4296eSRuslan Ermilov_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 93a962de47SPeter Wemm 94a962de47SPeter Wemm# 95d911f786SMarcel Moolenaar# Make sure we have an up-to-date make(1). Only world and buildworld 96d911f786SMarcel Moolenaar# should do this as those are the initial targets used for upgrades. 97d911f786SMarcel Moolenaar# The user can define ALWAYS_CHECK_MAKE to have this check performed 98d911f786SMarcel Moolenaar# for all targets. 99d911f786SMarcel Moolenaar# 100d911f786SMarcel Moolenaar.if defined(ALWAYS_CHECK_MAKE) 101b797df80SRuslan Ermilov${TGTS}: upgrade_checks 102d911f786SMarcel Moolenaar.else 103d911f786SMarcel Moolenaarbuildworld: upgrade_checks 104d911f786SMarcel Moolenaar.endif 105d911f786SMarcel Moolenaar 106d911f786SMarcel Moolenaar# 107224f0698SGarance A Drosehn# This 'cleanworld' target is not included in TGTS, because it is not a 1081a974787SGarance A Drosehn# recursive target. All of the work for it is done right here. It is 1091a974787SGarance A Drosehn# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 1101a974787SGarance A Drosehn# created by bsd.obj.mk, except that we don't want to .include that file 1111a974787SGarance A Drosehn# in this makefile. 1121a974787SGarance A Drosehn# 1131a974787SGarance A Drosehn# In the following, the first 'rm' in a series will usually remove all 1141a974787SGarance A Drosehn# files and directories. If it does not, then there are probably some 1151a974787SGarance A Drosehn# files with chflags set, so this unsets them and tries the 'rm' a 1161a974787SGarance A Drosehn# second time. There are situations where this target will be cleaning 1171a974787SGarance A Drosehn# some directories via more than one method, but that duplication is 1181a974787SGarance A Drosehn# needed to correctly handle all the possible situations. 1191a974787SGarance A Drosehn# 1201a974787SGarance A DrosehnBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 121224f0698SGarance A Drosehncleanworld: 1221a974787SGarance A Drosehn.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 1231a974787SGarance A Drosehn.if exists(${BW_CANONICALOBJDIR}/) 1241a974787SGarance A Drosehn -rm -rf ${BW_CANONICALOBJDIR}/* 1251a974787SGarance A Drosehn chflags -R 0 ${BW_CANONICALOBJDIR} 1261a974787SGarance A Drosehn rm -rf ${BW_CANONICALOBJDIR}/* 1271a974787SGarance A Drosehn.endif 1281a974787SGarance A Drosehn # To be safe in this case, fall back to a 'make cleandir' 1291a974787SGarance A Drosehn @cd ${.CURDIR}; ${_MAKE} cleandir 1301a974787SGarance A Drosehn.else 1311a974787SGarance A Drosehn -rm -rf ${.OBJDIR}/* 1321a974787SGarance A Drosehn chflags -R 0 ${.OBJDIR} 1331a974787SGarance A Drosehn rm -rf ${.OBJDIR}/* 1341a974787SGarance A Drosehn.endif 1352047c5d3SGarance A Drosehn 1362047c5d3SGarance A Drosehn# 13711fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files. 138f3c4dd0dSBruce Evans# 139d911f786SMarcel Moolenaar 140b797df80SRuslan Ermilov${TGTS}: 14111fb97daSJohn Birrell @cd ${.CURDIR}; \ 14276499f15SRuslan Ermilov ${_MAKE} ${.TARGET} 143c3d9b0f0SRodney W. Grimes 144ce53af53SJordan K. Hubbard# Set a reasonable default 145ce53af53SJordan K. Hubbard.MAIN: all 146ce53af53SJordan K. Hubbard 147954c5b43SMark Murray.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) 1486e14763eSRuslan Ermilov.if make(world) 149afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date 1506e14763eSRuslan Ermilov.endif 1516e59a256SMarcel Moolenaar# 1526e59a256SMarcel Moolenaar# world 1536e59a256SMarcel Moolenaar# 1540a945825SMarcel Moolenaar# Attempt to rebuild and reinstall everything. This target is not to be 1550a945825SMarcel Moolenaar# used for upgrading an existing FreeBSD system, because the kernel is 1560a945825SMarcel Moolenaar# not included. One can argue that this target doesn't build everything 1570a945825SMarcel Moolenaar# then. 1586e59a256SMarcel Moolenaar# 1596e59a256SMarcel Moolenaarworld: upgrade_checks 1606e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1615ab77811SRuslan Ermilov @echo ">>> make world started on ${STARTTIME}" 1626e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1636e59a256SMarcel Moolenaar.if target(pre-world) 1646e59a256SMarcel Moolenaar @echo 1656e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1666e59a256SMarcel Moolenaar @echo ">>> Making 'pre-world' target" 1676e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 16876499f15SRuslan Ermilov @cd ${.CURDIR}; ${_MAKE} pre-world 1696e59a256SMarcel Moolenaar.endif 17076499f15SRuslan Ermilov @cd ${.CURDIR}; ${_MAKE} buildworld 17176499f15SRuslan Ermilov @cd ${.CURDIR}; ${_MAKE} -B installworld 1726e59a256SMarcel Moolenaar.if target(post-world) 1736e59a256SMarcel Moolenaar @echo 1746e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1756e59a256SMarcel Moolenaar @echo ">>> Making 'post-world' target" 1766e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 17776499f15SRuslan Ermilov @cd ${.CURDIR}; ${_MAKE} post-world 1786e59a256SMarcel Moolenaar.endif 1796e59a256SMarcel Moolenaar @echo 1806e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1815ab77811SRuslan Ermilov @echo ">>> make world completed on `LC_ALL=C date`" 1825ab77811SRuslan Ermilov @echo " (started ${STARTTIME})" 1836e59a256SMarcel Moolenaar @echo "--------------------------------------------------------------" 1840a945825SMarcel Moolenaar.else 1850a945825SMarcel Moolenaarworld: 1860a945825SMarcel Moolenaar @echo "WARNING: make world will overwrite your existing FreeBSD" 1870a945825SMarcel Moolenaar @echo "installation without also building and installing a new" 1880a945825SMarcel Moolenaar @echo "kernel. This can be dangerous. Please read the handbook," 1891f6483e4SKen Smith @echo "'Rebuilding world', for how to upgrade your system." 190954c5b43SMark Murray @echo "Define DESTDIR to where you want to install FreeBSD," 1910a945825SMarcel Moolenaar @echo "including /, to override this warning and proceed as usual." 192954c5b43SMark Murray @echo "You may get the historical 'make world' behavior by defining" 193954c5b43SMark Murray @echo "HISTORICAL_MAKE_WORLD. You should understand the implications" 194954c5b43SMark Murray @echo "before doing this." 195954c5b43SMark Murray @echo "" 1960a945825SMarcel Moolenaar @echo "Bailing out now..." 1970a945825SMarcel Moolenaar @false 1980a945825SMarcel Moolenaar.endif 1996e59a256SMarcel Moolenaar 200cf94fb21SBruce Evans# 201d672a609SRuslan Ermilov# kernel 202d672a609SRuslan Ermilov# 203d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel' 204d672a609SRuslan Ermilov# 205d672a609SRuslan Ermilovkernel: buildkernel installkernel 206d672a609SRuslan Ermilov 207d672a609SRuslan Ermilov# 20811fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate 209113cf9e6SRuslan Ermilov# for building the world. 21011fb97daSJohn Birrell# 21111fb97daSJohn Birrellupgrade_checks: 21276499f15SRuslan Ermilov @if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \ 213ef2c779bSRuslan Ermilov PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 21476499f15SRuslan Ermilov then \ 21576499f15SRuslan Ermilov (cd ${.CURDIR} && make make); \ 21676499f15SRuslan Ermilov fi 2176a8d432dSMark Murray 218a962de47SPeter Wemm# 2192e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed 220113cf9e6SRuslan Ermilov# headers, libraries and tools. 221549f978aSMarcel Moolenaar# 2222e84ab94SRuslan ErmilovMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 2232e84ab94SRuslan Ermilov DESTDIR= \ 2242e84ab94SRuslan Ermilov INSTALL="sh ${.CURDIR}/tools/install.sh" 2252e84ab94SRuslan ErmilovMMAKE= ${MMAKEENV} make \ 2262e84ab94SRuslan Ermilov -D_UPGRADING \ 2272e84ab94SRuslan Ermilov -DNOMAN -DNOSHARED \ 2282e84ab94SRuslan Ermilov -DNO_CPU_CFLAGS -DNO_WERROR 2292e84ab94SRuslan Ermilov 2302a6e9f88SKris Kennawaymake: .PHONY 231549f978aSMarcel Moolenaar @echo 232549f978aSMarcel Moolenaar @echo "--------------------------------------------------------------" 233b31745f5SRuslan Ermilov @echo ">>> Building an up-to-date make(1)" 234549f978aSMarcel Moolenaar @echo "--------------------------------------------------------------" 235549f978aSMarcel Moolenaar @cd ${.CURDIR}/usr.bin/make; \ 2362e84ab94SRuslan Ermilov ${MMAKE} obj && \ 2372e84ab94SRuslan Ermilov ${MMAKE} depend && \ 2382e84ab94SRuslan Ermilov ${MMAKE} all && \ 2392e84ab94SRuslan Ermilov ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 240549f978aSMarcel Moolenaar 241549f978aSMarcel Moolenaar# 2421f4f7670SRuslan Ermilov# universe 2431f4f7670SRuslan Ermilov# 2441f4f7670SRuslan Ermilov# Attempt to rebuild *everything* for all supported architectures, 2451f4f7670SRuslan Ermilov# with reasonable chance of success, regardless of how old your 2461f4f7670SRuslan Ermilov# existing system is. 2471f4f7670SRuslan Ermilov# 2481f4f7670SRuslan Ermilovi386_mach= pc98 24977c1699fSPoul-Henning Kampuniverse: 25077c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 25177c1699fSPoul-Henning Kamp @echo ">>> make universe started on ${STARTTIME}" 25277c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 253506f4c06SJohan Karlsson.for arch in i386 sparc64 alpha ia64 amd64 2541f4f7670SRuslan Ermilov.for mach in ${arch} ${${arch}_mach} 2551f4f7670SRuslan Ermilov @echo ">> ${mach} started on `LC_ALL=C date`" 2560d4e175dSPoul-Henning Kamp -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ 2571f4f7670SRuslan Ermilov TARGET_ARCH=${arch} TARGET=${mach} \ 25877c1699fSPoul-Henning Kamp __MAKE_CONF=/dev/null \ 2591f4f7670SRuslan Ermilov > _.${mach}.buildworld 2>&1 2601f4f7670SRuslan Ermilov @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 2611f4f7670SRuslan Ermilov.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 2621f4f7670SRuslan Ermilov -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 263301c4069SRuslan Ermilov > ${.CURDIR}/_.${mach}.makeLINT 2>&1 26477c1699fSPoul-Henning Kamp.endif 2650d4e175dSPoul-Henning Kamp cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 2661f4f7670SRuslan Ermilov @echo ">> ${mach} completed on `LC_ALL=C date`" 26777c1699fSPoul-Henning Kamp.endfor 2681f4f7670SRuslan Ermilov.endfor 26977c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 2705ab77811SRuslan Ermilov @echo ">>> make universe completed on `LC_ALL=C date`" 2715ab77811SRuslan Ermilov @echo " (started ${STARTTIME})" 27277c1699fSPoul-Henning Kamp @echo "--------------------------------------------------------------" 27377c1699fSPoul-Henning Kamp 2746e14763eSRuslan Ermilov.if make(buildkernels) 2751f4f7670SRuslan ErmilovKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 2761f4f7670SRuslan Ermilov find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 2776e14763eSRuslan Ermilov.endif 27877c1699fSPoul-Henning Kamp 27977c1699fSPoul-Henning Kampbuildkernels: 2801f4f7670SRuslan Ermilov.for kernel in ${KERNCONFS} 2810d4e175dSPoul-Henning Kamp -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ 2821f4f7670SRuslan Ermilov KERNCONF=${kernel} \ 28377c1699fSPoul-Henning Kamp __MAKE_CONF=/dev/null \ 2841f4f7670SRuslan Ermilov > _.${TARGET}.${kernel} 2>&1 28577c1699fSPoul-Henning Kamp.endfor 286