Makefile revision 96164
1#
2# $FreeBSD: head/Makefile 96164 2002-05-07 15:42:56Z ru $
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# For novices wanting to build from current sources, the simple instructions
36# are:
37#
38# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
39# 2.  `cd /usr/src'  (or to the directory containing your source tree).
40# 3.  `make world'
41#
42# Be warned, this will update your installed system, except for configuration
43# files in the /etc directory and for the kernel. You have to do those manually.
44#
45# If at first you're a little nervous about having a `make world' update
46# your system, a `make buildworld' will build everything in the /usr/obj
47# tree without touching your installed system. To be of any further use
48# though, a `make installworld' is required.
49#
50# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
51# update the legacy support for aout. This includes all libraries, ld.so
52# and boot objects. This part of build should be regarded as
53# deprecated and you should _not_ expect to be able to do this past the
54# release of 4.0. You have exactly one major release to move entirely
55# to elf.
56#
57# ----------------------------------------------------------------------------
58#
59#           Upgrading an i386 system from a.out to elf format
60#
61#
62# The aout->elf transition build is performed by doing a `make upgrade' (or
63# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
64# by a `make aout-to-elf-install', depending on user preference.
65# You need to have at least 320 Mb of free space for the object tree.
66#
67# The upgrade process checks the installed release. If this is 3.0-CURRENT,
68# it is assumed that your kernel contains all the syscalls required by the
69# current sources.
70#
71# The upgrade procedure will stop and ask for confirmation to proceed
72# several times. On each occasion, you can type Ctrl-C to abort the
73# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
74# the confirmation steps.
75#
76# At the end of the upgrade procedure, /etc/objformat is created or
77# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
78#
79# ----------------------------------------------------------------------------
80#
81#
82# Define the user-driven targets. These are listed here in alphabetical
83# order, but that's not important.
84#
85TGTS=	all all-man buildkernel buildworld checkdpadd clean \
86	cleandepend cleandir depend distribute distributeworld everything \
87	hierarchy includes install installcheck installkernel \
88	reinstallkernel installmost installworld libraries lint maninstall \
89	mk most obj objlink regress rerelease tags update
90
91.ORDER: buildworld installworld
92.ORDER: buildworld distributeworld
93.ORDER: buildkernel installkernel
94.ORDER: buildkernel reinstallkernel
95
96PATH=	/sbin:/bin:/usr/sbin:/usr/bin
97MAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
98
99#
100# Handle the user-driven targets, using the source relative mk files.
101#
102${TGTS}: upgrade_checks
103	@cd ${.CURDIR}; \
104		${MAKE} ${.TARGET}
105
106# Set a reasonable default
107.MAIN:	all
108
109STARTTIME!= LC_ALL=C date
110#
111# world
112#
113# Attempt to rebuild and reinstall *everything*, with reasonable chance of
114# success, regardless of how old your existing system is.
115#
116world: upgrade_checks
117	@echo "--------------------------------------------------------------"
118	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
119	@echo "--------------------------------------------------------------"
120.if target(pre-world)
121	@echo
122	@echo "--------------------------------------------------------------"
123	@echo ">>> Making 'pre-world' target"
124	@echo "--------------------------------------------------------------"
125	@cd ${.CURDIR}; ${MAKE} pre-world
126.endif
127	@cd ${.CURDIR}; ${MAKE} buildworld
128	@cd ${.CURDIR}; ${MAKE} -B installworld
129.if target(post-world)
130	@echo
131	@echo "--------------------------------------------------------------"
132	@echo ">>> Making 'post-world' target"
133	@echo "--------------------------------------------------------------"
134	@cd ${.CURDIR}; ${MAKE} post-world
135.endif
136	@echo
137	@echo "--------------------------------------------------------------"
138	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                        (started ${STARTTIME})\n"
139	@echo "--------------------------------------------------------------"
140
141#
142# kernel
143#
144# Short hand for `make buildkernel installkernel'
145#
146kernel: buildkernel installkernel
147
148#
149# Perform a few tests to determine if the installed tools are adequate
150# for building the world. These are for older systems (prior to 2.2.5).
151#
152# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
153# so the normal make world is capable of doing what is required to update
154# the system to current.
155#
156upgrade_checks:
157	@cd ${.CURDIR}; \
158		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
159			make make; \
160		fi
161	@cd ${.CURDIR}; \
162		if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
163		    grep -q "Unknown modifier 'C'"; then \
164			make make; \
165		fi
166
167#
168# A simple test target used as part of the test to see if make supports
169# the -m argument.
170#
171test:
172
173#
174# Upgrade the installed make to the current version using the installed
175# headers, libraries and build tools. This is required on installed versions
176# prior to 2.2.5 in which the installed make doesn't support the -m argument.
177#
178make:
179	@echo
180	@echo "--------------------------------------------------------------"
181	@echo " Upgrading the installed make"
182	@echo "--------------------------------------------------------------"
183	@cd ${.CURDIR}/usr.bin/make; \
184		make obj && make depend && make all && make install
185
186#
187# Define the upgrade targets. These are listed here in alphabetical
188# order, but that's not important.
189#
190UPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
191		move-aout-libs
192
193#
194# Handle the upgrade targets, using the source relative mk files.
195#
196
197upgrade:	aout-to-elf
198
199${UPGRADE} : upgrade_checks
200	@cd ${.CURDIR}; \
201		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
202