Makefile revision 73349
155714Skris#
255714Skris# $FreeBSD: head/Makefile 73349 2001-03-02 16:52:14Z ru $
355714Skris#
455714Skris# The user-driven targets are:
555714Skris#
655714Skris# buildworld          - Rebuild *everything*, including glue to help do
755714Skris#                       upgrades.
855714Skris# installworld        - Install everything built by "buildworld".
955714Skris# world               - buildworld + installworld.
1055714Skris# buildkernel         - Rebuild the kernel and the kernel-modules.
1176866Skris# installkernel       - Install the kernel and the kernel-modules.
1255714Skris# reinstallkernel     - Reinstall the kernel and the kernel-modules.
1355714Skris# kernel              - buildkernel + installkernel
1455714Skris# update              - Convenient way to update your source tree (cvs).
1555714Skris# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1655714Skris# most                - Build user commands, no libraries or include files.
1755714Skris# installmost         - Install user commands, no libraries or include files.
1855714Skris# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
1955714Skris# aout-to-elf-build   - Build everything required to upgrade a system from
2055714Skris#                       a.out to elf format (see below).
2155714Skris# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2255714Skris#                       below).
2355714Skris# move-aout-libs      - Move the a.out libraries into an aout sub-directory
2455714Skris#                       of each elf library sub-directory.
2555714Skris#
2655714Skris# This makefile is simple by design. The FreeBSD make automatically reads
2755714Skris# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
2855714Skris# command line. By keeping this makefile simple, it doesn't matter too
2955714Skris# much how different the installed mk files are from those in the source
3055714Skris# tree. This makefile executes a child make process, forcing it to use
3155714Skris# the mk files from the source tree which are supposed to DTRT.
3255714Skris#
3355714Skris# The user-driven targets (as listed above) are implemented in Makefile.inc0
3455714Skris# and the private targets are in Makefile.inc1. These are kept separate
3555714Skris# to help the bootstrap build from aout to elf format.
3655714Skris#
3755714Skris# For novices wanting to build from current sources, the simple instructions
3855714Skris# are:
3955714Skris#
4055714Skris# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
4155714Skris# 2.  `cd /usr/src'  (or to the directory containing your source tree).
4255714Skris# 3.  `make world'
4355714Skris#
4455714Skris# Be warned, this will update your installed system, except for configuration
4555714Skris# files in the /etc directory and for the kernel. You have to do those manually.
4655714Skris#
4755714Skris# If at first you're a little nervous about having a `make world' update
4855714Skris# your system, a `make buildworld' will build everything in the /usr/obj
4955714Skris# tree without touching your installed system. To be of any further use
5055714Skris# though, a `make installworld' is required.
5155714Skris#
5255714Skris# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
5355714Skris# update the legacy support for aout. This includes all libraries, ld.so
5455714Skris# and boot objects. This part of build should be regarded as
5555714Skris# deprecated and you should _not_ expect to be able to do this past the
5655714Skris# release of 4.0. You have exactly one major release to move entirely
5755714Skris# to elf.
5855714Skris#
5955714Skris# ----------------------------------------------------------------------------
6055714Skris#
6155714Skris#           Upgrading an i386 system from a.out to elf format
6255714Skris#
6355714Skris#
6455714Skris# The aout->elf transition build is performed by doing a `make upgrade' (or
6555714Skris# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
6655714Skris# by a `make aout-to-elf-install', depending on user preference.
6755714Skris# You need to have at least 320 Mb of free space for the object tree.
6855714Skris#
6955714Skris# The upgrade process checks the installed release. If this is 3.0-CURRENT,
7055714Skris# it is assumed that your kernel contains all the syscalls required by the
7155714Skris# current sources.
7255714Skris#
7355714Skris# The upgrade procedure will stop and ask for confirmation to proceed
7455714Skris# several times. On each occasion, you can type Ctrl-C to abort the
7555714Skris# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
7655714Skris# the confirmation steps.
7755714Skris#
7855714Skris# At the end of the upgrade procedure, /etc/objformat is created or
7955714Skris# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
8055714Skris#
8155714Skris# ----------------------------------------------------------------------------
8255714Skris#
8355714Skris#
8455714Skris# Define the user-driven targets. These are listed here in alphabetical
8555714Skris# order, but that's not important.
8655714Skris#
8755714SkrisTGTS=	afterdistribute all buildkernel buildworld checkdpadd clean \
8855714Skris	cleandepend cleandir depend distribute distribworld everything \
8955714Skris	hierarchy includes install installkernel kernel reinstallkernel \
9055714Skris	installmost installworld libraries lint maninstall mk most obj \
9155714Skris	objlink regress rerelease tags update
9255714Skris
9355714SkrisPATH=	/sbin:/bin:/usr/sbin:/usr/bin
9455714SkrisMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
9555714Skris
9655714Skris#
9755714Skris# Handle the user-driven targets, using the source relative mk files.
9855714Skris#
9955714Skris${TGTS}: upgrade_checks
10055714Skris	@cd ${.CURDIR}; \
10155714Skris		${MAKE} ${.TARGET}
10255714Skris
10355714Skris# Set a reasonable default
10455714Skris.MAIN:	all
10555714Skris
10655714SkrisSTARTTIME!= LC_ALL=C date
10755714Skris#
10855714Skris# world
10955714Skris#
11055714Skris# Attempt to rebuild and reinstall *everything*, with reasonable chance of
11155714Skris# success, regardless of how old your existing system is.
11255714Skris#
11355714Skrisworld: upgrade_checks
11455714Skris	@echo "--------------------------------------------------------------"
11555714Skris	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
11655714Skris	@echo "--------------------------------------------------------------"
11755714Skris.if target(pre-world)
11855714Skris	@echo
11955714Skris	@echo "--------------------------------------------------------------"
12055714Skris	@echo ">>> Making 'pre-world' target"
12155714Skris	@echo "--------------------------------------------------------------"
12255714Skris	@cd ${.CURDIR}; ${MAKE} pre-world
12355714Skris.endif
12455714Skris	@cd ${.CURDIR}; ${MAKE} buildworld
12555714Skris	@cd ${.CURDIR}; ${MAKE} -B installworld
12655714Skris.if target(post-world)
12755714Skris	@echo
12855714Skris	@echo "--------------------------------------------------------------"
12955714Skris	@echo ">>> Making 'post-world' target"
13055714Skris	@echo "--------------------------------------------------------------"
13155714Skris	@cd ${.CURDIR}; ${MAKE} post-world
132.endif
133	@echo
134	@echo "--------------------------------------------------------------"
135	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
136	@echo "--------------------------------------------------------------"
137
138#
139# Perform a few tests to determine if the installed tools are adequate
140# for building the world. These are for older systems (prior to 2.2.5).
141#
142# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
143# so the normal make world is capable of doing what is required to update
144# the system to current.
145#
146upgrade_checks:
147	@cd ${.CURDIR}; \
148		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
149			make make; \
150		fi
151
152#
153# A simple test target used as part of the test to see if make supports
154# the -m argument.
155#
156test:
157
158#
159# Upgrade the installed make to the current version using the installed
160# headers, libraries and build tools. This is required on installed versions
161# prior to 2.2.5 in which the installed make doesn't support the -m argument.
162#
163make:
164	@echo
165	@echo "--------------------------------------------------------------"
166	@echo " Upgrading the installed make"
167	@echo "--------------------------------------------------------------"
168	@cd ${.CURDIR}/usr.bin/make; \
169		make obj && make depend && make all && make install
170
171#
172# Define the upgrade targets. These are listed here in alphabetical
173# order, but that's not important.
174#
175UPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
176		move-aout-libs
177
178#
179# Handle the upgrade targets, using the source relative mk files.
180#
181
182upgrade:	aout-to-elf
183
184${UPGRADE} : upgrade_checks
185	@cd ${.CURDIR}; \
186		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
187