Makefile revision 111131
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 111131 2003-02-19 15:40:19Z ru $
32061Sjkh#
438666Sjb# The user-driven targets are:
532427Sjb#
6111131Sru# universe            - *Really* build *everything* (buildworld and
7111131Sru#                       all kernels on all architectures).
838666Sjb# buildworld          - Rebuild *everything*, including glue to help do
938666Sjb#                       upgrades.
1038666Sjb# installworld        - Install everything built by "buildworld".
1138666Sjb# world               - buildworld + installworld.
1264049Salex# buildkernel         - Rebuild the kernel and the kernel-modules.
1364049Salex# installkernel       - Install the kernel and the kernel-modules.
1466071Smarkm# reinstallkernel     - Reinstall the kernel and the kernel-modules.
1573504Sobrien# kernel              - buildkernel + installkernel.
1638666Sjb# update              - Convenient way to update your source tree (cvs).
1744918Sjkh# upgrade             - Upgrade a.out (2.2.x/3.0) system to the new ELF way
1838666Sjb# most                - Build user commands, no libraries or include files.
1938666Sjb# installmost         - Install user commands, no libraries or include files.
20108451Sschweikh# aout-to-elf         - Upgrade a system from a.out to elf format (see below).
2138666Sjb# aout-to-elf-build   - Build everything required to upgrade a system from
2238666Sjb#                       a.out to elf format (see below).
2338666Sjb# aout-to-elf-install - Install everything built by aout-to-elf-build (see
2438666Sjb#                       below).
2538978Sjb# move-aout-libs      - Move the a.out libraries into an aout sub-directory
2638978Sjb#                       of each elf library sub-directory.
2732427Sjb#
2838666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
29108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
3038666Sjb# command line. By keeping this makefile simple, it doesn't matter too
3138666Sjb# much how different the installed mk files are from those in the source
3238666Sjb# tree. This makefile executes a child make process, forcing it to use
3338666Sjb# the mk files from the source tree which are supposed to DTRT.
3417308Speter#
3591606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3619175Sbde#
3796205Sjwd# If you want to build your system from source be sure that /usr/obj has
3896205Sjwd# at least 400MB of diskspace available.
3938042Sbde#
4096205Sjwd# For individuals wanting to build from the sources currently on their
4196205Sjwd# system, the simple instructions are:
4238042Sbde#
4396205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
4496205Sjwd# 2.  `make world'
4517308Speter#
4696205Sjwd# For individuals wanting to upgrade their sources (even if only a
4796205Sjwd# delta of a few days):
4817308Speter#
4996205Sjwd# 1.  `cd /usr/src'       (or to the directory containing your source tree).
5096205Sjwd# 2.  `make buildworld'
5196205Sjwd# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
5296205Sjwd# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
5396205Sjwd# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
5496205Sjwd# 6.  `mergemaster -p'
5596205Sjwd# 7.  `make installworld'
5696205Sjwd# 8.  `mergemaster'
5796205Sjwd# 9.  `reboot'
5896205Sjwd#
5996205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
6096205Sjwd#
6198775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
6298723Sdillon# cross build world for other architectures using the buildworld target,
6398723Sdillon# and once the world is built you can cross build a kernel using the
6498723Sdillon# buildkernel target.
6598723Sdillon#
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.
74108451Sschweikh# 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# ----------------------------------------------------------------------------
8627910Sasami#
8717308Speter#
8838666Sjb# Define the user-driven targets. These are listed here in alphabetical
8938666Sjb# order, but that's not important.
9017308Speter#
9195509SruTGTS=	all all-man buildkernel buildworld checkdpadd clean \
9295793Sru	cleandepend cleandir depend distribute distributeworld everything \
9397252Sru	hierarchy install installcheck installkernel \
9496164Sru	reinstallkernel installmost installworld libraries lint maninstall \
9595146Sgshapiro	mk most obj objlink regress rerelease tags update
962061Sjkh
9797769SruBITGTS=	files includes
9897252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
9997252Sru
10095730Sru.ORDER: buildworld installworld
10195793Sru.ORDER: buildworld distributeworld
10295730Sru.ORDER: buildkernel installkernel
10395730Sru.ORDER: buildkernel reinstallkernel
10495730Sru
105110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
106107516SruMAKEOBJDIRPREFIX?=	/usr/obj
107110035SruMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
108110035Sru_MAKE=	PATH=${PATH} \
109110035Sru	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
110110035Sru	-m ${.CURDIR}/share/mk -f Makefile.inc1
11154324Smarcel
11217308Speter#
11338666Sjb# Handle the user-driven targets, using the source relative mk files.
11417308Speter#
11597252Sru${TGTS} ${BITGTS}: upgrade_checks
11638666Sjb	@cd ${.CURDIR}; \
117110035Sru		${_MAKE} ${.TARGET}
1182302Spaul
11939206Sjkh# Set a reasonable default
12039206Sjkh.MAIN:	all
12139206Sjkh
12273349SruSTARTTIME!= LC_ALL=C date
12317308Speter#
12454324Smarcel# world
12554324Smarcel#
12654324Smarcel# Attempt to rebuild and reinstall *everything*, with reasonable chance of
12754324Smarcel# success, regardless of how old your existing system is.
12854324Smarcel#
12954324Smarcelworld: upgrade_checks
13054324Smarcel	@echo "--------------------------------------------------------------"
131103436Speter	@echo ">>> elf make world started on ${STARTTIME}"
13254324Smarcel	@echo "--------------------------------------------------------------"
13354324Smarcel.if target(pre-world)
13454324Smarcel	@echo
13554324Smarcel	@echo "--------------------------------------------------------------"
13654324Smarcel	@echo ">>> Making 'pre-world' target"
13754324Smarcel	@echo "--------------------------------------------------------------"
138110035Sru	@cd ${.CURDIR}; ${_MAKE} pre-world
13954324Smarcel.endif
140110035Sru	@cd ${.CURDIR}; ${_MAKE} buildworld
141110035Sru	@cd ${.CURDIR}; ${_MAKE} -B installworld
14254324Smarcel.if target(post-world)
14354324Smarcel	@echo
14454324Smarcel	@echo "--------------------------------------------------------------"
14554324Smarcel	@echo ">>> Making 'post-world' target"
14654324Smarcel	@echo "--------------------------------------------------------------"
147110035Sru	@cd ${.CURDIR}; ${_MAKE} post-world
14854324Smarcel.endif
14954324Smarcel	@echo
15054324Smarcel	@echo "--------------------------------------------------------------"
151103436Speter	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
15254324Smarcel	@echo "--------------------------------------------------------------"
15354324Smarcel
15454324Smarcel#
15595730Sru# kernel
15695730Sru#
15795730Sru# Short hand for `make buildkernel installkernel'
15895730Sru#
15995730Srukernel: buildkernel installkernel
16095730Sru
16195730Sru#
16238666Sjb# Perform a few tests to determine if the installed tools are adequate
163107374Sru# for building the world.
16417308Speter#
16555678Smarcelupgrade_checks:
166110035Sru	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
167110035Sru	    PATH=${PATH} ${MAKE} 2>/dev/null); \
168110035Sru	then \
169110035Sru	    (cd ${.CURDIR} && make make); \
170110035Sru	fi
1712061Sjkh
17217308Speter#
173107516Sru# Upgrade make(1) to the current version using the installed
174107374Sru# headers, libraries and tools.
17555678Smarcel#
176107516SruMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
177107516Sru		DESTDIR= \
178107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
179107516SruMMAKE=		${MMAKEENV} make \
180107516Sru		-D_UPGRADING \
181107516Sru		-DNOMAN -DNOSHARED \
182107516Sru		-DNO_CPU_CFLAGS -DNO_WERROR
183107516Sru
18455678Smarcelmake:
18555678Smarcel	@echo
18655678Smarcel	@echo "--------------------------------------------------------------"
187107556Sbmah	@echo " Building an up-to-date make(1)"
18855678Smarcel	@echo "--------------------------------------------------------------"
18955678Smarcel	@cd ${.CURDIR}/usr.bin/make; \
190107516Sru		${MMAKE} obj && \
191107516Sru		${MMAKE} depend && \
192107516Sru		${MMAKE} all && \
193107516Sru		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
19455678Smarcel
19555678Smarcel#
19638666Sjb# Define the upgrade targets. These are listed here in alphabetical
19738666Sjb# order, but that's not important.
19817308Speter#
19955678SmarcelUPGRADE=	aout-to-elf aout-to-elf-build aout-to-elf-install \
20038978Sjb		move-aout-libs
2013626Swollman
20217308Speter#
20338666Sjb# Handle the upgrade targets, using the source relative mk files.
20417308Speter#
20543226Sjkh
20643226Sjkhupgrade:	aout-to-elf
20743226Sjkh
20838666Sjb${UPGRADE} : upgrade_checks
20938666Sjb	@cd ${.CURDIR}; \
210110035Sru		${_MAKE} -f Makefile.upgrade -m ${.CURDIR}/share/mk ${.TARGET}
211103985Sphk
212111131Sru#
213111131Sru# universe
214111131Sru#
215111131Sru# Attempt to rebuild *everything* for all supported architectures,
216111131Sru# with reasonable chance of success, regardless of how old your
217111131Sru# existing system is.
218111131Sru#
219111131Srui386_mach=	pc98
220103985Sphkuniverse:
221103985Sphk	@echo "--------------------------------------------------------------"
222103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
223103985Sphk	@echo "--------------------------------------------------------------"
224111089Sphk.for arch in i386 sparc64 alpha ia64
225111131Sru.for mach in ${arch} ${${arch}_mach}
226111131Sru	@echo ">> ${mach} started on `LC_ALL=C date`"
227111131Sru	-cd ${.CURDIR} && ${MAKE} buildworld \
228111131Sru	    TARGET_ARCH=${arch} TARGET=${mach} \
229111131Sru	    __MAKE_CONF=/dev/null \
230111131Sru	    > _.${mach}.buildworld 2>&1
231111131Sru	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
232111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
233111131Sru	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
234111131Sru	    > _.${mach}.makeLINT 2>&1
235103985Sphk.endif
236111131Sru	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
237111131Sru	@echo ">> ${mach} completed on `LC_ALL=C date`"
238103985Sphk.endfor
239111131Sru.endfor
240103985Sphk	@echo "--------------------------------------------------------------"
241107884Simp	@printf ">>> make universe completed on `LC_ALL=C date`\n                      (started ${STARTTIME})\n"
242103985Sphk	@echo "--------------------------------------------------------------"
243103985Sphk
244111131SruKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
245111131Sru		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
246103985Sphk
247103985Sphkbuildkernels:
248111131Sru.for kernel in ${KERNCONFS}
249111131Sru	-cd ${.CURDIR} && ${MAKE} buildkernel \
250111131Sru	    KERNCONF=${kernel} \
251111131Sru	    __MAKE_CONF=/dev/null \
252111131Sru	    > _.${TARGET}.${kernel} 2>&1
253103985Sphk.endfor
254