Makefile revision 118531
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 118531 2003-08-06 11:06:38Z 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/}
7297252Sru
7395730Sru.ORDER: buildworld installworld
7495793Sru.ORDER: buildworld distributeworld
75111617Sru.ORDER: buildworld buildkernel
7695730Sru.ORDER: buildkernel installkernel
77116679Ssimokawa.ORDER: buildkernel installkernel.debug
7895730Sru.ORDER: buildkernel reinstallkernel
79116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
8095730Sru
81110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
82107516SruMAKEOBJDIRPREFIX?=	/usr/obj
83110035SruMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
84117234SruBINMAKE= \
85110035Sru	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
86117229Sru	-m ${.CURDIR}/share/mk
87117234Sru_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
8854324Smarcel
8917308Speter#
9038666Sjb# Handle the user-driven targets, using the source relative mk files.
9117308Speter#
9297252Sru${TGTS} ${BITGTS}: upgrade_checks
9338666Sjb	@cd ${.CURDIR}; \
94110035Sru		${_MAKE} ${.TARGET}
952302Spaul
9639206Sjkh# Set a reasonable default
9739206Sjkh.MAIN:	all
9839206Sjkh
9973349SruSTARTTIME!= LC_ALL=C date
10017308Speter#
10154324Smarcel# world
10254324Smarcel#
10354324Smarcel# Attempt to rebuild and reinstall *everything*, with reasonable chance of
10454324Smarcel# success, regardless of how old your existing system is.
10554324Smarcel#
10654324Smarcelworld: upgrade_checks
10754324Smarcel	@echo "--------------------------------------------------------------"
108118531Sru	@echo ">>> make world started on ${STARTTIME}"
10954324Smarcel	@echo "--------------------------------------------------------------"
11054324Smarcel.if target(pre-world)
11154324Smarcel	@echo
11254324Smarcel	@echo "--------------------------------------------------------------"
11354324Smarcel	@echo ">>> Making 'pre-world' target"
11454324Smarcel	@echo "--------------------------------------------------------------"
115110035Sru	@cd ${.CURDIR}; ${_MAKE} pre-world
11654324Smarcel.endif
117110035Sru	@cd ${.CURDIR}; ${_MAKE} buildworld
118110035Sru	@cd ${.CURDIR}; ${_MAKE} -B installworld
11954324Smarcel.if target(post-world)
12054324Smarcel	@echo
12154324Smarcel	@echo "--------------------------------------------------------------"
12254324Smarcel	@echo ">>> Making 'post-world' target"
12354324Smarcel	@echo "--------------------------------------------------------------"
124110035Sru	@cd ${.CURDIR}; ${_MAKE} post-world
12554324Smarcel.endif
12654324Smarcel	@echo
12754324Smarcel	@echo "--------------------------------------------------------------"
128118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
129118531Sru	@echo "                   (started ${STARTTIME})"
13054324Smarcel	@echo "--------------------------------------------------------------"
13154324Smarcel
13254324Smarcel#
13395730Sru# kernel
13495730Sru#
13595730Sru# Short hand for `make buildkernel installkernel'
13695730Sru#
13795730Srukernel: buildkernel installkernel
13895730Sru
13995730Sru#
14038666Sjb# Perform a few tests to determine if the installed tools are adequate
141107374Sru# for building the world.
14217308Speter#
14355678Smarcelupgrade_checks:
144110035Sru	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
145117793Sru	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
146110035Sru	then \
147110035Sru	    (cd ${.CURDIR} && make make); \
148110035Sru	fi
1492061Sjkh
15017308Speter#
151107516Sru# Upgrade make(1) to the current version using the installed
152107374Sru# headers, libraries and tools.
15355678Smarcel#
154107516SruMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
155107516Sru		DESTDIR= \
156107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
157107516SruMMAKE=		${MMAKEENV} make \
158107516Sru		-D_UPGRADING \
159107516Sru		-DNOMAN -DNOSHARED \
160107516Sru		-DNO_CPU_CFLAGS -DNO_WERROR
161107516Sru
16255678Smarcelmake:
16355678Smarcel	@echo
16455678Smarcel	@echo "--------------------------------------------------------------"
165116696Sru	@echo ">>> Building an up-to-date make(1)"
16655678Smarcel	@echo "--------------------------------------------------------------"
16755678Smarcel	@cd ${.CURDIR}/usr.bin/make; \
168107516Sru		${MMAKE} obj && \
169107516Sru		${MMAKE} depend && \
170107516Sru		${MMAKE} all && \
171107516Sru		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
17255678Smarcel
17355678Smarcel#
174111131Sru# universe
175111131Sru#
176111131Sru# Attempt to rebuild *everything* for all supported architectures,
177111131Sru# with reasonable chance of success, regardless of how old your
178111131Sru# existing system is.
179111131Sru#
180111131Srui386_mach=	pc98
181103985Sphkuniverse:
182103985Sphk	@echo "--------------------------------------------------------------"
183103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
184103985Sphk	@echo "--------------------------------------------------------------"
185111089Sphk.for arch in i386 sparc64 alpha ia64
186111131Sru.for mach in ${arch} ${${arch}_mach}
187111131Sru	@echo ">> ${mach} started on `LC_ALL=C date`"
188111131Sru	-cd ${.CURDIR} && ${MAKE} buildworld \
189111131Sru	    TARGET_ARCH=${arch} TARGET=${mach} \
190111131Sru	    __MAKE_CONF=/dev/null \
191111131Sru	    > _.${mach}.buildworld 2>&1
192111131Sru	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
193111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
194111131Sru	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
195111133Sru	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
196103985Sphk.endif
197111131Sru	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
198111131Sru	@echo ">> ${mach} completed on `LC_ALL=C date`"
199103985Sphk.endfor
200111131Sru.endfor
201103985Sphk	@echo "--------------------------------------------------------------"
202118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
203118531Sru	@echo "                      (started ${STARTTIME})"
204103985Sphk	@echo "--------------------------------------------------------------"
205103985Sphk
206111131SruKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
207111131Sru		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
208103985Sphk
209103985Sphkbuildkernels:
210111131Sru.for kernel in ${KERNCONFS}
211111131Sru	-cd ${.CURDIR} && ${MAKE} buildkernel \
212111131Sru	    KERNCONF=${kernel} \
213111131Sru	    __MAKE_CONF=/dev/null \
214111131Sru	    > _.${TARGET}.${kernel} 2>&1
215103985Sphk.endfor
216