Makefile revision 88479
1144564Simp#
21558Srgrimes# $FreeBSD: head/Makefile 74842 2001-03-27 08:43:28Z ru $
31558Srgrimes#
41558Srgrimes# The user-driven targets are:
51558Srgrimes#
61558Srgrimes# buildworld          - Rebuild *everything*, including glue to help do
71558Srgrimes#                       upgrades.
81558Srgrimes# installworld        - Install everything built by "buildworld".
91558Srgrimes# world               - buildworld + installworld.
101558Srgrimes# buildkernel         - Rebuild the kernel and the kernel-modules.
111558Srgrimes# installkernel       - Install the kernel and the kernel-modules.
121558Srgrimes# reinstallkernel     - Reinstall the kernel and the kernel-modules.
131558Srgrimes# kernel              - buildkernel + installkernel.
141558Srgrimes# update              - Convenient way to update your source tree (cvs).
151558Srgrimes# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
161558Srgrimes# most                - Build user commands, no libraries or include files.
171558Srgrimes# installmost         - Install user commands, no libraries or include files.
181558Srgrimes# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
191558Srgrimes# aout-to-elf-build   - Build everything required to upgrade a system from
201558Srgrimes#                       a.out to elf format (see below).
211558Srgrimes# aout-to-elf-install - Install everything built by aout-to-elf-build (see
221558Srgrimes#                       below).
231558Srgrimes# move-aout-libs      - Move the a.out libraries into an aout sub-directory
241558Srgrimes#                       of each elf library sub-directory.
251558Srgrimes#
261558Srgrimes# This makefile is simple by design. The FreeBSD make automatically reads
271558Srgrimes# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
281558Srgrimes# command line. By keeping this makefile simple, it doesn't matter too
291558Srgrimes# much how different the installed mk files are from those in the source
301558Srgrimes# tree. This makefile executes a child make process, forcing it to use
311558Srgrimes# the mk files from the source tree which are supposed to DTRT.
321558Srgrimes#
331558Srgrimes# The user-driven targets (as listed above) are implemented in Makefile.inc0
3423669Speter# and the private targets are in Makefile.inc1. These are kept separate
3596707Strhodes# to help the bootstrap build from aout to elf format.
361558Srgrimes#
371558Srgrimes# For novices wanting to build from current sources, the simple instructions
381558Srgrimes# are:
391558Srgrimes#
401558Srgrimes# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
411558Srgrimes# 2.  `cd /usr/src'  (or to the directory containing your source tree).
421558Srgrimes# 3.  `make world'
43164911Sdwmalone#
44204111Suqs# Be warned, this will update your installed system, except for configuration
451558Srgrimes# files in the /etc directory and for the kernel. You have to do those manually.
461558Srgrimes#
4735852Sjkh# If at first you're a little nervous about having a `make world' update
481558Srgrimes# your system, a `make buildworld' will build everything in the /usr/obj
491558Srgrimes# tree without touching your installed system. To be of any further use
501558Srgrimes# though, a `make installworld' is required.
511558Srgrimes#
521558Srgrimes# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
531558Srgrimes# update the legacy support for aout. This includes all libraries, ld.so
5423669Speter# and boot objects. This part of build should be regarded as
55102231Strhodes# deprecated and you should _not_ expect to be able to do this past the
561558Srgrimes# release of 4.0. You have exactly one major release to move entirely
571558Srgrimes# to elf.
581558Srgrimes#
591558Srgrimes# ----------------------------------------------------------------------------
601558Srgrimes#
611558Srgrimes#           Upgrading an i386 system from a.out to elf format
621558Srgrimes#
631558Srgrimes#
64144099Simp# The aout->elf transition build is performed by doing a `make upgrade' (or
651558Srgrimes# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
661558Srgrimes# by a `make aout-to-elf-install', depending on user preference.
67102231Strhodes# You need to have at least 320 Mb of free space for the object tree.
681558Srgrimes#
691558Srgrimes# The upgrade process checks the installed release. If this is 3.0-CURRENT,
701558Srgrimes# it is assumed that your kernel contains all the syscalls required by the
711558Srgrimes# current sources.
721558Srgrimes#
731558Srgrimes# The upgrade procedure will stop and ask for confirmation to proceed
741558Srgrimes# several times. On each occasion, you can type Ctrl-C to abort the
751558Srgrimes# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
761558Srgrimes# the confirmation steps.
771558Srgrimes#
781558Srgrimes# At the end of the upgrade procedure, /etc/objformat is created or
791558Srgrimes# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
801558Srgrimes#
811558Srgrimes# ----------------------------------------------------------------------------
821558Srgrimes#
831558Srgrimes#
841558Srgrimes# Define the user-driven targets. These are listed here in alphabetical
851558Srgrimes# order, but that's not important.
861558Srgrimes#
871558SrgrimesTGTS=	afterdistribute all all-man buildkernel buildworld checkdpadd clean \
881558Srgrimes	cleandepend cleandir depend distribute distribworld everything \
891558Srgrimes	hierarchy includes install installkernel kernel reinstallkernel \
901558Srgrimes	installmost installworld libraries lint maninstall mk most obj \
911558Srgrimes	objlink regress rerelease tags update
921558Srgrimes
931558SrgrimesPATH=	/sbin:/bin:/usr/sbin:/usr/bin
941558SrgrimesMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
951558Srgrimes
961558Srgrimes#
971558Srgrimes# Handle the user-driven targets, using the source relative mk files.
981558Srgrimes#
991558Srgrimes${TGTS}: upgrade_checks
1001558Srgrimes	@cd ${.CURDIR}; \
1011558Srgrimes		${MAKE} ${.TARGET}
1021558Srgrimes
1031558Srgrimes# Set a reasonable default
1041558Srgrimes.MAIN:	all
10598542Smckusick
10698542SmckusickSTARTTIME!= LC_ALL=C date
10798542Smckusick#
10898542Smckusick# world
10998542Smckusick#
11098542Smckusick# Attempt to rebuild and reinstall *everything*, with reasonable chance of
11198542Smckusick# success, regardless of how old your existing system is.
11298542Smckusick#
11398542Smckusickworld: upgrade_checks
114100207Smckusick	@echo "--------------------------------------------------------------"
11598542Smckusick	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
11698542Smckusick	@echo "--------------------------------------------------------------"
117100207Smckusick.if target(pre-world)
118167011Smckusick	@echo
11998542Smckusick	@echo "--------------------------------------------------------------"
1201558Srgrimes	@echo ">>> Making 'pre-world' target"
1211558Srgrimes	@echo "--------------------------------------------------------------"
1221558Srgrimes	@cd ${.CURDIR}; ${MAKE} pre-world
1231558Srgrimes.endif
1241558Srgrimes	@cd ${.CURDIR}; ${MAKE} buildworld
1251558Srgrimes	@cd ${.CURDIR}; ${MAKE} -B installworld
1261558Srgrimes.if target(post-world)
1271558Srgrimes	@echo
1281558Srgrimes	@echo "--------------------------------------------------------------"
1291558Srgrimes	@echo ">>> Making 'post-world' target"
1301558Srgrimes	@echo "--------------------------------------------------------------"
1311558Srgrimes	@cd ${.CURDIR}; ${MAKE} post-world
1321558Srgrimes.endif
1331558Srgrimes	@echo
1341558Srgrimes	@echo "--------------------------------------------------------------"
1351558Srgrimes	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                        (started ${STARTTIME})\n"
1361558Srgrimes	@echo "--------------------------------------------------------------"
1371558Srgrimes
1381558Srgrimes#
1391558Srgrimes# Perform a few tests to determine if the installed tools are adequate
1401558Srgrimes# for building the world. These are for older systems (prior to 2.2.5).
141103949Smike#
142103949Smike# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
14323669Speter# so the normal make world is capable of doing what is required to update
144103949Smike# the system to current.
145103949Smike#
1461558Srgrimesupgrade_checks:
1471558Srgrimes	@cd ${.CURDIR}; \
1481558Srgrimes		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
1491558Srgrimes			make make; \
1501558Srgrimes		fi
1511558Srgrimes
152144099Simp#
153144099Simp# 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