xref: /freebsd/Makefile (revision b797df80)
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/}
72b797df80SRuslan ErmilovTGTS+=	${BITGTS}
7328d2080aSRuslan Ermilov
74d672a609SRuslan Ermilov.ORDER: buildworld installworld
758f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld
7620902bd3SRuslan Ermilov.ORDER: buildworld buildkernel
77d672a609SRuslan Ermilov.ORDER: buildkernel installkernel
780147d2aaSHidetoshi Shimokawa.ORDER: buildkernel installkernel.debug
79d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel
800147d2aaSHidetoshi Shimokawa.ORDER: buildkernel reinstallkernel.debug
81d672a609SRuslan Ermilov
8276499f15SRuslan ErmilovPATH=	/sbin:/bin:/usr/sbin:/usr/bin
832e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?=	/usr/obj
8476499f15SRuslan ErmilovMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
85ead4296eSRuslan ErmilovBINMAKE= \
8676499f15SRuslan Ermilov	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
875dc63117SRuslan Ermilov	-m ${.CURDIR}/share/mk
88ead4296eSRuslan Ermilov_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
89a962de47SPeter Wemm
90a962de47SPeter Wemm#
91d911f786SMarcel Moolenaar# Make sure we have an up-to-date make(1). Only world and buildworld
92d911f786SMarcel Moolenaar# should do this as those are the initial targets used for upgrades.
93d911f786SMarcel Moolenaar# The user can define ALWAYS_CHECK_MAKE to have this check performed
94d911f786SMarcel Moolenaar# for all targets.
95d911f786SMarcel Moolenaar#
96d911f786SMarcel Moolenaar.if defined(ALWAYS_CHECK_MAKE)
97b797df80SRuslan Ermilov${TGTS}: upgrade_checks
98d911f786SMarcel Moolenaar.else
99d911f786SMarcel Moolenaarbuildworld: upgrade_checks
100d911f786SMarcel Moolenaar.endif
101d911f786SMarcel Moolenaar
102d911f786SMarcel Moolenaar#
10311fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files.
104f3c4dd0dSBruce Evans#
105d911f786SMarcel Moolenaar
106b797df80SRuslan Ermilov${TGTS}:
10711fb97daSJohn Birrell	@cd ${.CURDIR}; \
10876499f15SRuslan Ermilov		${_MAKE} ${.TARGET}
109c3d9b0f0SRodney W. Grimes
110ce53af53SJordan K. Hubbard# Set a reasonable default
111ce53af53SJordan K. Hubbard.MAIN:	all
112ce53af53SJordan K. Hubbard
113afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date
1146e59a256SMarcel Moolenaar#
1156e59a256SMarcel Moolenaar# world
1166e59a256SMarcel Moolenaar#
1176e59a256SMarcel Moolenaar# Attempt to rebuild and reinstall *everything*, with reasonable chance of
1186e59a256SMarcel Moolenaar# success, regardless of how old your existing system is.
1196e59a256SMarcel Moolenaar#
1206e59a256SMarcel Moolenaarworld: upgrade_checks
1216e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1225ab77811SRuslan Ermilov	@echo ">>> make world started on ${STARTTIME}"
1236e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1246e59a256SMarcel Moolenaar.if target(pre-world)
1256e59a256SMarcel Moolenaar	@echo
1266e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1276e59a256SMarcel Moolenaar	@echo ">>> Making 'pre-world' target"
1286e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
12976499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} pre-world
1306e59a256SMarcel Moolenaar.endif
13176499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} buildworld
13276499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} -B installworld
1336e59a256SMarcel Moolenaar.if target(post-world)
1346e59a256SMarcel Moolenaar	@echo
1356e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1366e59a256SMarcel Moolenaar	@echo ">>> Making 'post-world' target"
1376e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
13876499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} post-world
1396e59a256SMarcel Moolenaar.endif
1406e59a256SMarcel Moolenaar	@echo
1416e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1425ab77811SRuslan Ermilov	@echo ">>> make world completed on `LC_ALL=C date`"
1435ab77811SRuslan Ermilov	@echo "                   (started ${STARTTIME})"
1446e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1456e59a256SMarcel Moolenaar
146cf94fb21SBruce Evans#
147d672a609SRuslan Ermilov# kernel
148d672a609SRuslan Ermilov#
149d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel'
150d672a609SRuslan Ermilov#
151d672a609SRuslan Ermilovkernel: buildkernel installkernel
152d672a609SRuslan Ermilov
153d672a609SRuslan Ermilov#
15411fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate
155113cf9e6SRuslan Ermilov# for building the world.
15611fb97daSJohn Birrell#
15711fb97daSJohn Birrellupgrade_checks:
15876499f15SRuslan Ermilov	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
159ef2c779bSRuslan Ermilov	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
16076499f15SRuslan Ermilov	then \
16176499f15SRuslan Ermilov	    (cd ${.CURDIR} && make make); \
16276499f15SRuslan Ermilov	fi
1636a8d432dSMark Murray
164a962de47SPeter Wemm#
1652e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed
166113cf9e6SRuslan Ermilov# headers, libraries and tools.
167549f978aSMarcel Moolenaar#
1682e84ab94SRuslan ErmilovMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
1692e84ab94SRuslan Ermilov		DESTDIR= \
1702e84ab94SRuslan Ermilov		INSTALL="sh ${.CURDIR}/tools/install.sh"
1712e84ab94SRuslan ErmilovMMAKE=		${MMAKEENV} make \
1722e84ab94SRuslan Ermilov		-D_UPGRADING \
1732e84ab94SRuslan Ermilov		-DNOMAN -DNOSHARED \
1742e84ab94SRuslan Ermilov		-DNO_CPU_CFLAGS -DNO_WERROR
1752e84ab94SRuslan Ermilov
176549f978aSMarcel Moolenaarmake:
177549f978aSMarcel Moolenaar	@echo
178549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
179b31745f5SRuslan Ermilov	@echo ">>> Building an up-to-date make(1)"
180549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
181549f978aSMarcel Moolenaar	@cd ${.CURDIR}/usr.bin/make; \
1822e84ab94SRuslan Ermilov		${MMAKE} obj && \
1832e84ab94SRuslan Ermilov		${MMAKE} depend && \
1842e84ab94SRuslan Ermilov		${MMAKE} all && \
1852e84ab94SRuslan Ermilov		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
186549f978aSMarcel Moolenaar
187549f978aSMarcel Moolenaar#
1881f4f7670SRuslan Ermilov# universe
1891f4f7670SRuslan Ermilov#
1901f4f7670SRuslan Ermilov# Attempt to rebuild *everything* for all supported architectures,
1911f4f7670SRuslan Ermilov# with reasonable chance of success, regardless of how old your
1921f4f7670SRuslan Ermilov# existing system is.
1931f4f7670SRuslan Ermilov#
1941f4f7670SRuslan Ermilovi386_mach=	pc98
19577c1699fSPoul-Henning Kampuniverse:
19677c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
19777c1699fSPoul-Henning Kamp	@echo ">>> make universe started on ${STARTTIME}"
19877c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
19911c10660SPoul-Henning Kamp.for arch in i386 sparc64 alpha ia64
2001f4f7670SRuslan Ermilov.for mach in ${arch} ${${arch}_mach}
2011f4f7670SRuslan Ermilov	@echo ">> ${mach} started on `LC_ALL=C date`"
2021f4f7670SRuslan Ermilov	-cd ${.CURDIR} && ${MAKE} buildworld \
2031f4f7670SRuslan Ermilov	    TARGET_ARCH=${arch} TARGET=${mach} \
20477c1699fSPoul-Henning Kamp	    __MAKE_CONF=/dev/null \
2051f4f7670SRuslan Ermilov	    > _.${mach}.buildworld 2>&1
2061f4f7670SRuslan Ermilov	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
2071f4f7670SRuslan Ermilov.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
2081f4f7670SRuslan Ermilov	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
209301c4069SRuslan Ermilov	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
21077c1699fSPoul-Henning Kamp.endif
2111f4f7670SRuslan Ermilov	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
2121f4f7670SRuslan Ermilov	@echo ">> ${mach} completed on `LC_ALL=C date`"
21377c1699fSPoul-Henning Kamp.endfor
2141f4f7670SRuslan Ermilov.endfor
21577c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
2165ab77811SRuslan Ermilov	@echo ">>> make universe completed on `LC_ALL=C date`"
2175ab77811SRuslan Ermilov	@echo "                      (started ${STARTTIME})"
21877c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
21977c1699fSPoul-Henning Kamp
2201f4f7670SRuslan ErmilovKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
2211f4f7670SRuslan Ermilov		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
22277c1699fSPoul-Henning Kamp
22377c1699fSPoul-Henning Kampbuildkernels:
2241f4f7670SRuslan Ermilov.for kernel in ${KERNCONFS}
2251f4f7670SRuslan Ermilov	-cd ${.CURDIR} && ${MAKE} buildkernel \
2261f4f7670SRuslan Ermilov	    KERNCONF=${kernel} \
22777c1699fSPoul-Henning Kamp	    __MAKE_CONF=/dev/null \
2281f4f7670SRuslan Ermilov	    > _.${TARGET}.${kernel} 2>&1
22977c1699fSPoul-Henning Kamp.endfor
230