xref: /freebsd/Makefile (revision 76499f15)
13540f0e1SJordan K. Hubbard#
297d92980SPeter Wemm# $FreeBSD$
3cf763a57SJohn Birrell#
411fb97daSJohn Birrell# The user-driven targets are:
5cf763a57SJohn Birrell#
677c1699fSPoul-Henning Kamp# universe 	      - *Really* build *everything*:  Buildworld and
777c1699fSPoul-Henning Kamp#			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.
14737ffab7SMark Murray# reinstallkernel     - Reinstall the kernel and the kernel-modules.
15bc4311beSDavid E. O'Brien# kernel              - buildkernel + installkernel.
1611fb97daSJohn Birrell# update              - Convenient way to update your source tree (cvs).
177785c4f2SJordan K. Hubbard# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1811fb97daSJohn Birrell# most                - Build user commands, no libraries or include files.
1911fb97daSJohn Birrell# installmost         - Install user commands, no libraries or include files.
20d98744aaSJens Schweikhardt# aout-to-elf         - Upgrade a system from a.out to elf format (see below).
2111fb97daSJohn Birrell# aout-to-elf-build   - Build everything required to upgrade a system from
2211fb97daSJohn Birrell#                       a.out to elf format (see below).
2311fb97daSJohn Birrell# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2411fb97daSJohn Birrell#                       below).
252b0dadddSJohn Birrell# move-aout-libs      - Move the a.out libraries into an aout sub-directory
262b0dadddSJohn Birrell#                       of each elf library sub-directory.
273540f0e1SJordan K. Hubbard#
2811fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads
2911fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the
3011fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too
3111fb97daSJohn Birrell# much how different the installed mk files are from those in the source
3211fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use
3311fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT.
3411fb97daSJohn Birrell#
35912422f0SGiorgos Keramidas# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3611fb97daSJohn Birrell#
3776fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has
3876fdd728SJohn W. De Boskey# at least 400MB of diskspace available.
3911fb97daSJohn Birrell#
4076fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their
4176fdd728SJohn W. De Boskey# system, the simple instructions are:
4211fb97daSJohn Birrell#
4376fdd728SJohn W. De Boskey# 1.  `cd /usr/src'  (or to the directory containing your source tree).
4476fdd728SJohn W. De Boskey# 2.  `make world'
4511fb97daSJohn Birrell#
4676fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a
4776fdd728SJohn W. De Boskey# delta of a few days):
4876fdd728SJohn W. De Boskey#
4976fdd728SJohn W. De Boskey# 1.  `cd /usr/src'       (or to the directory containing your source tree).
5076fdd728SJohn W. De Boskey# 2.  `make buildworld'
5176fdd728SJohn W. De Boskey# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
5276fdd728SJohn W. De Boskey# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
5376fdd728SJohn W. De Boskey# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
5476fdd728SJohn W. De Boskey# 6.  `mergemaster -p'
5576fdd728SJohn W. De Boskey# 7.  `make installworld'
5676fdd728SJohn W. De Boskey# 8.  `mergemaster'
5776fdd728SJohn W. De Boskey# 9.  `reboot'
5876fdd728SJohn W. De Boskey#
5976fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information.
6011fb97daSJohn Birrell#
611b71212bSMatthew Dillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
62dbc3719dSMatthew Dillon# cross build world for other architectures 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# ----------------------------------------------------------------------------
6711fb97daSJohn Birrell#
6811fb97daSJohn Birrell#           Upgrading an i386 system from a.out to elf format
6911fb97daSJohn Birrell#
7011fb97daSJohn Birrell#
711c67f883SJordan K. Hubbard# The aout->elf transition build is performed by doing a `make upgrade' (or
721c67f883SJordan K. Hubbard# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
731c67f883SJordan K. Hubbard# by a `make aout-to-elf-install', depending on user preference.
74d98744aaSJens Schweikhardt# You need to have at least 320 MB of free space for the object tree.
7511fb97daSJohn Birrell#
7611fb97daSJohn Birrell# The upgrade process checks the installed release. If this is 3.0-CURRENT,
7711fb97daSJohn Birrell# it is assumed that your kernel contains all the syscalls required by the
7811fb97daSJohn Birrell# current sources.
7911fb97daSJohn Birrell#
8011fb97daSJohn Birrell# The upgrade procedure will stop and ask for confirmation to proceed
8111fb97daSJohn Birrell# several times. On each occasion, you can type Ctrl-C to abort the
821c67f883SJordan K. Hubbard# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
831c67f883SJordan K. Hubbard# the confirmation steps.
8411fb97daSJohn Birrell#
8511fb97daSJohn Birrell# ----------------------------------------------------------------------------
8611fb97daSJohn Birrell#
8711fb97daSJohn Birrell#
8811fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical
8911fb97daSJohn Birrell# order, but that's not important.
9011fb97daSJohn Birrell#
916bde859fSRuslan ErmilovTGTS=	all all-man buildkernel buildworld checkdpadd clean \
928f1f55e9SRuslan Ermilov	cleandepend cleandir depend distribute distributeworld everything \
9328d2080aSRuslan Ermilov	hierarchy install installcheck installkernel \
94afeaaa84SRuslan Ermilov	reinstallkernel installmost installworld libraries lint maninstall \
95b56f8802SGregory Neil Shapiro	mk most obj objlink regress rerelease tags update
966e59a256SMarcel Moolenaar
97af2dc868SRuslan ErmilovBITGTS=	files includes
9828d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
9928d2080aSRuslan Ermilov
100d672a609SRuslan Ermilov.ORDER: buildworld installworld
1018f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld
102d672a609SRuslan Ermilov.ORDER: buildkernel installkernel
103d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel
104d672a609SRuslan Ermilov
10576499f15SRuslan ErmilovPATH=	/sbin:/bin:/usr/sbin:/usr/bin
1062e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?=	/usr/obj
10776499f15SRuslan ErmilovMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
10876499f15SRuslan Ermilov_MAKE=	PATH=${PATH} \
10976499f15SRuslan Ermilov	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
11076499f15SRuslan Ermilov	-m ${.CURDIR}/share/mk -f Makefile.inc1
111a962de47SPeter Wemm
112a962de47SPeter Wemm#
11311fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files.
114f3c4dd0dSBruce Evans#
11528d2080aSRuslan Ermilov${TGTS} ${BITGTS}: upgrade_checks
11611fb97daSJohn Birrell	@cd ${.CURDIR}; \
11776499f15SRuslan Ermilov		${_MAKE} ${.TARGET}
118c3d9b0f0SRodney W. Grimes
119ce53af53SJordan K. Hubbard# Set a reasonable default
120ce53af53SJordan K. Hubbard.MAIN:	all
121ce53af53SJordan K. Hubbard
122afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date
1236e59a256SMarcel Moolenaar#
1246e59a256SMarcel Moolenaar# world
1256e59a256SMarcel Moolenaar#
1266e59a256SMarcel Moolenaar# Attempt to rebuild and reinstall *everything*, with reasonable chance of
1276e59a256SMarcel Moolenaar# success, regardless of how old your existing system is.
1286e59a256SMarcel Moolenaar#
1296e59a256SMarcel Moolenaarworld: upgrade_checks
1306e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
13166422f5bSPeter Wemm	@echo ">>> elf make world started on ${STARTTIME}"
1326e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1336e59a256SMarcel Moolenaar.if target(pre-world)
1346e59a256SMarcel Moolenaar	@echo
1356e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1366e59a256SMarcel Moolenaar	@echo ">>> Making 'pre-world' target"
1376e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
13876499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} pre-world
1396e59a256SMarcel Moolenaar.endif
14076499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} buildworld
14176499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} -B installworld
1426e59a256SMarcel Moolenaar.if target(post-world)
1436e59a256SMarcel Moolenaar	@echo
1446e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1456e59a256SMarcel Moolenaar	@echo ">>> Making 'post-world' target"
1466e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
14776499f15SRuslan Ermilov	@cd ${.CURDIR}; ${_MAKE} post-world
1486e59a256SMarcel Moolenaar.endif
1496e59a256SMarcel Moolenaar	@echo
1506e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
15166422f5bSPeter Wemm	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
1526e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1536e59a256SMarcel Moolenaar
154cf94fb21SBruce Evans#
155d672a609SRuslan Ermilov# kernel
156d672a609SRuslan Ermilov#
157d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel'
158d672a609SRuslan Ermilov#
159d672a609SRuslan Ermilovkernel: buildkernel installkernel
160d672a609SRuslan Ermilov
161d672a609SRuslan Ermilov#
16211fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate
163113cf9e6SRuslan Ermilov# for building the world.
16411fb97daSJohn Birrell#
16511fb97daSJohn Birrellupgrade_checks:
16676499f15SRuslan Ermilov	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
16776499f15SRuslan Ermilov	    PATH=${PATH} ${MAKE} 2>/dev/null); \
16876499f15SRuslan Ermilov	then \
16976499f15SRuslan Ermilov	    (cd ${.CURDIR} && make make); \
17076499f15SRuslan Ermilov	fi
1716a8d432dSMark Murray
172a962de47SPeter Wemm#
1732e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed
174113cf9e6SRuslan Ermilov# headers, libraries and tools.
175549f978aSMarcel Moolenaar#
1762e84ab94SRuslan ErmilovMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
1772e84ab94SRuslan Ermilov		DESTDIR= \
1782e84ab94SRuslan Ermilov		INSTALL="sh ${.CURDIR}/tools/install.sh"
1792e84ab94SRuslan ErmilovMMAKE=		${MMAKEENV} make \
1802e84ab94SRuslan Ermilov		-D_UPGRADING \
1812e84ab94SRuslan Ermilov		-DNOMAN -DNOSHARED \
1822e84ab94SRuslan Ermilov		-DNO_CPU_CFLAGS -DNO_WERROR
1832e84ab94SRuslan Ermilov
184549f978aSMarcel Moolenaarmake:
185549f978aSMarcel Moolenaar	@echo
186549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
187280e7ae9SBruce A. Mah	@echo " Building an up-to-date make(1)"
188549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
189549f978aSMarcel Moolenaar	@cd ${.CURDIR}/usr.bin/make; \
1902e84ab94SRuslan Ermilov		${MMAKE} obj && \
1912e84ab94SRuslan Ermilov		${MMAKE} depend && \
1922e84ab94SRuslan Ermilov		${MMAKE} all && \
1932e84ab94SRuslan Ermilov		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
194549f978aSMarcel Moolenaar
195549f978aSMarcel Moolenaar#
19611fb97daSJohn Birrell# Define the upgrade targets. These are listed here in alphabetical
19711fb97daSJohn Birrell# order, but that's not important.
198a962de47SPeter Wemm#
1992b0dadddSJohn BirrellUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
2002b0dadddSJohn Birrell		move-aout-libs
2012799473bSSatoshi Asami
2022799473bSSatoshi Asami#
20311fb97daSJohn Birrell# Handle the upgrade targets, using the source relative mk files.
2042799473bSSatoshi Asami#
2051c67f883SJordan K. Hubbard
2061c67f883SJordan K. Hubbardupgrade:	aout-to-elf
2071c67f883SJordan K. Hubbard
20811fb97daSJohn Birrell${UPGRADE} : upgrade_checks
20911fb97daSJohn Birrell	@cd ${.CURDIR}; \
21076499f15SRuslan Ermilov		${_MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
21177c1699fSPoul-Henning Kamp
21277c1699fSPoul-Henning Kamp
21377c1699fSPoul-Henning Kampuniverse:
21477c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
21577c1699fSPoul-Henning Kamp	@echo ">>> make universe started on ${STARTTIME}"
21677c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
21711c10660SPoul-Henning Kamp.for arch in i386 sparc64 alpha ia64
21877c1699fSPoul-Henning Kamp	@printf ">> ${arch} started on `LC_ALL=C date`\n"
21977c1699fSPoul-Henning Kamp	-cd ${.CURDIR} && make ${JFLAG} buildworld TARGET_ARCH=${arch} \
22077c1699fSPoul-Henning Kamp		__MAKE_CONF=/dev/null \
22177c1699fSPoul-Henning Kamp		> _.${arch}.buildworld 2>&1
22277c1699fSPoul-Henning Kamp	@printf ">> ${arch} buildworld ended on `LC_ALL=C date`\n"
22389d0989fSPoul-Henning Kamp.if exists(${.CURDIR}/sys/${arch}/conf/NOTES)
22489d0989fSPoul-Henning Kamp	-cd ${.CURDIR}/sys/${arch}/conf && make LINT \
22577c1699fSPoul-Henning Kamp		> _.${arch}.makeLINT 2>&1
22677c1699fSPoul-Henning Kamp.endif
22777c1699fSPoul-Henning Kamp	cd ${.CURDIR} && make buildkernels TARGET_ARCH=${arch} JFLAG="${JFLAG}"
22877c1699fSPoul-Henning Kamp	@printf ">> ${arch} ended on `LC_ALL=C date`\n"
22977c1699fSPoul-Henning Kamp.endfor
230deadd433SWarner Losh	@printf ">> pc98 started on `LC_ALL=C date`\n"
23111c10660SPoul-Henning Kamp	-cd ${.CURDIR} && make buildworld TARGET=pc98 TARGET_ARCH=i386 \
23211c10660SPoul-Henning Kamp		__MAKE_CONF=/dev/null \
23311c10660SPoul-Henning Kamp		> _.pc98.buildworld 2>&1
234deadd433SWarner Losh	@printf ">> pc98 buildworld ended on `LC_ALL=C date`\n"
235deadd433SWarner Losh.if exists(${.CURDIR}/sys/pc98/conf/NOTES)
236deadd433SWarner Losh	-cd ${.CURDIR}/sys/pc98/conf && make LINT \
237deadd433SWarner Losh		> _.pc98.makeLINT 2>&1
238deadd433SWarner Losh.endif
239deadd433SWarner Losh	cd ${.CURDIR} && make buildkernels TARGET=pc98 TARGET_ARCH=i386 \
240deadd433SWarner Losh		JFLAG="${JFLAG}"
241deadd433SWarner Losh	@printf ">> pc98 ended on `LC_ALL=C date`\n"
24277c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
24377c1699fSPoul-Henning Kamp	@printf ">>> make universe completed on `LC_ALL=C date`\n                      (started ${STARTTIME})\n"
24477c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
24577c1699fSPoul-Henning Kamp
24677c1699fSPoul-Henning KampKERNCONFS !=	echo ${.CURDIR}/sys/${TARGET_ARCH}/conf/[A-Z]*
24777c1699fSPoul-Henning KampKERNCONF2 = ${KERNCONFS:T:N*[a-z]*:NCVS:NNOTES}
24877c1699fSPoul-Henning Kamp
24977c1699fSPoul-Henning Kampbuildkernels:
25077c1699fSPoul-Henning Kamp.for kernel in ${KERNCONF2}
25177c1699fSPoul-Henning Kamp.if exists(${.CURDIR}/sys/${TARGET_ARCH}/conf/${kernel})
25277c1699fSPoul-Henning Kamp	-cd ${.CURDIR} && make ${JFLAG} buildkernel \
25377c1699fSPoul-Henning Kamp		TARGET_ARCH=${TARGET_ARCH} KERNCONF=${kernel} \
25477c1699fSPoul-Henning Kamp		__MAKE_CONF=/dev/null \
25577c1699fSPoul-Henning Kamp		 > _.${TARGET_ARCH}.${kernel} 2>&1
25677c1699fSPoul-Henning Kamp.endif
25777c1699fSPoul-Henning Kamp.endfor
258