Makefile revision 66071
1219820Sjeff#
2219820Sjeff# $FreeBSD: head/Makefile 66071 2000-09-19 11:15:40Z markm $
3219820Sjeff#
4219820Sjeff# The user-driven targets are:
5270710Shselasky#
6219820Sjeff# buildworld          - Rebuild *everything*, including glue to help do
7219820Sjeff#                       upgrades.
8219820Sjeff# installworld        - Install everything built by "buildworld".
9219820Sjeff# world               - buildworld + installworld.
10219820Sjeff# buildkernel         - Rebuild the kernel and the kernel-modules.
11219820Sjeff# installkernel       - Install the kernel and the kernel-modules.
12219820Sjeff# reinstallkernel     - Reinstall the kernel and the kernel-modules.
13219820Sjeff# update              - Convenient way to update your source tree (cvs).
14219820Sjeff# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
15219820Sjeff# most                - Build user commands, no libraries or include files.
16219820Sjeff# installmost         - Install user commands, no libraries or include files.
17219820Sjeff# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
18219820Sjeff# aout-to-elf-build   - Build everything required to upgrade a system from
19219820Sjeff#                       a.out to elf format (see below).
20219820Sjeff# aout-to-elf-install - Install everything built by aout-to-elf-build (see
21219820Sjeff#                       below).
22219820Sjeff# move-aout-libs      - Move the a.out libraries into an aout sub-directory
23219820Sjeff#                       of each elf library sub-directory.
24219820Sjeff#
25219820Sjeff# This makefile is simple by design. The FreeBSD make automatically reads
26219820Sjeff# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
27219820Sjeff# command line. By keeping this makefile simple, it doesn't matter too
28219820Sjeff# much how different the installed mk files are from those in the source
29219820Sjeff# tree. This makefile executes a child make process, forcing it to use
30219820Sjeff# the mk files from the source tree which are supposed to DTRT.
31219820Sjeff#
32219820Sjeff# The user-driven targets (as listed above) are implemented in Makefile.inc0
33219820Sjeff# and the private targets are in Makefile.inc1. These are kept separate
34219820Sjeff# to help the bootstrap build from aout to elf format.
35219820Sjeff#
36219820Sjeff# For novices wanting to build from current sources, the simple instructions
37219820Sjeff# are:
38219820Sjeff#
39219820Sjeff# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
40219820Sjeff# 2.  `cd /usr/src'  (or to the directory containing your source tree).
41219820Sjeff# 3.  `make world'
42219820Sjeff#
43219820Sjeff# Be warned, this will update your installed system, except for configuration
44219820Sjeff# files in the /etc directory and for the kernel. You have to do those manually.
45219820Sjeff#
46219820Sjeff# If at first you're a little nervous about having a `make world' update
47219820Sjeff# your system, a `make buildworld' will build everything in the /usr/obj
48219820Sjeff# tree without touching your installed system. To be of any further use
49219820Sjeff# though, a `make installworld' is required.
50219820Sjeff#
51219820Sjeff# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
52219820Sjeff# update the legacy support for aout. This includes all libraries, ld.so
53219820Sjeff# and boot objects. This part of build should be regarded as
54219820Sjeff# deprecated and you should _not_ expect to be able to do this past the
55219820Sjeff# release of 4.0. You have exactly one major release to move entirely
56219820Sjeff# to elf.
57219820Sjeff#
58219820Sjeff# ----------------------------------------------------------------------------
59219820Sjeff#
60219820Sjeff#           Upgrading an i386 system from a.out to elf format
61219820Sjeff#
62219820Sjeff#
63219820Sjeff# The aout->elf transition build is performed by doing a `make upgrade' (or
64219820Sjeff# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
65219820Sjeff# by a `make aout-to-elf-install', depending on user preference.
66219820Sjeff# You need to have at least 320 Mb of free space for the object tree.
67219820Sjeff#
68219820Sjeff# The upgrade process checks the installed release. If this is 3.0-CURRENT,
69219820Sjeff# it is assumed that your kernel contains all the syscalls required by the
70219820Sjeff# current sources.
71219820Sjeff#
72219820Sjeff# The upgrade procedure will stop and ask for confirmation to proceed
73219820Sjeff# several times. On each occasion, you can type Ctrl-C to abort the
74219820Sjeff# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
75219820Sjeff# the confirmation steps.
76219820Sjeff#
77219820Sjeff# At the end of the upgrade procedure, /etc/objformat is created or
78219820Sjeff# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
79219820Sjeff#
80219820Sjeff# ----------------------------------------------------------------------------
81219820Sjeff#
82219820Sjeff#
83219820Sjeff# Define the user-driven targets. These are listed here in alphabetical
84219820Sjeff# order, but that's not important.
85219820Sjeff#
86219820SjeffTGTS=	afterdistribute all buildkernel buildworld checkdpadd clean \
87219820Sjeff	cleandepend cleandir depend distribute everything hierarchy includes \
88219820Sjeff	install installkernel reinstallkernel installmost installworld \
89219820Sjeff	libraries lint maninstall mk most obj objlink regress rerelease \
90219820Sjeff	tags update
91219820Sjeff
92219820SjeffPATH=	/sbin:/bin:/usr/sbin:/usr/bin
93219820SjeffMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
94219820Sjeff
95219820Sjeff#
96219820Sjeff# Handle the user-driven targets, using the source relative mk files.
97219820Sjeff#
98219820Sjeff${TGTS}: upgrade_checks
99219820Sjeff	@cd ${.CURDIR}; \
100219820Sjeff		${MAKE} ${.TARGET}
101219820Sjeff
102219820Sjeff# Set a reasonable default
103219820Sjeff.MAIN:	all
104219820Sjeff
105219820SjeffSTARTTIME!= LC_TIME=C date
106219820Sjeff#
107219820Sjeff# world
108219820Sjeff#
109219820Sjeff# Attempt to rebuild and reinstall *everything*, with reasonable chance of
110219820Sjeff# success, regardless of how old your existing system is.
111219820Sjeff#
112219820Sjeffworld: upgrade_checks
113	@echo "--------------------------------------------------------------"
114	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
115	@echo "--------------------------------------------------------------"
116.if target(pre-world)
117	@echo
118	@echo "--------------------------------------------------------------"
119	@echo ">>> Making 'pre-world' target"
120	@echo "--------------------------------------------------------------"
121	@cd ${.CURDIR}; ${MAKE} pre-world
122.endif
123	@cd ${.CURDIR}; ${MAKE} buildworld
124	@cd ${.CURDIR}; ${MAKE} -B installworld
125.if target(post-world)
126	@echo
127	@echo "--------------------------------------------------------------"
128	@echo ">>> Making 'post-world' target"
129	@echo "--------------------------------------------------------------"
130	@cd ${.CURDIR}; ${MAKE} post-world
131.endif
132	@echo
133	@echo "--------------------------------------------------------------"
134	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
135	@echo ">>> ${OBJFORMAT} make world completed on `LC_TIME=C date`"
136	@echo "--------------------------------------------------------------"
137
138#
139# Perform a few tests to determine if the installed tools are adequate
140# for building the world. These are for older systems (prior to 2.2.5).
141#
142# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
143# so the normal make world is capable of doing what is required to update
144# the system to current.
145#
146upgrade_checks:
147	@cd ${.CURDIR}; \
148		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
149			make make; \
150		fi
151
152#
153# A simple test target used as part of the test to see if make supports
154# the -m argument.
155#
156test:
157
158#
159# Upgrade the installed make to the current version using the installed
160# headers, libraries and build tools. This is required on installed versions
161# prior to 2.2.5 in which the installed make doesn't support the -m argument.
162#
163make:
164	@echo
165	@echo "--------------------------------------------------------------"
166	@echo " Upgrading the installed make"
167	@echo "--------------------------------------------------------------"
168	@cd ${.CURDIR}/usr.bin/make; \
169		make obj && make depend && make all && make install
170
171#
172# Define the upgrade targets. These are listed here in alphabetical
173# order, but that's not important.
174#
175UPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
176		move-aout-libs
177
178#
179# Handle the upgrade targets, using the source relative mk files.
180#
181
182upgrade:	aout-to-elf
183
184${UPGRADE} : upgrade_checks
185	@cd ${.CURDIR}; \
186		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
187