xref: /freebsd/Makefile (revision afcf05e4)
13540f0e1SJordan K. Hubbard#
297d92980SPeter Wemm# $FreeBSD$
3cf763a57SJohn Birrell#
411fb97daSJohn Birrell# The user-driven targets are:
5cf763a57SJohn Birrell#
611fb97daSJohn Birrell# buildworld          - Rebuild *everything*, including glue to help do
711fb97daSJohn Birrell#                       upgrades.
811fb97daSJohn Birrell# installworld        - Install everything built by "buildworld".
911fb97daSJohn Birrell# world               - buildworld + installworld.
1000eb8cbdSAlexander Langer# buildkernel         - Rebuild the kernel and the kernel-modules.
1100eb8cbdSAlexander Langer# installkernel       - Install the kernel and the kernel-modules.
12737ffab7SMark Murray# reinstallkernel     - Reinstall the kernel and the kernel-modules.
136333b4a2SJordan K. Hubbard# kernel              - buildkernel + installkernel
1411fb97daSJohn Birrell# update              - Convenient way to update your source tree (cvs).
157785c4f2SJordan K. Hubbard# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1611fb97daSJohn Birrell# most                - Build user commands, no libraries or include files.
1711fb97daSJohn Birrell# installmost         - Install user commands, no libraries or include files.
1811fb97daSJohn Birrell# aout-to-elf         - Upgrade an system from a.out to elf format (see below).
1911fb97daSJohn Birrell# aout-to-elf-build   - Build everything required to upgrade a system from
2011fb97daSJohn Birrell#                       a.out to elf format (see below).
2111fb97daSJohn Birrell# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2211fb97daSJohn Birrell#                       below).
232b0dadddSJohn Birrell# move-aout-libs      - Move the a.out libraries into an aout sub-directory
242b0dadddSJohn Birrell#                       of each elf library sub-directory.
253540f0e1SJordan K. Hubbard#
2611fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads
2711fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the
2811fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too
2911fb97daSJohn Birrell# much how different the installed mk files are from those in the source
3011fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use
3111fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT.
3211fb97daSJohn Birrell#
3311fb97daSJohn Birrell# The user-driven targets (as listed above) are implemented in Makefile.inc0
3411fb97daSJohn Birrell# and the private targets are in Makefile.inc1. These are kept separate
3511fb97daSJohn Birrell# to help the bootstrap build from aout to elf format.
3611fb97daSJohn Birrell#
3711fb97daSJohn Birrell# For novices wanting to build from current sources, the simple instructions
3811fb97daSJohn Birrell# are:
3911fb97daSJohn Birrell#
40cd486f4dSJohn Birrell# 1.  Ensure that your /usr/obj directory has at least 260 Mb of free space.
4111fb97daSJohn Birrell# 2.  `cd /usr/src'  (or to the directory containing your source tree).
4211fb97daSJohn Birrell# 3.  `make world'
4311fb97daSJohn Birrell#
4411fb97daSJohn Birrell# Be warned, this will update your installed system, except for configuration
45e74ce1d5STim Vanderhoek# files in the /etc directory and for the kernel. You have to do those manually.
4611fb97daSJohn Birrell#
4711fb97daSJohn Birrell# If at first you're a little nervous about having a `make world' update
4811fb97daSJohn Birrell# your system, a `make buildworld' will build everything in the /usr/obj
4911fb97daSJohn Birrell# tree without touching your installed system. To be of any further use
5011fb97daSJohn Birrell# though, a `make installworld' is required.
5111fb97daSJohn Birrell#
52990cbc64SDavid E. O'Brien# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
5341da0323SPeter Wemm# update the legacy support for aout. This includes all libraries, ld.so
5441da0323SPeter Wemm# and boot objects. This part of build should be regarded as
5511fb97daSJohn Birrell# deprecated and you should _not_ expect to be able to do this past the
561379f879SJohn Birrell# release of 4.0. You have exactly one major release to move entirely
5711fb97daSJohn Birrell# to elf.
5811fb97daSJohn Birrell#
5911fb97daSJohn Birrell# ----------------------------------------------------------------------------
6011fb97daSJohn Birrell#
6111fb97daSJohn Birrell#           Upgrading an i386 system from a.out to elf format
6211fb97daSJohn Birrell#
6311fb97daSJohn Birrell#
641c67f883SJordan K. Hubbard# The aout->elf transition build is performed by doing a `make upgrade' (or
651c67f883SJordan K. Hubbard# `make aout-to-elf') or in two steps by a `make aout-to-elf-build' followed
661c67f883SJordan K. Hubbard# by a `make aout-to-elf-install', depending on user preference.
6711fb97daSJohn Birrell# You need to have at least 320 Mb of free space for the object tree.
6811fb97daSJohn Birrell#
6911fb97daSJohn Birrell# The upgrade process checks the installed release. If this is 3.0-CURRENT,
7011fb97daSJohn Birrell# it is assumed that your kernel contains all the syscalls required by the
7111fb97daSJohn Birrell# current sources.
7211fb97daSJohn Birrell#
7311fb97daSJohn Birrell# The upgrade procedure will stop and ask for confirmation to proceed
7411fb97daSJohn Birrell# several times. On each occasion, you can type Ctrl-C to abort the
751c67f883SJordan K. Hubbard# upgrade.  Optionally, you can also start it with NOCONFIRM=yes and skip
761c67f883SJordan K. Hubbard# the confirmation steps.
7711fb97daSJohn Birrell#
7811fb97daSJohn Birrell# At the end of the upgrade procedure, /etc/objformat is created or
7911fb97daSJohn Birrell# updated to contain OBJFORMAT=elf. From then on, you're elf by default.
8011fb97daSJohn Birrell#
8111fb97daSJohn Birrell# ----------------------------------------------------------------------------
8211fb97daSJohn Birrell#
8311fb97daSJohn Birrell#
8411fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical
8511fb97daSJohn Birrell# order, but that's not important.
8611fb97daSJohn Birrell#
87549f978aSMarcel MoolenaarTGTS=	afterdistribute all buildkernel buildworld checkdpadd clean \
880a0743b5SMarcel Moolenaar	cleandepend cleandir depend distribute distribworld everything \
898fd61eafSJordan K. Hubbard	hierarchy includes install installkernel kernel reinstallkernel \
908fd61eafSJordan K. Hubbard	installmost installworld libraries lint maninstall mk most obj \
918fd61eafSJordan K. Hubbard	objlink regress rerelease tags update
926e59a256SMarcel Moolenaar
933e3a3133SMarcel MoolenaarPATH=	/sbin:/bin:/usr/sbin:/usr/bin
943e3a3133SMarcel MoolenaarMAKE=	PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
95a962de47SPeter Wemm
96a962de47SPeter Wemm#
9711fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files.
98f3c4dd0dSBruce Evans#
9911fb97daSJohn Birrell${TGTS}: upgrade_checks
10011fb97daSJohn Birrell	@cd ${.CURDIR}; \
1016e59a256SMarcel Moolenaar		${MAKE} ${.TARGET}
102c3d9b0f0SRodney W. Grimes
103ce53af53SJordan K. Hubbard# Set a reasonable default
104ce53af53SJordan K. Hubbard.MAIN:	all
105ce53af53SJordan K. Hubbard
106afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date
1076e59a256SMarcel Moolenaar#
1086e59a256SMarcel Moolenaar# world
1096e59a256SMarcel Moolenaar#
1106e59a256SMarcel Moolenaar# Attempt to rebuild and reinstall *everything*, with reasonable chance of
1116e59a256SMarcel Moolenaar# success, regardless of how old your existing system is.
1126e59a256SMarcel Moolenaar#
1136e59a256SMarcel Moolenaarworld: upgrade_checks
1146e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
11559084d0cSDavid E. O'Brien	@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
1166e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1176e59a256SMarcel Moolenaar.if target(pre-world)
1186e59a256SMarcel Moolenaar	@echo
1196e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1206e59a256SMarcel Moolenaar	@echo ">>> Making 'pre-world' target"
1216e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1226e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} pre-world
1236e59a256SMarcel Moolenaar.endif
1246e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} buildworld
1256e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} -B installworld
1266e59a256SMarcel Moolenaar.if target(post-world)
1276e59a256SMarcel Moolenaar	@echo
1286e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1296e59a256SMarcel Moolenaar	@echo ">>> Making 'post-world' target"
1306e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1316e59a256SMarcel Moolenaar	@cd ${.CURDIR}; ${MAKE} post-world
1326e59a256SMarcel Moolenaar.endif
1336e59a256SMarcel Moolenaar	@echo
1346e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
135afcf05e4SRuslan Ermilov	@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
1366e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
1376e59a256SMarcel Moolenaar
138cf94fb21SBruce Evans#
13911fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate
14011fb97daSJohn Birrell# for building the world. These are for older systems (prior to 2.2.5).
141cf94fb21SBruce Evans#
14211fb97daSJohn Birrell# From 2.2.5 onwards, the installed tools will pass these upgrade tests,
14311fb97daSJohn Birrell# so the normal make world is capable of doing what is required to update
14411fb97daSJohn Birrell# the system to current.
14511fb97daSJohn Birrell#
14611fb97daSJohn Birrellupgrade_checks:
147549f978aSMarcel Moolenaar	@cd ${.CURDIR}; \
148549f978aSMarcel Moolenaar		if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
149549f978aSMarcel Moolenaar			make make; \
150549f978aSMarcel Moolenaar		fi
151a42830afSAndrey A. Chernov
152a962de47SPeter Wemm#
15311fb97daSJohn Birrell# A simple test target used as part of the test to see if make supports
15411fb97daSJohn Birrell# the -m argument.
155a962de47SPeter Wemm#
15611fb97daSJohn Birrelltest:
1576a8d432dSMark Murray
158a962de47SPeter Wemm#
159549f978aSMarcel Moolenaar# Upgrade the installed make to the current version using the installed
160549f978aSMarcel Moolenaar# headers, libraries and build tools. This is required on installed versions
161549f978aSMarcel Moolenaar# prior to 2.2.5 in which the installed make doesn't support the -m argument.
162549f978aSMarcel Moolenaar#
163549f978aSMarcel Moolenaarmake:
164549f978aSMarcel Moolenaar	@echo
165549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
166549f978aSMarcel Moolenaar	@echo " Upgrading the installed make"
167549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
168549f978aSMarcel Moolenaar	@cd ${.CURDIR}/usr.bin/make; \
169549f978aSMarcel Moolenaar		make obj && make depend && make all && make install
170549f978aSMarcel Moolenaar
171549f978aSMarcel Moolenaar#
17211fb97daSJohn Birrell# Define the upgrade targets. These are listed here in alphabetical
17311fb97daSJohn Birrell# order, but that's not important.
174a962de47SPeter Wemm#
1752b0dadddSJohn BirrellUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
1762b0dadddSJohn Birrell		move-aout-libs
1772799473bSSatoshi Asami
1782799473bSSatoshi Asami#
17911fb97daSJohn Birrell# Handle the upgrade targets, using the source relative mk files.
1802799473bSSatoshi Asami#
1811c67f883SJordan K. Hubbard
1821c67f883SJordan K. Hubbardupgrade:	aout-to-elf
1831c67f883SJordan K. Hubbard
18411fb97daSJohn Birrell${UPGRADE} : upgrade_checks
18511fb97daSJohn Birrell	@cd ${.CURDIR}; \
1868bc83b23SMike Smith		${MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
187