Makefile revision 98723
10Sduke#
210248Smikael# $FreeBSD: head/Makefile 98723 2002-06-24 05:14:54Z dillon $
30Sduke#
40Sduke# The user-driven targets are:
50Sduke#
60Sduke# buildworld          - Rebuild *everything*, including glue to help do
70Sduke#                       upgrades.
80Sduke# installworld        - Install everything built by "buildworld".
90Sduke# world               - buildworld + installworld.
100Sduke# buildkernel         - Rebuild the kernel and the kernel-modules.
110Sduke# installkernel       - Install the kernel and the kernel-modules.
120Sduke# reinstallkernel     - Reinstall the kernel and the kernel-modules.
130Sduke# kernel              - buildkernel + installkernel.
140Sduke# update              - Convenient way to update your source tree (cvs).
150Sduke# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
160Sduke# most                - Build user commands, no libraries or include files.
170Sduke# installmost         - Install user commands, no libraries or include files.
180Sduke# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
191472Strims# aout-to-elf-build   - Build everything required to upgrade a system from
201472Strims#                       a.out to elf format (see below).
211472Strims# aout-to-elf-install - Install everything built by aout-to-elf-build (see
220Sduke#                       below).
230Sduke# move-aout-libs      - Move the a.out libraries into an aout sub-directory
240Sduke#                       of each elf library sub-directory.
251879Sstefank#
261879Sstefank# This makefile is simple by design. The FreeBSD make automatically reads
2713249Sstefank# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
281879Sstefank# command line. By keeping this makefile simple, it doesn't matter too
290Sduke# much how different the installed mk files are from those in the source
300Sduke# tree. This makefile executes a child make process, forcing it to use
310Sduke# the mk files from the source tree which are supposed to DTRT.
320Sduke#
330Sduke# The user-driven targets (as listed above) are implemented in Makefile.inc1.
340Sduke#
350Sduke# If you want to build your system from source be sure that /usr/obj has
360Sduke# at least 400MB of diskspace available.
370Sduke#
380Sduke# For individuals wanting to build from the sources currently on their
390Sduke# system, the simple instructions are:
400Sduke#
410Sduke# 1.  `cd /usr/src'  (or to the directory containing your source tree).
420Sduke# 2.  `make world'
430Sduke#
440Sduke# For individuals wanting to upgrade their sources (even if only a
450Sduke# delta of a few days):
460Sduke#
470Sduke# 1.  `cd /usr/src'       (or to the directory containing your source tree).
480Sduke# 2.  `make buildworld'
490Sduke# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
500Sduke# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
510Sduke# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
520Sduke# 6.  `mergemaster -p'
531523Skvn# 7.  `make installworld'
540Sduke# 8.  `mergemaster'
550Sduke# 9.  `reboot'
560Sduke#
5710248Smikael# See src/UPDATING `COMMON ITEMS' for more complete information.
5810248Smikael#
5910248Smikael# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
6013128Smikael# update the legacy support for aout. This includes all libraries, ld.so
6113128Smikael# and boot objects. This part of build should be regarded as
6213128Smikael# deprecated and you should _not_ expect to be able to do this past the
6310248Smikael# release of 4.0. You have exactly one major release to move entirely
6410248Smikael# to elf.
6510248Smikael#
6610248Smikael# If -DTARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
6710248Smikael# cross build world for other architectures using the buildworld target,
6810248Smikael# and once the world is built you can cross build a kernel using the
6913128Smikael# buildkernel target.
7013128Smikael#
7110248Smikael# ----------------------------------------------------------------------------
7210248Smikael#
7310248Smikael#           Upgrading an i386 system from a.out to elf format
7410248Smikael#
7513243Sstefank#
7610248Smikael# The aout->elf transition build is performed by doing a `make upgrade' (or
7710248Smikael# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
7813128Smikael# by a `make aout-to-elf-install', depending on user preference.
7910248Smikael# You need to have at least 320 Mb of free space for the object tree.
8010248Smikael#
8113128Smikael# The upgrade process checks the installed release. If this is 3.0-CURRENT,
8210248Smikael# it is assumed that your kernel contains all the syscalls required by the
8313128Smikael# current sources.
8410248Smikael#
8510248Smikael# The upgrade procedure will stop and ask for confirmation to proceed
8610248Smikael# several times. On each occasion, you can type Ctrl-C to abort the
8710248Smikael# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
8810248Smikael# the confirmation steps.
8910248Smikael#
9010248Smikael# At the end of the upgrade procedure, /etc/objformat is created or
9110248Smikael# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
9210248Smikael#
9310248Smikael# ----------------------------------------------------------------------------
9410248Smikael#
9510248Smikael#
9610248Smikael# Define the user-driven targets. These are listed here in alphabetical
9710248Smikael# order, but that's not important.
9810248Smikael#
9910248SmikaelTGTS=	all all-man buildkernel buildworld checkdpadd clean \
10010248Smikael	cleandepend cleandir depend distribute distributeworld everything \
10110248Smikael	hierarchy install installcheck installkernel \
10210248Smikael	reinstallkernel installmost installworld libraries lint maninstall \
10310248Smikael	mk most obj objlink regress rerelease tags update
10410248Smikael
10510248SmikaelBITGTS=	files includes
10610248SmikaelBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
10710248Smikael
10810248Smikael.ORDER: buildworld installworld
10910248Smikael.ORDER: buildworld distributeworld
11010248Smikael.ORDER: buildkernel installkernel
11110248Smikael.ORDER: buildkernel reinstallkernel
11210248Smikael
11310248SmikaelPATH=	/sbin:/bin:/usr/sbin:/usr/bin
11410248SmikaelMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
11510248Smikael
11610248Smikael#
11710248Smikael# Handle the user-driven targets, using the source relative mk files.
11810248Smikael#
11910248Smikael${TGTS} ${BITGTS}: upgrade_checks
12010248Smikael	@cd ${.CURDIR}; \
12110248Smikael		${MAKE} ${.TARGET}
12210248Smikael
12310248Smikael# Set a reasonable default
12410248Smikael.MAIN:	all
12510248Smikael
12610248SmikaelSTARTTIME!= LC_ALL=C date
12710248Smikael#
12810248Smikael# world
12910248Smikael#
13010248Smikael# Attempt to rebuild and reinstall *everything*, with reasonable chance of
13110248Smikael# success, regardless of how old your existing system is.
13213128Smikael#
13313128Smikaelworld: upgrade_checks
13413128Smikael	@echo "--------------------------------------------------------------"
13513128Smikael	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
13610248Smikael	@echo "--------------------------------------------------------------"
13710248Smikael.if target(pre-world)
13810248Smikael	@echo
13913128Smikael	@echo "--------------------------------------------------------------"
14013128Smikael	@echo ">>> Making 'pre-world' target"
14110248Smikael	@echo "--------------------------------------------------------------"
14210248Smikael	@cd ${.CURDIR}; ${MAKE} pre-world
14313128Smikael.endif
14413128Smikael	@cd ${.CURDIR}; ${MAKE} buildworld
14510248Smikael	@cd ${.CURDIR}; ${MAKE} -B installworld
14610248Smikael.if target(post-world)
14710248Smikael	@echo
14810248Smikael	@echo "--------------------------------------------------------------"
14910248Smikael	@echo ">>> Making 'post-world' target"
15010248Smikael	@echo "--------------------------------------------------------------"
15110248Smikael	@cd ${.CURDIR}; ${MAKE} post-world
15210248Smikael.endif
15310248Smikael	@echo
15410248Smikael	@echo "--------------------------------------------------------------"
15510248Smikael	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
15610248Smikael	@echo "--------------------------------------------------------------"
15713128Smikael
15813128Smikael#
15913128Smikael# kernel
16010248Smikael#
16110248Smikael# Short hand for `make buildkernel installkernel'
16210248Smikael#
16310248Smikaelkernel: buildkernel installkernel
16410248Smikael
16510248Smikael#
16610248Smikael# Perform a few tests to determine if the installed tools are adequate
16710248Smikael# for building the world. These are for older systems (prior to 2.2.5).
16810248Smikael#
16910248Smikael# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
17010248Smikael# so the normal make world is capable of doing what is required to update
17110248Smikael# the system to current.
17210248Smikael#
17310248Smikaelupgrade_checks:
17410248Smikael	@cd ${.CURDIR}; \
17510248Smikael		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
17610248Smikael			make make; \
17710248Smikael		fi
17810248Smikael	@cd ${.CURDIR}; \
17910248Smikael		if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
18010248Smikael		    grep -q "Unknown modifier 'C'"; then \
18110248Smikael			make make; \
18210248Smikael		fi
18313128Smikael
18413128Smikael#
18513128Smikael# A simple test target used as part of the test to see if make supports
18610248Smikael# the -m argument.
18710248Smikael#
18810248Smikaeltest:
18910248Smikael
19010248Smikael#
19113128Smikael# Upgrade the installed make to the current version using the installed
19213128Smikael# headers, libraries and build tools. This is required on installed versions
19313243Sstefank# prior to 2.2.5 in which the installed make doesn't support the -m argument.
19413243Sstefank#
19513128Smikaelmake:
19610248Smikael	@echo
19713128Smikael	@echo "--------------------------------------------------------------"
19810248Smikael	@echo " Upgrading the installed make"
19910248Smikael	@echo "--------------------------------------------------------------"
20013243Sstefank	@cd ${.CURDIR}/usr.bin/make; \
20113128Smikael		make obj && make depend && make all && make install
20210248Smikael
20313128Smikael#
20410248Smikael# Define the upgrade targets. These are listed here in alphabetical
20510248Smikael# order, but that's not important.
20610248Smikael#
20710248SmikaelUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
20810248Smikael		move-aout-libs
20910248Smikael
21010248Smikael#
21110248Smikael# Handle the upgrade targets, using the source relative mk files.
21213128Smikael#
21313128Smikael
21410248Smikaelupgrade:	aout-to-elf
21510248Smikael
21610248Smikael${UPGRADE} : upgrade_checks
21710248Smikael	@cd ${.CURDIR}; \
21810248Smikael		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
21910248Smikael