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