Makefile revision 119579
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 119579 2003-08-30 13:33:41Z 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.
14116679Ssimokawa# installkernel.debug
1566071Smarkm# reinstallkernel     - Reinstall the kernel and the kernel-modules.
16116679Ssimokawa# reinstallkernel.debug
1773504Sobrien# kernel              - buildkernel + installkernel.
1838666Sjb# update              - Convenient way to update your source tree (cvs).
1938666Sjb# most                - Build user commands, no libraries or include files.
2038666Sjb# installmost         - Install user commands, no libraries or include files.
2132427Sjb#
2238666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
23108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
2438666Sjb# command line. By keeping this makefile simple, it doesn't matter too
2538666Sjb# much how different the installed mk files are from those in the source
2638666Sjb# tree. This makefile executes a child make process, forcing it to use
2738666Sjb# the mk files from the source tree which are supposed to DTRT.
2817308Speter#
2991606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3019175Sbde#
3196205Sjwd# If you want to build your system from source be sure that /usr/obj has
3296205Sjwd# at least 400MB of diskspace available.
3338042Sbde#
3496205Sjwd# For individuals wanting to build from the sources currently on their
3596205Sjwd# system, the simple instructions are:
3638042Sbde#
3796205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
3896205Sjwd# 2.  `make world'
3917308Speter#
4096205Sjwd# For individuals wanting to upgrade their sources (even if only a
4196205Sjwd# delta of a few days):
4217308Speter#
4396205Sjwd# 1.  `cd /usr/src'       (or to the directory containing your source tree).
4496205Sjwd# 2.  `make buildworld'
4596205Sjwd# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
4696205Sjwd# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
4796205Sjwd# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
4896205Sjwd# 6.  `mergemaster -p'
4996205Sjwd# 7.  `make installworld'
5096205Sjwd# 8.  `mergemaster'
5196205Sjwd# 9.  `reboot'
5296205Sjwd#
5396205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
5496205Sjwd#
5598775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
5698723Sdillon# cross build world for other architectures using the buildworld target,
5798723Sdillon# and once the world is built you can cross build a kernel using the
5898723Sdillon# buildkernel target.
5998723Sdillon#
6038666Sjb# Define the user-driven targets. These are listed here in alphabetical
6138666Sjb# order, but that's not important.
6217308Speter#
6395509SruTGTS=	all all-man buildkernel buildworld checkdpadd clean \
6495793Sru	cleandepend cleandir depend distribute distributeworld everything \
65116679Ssimokawa	hierarchy install installcheck installkernel installkernel.debug\
66116679Ssimokawa	reinstallkernel reinstallkernel.debug installmost installworld \
67116679Ssimokawa	libraries lint maninstall \
68117806Sru	most obj objlink regress rerelease tags update
692061Sjkh
7097769SruBITGTS=	files includes
7197252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
72119579SruTGTS+=	${BITGTS}
7397252Sru
7495730Sru.ORDER: buildworld installworld
7595793Sru.ORDER: buildworld distributeworld
76111617Sru.ORDER: buildworld buildkernel
7795730Sru.ORDER: buildkernel installkernel
78116679Ssimokawa.ORDER: buildkernel installkernel.debug
7995730Sru.ORDER: buildkernel reinstallkernel
80116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
8195730Sru
82110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
83107516SruMAKEOBJDIRPREFIX?=	/usr/obj
84110035SruMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
85117234SruBINMAKE= \
86110035Sru	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
87117229Sru	-m ${.CURDIR}/share/mk
88117234Sru_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
8954324Smarcel
9017308Speter#
91119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
92119519Smarcel# should do this as those are the initial targets used for upgrades.
93119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
94119519Smarcel# for all targets.
95119519Smarcel#
96119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
97119579Sru${TGTS}: upgrade_checks
98119519Smarcel.else
99119519Smarcelbuildworld: upgrade_checks
100119519Smarcel.endif
101119519Smarcel
102119519Smarcel#
10338666Sjb# Handle the user-driven targets, using the source relative mk files.
10417308Speter#
105119519Smarcel
106119579Sru${TGTS}:
10738666Sjb	@cd ${.CURDIR}; \
108110035Sru		${_MAKE} ${.TARGET}
1092302Spaul
11039206Sjkh# Set a reasonable default
11139206Sjkh.MAIN:	all
11239206Sjkh
11373349SruSTARTTIME!= LC_ALL=C date
11417308Speter#
11554324Smarcel# world
11654324Smarcel#
11754324Smarcel# Attempt to rebuild and reinstall *everything*, with reasonable chance of
11854324Smarcel# success, regardless of how old your existing system is.
11954324Smarcel#
12054324Smarcelworld: upgrade_checks
12154324Smarcel	@echo "--------------------------------------------------------------"
122118531Sru	@echo ">>> make world started on ${STARTTIME}"
12354324Smarcel	@echo "--------------------------------------------------------------"
12454324Smarcel.if target(pre-world)
12554324Smarcel	@echo
12654324Smarcel	@echo "--------------------------------------------------------------"
12754324Smarcel	@echo ">>> Making 'pre-world' target"
12854324Smarcel	@echo "--------------------------------------------------------------"
129110035Sru	@cd ${.CURDIR}; ${_MAKE} pre-world
13054324Smarcel.endif
131110035Sru	@cd ${.CURDIR}; ${_MAKE} buildworld
132110035Sru	@cd ${.CURDIR}; ${_MAKE} -B installworld
13354324Smarcel.if target(post-world)
13454324Smarcel	@echo
13554324Smarcel	@echo "--------------------------------------------------------------"
13654324Smarcel	@echo ">>> Making 'post-world' target"
13754324Smarcel	@echo "--------------------------------------------------------------"
138110035Sru	@cd ${.CURDIR}; ${_MAKE} post-world
13954324Smarcel.endif
14054324Smarcel	@echo
14154324Smarcel	@echo "--------------------------------------------------------------"
142118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
143118531Sru	@echo "                   (started ${STARTTIME})"
14454324Smarcel	@echo "--------------------------------------------------------------"
14554324Smarcel
14654324Smarcel#
14795730Sru# kernel
14895730Sru#
14995730Sru# Short hand for `make buildkernel installkernel'
15095730Sru#
15195730Srukernel: buildkernel installkernel
15295730Sru
15395730Sru#
15438666Sjb# Perform a few tests to determine if the installed tools are adequate
155107374Sru# for building the world.
15617308Speter#
15755678Smarcelupgrade_checks:
158110035Sru	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
159117793Sru	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
160110035Sru	then \
161110035Sru	    (cd ${.CURDIR} && make make); \
162110035Sru	fi
1632061Sjkh
16417308Speter#
165107516Sru# Upgrade make(1) to the current version using the installed
166107374Sru# headers, libraries and tools.
16755678Smarcel#
168107516SruMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
169107516Sru		DESTDIR= \
170107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
171107516SruMMAKE=		${MMAKEENV} make \
172107516Sru		-D_UPGRADING \
173107516Sru		-DNOMAN -DNOSHARED \
174107516Sru		-DNO_CPU_CFLAGS -DNO_WERROR
175107516Sru
17655678Smarcelmake:
17755678Smarcel	@echo
17855678Smarcel	@echo "--------------------------------------------------------------"
179116696Sru	@echo ">>> Building an up-to-date make(1)"
18055678Smarcel	@echo "--------------------------------------------------------------"
18155678Smarcel	@cd ${.CURDIR}/usr.bin/make; \
182107516Sru		${MMAKE} obj && \
183107516Sru		${MMAKE} depend && \
184107516Sru		${MMAKE} all && \
185107516Sru		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
18655678Smarcel
18755678Smarcel#
188111131Sru# universe
189111131Sru#
190111131Sru# Attempt to rebuild *everything* for all supported architectures,
191111131Sru# with reasonable chance of success, regardless of how old your
192111131Sru# existing system is.
193111131Sru#
194111131Srui386_mach=	pc98
195103985Sphkuniverse:
196103985Sphk	@echo "--------------------------------------------------------------"
197103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
198103985Sphk	@echo "--------------------------------------------------------------"
199111089Sphk.for arch in i386 sparc64 alpha ia64
200111131Sru.for mach in ${arch} ${${arch}_mach}
201111131Sru	@echo ">> ${mach} started on `LC_ALL=C date`"
202111131Sru	-cd ${.CURDIR} && ${MAKE} buildworld \
203111131Sru	    TARGET_ARCH=${arch} TARGET=${mach} \
204111131Sru	    __MAKE_CONF=/dev/null \
205111131Sru	    > _.${mach}.buildworld 2>&1
206111131Sru	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
207111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
208111131Sru	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
209111133Sru	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
210103985Sphk.endif
211111131Sru	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
212111131Sru	@echo ">> ${mach} completed on `LC_ALL=C date`"
213103985Sphk.endfor
214111131Sru.endfor
215103985Sphk	@echo "--------------------------------------------------------------"
216118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
217118531Sru	@echo "                      (started ${STARTTIME})"
218103985Sphk	@echo "--------------------------------------------------------------"
219103985Sphk
220111131SruKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
221111131Sru		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
222103985Sphk
223103985Sphkbuildkernels:
224111131Sru.for kernel in ${KERNCONFS}
225111131Sru	-cd ${.CURDIR} && ${MAKE} buildkernel \
226111131Sru	    KERNCONF=${kernel} \
227111131Sru	    __MAKE_CONF=/dev/null \
228111131Sru	    > _.${TARGET}.${kernel} 2>&1
229103985Sphk.endfor
230