Makefile revision 97769
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 97769 2002-06-03 14:49:34Z ru $
32061Sjkh#
438666Sjb# The user-driven targets are:
532427Sjb#
638666Sjb# buildworld          - Rebuild *everything*, including glue to help do
738666Sjb#                       upgrades.
838666Sjb# installworld        - Install everything built by "buildworld".
938666Sjb# world               - buildworld + installworld.
1064049Salex# buildkernel         - Rebuild the kernel and the kernel-modules.
1164049Salex# installkernel       - Install the kernel and the kernel-modules.
1266071Smarkm# reinstallkernel     - Reinstall the kernel and the kernel-modules.
1373504Sobrien# kernel              - buildkernel + installkernel.
1438666Sjb# update              - Convenient way to update your source tree (cvs).
1544918Sjkh# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1638666Sjb# most                - Build user commands, no libraries or include files.
1738666Sjb# installmost         - Install user commands, no libraries or include files.
1838666Sjb# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
1938666Sjb# aout-to-elf-build   - Build everything required to upgrade a system from
2038666Sjb#                       a.out to elf format (see below).
2138666Sjb# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2238666Sjb#                       below).
2338978Sjb# move-aout-libs      - Move the a.out libraries into an aout sub-directory
2438978Sjb#                       of each elf library sub-directory.
2532427Sjb#
2638666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
2738666Sjb# the /usr/share/mk/sys.mk unless the -m argument is specified on the 
2838666Sjb# command line. By keeping this makefile simple, it doesn't matter too
2938666Sjb# much how different the installed mk files are from those in the source
3038666Sjb# tree. This makefile executes a child make process, forcing it to use
3138666Sjb# the mk files from the source tree which are supposed to DTRT.
3217308Speter#
3391606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3419175Sbde#
3596205Sjwd# If you want to build your system from source be sure that /usr/obj has
3696205Sjwd# at least 400MB of diskspace available.
3738042Sbde#
3896205Sjwd# For individuals wanting to build from the sources currently on their
3996205Sjwd# system, the simple instructions are:
4038042Sbde#
4196205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
4296205Sjwd# 2.  `make world'
4317308Speter#
4496205Sjwd# For individuals wanting to upgrade their sources (even if only a
4596205Sjwd# delta of a few days):
4617308Speter#
4796205Sjwd# 1.  `cd /usr/src'       (or to the directory containing your source tree).
4896205Sjwd# 2.  `make buildworld'
4996205Sjwd# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
5096205Sjwd# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
5196205Sjwd# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
5296205Sjwd# 6.  `mergemaster -p'
5396205Sjwd# 7.  `make installworld'
5496205Sjwd# 8.  `mergemaster'
5596205Sjwd# 9.  `reboot'
5696205Sjwd#
5796205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
5896205Sjwd#
5945108Sobrien# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
6042128Speter# update the legacy support for aout. This includes all libraries, ld.so
6142128Speter# and boot objects. This part of build should be regarded as
6238666Sjb# deprecated and you should _not_ expect to be able to do this past the
6351361Sjb# release of 4.0. You have exactly one major release to move entirely
6438666Sjb# to elf.
6517308Speter#
6638666Sjb# ----------------------------------------------------------------------------
6717308Speter#
6838666Sjb#           Upgrading an i386 system from a.out to elf format
6917308Speter#
7027910Sasami#
7143226Sjkh# The aout->elf transition build is performed by doing a `make upgrade' (or
7243226Sjkh# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
7343226Sjkh# by a `make aout-to-elf-install', depending on user preference.
7438666Sjb# You need to have at least 320 Mb of free space for the object tree.
7527910Sasami#
7638666Sjb# The upgrade process checks the installed release. If this is 3.0-CURRENT,
7738666Sjb# it is assumed that your kernel contains all the syscalls required by the
7838666Sjb# current sources.
7927910Sasami#
8038666Sjb# The upgrade procedure will stop and ask for confirmation to proceed
8138666Sjb# several times. On each occasion, you can type Ctrl-C to abort the
8243226Sjkh# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
8343226Sjkh# the confirmation steps.
8427910Sasami#
8538666Sjb# At the end of the upgrade procedure, /etc/objformat is created or
8638666Sjb# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
8727910Sasami#
8838666Sjb# ----------------------------------------------------------------------------
8927910Sasami#
9017308Speter#
9138666Sjb# Define the user-driven targets. These are listed here in alphabetical
9238666Sjb# order, but that's not important.
9317308Speter#
9495509SruTGTS=	all all-man buildkernel buildworld checkdpadd clean \
9595793Sru	cleandepend cleandir depend distribute distributeworld everything \
9697252Sru	hierarchy install installcheck installkernel \
9796164Sru	reinstallkernel installmost installworld libraries lint maninstall \
9895146Sgshapiro	mk most obj objlink regress rerelease tags update
992061Sjkh
10097769SruBITGTS=	files includes
10197252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
10297252Sru
10395730Sru.ORDER: buildworld installworld
10495793Sru.ORDER: buildworld distributeworld
10595730Sru.ORDER: buildkernel installkernel
10695730Sru.ORDER: buildkernel reinstallkernel
10795730Sru
10855026SmarcelPATH=	/sbin:/bin:/usr/sbin:/usr/bin
10955026SmarcelMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
11054324Smarcel
11117308Speter#
11238666Sjb# Handle the user-driven targets, using the source relative mk files.
11317308Speter#
11497252Sru${TGTS} ${BITGTS}: upgrade_checks
11538666Sjb	@cd ${.CURDIR}; \
11654324Smarcel		${MAKE} ${.TARGET}
1172302Spaul
11839206Sjkh# Set a reasonable default
11939206Sjkh.MAIN:	all
12039206Sjkh
12173349SruSTARTTIME!= LC_ALL=C date
12217308Speter#
12354324Smarcel# world
12454324Smarcel#
12554324Smarcel# Attempt to rebuild and reinstall *everything*, with reasonable chance of
12654324Smarcel# success, regardless of how old your existing system is.
12754324Smarcel#
12854324Smarcelworld: upgrade_checks
12954324Smarcel	@echo "--------------------------------------------------------------"
13069659Sobrien	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
13154324Smarcel	@echo "--------------------------------------------------------------"
13254324Smarcel.if target(pre-world)
13354324Smarcel	@echo
13454324Smarcel	@echo "--------------------------------------------------------------"
13554324Smarcel	@echo ">>> Making 'pre-world' target"
13654324Smarcel	@echo "--------------------------------------------------------------"
13754324Smarcel	@cd ${.CURDIR}; ${MAKE} pre-world
13854324Smarcel.endif
13954324Smarcel	@cd ${.CURDIR}; ${MAKE} buildworld
14054324Smarcel	@cd ${.CURDIR}; ${MAKE} -B installworld
14154324Smarcel.if target(post-world)
14254324Smarcel	@echo
14354324Smarcel	@echo "--------------------------------------------------------------"
14454324Smarcel	@echo ">>> Making 'post-world' target"
14554324Smarcel	@echo "--------------------------------------------------------------"
14654324Smarcel	@cd ${.CURDIR}; ${MAKE} post-world
14754324Smarcel.endif
14854324Smarcel	@echo
14954324Smarcel	@echo "--------------------------------------------------------------"
15097536Sobrien	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
15154324Smarcel	@echo "--------------------------------------------------------------"
15254324Smarcel
15354324Smarcel#
15495730Sru# kernel
15595730Sru#
15695730Sru# Short hand for `make buildkernel installkernel'
15795730Sru#
15895730Srukernel: buildkernel installkernel
15995730Sru
16095730Sru#
16138666Sjb# Perform a few tests to determine if the installed tools are adequate
16238666Sjb# for building the world. These are for older systems (prior to 2.2.5).
16317308Speter#
16438666Sjb# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
16538666Sjb# so the normal make world is capable of doing what is required to update
16638666Sjb# the system to current.
16717308Speter#
16855678Smarcelupgrade_checks:
16955678Smarcel	@cd ${.CURDIR}; \
17055678Smarcel		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
17155678Smarcel			make make; \
17255678Smarcel		fi
17390395Sru	@cd ${.CURDIR}; \
17490395Sru		if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
17590395Sru		    grep -q "Unknown modifier 'C'"; then \
17690395Sru			make make; \
17790395Sru		fi
1782061Sjkh
17917308Speter#
18038666Sjb# A simple test target used as part of the test to see if make supports
18138666Sjb# the -m argument.
18217308Speter#
18355678Smarceltest:
1843626Swollman
18517308Speter#
18655678Smarcel# Upgrade the installed make to the current version using the installed
18755678Smarcel# headers, libraries and build tools. This is required on installed versions
18855678Smarcel# prior to 2.2.5 in which the installed make doesn't support the -m argument.
18955678Smarcel#
19055678Smarcelmake:
19155678Smarcel	@echo
19255678Smarcel	@echo "--------------------------------------------------------------"
19355678Smarcel	@echo " Upgrading the installed make"
19455678Smarcel	@echo "--------------------------------------------------------------"
19555678Smarcel	@cd ${.CURDIR}/usr.bin/make; \
19655678Smarcel		make obj && make depend && make all && make install
19755678Smarcel
19855678Smarcel#
19938666Sjb# Define the upgrade targets. These are listed here in alphabetical
20038666Sjb# order, but that's not important.
20117308Speter#
20255678SmarcelUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
20338978Sjb		move-aout-libs
2043626Swollman
20517308Speter#
20638666Sjb# Handle the upgrade targets, using the source relative mk files.
20717308Speter#
20843226Sjkh
20943226Sjkhupgrade:	aout-to-elf
21043226Sjkh
21138666Sjb${UPGRADE} : upgrade_checks
21238666Sjb	@cd ${.CURDIR}; \
21344103Smsmith		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
214