Makefile revision 123311
1127474Stjr#
2127474Stjr# $FreeBSD: head/Makefile 123311 2003-12-09 02:08:19Z peter $
3127474Stjr#
4127474Stjr# The user-driven targets are:
5127474Stjr#
6174990Sache# universe            - *Really* build *everything* (buildworld and
7127474Stjr#                       all kernels on all architectures).
8127474Stjr# buildworld          - Rebuild *everything*, including glue to help do
9127474Stjr#                       upgrades.
10127474Stjr# installworld        - Install everything built by "buildworld".
11127474Stjr# world               - buildworld + installworld.
12127474Stjr# buildkernel         - Rebuild the kernel and the kernel-modules.
13127474Stjr# installkernel       - Install the kernel and the kernel-modules.
14127474Stjr# installkernel.debug
15127474Stjr# reinstallkernel     - Reinstall the kernel and the kernel-modules.
16127474Stjr# reinstallkernel.debug
17127474Stjr# kernel              - buildkernel + installkernel.
18127474Stjr# update              - Convenient way to update your source tree (cvs).
19127474Stjr#
20127474Stjr# This makefile is simple by design. The FreeBSD make automatically reads
21174990Sache# the /usr/share/mk/sys.mk unless the -m argument is specified on the
22127474Stjr# command line. By keeping this makefile simple, it doesn't matter too
23127474Stjr# much how different the installed mk files are from those in the source
24127474Stjr# tree. This makefile executes a child make process, forcing it to use
25127474Stjr# the mk files from the source tree which are supposed to DTRT.
26127474Stjr#
27127474Stjr# The user-driven targets (as listed above) are implemented in Makefile.inc1.
28127474Stjr#
29127474Stjr# If you want to build your system from source be sure that /usr/obj has
30127474Stjr# at least 400MB of diskspace available.
31127474Stjr#
32127474Stjr# For individuals wanting to build from the sources currently on their
33127474Stjr# system, the simple instructions are:
34127474Stjr#
35127474Stjr# 1.  `cd /usr/src'  (or to the directory containing your source tree).
36174990Sache# 2.  `make world'
37127474Stjr#
38127474Stjr# For individuals wanting to upgrade their sources (even if only a
39127474Stjr# delta of a few days):
40127474Stjr#
41127474Stjr# 1.  `cd /usr/src'       (or to the directory containing your source tree).
42127474Stjr# 2.  `make buildworld'
43127474Stjr# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
44127474Stjr# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
45127474Stjr# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
46174990Sache# 6.  `mergemaster -p'
47127474Stjr# 7.  `make installworld'
48127474Stjr# 8.  `mergemaster'
49127474Stjr# 9.  `reboot'
50127474Stjr#
51127474Stjr# See src/UPDATING `COMMON ITEMS' for more complete information.
52127474Stjr#
53127474Stjr# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
54127474Stjr# cross build world for other architectures using the buildworld target,
55127474Stjr# and once the world is built you can cross build a kernel using the
56127474Stjr# buildkernel target.
57127474Stjr#
58127474Stjr# Define the user-driven targets. These are listed here in alphabetical
59127474Stjr# order, but that's not important.
60127474Stjr#
61127474Stjr# Targets that begin with underscore are internal targets intended for
62127474Stjr# developer convenience only.  They are intentionally not documented and
63127474Stjr# completely subject to change without notice.
64127474Stjr#
65127474StjrTGTS=	all all-man buildkernel buildworld checkdpadd clean \
66127474Stjr	cleandepend cleandir depend distribute distributeworld everything \
67127474Stjr	hierarchy install installcheck installkernel installkernel.debug\
68127474Stjr	reinstallkernel reinstallkernel.debug installworld \
69127474Stjr	libraries lint maninstall \
70127474Stjr	obj objlink regress rerelease tags update \
71127474Stjr	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
72127474Stjr	_build-tools _cross-tools _includes _libraries _depend
73127474Stjr
74127474StjrBITGTS=	files includes
75127474StjrBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
76127474StjrTGTS+=	${BITGTS}
77127474Stjr
78127474Stjr.ORDER: buildworld installworld
79127474Stjr.ORDER: buildworld distributeworld
80174990Sache.ORDER: buildworld buildkernel
81127474Stjr.ORDER: buildkernel installkernel
82127474Stjr.ORDER: buildkernel installkernel.debug
83127474Stjr.ORDER: buildkernel reinstallkernel
84127474Stjr.ORDER: buildkernel reinstallkernel.debug
85127474Stjr
86127474StjrPATH=	/sbin:/bin:/usr/sbin:/usr/bin
87127474StjrMAKEOBJDIRPREFIX?=	/usr/obj
88127474StjrMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
89127474StjrBINMAKE= \
90127474Stjr	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
91127474Stjr	-m ${.CURDIR}/share/mk
92127474Stjr_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
93127474Stjr
94127474Stjr#
95127474Stjr# Make sure we have an up-to-date make(1). Only world and buildworld
96127474Stjr# should do this as those are the initial targets used for upgrades.
97127474Stjr# The user can define ALWAYS_CHECK_MAKE to have this check performed
98127474Stjr# for all targets.
99127474Stjr#
100127474Stjr.if defined(ALWAYS_CHECK_MAKE)
101127474Stjr${TGTS}: upgrade_checks
102.else
103buildworld: upgrade_checks
104.endif
105
106#
107# Handle the user-driven targets, using the source relative mk files.
108#
109
110${TGTS}:
111	@cd ${.CURDIR}; \
112		${_MAKE} ${.TARGET}
113
114# Set a reasonable default
115.MAIN:	all
116
117STARTTIME!= LC_ALL=C date
118#
119# world
120#
121# Attempt to rebuild and reinstall *everything*, with reasonable chance of
122# success, regardless of how old your existing system is.
123#
124world: upgrade_checks
125	@echo "--------------------------------------------------------------"
126	@echo ">>> make world started on ${STARTTIME}"
127	@echo "--------------------------------------------------------------"
128.if target(pre-world)
129	@echo
130	@echo "--------------------------------------------------------------"
131	@echo ">>> Making 'pre-world' target"
132	@echo "--------------------------------------------------------------"
133	@cd ${.CURDIR}; ${_MAKE} pre-world
134.endif
135	@cd ${.CURDIR}; ${_MAKE} buildworld
136	@cd ${.CURDIR}; ${_MAKE} -B installworld
137.if target(post-world)
138	@echo
139	@echo "--------------------------------------------------------------"
140	@echo ">>> Making 'post-world' target"
141	@echo "--------------------------------------------------------------"
142	@cd ${.CURDIR}; ${_MAKE} post-world
143.endif
144	@echo
145	@echo "--------------------------------------------------------------"
146	@echo ">>> make world completed on `LC_ALL=C date`"
147	@echo "                   (started ${STARTTIME})"
148	@echo "--------------------------------------------------------------"
149
150#
151# kernel
152#
153# Short hand for `make buildkernel installkernel'
154#
155kernel: buildkernel installkernel
156
157#
158# Perform a few tests to determine if the installed tools are adequate
159# for building the world.
160#
161upgrade_checks:
162	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
163	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
164	then \
165	    (cd ${.CURDIR} && make make); \
166	fi
167
168#
169# Upgrade make(1) to the current version using the installed
170# headers, libraries and tools.
171#
172MMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
173		DESTDIR= \
174		INSTALL="sh ${.CURDIR}/tools/install.sh"
175MMAKE=		${MMAKEENV} make \
176		-D_UPGRADING \
177		-DNOMAN -DNOSHARED \
178		-DNO_CPU_CFLAGS -DNO_WERROR
179
180make: .PHONY
181	@echo
182	@echo "--------------------------------------------------------------"
183	@echo ">>> Building an up-to-date make(1)"
184	@echo "--------------------------------------------------------------"
185	@cd ${.CURDIR}/usr.bin/make; \
186		${MMAKE} obj && \
187		${MMAKE} depend && \
188		${MMAKE} all && \
189		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
190
191#
192# universe
193#
194# Attempt to rebuild *everything* for all supported architectures,
195# with reasonable chance of success, regardless of how old your
196# existing system is.
197#
198i386_mach=	pc98
199universe:
200	@echo "--------------------------------------------------------------"
201	@echo ">>> make universe started on ${STARTTIME}"
202	@echo "--------------------------------------------------------------"
203.for arch in i386 sparc64 alpha ia64
204.for mach in ${arch} ${${arch}_mach}
205	@echo ">> ${mach} started on `LC_ALL=C date`"
206	-cd ${.CURDIR} && ${MAKE} buildworld \
207	    TARGET_ARCH=${arch} TARGET=${mach} \
208	    __MAKE_CONF=/dev/null \
209	    > _.${mach}.buildworld 2>&1
210	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
211.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
212	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
213	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
214.endif
215	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
216	@echo ">> ${mach} completed on `LC_ALL=C date`"
217.endfor
218.endfor
219	@echo "--------------------------------------------------------------"
220	@echo ">>> make universe completed on `LC_ALL=C date`"
221	@echo "                      (started ${STARTTIME})"
222	@echo "--------------------------------------------------------------"
223
224KERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
225		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
226
227buildkernels:
228.for kernel in ${KERNCONFS}
229	-cd ${.CURDIR} && ${MAKE} buildkernel \
230	    KERNCONF=${kernel} \
231	    __MAKE_CONF=/dev/null \
232	    > _.${TARGET}.${kernel} 2>&1
233.endfor
234