Makefile revision 88473
118334Speter#
218334Speter# $FreeBSD: head/Makefile 74842 2001-03-27 08:43:28Z ru $
318334Speter#
418334Speter# The user-driven targets are:
518334Speter#
618334Speter# buildworld          - Rebuild *everything*, including glue to help do
718334Speter#                       upgrades.
818334Speter# installworld        - Install everything built by "buildworld".
918334Speter# world               - buildworld + installworld.
1018334Speter# buildkernel         - Rebuild the kernel and the kernel-modules.
1118334Speter# installkernel       - Install the kernel and the kernel-modules.
1218334Speter# reinstallkernel     - Reinstall the kernel and the kernel-modules.
1318334Speter# kernel              - buildkernel + installkernel.
1418334Speter# update              - Convenient way to update your source tree (cvs).
1518334Speter# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1618334Speter# most                - Build user commands, no libraries or include files.
1718334Speter# installmost         - Install user commands, no libraries or include files.
1818334Speter# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
1918334Speter# aout-to-elf-build   - Build everything required to upgrade a system from
2018334Speter#                       a.out to elf format (see below).
2118334Speter# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2218334Speter#                       below).
2318334Speter# move-aout-libs      - Move the a.out libraries into an aout sub-directory
2418334Speter#                       of each elf library sub-directory.
2518334Speter#
2618334Speter# This makefile is simple by design. The FreeBSD make automatically reads
2718334Speter# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
2818334Speter# command line. By keeping this makefile simple, it doesn't matter too
2918334Speter# much how different the installed mk files are from those in the source
3018334Speter# tree. This makefile executes a child make process, forcing it to use
3118334Speter# the mk files from the source tree which are supposed to DTRT.
3218334Speter#
3318334Speter# The user-driven targets (as listed above) are implemented in Makefile.inc0
3418334Speter# and the private targets are in Makefile.inc1. These are kept separate
3518334Speter# to help the bootstrap build from aout to elf format.
3618334Speter#
3718334Speter# For novices wanting to build from current sources, the simple instructions
3818334Speter# are:
3918334Speter#
4018334Speter# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
4118334Speter# 2.  `cd /usr/src'  (or to the directory containing your source tree).
4218334Speter# 3.  `make world'
4318334Speter#
4418334Speter# Be warned, this will update your installed system, except for configuration
4518334Speter# files in the /etc directory and for the kernel. You have to do those manually.
4618334Speter#
4718334Speter# If at first you're a little nervous about having a `make world' update
4818334Speter# your system, a `make buildworld' will build everything in the /usr/obj
4918334Speter# tree without touching your installed system. To be of any further use
5018334Speter# though, a `make installworld' is required.
5118334Speter#
5218334Speter# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
5318334Speter# update the legacy support for aout. This includes all libraries, ld.so
5418334Speter# and boot objects. This part of build should be regarded as
5518334Speter# deprecated and you should _not_ expect to be able to do this past the
5618334Speter# release of 4.0. You have exactly one major release to move entirely
5718334Speter# to elf.
5818334Speter#
5918334Speter# ----------------------------------------------------------------------------
6018334Speter#
6118334Speter#           Upgrading an i386 system from a.out to elf format
6218334Speter#
6318334Speter#
6418334Speter# The aout->elf transition build is performed by doing a `make upgrade' (or
6518334Speter# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
6618334Speter# by a `make aout-to-elf-install', depending on user preference.
6718334Speter# You need to have at least 320 Mb of free space for the object tree.
6818334Speter#
6918334Speter# The upgrade process checks the installed release. If this is 3.0-CURRENT,
7018334Speter# it is assumed that your kernel contains all the syscalls required by the
7118334Speter# current sources.
7218334Speter#
7318334Speter# The upgrade procedure will stop and ask for confirmation to proceed
7418334Speter# several times. On each occasion, you can type Ctrl-C to abort the
7518334Speter# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
7618334Speter# the confirmation steps.
7718334Speter#
7818334Speter# At the end of the upgrade procedure, /etc/objformat is created or
7918334Speter# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
8018334Speter#
8118334Speter# ----------------------------------------------------------------------------
8218334Speter#
8318334Speter#
8418334Speter# Define the user-driven targets. These are listed here in alphabetical
8518334Speter# order, but that's not important.
8618334Speter#
8718334SpeterTGTS=	afterdistribute all all-man buildkernel buildworld checkdpadd clean \
8818334Speter	cleandepend cleandir depend distribute distribworld everything \
8918334Speter	hierarchy includes install installkernel kernel reinstallkernel \
9018334Speter	installmost installworld libraries lint maninstall mk most obj \
9118334Speter	objlink regress rerelease tags update
9218334Speter
9318334SpeterPATH=	/sbin:/bin:/usr/sbin:/usr/bin
9418334SpeterMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
9518334Speter
9618334Speter#
9718334Speter# Handle the user-driven targets, using the source relative mk files.
9818334Speter#
9918334Speter${TGTS}: upgrade_checks
10018334Speter	@cd ${.CURDIR}; \
10118334Speter		${MAKE} ${.TARGET}
10218334Speter
10318334Speter# Set a reasonable default
10418334Speter.MAIN:	all
10518334Speter
10618334SpeterSTARTTIME!= LC_ALL=C date
10718334Speter#
10818334Speter# world
10918334Speter#
11018334Speter# Attempt to rebuild and reinstall *everything*, with reasonable chance of
11118334Speter# success, regardless of how old your existing system is.
11218334Speter#
11318334Speterworld: upgrade_checks
11418334Speter	@echo "--------------------------------------------------------------"
11518334Speter	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
11618334Speter	@echo "--------------------------------------------------------------"
11718334Speter.if target(pre-world)
11818334Speter	@echo
11918334Speter	@echo "--------------------------------------------------------------"
12018334Speter	@echo ">>> Making 'pre-world' target"
12118334Speter	@echo "--------------------------------------------------------------"
12218334Speter	@cd ${.CURDIR}; ${MAKE} pre-world
12318334Speter.endif
12418334Speter	@cd ${.CURDIR}; ${MAKE} buildworld
12518334Speter	@cd ${.CURDIR}; ${MAKE} -B installworld
12618334Speter.if target(post-world)
12718334Speter	@echo
12818334Speter	@echo "--------------------------------------------------------------"
12918334Speter	@echo ">>> Making 'post-world' target"
13018334Speter	@echo "--------------------------------------------------------------"
13118334Speter	@cd ${.CURDIR}; ${MAKE} post-world
13218334Speter.endif
13318334Speter	@echo
13418334Speter	@echo "--------------------------------------------------------------"
13518334Speter	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                        (started ${STARTTIME})\n"
13618334Speter	@echo "--------------------------------------------------------------"
13718334Speter
13818334Speter#
13918334Speter# Perform a few tests to determine if the installed tools are adequate
14018334Speter# for building the world. These are for older systems (prior to 2.2.5).
14118334Speter#
14218334Speter# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
14318334Speter# so the normal make world is capable of doing what is required to update
14418334Speter# the system to current.
14518334Speter#
14618334Speterupgrade_checks:
14718334Speter	@cd ${.CURDIR}; \
14818334Speter		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
14918334Speter			make make; \
15018334Speter		fi
15118334Speter
15218334Speter#
15318334Speter# A simple test target used as part of the test to see if make supports
15418334Speter# the -m argument.
15518334Speter#
15618334Spetertest:
15718334Speter
15818334Speter#
15918334Speter# Upgrade the installed make to the current version using the installed
16018334Speter# headers, libraries and build tools. This is required on installed versions
16118334Speter# prior to 2.2.5 in which the installed make doesn't support the -m argument.
16218334Speter#
16318334Spetermake:
16418334Speter	@echo
16518334Speter	@echo "--------------------------------------------------------------"
16618334Speter	@echo " Upgrading the installed make"
16718334Speter	@echo "--------------------------------------------------------------"
16818334Speter	@cd ${.CURDIR}/usr.bin/make; \
16918334Speter		make obj && make depend && make all && make install
17018334Speter
17118334Speter#
17218334Speter# Define the upgrade targets. These are listed here in alphabetical
17318334Speter# order, but that's not important.
17418334Speter#
17518334SpeterUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
17618334Speter		move-aout-libs
17718334Speter
17818334Speter#
17918334Speter# Handle the upgrade targets, using the source relative mk files.
18018334Speter#
18118334Speter
18218334Speterupgrade:	aout-to-elf
18318334Speter
18418334Speter${UPGRADE} : upgrade_checks
18518334Speter	@cd ${.CURDIR}; \
18618334Speter		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
18718334Speter