Makefile revision 114555
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 113000 2003-04-03 05:34:36Z imp $
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).
1738666Sjb# most                - Build user commands, no libraries or include files.
1838666Sjb# installmost         - Install user commands, no libraries or include files.
1932427Sjb#
2038666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
21108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
2238666Sjb# command line. By keeping this makefile simple, it doesn't matter too
2338666Sjb# much how different the installed mk files are from those in the source
2438666Sjb# tree. This makefile executes a child make process, forcing it to use
2538666Sjb# the mk files from the source tree which are supposed to DTRT.
2617308Speter#
2791606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1.
2819175Sbde#
2996205Sjwd# If you want to build your system from source be sure that /usr/obj has
3096205Sjwd# at least 400MB of diskspace available.
3138042Sbde#
3296205Sjwd# For individuals wanting to build from the sources currently on their
3396205Sjwd# system, the simple instructions are:
3438042Sbde#
3596205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
3696205Sjwd# 2.  `make world'
3717308Speter#
3896205Sjwd# For individuals wanting to upgrade their sources (even if only a
3996205Sjwd# delta of a few days):
4017308Speter#
4196205Sjwd# 1.  `cd /usr/src'       (or to the directory containing your source tree).
4296205Sjwd# 2.  `make buildworld'
4396205Sjwd# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
4496205Sjwd# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
4596205Sjwd# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
4696205Sjwd# 6.  `mergemaster -p'
4796205Sjwd# 7.  `make installworld'
4896205Sjwd# 8.  `mergemaster'
4996205Sjwd# 9.  `reboot'
5096205Sjwd#
5196205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
5296205Sjwd#
5398775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
5498723Sdillon# cross build world for other architectures using the buildworld target,
5598723Sdillon# and once the world is built you can cross build a kernel using the
5698723Sdillon# buildkernel target.
5798723Sdillon#
5838666Sjb# Define the user-driven targets. These are listed here in alphabetical
5938666Sjb# order, but that's not important.
6017308Speter#
6195509SruTGTS=	all all-man buildkernel buildworld checkdpadd clean \
6295793Sru	cleandepend cleandir depend distribute distributeworld everything \
6397252Sru	hierarchy install installcheck installkernel \
6496164Sru	reinstallkernel installmost installworld libraries lint maninstall \
6595146Sgshapiro	mk most obj objlink regress rerelease tags update
662061Sjkh
6797769SruBITGTS=	files includes
6897252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
6997252Sru
7095730Sru.ORDER: buildworld installworld
7195793Sru.ORDER: buildworld distributeworld
72111617Sru.ORDER: buildworld buildkernel
7395730Sru.ORDER: buildkernel installkernel
7495730Sru.ORDER: buildkernel reinstallkernel
7595730Sru
76110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
77107516SruMAKEOBJDIRPREFIX?=	/usr/obj
78110035SruMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
79110035Sru_MAKE=	PATH=${PATH} \
80110035Sru	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
81110035Sru	-m ${.CURDIR}/share/mk -f Makefile.inc1
8254324Smarcel
8317308Speter#
8438666Sjb# Handle the user-driven targets, using the source relative mk files.
8517308Speter#
8697252Sru${TGTS} ${BITGTS}: upgrade_checks
8738666Sjb	@cd ${.CURDIR}; \
88110035Sru		${_MAKE} ${.TARGET}
892302Spaul
9039206Sjkh# Set a reasonable default
9139206Sjkh.MAIN:	all
9239206Sjkh
9373349SruSTARTTIME!= LC_ALL=C date
9417308Speter#
9554324Smarcel# world
9654324Smarcel#
9754324Smarcel# Attempt to rebuild and reinstall *everything*, with reasonable chance of
9854324Smarcel# success, regardless of how old your existing system is.
9954324Smarcel#
10054324Smarcelworld: upgrade_checks
10154324Smarcel	@echo "--------------------------------------------------------------"
102103436Speter	@echo ">>> elf make world started on ${STARTTIME}"
10354324Smarcel	@echo "--------------------------------------------------------------"
10454324Smarcel.if target(pre-world)
10554324Smarcel	@echo
10654324Smarcel	@echo "--------------------------------------------------------------"
10754324Smarcel	@echo ">>> Making 'pre-world' target"
10854324Smarcel	@echo "--------------------------------------------------------------"
109110035Sru	@cd ${.CURDIR}; ${_MAKE} pre-world
11054324Smarcel.endif
111110035Sru	@cd ${.CURDIR}; ${_MAKE} buildworld
112110035Sru	@cd ${.CURDIR}; ${_MAKE} -B installworld
11354324Smarcel.if target(post-world)
11454324Smarcel	@echo
11554324Smarcel	@echo "--------------------------------------------------------------"
11654324Smarcel	@echo ">>> Making 'post-world' target"
11754324Smarcel	@echo "--------------------------------------------------------------"
118110035Sru	@cd ${.CURDIR}; ${_MAKE} post-world
11954324Smarcel.endif
12054324Smarcel	@echo
12154324Smarcel	@echo "--------------------------------------------------------------"
122103436Speter	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
12354324Smarcel	@echo "--------------------------------------------------------------"
12454324Smarcel
12554324Smarcel#
12695730Sru# kernel
12795730Sru#
12895730Sru# Short hand for `make buildkernel installkernel'
12995730Sru#
13095730Srukernel: buildkernel installkernel
13195730Sru
13295730Sru#
13338666Sjb# Perform a few tests to determine if the installed tools are adequate
134107374Sru# for building the world.
13517308Speter#
13655678Smarcelupgrade_checks:
137110035Sru	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
138110035Sru	    PATH=${PATH} ${MAKE} 2>/dev/null); \
139110035Sru	then \
140110035Sru	    (cd ${.CURDIR} && make make); \
141110035Sru	fi
1422061Sjkh
14317308Speter#
144107516Sru# Upgrade make(1) to the current version using the installed
145107374Sru# headers, libraries and tools.
14655678Smarcel#
147107516SruMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
148107516Sru		DESTDIR= \
149107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
150107516SruMMAKE=		${MMAKEENV} make \
151107516Sru		-D_UPGRADING \
152107516Sru		-DNOMAN -DNOSHARED \
153107516Sru		-DNO_CPU_CFLAGS -DNO_WERROR
154107516Sru
15555678Smarcelmake:
15655678Smarcel	@echo
15755678Smarcel	@echo "--------------------------------------------------------------"
158107556Sbmah	@echo " Building an up-to-date make(1)"
15955678Smarcel	@echo "--------------------------------------------------------------"
16055678Smarcel	@cd ${.CURDIR}/usr.bin/make; \
161107516Sru		${MMAKE} obj && \
162107516Sru		${MMAKE} depend && \
163107516Sru		${MMAKE} all && \
164107516Sru		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
16555678Smarcel
16655678Smarcel#
167111131Sru# universe
168111131Sru#
169111131Sru# Attempt to rebuild *everything* for all supported architectures,
170111131Sru# with reasonable chance of success, regardless of how old your
171111131Sru# existing system is.
172111131Sru#
173111131Srui386_mach=	pc98
174103985Sphkuniverse:
175103985Sphk	@echo "--------------------------------------------------------------"
176103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
177103985Sphk	@echo "--------------------------------------------------------------"
178111089Sphk.for arch in i386 sparc64 alpha ia64
179111131Sru.for mach in ${arch} ${${arch}_mach}
180111131Sru	@echo ">> ${mach} started on `LC_ALL=C date`"
181111131Sru	-cd ${.CURDIR} && ${MAKE} buildworld \
182111131Sru	    TARGET_ARCH=${arch} TARGET=${mach} \
183111131Sru	    __MAKE_CONF=/dev/null \
184111131Sru	    > _.${mach}.buildworld 2>&1
185111131Sru	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
186111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
187111131Sru	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
188111133Sru	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
189103985Sphk.endif
190111131Sru	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
191111131Sru	@echo ">> ${mach} completed on `LC_ALL=C date`"
192103985Sphk.endfor
193111131Sru.endfor
194103985Sphk	@echo "--------------------------------------------------------------"
195107884Simp	@printf ">>> make universe completed on `LC_ALL=C date`\n                      (started ${STARTTIME})\n"
196103985Sphk	@echo "--------------------------------------------------------------"
197103985Sphk
198111131SruKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
199111131Sru		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
200103985Sphk
201103985Sphkbuildkernels:
202111131Sru.for kernel in ${KERNCONFS}
203111131Sru	-cd ${.CURDIR} && ${MAKE} buildkernel \
204111131Sru	    KERNCONF=${kernel} \
205111131Sru	    __MAKE_CONF=/dev/null \
206111131Sru	    > _.${TARGET}.${kernel} 2>&1
207103985Sphk.endfor
208