Makefile revision 118531
1199080Sume#
2199080Sume# $FreeBSD: head/Makefile 118531 2003-08-06 11:06:38Z ru $
3199082Sume#
4199080Sume# The user-driven targets are:
5199080Sume#
6199080Sume# universe            - *Really* build *everything* (buildworld and
7199080Sume#                       all kernels on all architectures).
8199080Sume# buildworld          - Rebuild *everything*, including glue to help do
9199080Sume#                       upgrades.
10199080Sume# installworld        - Install everything built by "buildworld".
11199080Sume# world               - buildworld + installworld.
12199080Sume# buildkernel         - Rebuild the kernel and the kernel-modules.
13199080Sume# installkernel       - Install the kernel and the kernel-modules.
14199080Sume# installkernel.debug
15199080Sume# reinstallkernel     - Reinstall the kernel and the kernel-modules.
16199080Sume# reinstallkernel.debug
17199080Sume# kernel              - buildkernel + installkernel.
18199080Sume# update              - Convenient way to update your source tree (cvs).
19199080Sume# most                - Build user commands, no libraries or include files.
20199080Sume# installmost         - Install user commands, no libraries or include files.
21199080Sume#
22199080Sume# This makefile is simple by design. The FreeBSD make automatically reads
23199080Sume# the /usr/share/mk/sys.mk unless the -m argument is specified on the
24199080Sume# command line. By keeping this makefile simple, it doesn't matter too
25199080Sume# much how different the installed mk files are from those in the source
26199080Sume# tree. This makefile executes a child make process, forcing it to use
27199080Sume# the mk files from the source tree which are supposed to DTRT.
28199080Sume#
29199080Sume# The user-driven targets (as listed above) are implemented in Makefile.inc1.
30199080Sume#
31199080Sume# If you want to build your system from source be sure that /usr/obj has
32199080Sume# at least 400MB of diskspace available.
33199080Sume#
34199080Sume# For individuals wanting to build from the sources currently on their
35199080Sume# system, the simple instructions are:
36199080Sume#
37199080Sume# 1.  `cd /usr/src'  (or to the directory containing your source tree).
38199080Sume# 2.  `make world'
39199080Sume#
40199080Sume# For individuals wanting to upgrade their sources (even if only a
41199080Sume# delta of a few days):
42199080Sume#
43199080Sume# 1.  `cd /usr/src'       (or to the directory containing your source tree).
44199080Sume# 2.  `make buildworld'
45199080Sume# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
46199080Sume# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
47199080Sume# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
48199080Sume# 6.  `mergemaster -p'
49199080Sume# 7.  `make installworld'
50199080Sume# 8.  `mergemaster'
51199080Sume# 9.  `reboot'
52199080Sume#
53199080Sume# See src/UPDATING `COMMON ITEMS' for more complete information.
54199080Sume#
55199080Sume# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
56199080Sume# cross build world for other architectures using the buildworld target,
57199080Sume# and once the world is built you can cross build a kernel using the
58199080Sume# buildkernel target.
59199080Sume#
60199080Sume# Define the user-driven targets. These are listed here in alphabetical
61199080Sume# order, but that's not important.
62199080Sume#
63199080SumeTGTS=	all all-man buildkernel buildworld checkdpadd clean \
64199080Sume	cleandepend cleandir depend distribute distributeworld everything \
65199080Sume	hierarchy install installcheck installkernel installkernel.debug\
66199080Sume	reinstallkernel reinstallkernel.debug installmost installworld \
67199080Sume	libraries lint maninstall \
68199080Sume	most obj objlink regress rerelease tags update
69199080Sume
70199080SumeBITGTS=	files includes
71199080SumeBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
72199080Sume
73199080Sume.ORDER: buildworld installworld
74199080Sume.ORDER: buildworld distributeworld
75199080Sume.ORDER: buildworld buildkernel
76199080Sume.ORDER: buildkernel installkernel
77199080Sume.ORDER: buildkernel installkernel.debug
78199080Sume.ORDER: buildkernel reinstallkernel
79199080Sume.ORDER: buildkernel reinstallkernel.debug
80199080Sume
81199080SumePATH=	/sbin:/bin:/usr/sbin:/usr/bin
82199080SumeMAKEOBJDIRPREFIX?=	/usr/obj
83199080SumeMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
84199080SumeBINMAKE= \
85199080Sume	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
86199080Sume	-m ${.CURDIR}/share/mk
87199080Sume_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
88199080Sume
89199080Sume#
90199080Sume# Handle the user-driven targets, using the source relative mk files.
91199080Sume#
92199080Sume${TGTS} ${BITGTS}: upgrade_checks
93199080Sume	@cd ${.CURDIR}; \
94199080Sume		${_MAKE} ${.TARGET}
95199080Sume
96199080Sume# Set a reasonable default
97199080Sume.MAIN:	all
98199080Sume
99199080SumeSTARTTIME!= LC_ALL=C date
100199080Sume#
101199080Sume# world
102199080Sume#
103199080Sume# Attempt to rebuild and reinstall *everything*, with reasonable chance of
104199080Sume# success, regardless of how old your existing system is.
105199080Sume#
106199080Sumeworld: upgrade_checks
107199080Sume	@echo "--------------------------------------------------------------"
108199080Sume	@echo ">>> make world started on ${STARTTIME}"
109199080Sume	@echo "--------------------------------------------------------------"
110199080Sume.if target(pre-world)
111199080Sume	@echo
112199080Sume	@echo "--------------------------------------------------------------"
113199080Sume	@echo ">>> Making 'pre-world' target"
114199080Sume	@echo "--------------------------------------------------------------"
115199080Sume	@cd ${.CURDIR}; ${_MAKE} pre-world
116199080Sume.endif
117199080Sume	@cd ${.CURDIR}; ${_MAKE} buildworld
118199080Sume	@cd ${.CURDIR}; ${_MAKE} -B installworld
119199080Sume.if target(post-world)
120199080Sume	@echo
121199080Sume	@echo "--------------------------------------------------------------"
122199080Sume	@echo ">>> Making 'post-world' target"
123199080Sume	@echo "--------------------------------------------------------------"
124199080Sume	@cd ${.CURDIR}; ${_MAKE} post-world
125199080Sume.endif
126199080Sume	@echo
127199080Sume	@echo "--------------------------------------------------------------"
128199080Sume	@echo ">>> make world completed on `LC_ALL=C date`"
129199080Sume	@echo "                   (started ${STARTTIME})"
130199080Sume	@echo "--------------------------------------------------------------"
131199080Sume
132199080Sume#
133199080Sume# kernel
134199080Sume#
135199080Sume# Short hand for `make buildkernel installkernel'
136199080Sume#
137199080Sumekernel: buildkernel installkernel
138199080Sume
139199080Sume#
140199080Sume# Perform a few tests to determine if the installed tools are adequate
141199080Sume# for building the world.
142199080Sume#
143199080Sumeupgrade_checks:
144199080Sume	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
145199080Sume	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
146199080Sume	then \
147199080Sume	    (cd ${.CURDIR} && make make); \
148199080Sume	fi
149199080Sume
150199080Sume#
151199080Sume# Upgrade make(1) to the current version using the installed
152199080Sume# headers, libraries and tools.
153199080Sume#
154199080SumeMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
155199080Sume		DESTDIR= \
156199080Sume		INSTALL="sh ${.CURDIR}/tools/install.sh"
157199080SumeMMAKE=		${MMAKEENV} make \
158199080Sume		-D_UPGRADING \
159199080Sume		-DNOMAN -DNOSHARED \
160199080Sume		-DNO_CPU_CFLAGS -DNO_WERROR
161199080Sume
162199080Sumemake:
163199080Sume	@echo
164199080Sume	@echo "--------------------------------------------------------------"
165199080Sume	@echo ">>> Building an up-to-date make(1)"
166199080Sume	@echo "--------------------------------------------------------------"
167199080Sume	@cd ${.CURDIR}/usr.bin/make; \
168199080Sume		${MMAKE} obj && \
169199080Sume		${MMAKE} depend && \
170199080Sume		${MMAKE} all && \
171199080Sume		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
172199080Sume
173199080Sume#
174199080Sume# universe
175199080Sume#
176199080Sume# Attempt to rebuild *everything* for all supported architectures,
177199080Sume# with reasonable chance of success, regardless of how old your
178199080Sume# existing system is.
179199080Sume#
180199080Sumei386_mach=	pc98
181199080Sumeuniverse:
182199080Sume	@echo "--------------------------------------------------------------"
183199080Sume	@echo ">>> make universe started on ${STARTTIME}"
184199128Sume	@echo "--------------------------------------------------------------"
185199128Sume.for arch in i386 sparc64 alpha ia64
186199128Sume.for mach in ${arch} ${${arch}_mach}
187199128Sume	@echo ">> ${mach} started on `LC_ALL=C date`"
188199128Sume	-cd ${.CURDIR} && ${MAKE} buildworld \
189199128Sume	    TARGET_ARCH=${arch} TARGET=${mach} \
190199128Sume	    __MAKE_CONF=/dev/null \
191199128Sume	    > _.${mach}.buildworld 2>&1
192199128Sume	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
193199128Sume.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
194199080Sume	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
195199080Sume	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
196199080Sume.endif
197199080Sume	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
198199080Sume	@echo ">> ${mach} completed on `LC_ALL=C date`"
199199080Sume.endfor
200199080Sume.endfor
201199080Sume	@echo "--------------------------------------------------------------"
202199080Sume	@echo ">>> make universe completed on `LC_ALL=C date`"
203199080Sume	@echo "                      (started ${STARTTIME})"
204199080Sume	@echo "--------------------------------------------------------------"
205199080Sume
206199080SumeKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
207199080Sume		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
208199080Sume
209199080Sumebuildkernels:
210199080Sume.for kernel in ${KERNCONFS}
211199080Sume	-cd ${.CURDIR} && ${MAKE} buildkernel \
212199080Sume	    KERNCONF=${kernel} \
213199080Sume	    __MAKE_CONF=/dev/null \
214199080Sume	    > _.${TARGET}.${kernel} 2>&1
215199080Sume.endfor
216199080Sume