Makefile revision 100402
1234938Sgrehan#
2234938Sgrehan# $FreeBSD: head/Makefile 100402 2002-07-20 10:01:00Z ru $
3234938Sgrehan#
4234938Sgrehan# The user-driven targets are:
5234938Sgrehan#
6234938Sgrehan# buildworld          - Rebuild *everything*, including glue to help do
7234938Sgrehan#                       upgrades.
8234938Sgrehan# installworld        - Install everything built by "buildworld".
9234938Sgrehan# world               - buildworld + installworld.
10234938Sgrehan# buildkernel         - Rebuild the kernel and the kernel-modules.
11234938Sgrehan# installkernel       - Install the kernel and the kernel-modules.
12234938Sgrehan# reinstallkernel     - Reinstall the kernel and the kernel-modules.
13234938Sgrehan# kernel              - buildkernel + installkernel.
14234938Sgrehan# update              - Convenient way to update your source tree (cvs).
15234938Sgrehan# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
16234938Sgrehan# most                - Build user commands, no libraries or include files.
17234938Sgrehan# installmost         - Install user commands, no libraries or include files.
18234938Sgrehan# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
19234938Sgrehan# aout-to-elf-build   - Build everything required to upgrade a system from
20234938Sgrehan#                       a.out to elf format (see below).
21234938Sgrehan# aout-to-elf-install - Install everything built by aout-to-elf-build (see
22234938Sgrehan#                       below).
23234938Sgrehan# move-aout-libs      - Move the a.out libraries into an aout sub-directory
24234938Sgrehan#                       of each elf library sub-directory.
25234938Sgrehan#
26234938Sgrehan# This makefile is simple by design. The FreeBSD make automatically reads
27234938Sgrehan# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
28234938Sgrehan# command line. By keeping this makefile simple, it doesn't matter too
29234938Sgrehan# much how different the installed mk files are from those in the source
30234938Sgrehan# tree. This makefile executes a child make process, forcing it to use
31234938Sgrehan# the mk files from the source tree which are supposed to DTRT.
32234938Sgrehan#
33234938Sgrehan# The user-driven targets (as listed above) are implemented in Makefile.inc1.
34234938Sgrehan#
35234938Sgrehan# If you want to build your system from source be sure that /usr/obj has
36244167Sgrehan# at least 400MB of diskspace available.
37234938Sgrehan#
38257396Sneel# For individuals wanting to build from the sources currently on their
39234938Sgrehan# system, the simple instructions are:
40234938Sgrehan#
41234938Sgrehan# 1.  `cd /usr/src'  (or to the directory containing your source tree).
42234938Sgrehan# 2.  `make world'
43234938Sgrehan#
44234938Sgrehan# For individuals wanting to upgrade their sources (even if only a
45234938Sgrehan# delta of a few days):
46234938Sgrehan#
47234938Sgrehan# 1.  `cd /usr/src'       (or to the directory containing your source tree).
48234938Sgrehan# 2.  `make buildworld'
49257396Sneel# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
50234938Sgrehan# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
51257396Sneel# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
52234938Sgrehan# 6.  `mergemaster -p'
53257396Sneel# 7.  `make installworld'
54234938Sgrehan# 8.  `mergemaster'
55234938Sgrehan# 9.  `reboot'
56234938Sgrehan#
57257396Sneel# See src/UPDATING `COMMON ITEMS' for more complete information.
58234938Sgrehan#
59257396Sneel# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
60234938Sgrehan# update the legacy support for aout. This includes all libraries, ld.so
61257396Sneel# and boot objects. This part of build should be regarded as
62234938Sgrehan# deprecated and you should _not_ expect to be able to do this past the
63234938Sgrehan# release of 4.0. You have exactly one major release to move entirely
64234938Sgrehan# to elf.
65241744Sgrehan#
66241744Sgrehan# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
67234938Sgrehan# cross build world for other architectures using the buildworld target,
68234938Sgrehan# and once the world is built you can cross build a kernel using the
69241744Sgrehan# buildkernel target.
70234938Sgrehan#
71234938Sgrehan# ----------------------------------------------------------------------------
72257396Sneel#
73234938Sgrehan#           Upgrading an i386 system from a.out to elf format
74234938Sgrehan#
75241744Sgrehan#
76241744Sgrehan# The aout->elf transition build is performed by doing a `make upgrade' (or
77241744Sgrehan# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
78234938Sgrehan# by a `make aout-to-elf-install', depending on user preference.
79257396Sneel# You need to have at least 320 Mb of free space for the object tree.
80234938Sgrehan#
81241744Sgrehan# The upgrade process checks the installed release. If this is 3.0-CURRENT,
82234938Sgrehan# it is assumed that your kernel contains all the syscalls required by the
83234938Sgrehan# current sources.
84257396Sneel#
85257396Sneel# The upgrade procedure will stop and ask for confirmation to proceed
86257396Sneel# several times. On each occasion, you can type Ctrl-C to abort the
87234938Sgrehan# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
88257396Sneel# the confirmation steps.
89245127Sgrehan#
90234938Sgrehan# At the end of the upgrade procedure, /etc/objformat is created or
91234938Sgrehan# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
92234938Sgrehan#
93257396Sneel# ----------------------------------------------------------------------------
94257396Sneel#
95234938Sgrehan#
96234938Sgrehan# Define the user-driven targets. These are listed here in alphabetical
97257396Sneel# order, but that's not important.
98257396Sneel#
99257396SneelTGTS=	all all-man buildkernel buildworld checkdpadd clean \
100257396Sneel	cleandepend cleandir depend distribute distributeworld everything \
101257396Sneel	hierarchy install installcheck installkernel \
102257396Sneel	reinstallkernel installmost installworld libraries lint maninstall \
103257396Sneel	mk most obj objlink regress rerelease tags update
104257396Sneel
105234938SgrehanBITGTS=	files includes
106234938SgrehanBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
107257396Sneel
108234938Sgrehan.ORDER: buildworld installworld
109234938Sgrehan.ORDER: buildworld distributeworld
110234938Sgrehan.ORDER: buildkernel installkernel
111257396Sneel.ORDER: buildkernel reinstallkernel
112257396Sneel
113257396SneelPATH=	/sbin:/bin:/usr/sbin:/usr/bin
114257396SneelMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
115257396Sneel
116257396Sneel#
117257396Sneel# Handle the user-driven targets, using the source relative mk files.
118257396Sneel#
119257396Sneel${TGTS} ${BITGTS}: upgrade_checks
120257396Sneel	@cd ${.CURDIR}; \
121257396Sneel		${MAKE} ${.TARGET}
122257396Sneel
123234938Sgrehan# Set a reasonable default
124234938Sgrehan.MAIN:	all
125234938Sgrehan
126234938SgrehanSTARTTIME!= LC_ALL=C date
127234938Sgrehan#
128234938Sgrehan# world
129241744Sgrehan#
130241744Sgrehan# Attempt to rebuild and reinstall *everything*, with reasonable chance of
131241744Sgrehan# success, regardless of how old your existing system is.
132241744Sgrehan#
133234938Sgrehanworld: upgrade_checks
134234938Sgrehan	@echo "--------------------------------------------------------------"
135	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
136	@echo "--------------------------------------------------------------"
137.if target(pre-world)
138	@echo
139	@echo "--------------------------------------------------------------"
140	@echo ">>> Making 'pre-world' target"
141	@echo "--------------------------------------------------------------"
142	@cd ${.CURDIR}; ${MAKE} pre-world
143.endif
144	@cd ${.CURDIR}; ${MAKE} buildworld
145	@cd ${.CURDIR}; ${MAKE} -B installworld
146.if target(post-world)
147	@echo
148	@echo "--------------------------------------------------------------"
149	@echo ">>> Making 'post-world' target"
150	@echo "--------------------------------------------------------------"
151	@cd ${.CURDIR}; ${MAKE} post-world
152.endif
153	@echo
154	@echo "--------------------------------------------------------------"
155	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
156	@echo "--------------------------------------------------------------"
157
158#
159# kernel
160#
161# Short hand for `make buildkernel installkernel'
162#
163kernel: buildkernel installkernel
164
165#
166# Perform a few tests to determine if the installed tools are adequate
167# for building the world. These are for older systems (prior to 2.2.5).
168#
169# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
170# so the normal make world is capable of doing what is required to update
171# the system to current.
172#
173upgrade_checks:
174	@cd ${.CURDIR}; \
175	if ! make -m ${.CURDIR}/share/mk -Dnotdef test >/dev/null 2>&1; then \
176		make make; \
177	fi
178	@cd ${.CURDIR}; \
179	if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
180	    grep -q "Unknown modifier 'C'"; then \
181		make make; \
182	fi
183
184#
185# A simple test target used as part of the test to see if make supports
186# the -m argument.  Also test that make will only evaluate a conditional
187# as far as is necessary to determine its value.
188#
189test:
190.if defined(notdef)
191.undef notdef
192.if defined(notdef) && ${notdef:U}
193.endif
194.endif
195
196#
197# Upgrade the installed make to the current version using the installed
198# headers, libraries and build tools. This is required on installed versions
199# prior to 2.2.5 in which the installed make doesn't support the -m argument.
200#
201make:
202	@echo
203	@echo "--------------------------------------------------------------"
204	@echo " Upgrading the installed make"
205	@echo "--------------------------------------------------------------"
206	@cd ${.CURDIR}/usr.bin/make; \
207		make obj && make depend && make all && make install
208
209#
210# Define the upgrade targets. These are listed here in alphabetical
211# order, but that's not important.
212#
213UPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
214		move-aout-libs
215
216#
217# Handle the upgrade targets, using the source relative mk files.
218#
219
220upgrade:	aout-to-elf
221
222${UPGRADE} : upgrade_checks
223	@cd ${.CURDIR}; \
224		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
225