Makefile revision 68428
1191418Srwatson#
2191418Srwatson# $FreeBSD: head/Makefile 68428 2000-11-07 08:47:11Z jkh $
3191418Srwatson#
4191418Srwatson# The user-driven targets are:
5191418Srwatson#
6191418Srwatson# buildworld          - Rebuild *everything*, including glue to help do
7191418Srwatson#                       upgrades.
8191418Srwatson# installworld        - Install everything built by "buildworld".
9191418Srwatson# world               - buildworld + installworld.
10191418Srwatson# buildkernel         - Rebuild the kernel and the kernel-modules.
11191418Srwatson# installkernel       - Install the kernel and the kernel-modules.
12191418Srwatson# reinstallkernel     - Reinstall the kernel and the kernel-modules.
13191418Srwatson# update              - Convenient way to update your source tree (cvs).
14191418Srwatson# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
15191418Srwatson# most                - Build user commands, no libraries or include files.
16191418Srwatson# installmost         - Install user commands, no libraries or include files.
17191418Srwatson# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
18191418Srwatson# aout-to-elf-build   - Build everything required to upgrade a system from
19191418Srwatson#                       a.out to elf format (see below).
20191418Srwatson# aout-to-elf-install - Install everything built by aout-to-elf-build (see
21191418Srwatson#                       below).
22191418Srwatson# move-aout-libs      - Move the a.out libraries into an aout sub-directory
23191418Srwatson#                       of each elf library sub-directory.
24191418Srwatson#
25191418Srwatson# This makefile is simple by design. The FreeBSD make automatically reads
26191418Srwatson# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
27191418Srwatson# command line. By keeping this makefile simple, it doesn't matter too
28191418Srwatson# much how different the installed mk files are from those in the source
29191418Srwatson# tree. This makefile executes a child make process, forcing it to use
30191418Srwatson# the mk files from the source tree which are supposed to DTRT.
31191418Srwatson#
32191418Srwatson# The user-driven targets (as listed above) are implemented in Makefile.inc0
33191418Srwatson# and the private targets are in Makefile.inc1. These are kept separate
34191418Srwatson# to help the bootstrap build from aout to elf format.
35191418Srwatson#
36191418Srwatson# For novices wanting to build from current sources, the simple instructions
37191418Srwatson# are:
38191418Srwatson#
39191418Srwatson# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
40191418Srwatson# 2.  `cd /usr/src'  (or to the directory containing your source tree).
41191418Srwatson# 3.  `make world'
42191418Srwatson#
43191418Srwatson# Be warned, this will update your installed system, except for configuration
44191418Srwatson# files in the /etc directory and for the kernel. You have to do those manually.
45191418Srwatson#
46191418Srwatson# If at first you're a little nervous about having a `make world' update
47191418Srwatson# your system, a `make buildworld' will build everything in the /usr/obj
48191418Srwatson# tree without touching your installed system. To be of any further use
49191418Srwatson# though, a `make installworld' is required.
50191418Srwatson#
51191418Srwatson# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
52191418Srwatson# update the legacy support for aout. This includes all libraries, ld.so
53191418Srwatson# and boot objects. This part of build should be regarded as
54191418Srwatson# deprecated and you should _not_ expect to be able to do this past the
55191418Srwatson# release of 4.0. You have exactly one major release to move entirely
56191418Srwatson# to elf.
57191418Srwatson#
58191418Srwatson# ----------------------------------------------------------------------------
59191418Srwatson#
60191418Srwatson#           Upgrading an i386 system from a.out to elf format
61191418Srwatson#
62191418Srwatson#
63191418Srwatson# The aout->elf transition build is performed by doing a `make upgrade' (or
64191418Srwatson# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
65191418Srwatson# by a `make aout-to-elf-install', depending on user preference.
66191418Srwatson# You need to have at least 320 Mb of free space for the object tree.
67191418Srwatson#
68191418Srwatson# The upgrade process checks the installed release. If this is 3.0-CURRENT,
69191418Srwatson# it is assumed that your kernel contains all the syscalls required by the
70191418Srwatson# current sources.
71191418Srwatson#
72191418Srwatson# The upgrade procedure will stop and ask for confirmation to proceed
73191418Srwatson# several times. On each occasion, you can type Ctrl-C to abort the
74191418Srwatson# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
75191418Srwatson# the confirmation steps.
76191418Srwatson#
77191418Srwatson# At the end of the upgrade procedure, /etc/objformat is created or
78191418Srwatson# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
79191418Srwatson#
80191418Srwatson# ----------------------------------------------------------------------------
81191418Srwatson#
82191418Srwatson#
83191418Srwatson# Define the user-driven targets. These are listed here in alphabetical
84191418Srwatson# order, but that's not important.
85191418Srwatson#
86191418SrwatsonTGTS=	afterdistribute all buildkernel buildworld checkdpadd clean \
87191418Srwatson	cleandepend cleandir depend distribute everything hierarchy includes \
88191418Srwatson	install installkernel reinstallkernel installmost installworld \
89191418Srwatson	libraries lint maninstall mk most obj objlink regress rerelease \
90191418Srwatson	tags update
91191418Srwatson
92191418SrwatsonPATH=	/sbin:/bin:/usr/sbin:/usr/bin
93191418SrwatsonMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
94191418Srwatson
95191418Srwatson#
96191418Srwatson# Handle the user-driven targets, using the source relative mk files.
97191418Srwatson#
98191418Srwatson${TGTS}: upgrade_checks
99191418Srwatson	@cd ${.CURDIR}; \
100191418Srwatson		${MAKE} ${.TARGET}
101191418Srwatson
102191418Srwatson# Set a reasonable default
103191418Srwatson.MAIN:	all
104191418Srwatson
105191418Srwatson#
106191418Srwatson# world
107191418Srwatson#
108# Attempt to rebuild and reinstall *everything*, with reasonable chance of
109# success, regardless of how old your existing system is.
110#
111world: upgrade_checks
112	@echo "--------------------------------------------------------------"
113	@echo ">>> ${OBJFORMAT} make world started on `LC_TIME=C date`"
114	@echo "--------------------------------------------------------------"
115.if target(pre-world)
116	@echo
117	@echo "--------------------------------------------------------------"
118	@echo ">>> Making 'pre-world' target"
119	@echo "--------------------------------------------------------------"
120	@cd ${.CURDIR}; ${MAKE} pre-world
121.endif
122	@cd ${.CURDIR}; ${MAKE} buildworld
123	@cd ${.CURDIR}; ${MAKE} -B installworld
124.if target(post-world)
125	@echo
126	@echo "--------------------------------------------------------------"
127	@echo ">>> Making 'post-world' target"
128	@echo "--------------------------------------------------------------"
129	@cd ${.CURDIR}; ${MAKE} post-world
130.endif
131	@echo
132	@echo "--------------------------------------------------------------"
133	@echo ">>> ${OBJFORMAT} make world completed on `LC_TIME=C date`"
134	@echo "--------------------------------------------------------------"
135
136#
137# Perform a few tests to determine if the installed tools are adequate
138# for building the world. These are for older systems (prior to 2.2.5).
139#
140# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
141# so the normal make world is capable of doing what is required to update
142# the system to current.
143#
144upgrade_checks:
145	@cd ${.CURDIR}; \
146		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
147			make make; \
148		fi
149
150#
151# A simple test target used as part of the test to see if make supports
152# the -m argument.
153#
154test:
155
156#
157# Upgrade the installed make to the current version using the installed
158# headers, libraries and build tools. This is required on installed versions
159# prior to 2.2.5 in which the installed make doesn't support the -m argument.
160#
161make:
162	@echo
163	@echo "--------------------------------------------------------------"
164	@echo " Upgrading the installed make"
165	@echo "--------------------------------------------------------------"
166	@cd ${.CURDIR}/usr.bin/make; \
167		make obj && make depend && make all && make install
168
169#
170# Define the upgrade targets. These are listed here in alphabetical
171# order, but that's not important.
172#
173UPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
174		move-aout-libs
175
176#
177# Handle the upgrade targets, using the source relative mk files.
178#
179
180upgrade:	aout-to-elf
181
182${UPGRADE} : upgrade_checks
183	@cd ${.CURDIR}; \
184		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
185