xref: /freebsd/Makefile (revision af2dc868)
13540f0e1SJordan K. Hubbard#
297d92980SPeter Wemm# $FreeBSD$
3cf763a57SJohn Birrell#
411fb97daSJohn Birrell# The user-driven targets are:
5cf763a57SJohn Birrell#
611fb97daSJohn Birrell# buildworld          - Rebuild *everything*, including glue to help do
711fb97daSJohn Birrell#                       upgrades.
811fb97daSJohn Birrell# installworld        - Install everything built by "buildworld".
911fb97daSJohn Birrell# world               - buildworld + installworld.
1000eb8cbdSAlexander Langer# buildkernel         - Rebuild the kernel and the kernel-modules.
1100eb8cbdSAlexander Langer# installkernel       - Install the kernel and the kernel-modules.
12737ffab7SMark Murray# reinstallkernel     - Reinstall the kernel and the kernel-modules.
13bc4311beSDavid E. O'Brien# kernel              - buildkernel + installkernel.
1411fb97daSJohn Birrell# update              - Convenient way to update your source tree (cvs).
157785c4f2SJordan K. Hubbard# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1611fb97daSJohn Birrell# most                - Build user commands, no libraries or include files.
1711fb97daSJohn Birrell# installmost         - Install user commands, no libraries or include files.
1811fb97daSJohn Birrell# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
1911fb97daSJohn Birrell# aout-to-elf-build   - Build everything required to upgrade a system from
2011fb97daSJohn Birrell#                       a.out to elf format (see below).
2111fb97daSJohn Birrell# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2211fb97daSJohn Birrell#                       below).
232b0dadddSJohn Birrell# move-aout-libs      - Move the a.out libraries into an aout sub-directory
242b0dadddSJohn Birrell#                       of each elf library sub-directory.
253540f0e1SJordan K. Hubbard#
2611fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads
2711fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the
2811fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too
2911fb97daSJohn Birrell# much how different the installed mk files are from those in the source
3011fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use
3111fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT.
3211fb97daSJohn Birrell#
33912422f0SGiorgos Keramidas# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3411fb97daSJohn Birrell#
3576fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has
3676fdd728SJohn W. De Boskey# at least 400MB of diskspace available.
3711fb97daSJohn Birrell#
3876fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their
3976fdd728SJohn W. De Boskey# system, the simple instructions are:
4011fb97daSJohn Birrell#
4176fdd728SJohn W. De Boskey# 1.  `cd /usr/src'  (or to the directory containing your source tree).
4276fdd728SJohn W. De Boskey# 2.  `make world'
4311fb97daSJohn Birrell#
4476fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a
4576fdd728SJohn W. De Boskey# delta of a few days):
4676fdd728SJohn W. De Boskey#
4776fdd728SJohn W. De Boskey# 1.  `cd /usr/src'       (or to the directory containing your source tree).
4876fdd728SJohn W. De Boskey# 2.  `make buildworld'
4976fdd728SJohn W. De Boskey# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
5076fdd728SJohn W. De Boskey# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
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'
5476fdd728SJohn W. De Boskey# 8.  `mergemaster'
5576fdd728SJohn W. De Boskey# 9.  `reboot'
5676fdd728SJohn W. De Boskey#
5776fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information.
5811fb97daSJohn Birrell#
59990cbc64SDavid E. O'Brien# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
6041da0323SPeter Wemm# update the legacy support for aout. This includes all libraries, ld.so
6141da0323SPeter Wemm# and boot objects. This part of build should be regarded as
6211fb97daSJohn Birrell# deprecated and you should _not_ expect to be able to do this past the
631379f879SJohn Birrell# release of 4.0. You have exactly one major release to move entirely
6411fb97daSJohn Birrell# to elf.
6511fb97daSJohn Birrell#
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.
7411fb97daSJohn Birrell# 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# At the end of the upgrade procedure, /etc/objformat is created or
8611fb97daSJohn Birrell# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
8711fb97daSJohn Birrell#
8811fb97daSJohn Birrell# ----------------------------------------------------------------------------
8911fb97daSJohn Birrell#
9011fb97daSJohn Birrell#
9111fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical
9211fb97daSJohn Birrell# order, but that's not important.
9311fb97daSJohn Birrell#
946bde859fSRuslan ErmilovTGTS=	all all-man buildkernel buildworld checkdpadd clean \
958f1f55e9SRuslan Ermilov	cleandepend cleandir depend distribute distributeworld everything \
9628d2080aSRuslan Ermilov	hierarchy install installcheck installkernel \
97afeaaa84SRuslan Ermilov	reinstallkernel installmost installworld libraries lint maninstall \
98b56f8802SGregory Neil Shapiro	mk most obj objlink regress rerelease tags update
996e59a256SMarcel Moolenaar
100af2dc868SRuslan ErmilovBITGTS=	files includes
10128d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
10228d2080aSRuslan Ermilov
103d672a609SRuslan Ermilov.ORDER: buildworld installworld
1048f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld
105d672a609SRuslan Ermilov.ORDER: buildkernel installkernel
106d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel
107d672a609SRuslan Ermilov
1083e3a3133SMarcel MoolenaarPATH=	/sbin:/bin:/usr/sbin:/usr/bin
1093e3a3133SMarcel MoolenaarMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
110a962de47SPeter Wemm
111a962de47SPeter Wemm#
11211fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files.
113f3c4dd0dSBruce Evans#
11428d2080aSRuslan Ermilov${TGTS} ${BITGTS}: upgrade_checks
11511fb97daSJohn Birrell	@cd ${.CURDIR}; \
1166e59a256SMarcel Moolenaar		${MAKE} ${.TARGET}
117c3d9b0f0SRodney W. Grimes
118ce53af53SJordan K. Hubbard# Set a reasonable default
119ce53af53SJordan K. Hubbard.MAIN:	all
120ce53af53SJordan K. Hubbard
121afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date
1226e59a256SMarcel Moolenaar#
1236e59a256SMarcel Moolenaar# world
1246e59a256SMarcel Moolenaar#
1256e59a256SMarcel Moolenaar# Attempt to rebuild and reinstall *everything*, with reasonable chance of
1266e59a256SMarcel Moolenaar# success, regardless of how old your existing system is.
1276e59a256SMarcel Moolenaar#
1286e59a256SMarcel Moolenaarworld: upgrade_checks
1296e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
13059084d0cSDavid E. O'Brien	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
1316e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1326e59a256SMarcel Moolenaar.if target(pre-world)
1336e59a256SMarcel Moolenaar	@echo
1346e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1356e59a256SMarcel Moolenaar	@echo ">>> Making 'pre-world' target"
1366e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1376e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} pre-world
1386e59a256SMarcel Moolenaar.endif
1396e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} buildworld
1406e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} -B installworld
1416e59a256SMarcel Moolenaar.if target(post-world)
1426e59a256SMarcel Moolenaar	@echo
1436e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1446e59a256SMarcel Moolenaar	@echo ">>> Making 'post-world' target"
1456e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1466e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} post-world
1476e59a256SMarcel Moolenaar.endif
1486e59a256SMarcel Moolenaar	@echo
1496e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
150afcf05e4SRuslan Ermilov	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
1516e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1526e59a256SMarcel Moolenaar
153cf94fb21SBruce Evans#
154d672a609SRuslan Ermilov# kernel
155d672a609SRuslan Ermilov#
156d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel'
157d672a609SRuslan Ermilov#
158d672a609SRuslan Ermilovkernel: buildkernel installkernel
159d672a609SRuslan Ermilov
160d672a609SRuslan Ermilov#
16111fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate
16211fb97daSJohn Birrell# for building the world. These are for older systems (prior to 2.2.5).
163cf94fb21SBruce Evans#
16411fb97daSJohn Birrell# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
16511fb97daSJohn Birrell# so the normal make world is capable of doing what is required to update
16611fb97daSJohn Birrell# the system to current.
16711fb97daSJohn Birrell#
16811fb97daSJohn Birrellupgrade_checks:
169549f978aSMarcel Moolenaar	@cd ${.CURDIR}; \
170549f978aSMarcel Moolenaar		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
171549f978aSMarcel Moolenaar			make make; \
172549f978aSMarcel Moolenaar		fi
173ceeb1caaSRuslan Ermilov	@cd ${.CURDIR}; \
174ceeb1caaSRuslan Ermilov		if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
175ceeb1caaSRuslan Ermilov		    grep -q "Unknown modifier 'C'"; then \
176ceeb1caaSRuslan Ermilov			make make; \
177ceeb1caaSRuslan Ermilov		fi
178a42830afSAndrey A. Chernov
179a962de47SPeter Wemm#
18011fb97daSJohn Birrell# A simple test target used as part of the test to see if make supports
18111fb97daSJohn Birrell# the -m argument.
182a962de47SPeter Wemm#
18311fb97daSJohn Birrelltest:
1846a8d432dSMark Murray
185a962de47SPeter Wemm#
186549f978aSMarcel Moolenaar# Upgrade the installed make to the current version using the installed
187549f978aSMarcel Moolenaar# headers, libraries and build tools. This is required on installed versions
188549f978aSMarcel Moolenaar# prior to 2.2.5 in which the installed make doesn't support the -m argument.
189549f978aSMarcel Moolenaar#
190549f978aSMarcel Moolenaarmake:
191549f978aSMarcel Moolenaar	@echo
192549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
193549f978aSMarcel Moolenaar	@echo " Upgrading the installed make"
194549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
195549f978aSMarcel Moolenaar	@cd ${.CURDIR}/usr.bin/make; \
196549f978aSMarcel Moolenaar		make obj && make depend && make all && make install
197549f978aSMarcel Moolenaar
198549f978aSMarcel Moolenaar#
19911fb97daSJohn Birrell# Define the upgrade targets. These are listed here in alphabetical
20011fb97daSJohn Birrell# order, but that's not important.
201a962de47SPeter Wemm#
2022b0dadddSJohn BirrellUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
2032b0dadddSJohn Birrell		move-aout-libs
2042799473bSSatoshi Asami
2052799473bSSatoshi Asami#
20611fb97daSJohn Birrell# Handle the upgrade targets, using the source relative mk files.
2072799473bSSatoshi Asami#
2081c67f883SJordan K. Hubbard
2091c67f883SJordan K. Hubbardupgrade:	aout-to-elf
2101c67f883SJordan K. Hubbard
21111fb97daSJohn Birrell${UPGRADE} : upgrade_checks
21211fb97daSJohn Birrell	@cd ${.CURDIR}; \
2138bc83b23SMike Smith		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
214