Makefile revision 103985
1#
2# $FreeBSD: head/Makefile 103985 2002-09-26 04:40:54Z phk $
3#
4# The user-driven targets are:
5#
6# universe 	      - *Really* build *everything*:  Buildworld and
7#			all kernels on all architectures.
8# buildworld          - Rebuild *everything*, including glue to help do
9#                       upgrades.
10# installworld        - Install everything built by "buildworld".
11# world               - buildworld + installworld.
12# buildkernel         - Rebuild the kernel and the kernel-modules.
13# installkernel       - Install the kernel and the kernel-modules.
14# reinstallkernel     - Reinstall the kernel and the kernel-modules.
15# kernel              - buildkernel + installkernel.
16# update              - Convenient way to update your source tree (cvs).
17# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
18# most                - Build user commands, no libraries or include files.
19# installmost         - Install user commands, no libraries or include files.
20# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
21# aout-to-elf-build   - Build everything required to upgrade a system from
22#                       a.out to elf format (see below).
23# aout-to-elf-install - Install everything built by aout-to-elf-build (see
24#                       below).
25# move-aout-libs      - Move the a.out libraries into an aout sub-directory
26#                       of each elf library sub-directory.
27#
28# This makefile is simple by design. The FreeBSD make automatically reads
29# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
30# command line. By keeping this makefile simple, it doesn't matter too
31# much how different the installed mk files are from those in the source
32# tree. This makefile executes a child make process, forcing it to use
33# the mk files from the source tree which are supposed to DTRT.
34#
35# The user-driven targets (as listed above) are implemented in Makefile.inc1.
36#
37# If you want to build your system from source be sure that /usr/obj has
38# at least 400MB of diskspace available.
39#
40# For individuals wanting to build from the sources currently on their
41# system, the simple instructions are:
42#
43# 1.  `cd /usr/src'  (or to the directory containing your source tree).
44# 2.  `make world'
45#
46# For individuals wanting to upgrade their sources (even if only a
47# delta of a few days):
48#
49# 1.  `cd /usr/src'       (or to the directory containing your source tree).
50# 2.  `make buildworld'
51# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
52# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
53# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
54# 6.  `mergemaster -p'
55# 7.  `make installworld'
56# 8.  `mergemaster'
57# 9.  `reboot'
58#
59# See src/UPDATING `COMMON ITEMS' for more complete information.
60#
61# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
62# cross build world for other architectures using the buildworld target,
63# and once the world is built you can cross build a kernel using the
64# buildkernel target.
65#
66# ----------------------------------------------------------------------------
67#
68#           Upgrading an i386 system from a.out to elf format
69#
70#
71# The aout->elf transition build is performed by doing a `make upgrade' (or
72# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
73# by a `make aout-to-elf-install', depending on user preference.
74# You need to have at least 320 Mb of free space for the object tree.
75#
76# The upgrade process checks the installed release. If this is 3.0-CURRENT,
77# it is assumed that your kernel contains all the syscalls required by the
78# current sources.
79#
80# The upgrade procedure will stop and ask for confirmation to proceed
81# several times. On each occasion, you can type Ctrl-C to abort the
82# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
83# the confirmation steps.
84#
85# ----------------------------------------------------------------------------
86#
87#
88# Define the user-driven targets. These are listed here in alphabetical
89# order, but that's not important.
90#
91TGTS=	all all-man buildkernel buildworld checkdpadd clean \
92	cleandepend cleandir depend distribute distributeworld everything \
93	hierarchy install installcheck installkernel \
94	reinstallkernel installmost installworld libraries lint maninstall \
95	mk most obj objlink regress rerelease tags update
96
97BITGTS=	files includes
98BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
99
100.ORDER: buildworld installworld
101.ORDER: buildworld distributeworld
102.ORDER: buildkernel installkernel
103.ORDER: buildkernel reinstallkernel
104
105PATH=	/sbin:/bin:/usr/sbin:/usr/bin
106MAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
107
108#
109# Handle the user-driven targets, using the source relative mk files.
110#
111${TGTS} ${BITGTS}: upgrade_checks
112	@cd ${.CURDIR}; \
113		${MAKE} ${.TARGET}
114
115# Set a reasonable default
116.MAIN:	all
117
118STARTTIME!= LC_ALL=C date
119#
120# world
121#
122# Attempt to rebuild and reinstall *everything*, with reasonable chance of
123# success, regardless of how old your existing system is.
124#
125world: upgrade_checks
126	@echo "--------------------------------------------------------------"
127	@echo ">>> elf make world started on ${STARTTIME}"
128	@echo "--------------------------------------------------------------"
129.if target(pre-world)
130	@echo
131	@echo "--------------------------------------------------------------"
132	@echo ">>> Making 'pre-world' target"
133	@echo "--------------------------------------------------------------"
134	@cd ${.CURDIR}; ${MAKE} pre-world
135.endif
136	@cd ${.CURDIR}; ${MAKE} buildworld
137	@cd ${.CURDIR}; ${MAKE} -B installworld
138.if target(post-world)
139	@echo
140	@echo "--------------------------------------------------------------"
141	@echo ">>> Making 'post-world' target"
142	@echo "--------------------------------------------------------------"
143	@cd ${.CURDIR}; ${MAKE} post-world
144.endif
145	@echo
146	@echo "--------------------------------------------------------------"
147	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
148	@echo "--------------------------------------------------------------"
149
150#
151# kernel
152#
153# Short hand for `make buildkernel installkernel'
154#
155kernel: buildkernel installkernel
156
157#
158# Perform a few tests to determine if the installed tools are adequate
159# for building the world. These are for older systems (prior to 2.2.5).
160#
161# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
162# so the normal make world is capable of doing what is required to update
163# the system to current.
164#
165upgrade_checks:
166	@cd ${.CURDIR}; \
167	if ! make -m ${.CURDIR}/share/mk -Dnotdef test >/dev/null 2>&1; then \
168		make make; \
169	fi
170	@cd ${.CURDIR}; \
171	if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
172	    grep -q "Unknown modifier 'C'"; then \
173		make make; \
174	fi
175
176#
177# A simple test target used as part of the test to see if make supports
178# the -m argument.  Also test that make will only evaluate a conditional
179# as far as is necessary to determine its value.
180#
181test:
182.if defined(notdef)
183.undef notdef
184.if defined(notdef) && ${notdef:U}
185.endif
186.endif
187
188#
189# Upgrade the installed make to the current version using the installed
190# headers, libraries and build tools. This is required on installed versions
191# prior to 2.2.5 in which the installed make doesn't support the -m argument.
192#
193make:
194	@echo
195	@echo "--------------------------------------------------------------"
196	@echo " Upgrading the installed make"
197	@echo "--------------------------------------------------------------"
198	@cd ${.CURDIR}/usr.bin/make; \
199		make obj && make -D_UPGRADING depend && \
200		make -D_UPGRADING all && make install
201
202#
203# Define the upgrade targets. These are listed here in alphabetical
204# order, but that's not important.
205#
206UPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
207		move-aout-libs
208
209#
210# Handle the upgrade targets, using the source relative mk files.
211#
212
213upgrade:	aout-to-elf
214
215${UPGRADE} : upgrade_checks
216	@cd ${.CURDIR}; \
217		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
218
219
220universe:
221	@echo "--------------------------------------------------------------"
222	@echo ">>> make universe started on ${STARTTIME}"
223	@echo "--------------------------------------------------------------"
224.for arch in i386 sparc64 alpha ia64
225	@printf ">> ${arch} started on `LC_ALL=C date`\n"
226	-cd ${.CURDIR} && make ${JFLAG} buildworld TARGET_ARCH=${arch} \
227		__MAKE_CONF=/dev/null \
228		> _.${arch}.buildworld 2>&1
229	@printf ">> ${arch} buildworld ended on `LC_ALL=C date`\n"
230.if exists(sys/${arch}/conf/NOTES)
231	cd ${.CURDIR}/sys/${arch}/conf && make LINT \
232		> _.${arch}.makeLINT 2>&1
233.endif
234	cd ${.CURDIR} && make buildkernels TARGET_ARCH=${arch} JFLAG="${JFLAG}"
235	@printf ">> ${arch} ended on `LC_ALL=C date`\n"
236.endfor
237	@echo "--------------------------------------------------------------"
238	@printf ">>> make universe completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
239	@echo "--------------------------------------------------------------"
240
241KERNCONFS !=	echo ${.CURDIR}/sys/${TARGET_ARCH}/conf/[A-Z]*
242KERNCONF2 = ${KERNCONFS:T:N*[a-z]*:NCVS:NNOTES}
243
244buildkernels:
245.for kernel in ${KERNCONF2}
246.if exists(${.CURDIR}/sys/${TARGET_ARCH}/conf/${kernel})
247	-cd ${.CURDIR} && make ${JFLAG} buildkernel \
248		TARGET_ARCH=${TARGET_ARCH} KERNCONF=${kernel} \
249		__MAKE_CONF=/dev/null \
250		 > _.${TARGET_ARCH}.${kernel} 2>&1
251.endif
252.endfor
253
254