xref: /freebsd/Makefile (revision d911f786)
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).
1911fb97daSJohn Birrell# most                - Build user commands, no libraries or include files.
2011fb97daSJohn Birrell# installmost         - Install user commands, no libraries or include files.
213540f0e1SJordan K. Hubbard#
2211fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads
2311fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the
2411fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too
2511fb97daSJohn Birrell# much how different the installed mk files are from those in the source
2611fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use
2711fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT.
2811fb97daSJohn Birrell#
29912422f0SGiorgos Keramidas# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3011fb97daSJohn Birrell#
3176fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has
3276fdd728SJohn W. De Boskey# at least 400MB of diskspace available.
3311fb97daSJohn Birrell#
3476fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their
3576fdd728SJohn W. De Boskey# system, the simple instructions are:
3611fb97daSJohn Birrell#
3776fdd728SJohn W. De Boskey# 1.  `cd /usr/src'  (or to the directory containing your source tree).
3876fdd728SJohn W. De Boskey# 2.  `make world'
3911fb97daSJohn Birrell#
4076fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a
4176fdd728SJohn W. De Boskey# delta of a few days):
4276fdd728SJohn W. De Boskey#
4376fdd728SJohn W. De Boskey# 1.  `cd /usr/src'       (or to the directory containing your source tree).
4476fdd728SJohn W. De Boskey# 2.  `make buildworld'
4576fdd728SJohn W. De Boskey# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
4676fdd728SJohn W. De Boskey# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
4776fdd728SJohn W. De Boskey# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
4876fdd728SJohn W. De Boskey# 6.  `mergemaster -p'
4976fdd728SJohn W. De Boskey# 7.  `make installworld'
5076fdd728SJohn W. De Boskey# 8.  `mergemaster'
5176fdd728SJohn W. De Boskey# 9.  `reboot'
5276fdd728SJohn W. De Boskey#
5376fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information.
5411fb97daSJohn Birrell#
551b71212bSMatthew Dillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
56dbc3719dSMatthew Dillon# cross build world for other architectures using the buildworld target,
57dbc3719dSMatthew Dillon# and once the world is built you can cross build a kernel using the
58dbc3719dSMatthew Dillon# buildkernel target.
59dbc3719dSMatthew Dillon#
6011fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical
6111fb97daSJohn Birrell# order, but that's not important.
6211fb97daSJohn Birrell#
636bde859fSRuslan ErmilovTGTS=	all all-man buildkernel buildworld checkdpadd clean \
648f1f55e9SRuslan Ermilov	cleandepend cleandir depend distribute distributeworld everything \
650147d2aaSHidetoshi Shimokawa	hierarchy install installcheck installkernel installkernel.debug\
660147d2aaSHidetoshi Shimokawa	reinstallkernel reinstallkernel.debug installmost installworld \
670147d2aaSHidetoshi Shimokawa	libraries lint maninstall \
689d1086a6SRuslan Ermilov	most obj objlink regress rerelease tags update
696e59a256SMarcel Moolenaar
70af2dc868SRuslan ErmilovBITGTS=	files includes
7128d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
7228d2080aSRuslan Ermilov
73d672a609SRuslan Ermilov.ORDER: buildworld installworld
748f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld
7520902bd3SRuslan Ermilov.ORDER: buildworld buildkernel
76d672a609SRuslan Ermilov.ORDER: buildkernel installkernel
770147d2aaSHidetoshi Shimokawa.ORDER: buildkernel installkernel.debug
78d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel
790147d2aaSHidetoshi Shimokawa.ORDER: buildkernel reinstallkernel.debug
80d672a609SRuslan Ermilov
8176499f15SRuslan ErmilovPATH=	/sbin:/bin:/usr/sbin:/usr/bin
822e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?=	/usr/obj
8376499f15SRuslan ErmilovMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
84ead4296eSRuslan ErmilovBINMAKE= \
8576499f15SRuslan Ermilov	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
865dc63117SRuslan Ermilov	-m ${.CURDIR}/share/mk
87ead4296eSRuslan Ermilov_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
88a962de47SPeter Wemm
89a962de47SPeter Wemm#
90d911f786SMarcel Moolenaar# Make sure we have an up-to-date make(1). Only world and buildworld
91d911f786SMarcel Moolenaar# should do this as those are the initial targets used for upgrades.
92d911f786SMarcel Moolenaar# The user can define ALWAYS_CHECK_MAKE to have this check performed
93d911f786SMarcel Moolenaar# for all targets.
94d911f786SMarcel Moolenaar#
95d911f786SMarcel Moolenaar.if defined(ALWAYS_CHECK_MAKE)
96d911f786SMarcel Moolenaar${TGTS} ${BITGTS}: upgrade_checks
97d911f786SMarcel Moolenaar.else
98d911f786SMarcel Moolenaarbuildworld: upgrade_checks
99d911f786SMarcel Moolenaar.endif
100d911f786SMarcel Moolenaar
101d911f786SMarcel Moolenaar#
10211fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files.
103f3c4dd0dSBruce Evans#
104d911f786SMarcel Moolenaar
105d911f786SMarcel Moolenaar${TGTS} ${BITGTS}:
10611fb97daSJohn Birrell	@cd ${.CURDIR}; \
10776499f15SRuslan Ermilov		${_MAKE} ${.TARGET}
108c3d9b0f0SRodney W. Grimes
109ce53af53SJordan K. Hubbard# Set a reasonable default
110ce53af53SJordan K. Hubbard.MAIN:	all
111ce53af53SJordan K. Hubbard
112afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date
1136e59a256SMarcel Moolenaar#
1146e59a256SMarcel Moolenaar# world
1156e59a256SMarcel Moolenaar#
1166e59a256SMarcel Moolenaar# Attempt to rebuild and reinstall *everything*, with reasonable chance of
1176e59a256SMarcel Moolenaar# success, regardless of how old your existing system is.
1186e59a256SMarcel Moolenaar#
1196e59a256SMarcel Moolenaarworld: upgrade_checks
1206e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1215ab77811SRuslan Ermilov	@echo ">>> make world started on ${STARTTIME}"
1226e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1236e59a256SMarcel Moolenaar.if target(pre-world)
1246e59a256SMarcel Moolenaar	@echo
1256e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1266e59a256SMarcel Moolenaar	@echo ">>> Making 'pre-world' target"
1276e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
12876499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} pre-world
1296e59a256SMarcel Moolenaar.endif
13076499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} buildworld
13176499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} -B installworld
1326e59a256SMarcel Moolenaar.if target(post-world)
1336e59a256SMarcel Moolenaar	@echo
1346e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1356e59a256SMarcel Moolenaar	@echo ">>> Making 'post-world' target"
1366e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
13776499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} post-world
1386e59a256SMarcel Moolenaar.endif
1396e59a256SMarcel Moolenaar	@echo
1406e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1415ab77811SRuslan Ermilov	@echo ">>> make world completed on `LC_ALL=C date`"
1425ab77811SRuslan Ermilov	@echo "                   (started ${STARTTIME})"
1436e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1446e59a256SMarcel Moolenaar
145cf94fb21SBruce Evans#
146d672a609SRuslan Ermilov# kernel
147d672a609SRuslan Ermilov#
148d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel'
149d672a609SRuslan Ermilov#
150d672a609SRuslan Ermilovkernel: buildkernel installkernel
151d672a609SRuslan Ermilov
152d672a609SRuslan Ermilov#
15311fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate
154113cf9e6SRuslan Ermilov# for building the world.
15511fb97daSJohn Birrell#
15611fb97daSJohn Birrellupgrade_checks:
15776499f15SRuslan Ermilov	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
158ef2c779bSRuslan Ermilov	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
15976499f15SRuslan Ermilov	then \
16076499f15SRuslan Ermilov	    (cd ${.CURDIR} && make make); \
16176499f15SRuslan Ermilov	fi
1626a8d432dSMark Murray
163a962de47SPeter Wemm#
1642e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed
165113cf9e6SRuslan Ermilov# headers, libraries and tools.
166549f978aSMarcel Moolenaar#
1672e84ab94SRuslan ErmilovMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
1682e84ab94SRuslan Ermilov		DESTDIR= \
1692e84ab94SRuslan Ermilov		INSTALL="sh ${.CURDIR}/tools/install.sh"
1702e84ab94SRuslan ErmilovMMAKE=		${MMAKEENV} make \
1712e84ab94SRuslan Ermilov		-D_UPGRADING \
1722e84ab94SRuslan Ermilov		-DNOMAN -DNOSHARED \
1732e84ab94SRuslan Ermilov		-DNO_CPU_CFLAGS -DNO_WERROR
1742e84ab94SRuslan Ermilov
175549f978aSMarcel Moolenaarmake:
176549f978aSMarcel Moolenaar	@echo
177549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
178b31745f5SRuslan Ermilov	@echo ">>> Building an up-to-date make(1)"
179549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
180549f978aSMarcel Moolenaar	@cd ${.CURDIR}/usr.bin/make; \
1812e84ab94SRuslan Ermilov		${MMAKE} obj && \
1822e84ab94SRuslan Ermilov		${MMAKE} depend && \
1832e84ab94SRuslan Ermilov		${MMAKE} all && \
1842e84ab94SRuslan Ermilov		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
185549f978aSMarcel Moolenaar
186549f978aSMarcel Moolenaar#
1871f4f7670SRuslan Ermilov# universe
1881f4f7670SRuslan Ermilov#
1891f4f7670SRuslan Ermilov# Attempt to rebuild *everything* for all supported architectures,
1901f4f7670SRuslan Ermilov# with reasonable chance of success, regardless of how old your
1911f4f7670SRuslan Ermilov# existing system is.
1921f4f7670SRuslan Ermilov#
1931f4f7670SRuslan Ermilovi386_mach=	pc98
19477c1699fSPoul-Henning Kampuniverse:
19577c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
19677c1699fSPoul-Henning Kamp	@echo ">>> make universe started on ${STARTTIME}"
19777c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
19811c10660SPoul-Henning Kamp.for arch in i386 sparc64 alpha ia64
1991f4f7670SRuslan Ermilov.for mach in ${arch} ${${arch}_mach}
2001f4f7670SRuslan Ermilov	@echo ">> ${mach} started on `LC_ALL=C date`"
2011f4f7670SRuslan Ermilov	-cd ${.CURDIR} && ${MAKE} buildworld \
2021f4f7670SRuslan Ermilov	    TARGET_ARCH=${arch} TARGET=${mach} \
20377c1699fSPoul-Henning Kamp	    __MAKE_CONF=/dev/null \
2041f4f7670SRuslan Ermilov	    > _.${mach}.buildworld 2>&1
2051f4f7670SRuslan Ermilov	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
2061f4f7670SRuslan Ermilov.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
2071f4f7670SRuslan Ermilov	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
208301c4069SRuslan Ermilov	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
20977c1699fSPoul-Henning Kamp.endif
2101f4f7670SRuslan Ermilov	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
2111f4f7670SRuslan Ermilov	@echo ">> ${mach} completed on `LC_ALL=C date`"
21277c1699fSPoul-Henning Kamp.endfor
2131f4f7670SRuslan Ermilov.endfor
21477c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
2155ab77811SRuslan Ermilov	@echo ">>> make universe completed on `LC_ALL=C date`"
2165ab77811SRuslan Ermilov	@echo "                      (started ${STARTTIME})"
21777c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
21877c1699fSPoul-Henning Kamp
2191f4f7670SRuslan ErmilovKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
2201f4f7670SRuslan Ermilov		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
22177c1699fSPoul-Henning Kamp
22277c1699fSPoul-Henning Kampbuildkernels:
2231f4f7670SRuslan Ermilov.for kernel in ${KERNCONFS}
2241f4f7670SRuslan Ermilov	-cd ${.CURDIR} && ${MAKE} buildkernel \
2251f4f7670SRuslan Ermilov	    KERNCONF=${kernel} \
22677c1699fSPoul-Henning Kamp	    __MAKE_CONF=/dev/null \
2271f4f7670SRuslan Ermilov	    > _.${TARGET}.${kernel} 2>&1
22877c1699fSPoul-Henning Kamp.endfor
229