Makefile revision 125885
1#
2# $FreeBSD: head/Makefile 125885 2004-02-16 20:18:25Z gad $
3#
4# The user-driven targets are:
5#
6# universe            - *Really* build *everything* (buildworld and
7#                       all kernels on all architectures).
8# buildworld          - Rebuild *everything*, including glue to help do
9#                       upgrades.
10# installworld        - Install everything built by "buildworld".
11# world               - buildworld + installworld.
12# buildkernel         - Rebuild the kernel and the kernel-modules.
13# installkernel       - Install the kernel and the kernel-modules.
14# installkernel.debug
15# reinstallkernel     - Reinstall the kernel and the kernel-modules.
16# reinstallkernel.debug
17# kernel              - buildkernel + installkernel.
18# update              - Convenient way to update your source tree (cvs).
19#
20# This makefile is simple by design. The FreeBSD make automatically reads
21# the /usr/share/mk/sys.mk unless the -m argument is specified on the
22# command line. By keeping this makefile simple, it doesn't matter too
23# much how different the installed mk files are from those in the source
24# tree. This makefile executes a child make process, forcing it to use
25# the mk files from the source tree which are supposed to DTRT.
26#
27# The user-driven targets (as listed above) are implemented in Makefile.inc1.
28#
29# If you want to build your system from source be sure that /usr/obj has
30# at least 400MB of diskspace available.
31#
32# For individuals wanting to build from the sources currently on their
33# system, the simple instructions are:
34#
35# 1.  `cd /usr/src'  (or to the directory containing your source tree).
36# 2.  `make world'
37#
38# For individuals wanting to upgrade their sources (even if only a
39# delta of a few days):
40#
41# 1.  `cd /usr/src'       (or to the directory containing your source tree).
42# 2.  `make buildworld'
43# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
44# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
45# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
46# 6.  `mergemaster -p'
47# 7.  `make installworld'
48# 8.  `mergemaster'
49# 9.  `reboot'
50#
51# See src/UPDATING `COMMON ITEMS' for more complete information.
52#
53# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
54# cross build world for other architectures using the buildworld target,
55# and once the world is built you can cross build a kernel using the
56# buildkernel target.
57#
58# Define the user-driven targets. These are listed here in alphabetical
59# order, but that's not important.
60#
61# Targets that begin with underscore are internal targets intended for
62# developer convenience only.  They are intentionally not documented and
63# completely subject to change without notice.
64#
65TGTS=	all all-man buildkernel buildworld checkdpadd clean \
66	cleandepend cleandir depend distribute distributeworld everything \
67	hierarchy install installcheck installkernel installkernel.debug\
68	reinstallkernel reinstallkernel.debug installworld \
69	libraries lint maninstall \
70	obj objlink regress rerelease tags update \
71	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
72	_build-tools _cross-tools _includes _libraries _depend
73
74BITGTS=	files includes
75BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
76TGTS+=	${BITGTS}
77
78.ORDER: buildworld installworld
79.ORDER: buildworld distributeworld
80.ORDER: buildworld buildkernel
81.ORDER: buildkernel installkernel
82.ORDER: buildkernel installkernel.debug
83.ORDER: buildkernel reinstallkernel
84.ORDER: buildkernel reinstallkernel.debug
85
86PATH=	/sbin:/bin:/usr/sbin:/usr/bin
87MAKEOBJDIRPREFIX?=	/usr/obj
88MAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
89BINMAKE= \
90	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
91	-m ${.CURDIR}/share/mk
92_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
93
94#
95# Make sure we have an up-to-date make(1). Only world and buildworld
96# should do this as those are the initial targets used for upgrades.
97# The user can define ALWAYS_CHECK_MAKE to have this check performed
98# for all targets.
99#
100.if defined(ALWAYS_CHECK_MAKE)
101${TGTS}: upgrade_checks
102.else
103buildworld: upgrade_checks
104.endif
105
106#
107# This 'realclean' target is not included in TGTS, because it is not
108# a recursive target.  All of the work for it is done right here.
109# The first 'rm' will usually remove all files and directories.  If
110# it does not, then there are probably some files with chflags set.
111# Unset all special chflags, and try the 'rm' a second time.
112realclean :
113	-rm -Rf ${.OBJDIR}/* 2>/dev/null
114	@-if [ "`echo ${.OBJDIR}/*`" != "${.OBJDIR}/*" ] ; then \
115	    echo "chflags -R 0 ${.OBJDIR}/*" ; \
116	    chflags -R 0 ${.OBJDIR}/* ;  \
117	    echo "rm -Rf ${.OBJDIR}/*" ; \
118	    rm -Rf ${.OBJDIR}/* ; \
119	fi
120
121#
122# Handle the user-driven targets, using the source relative mk files.
123#
124
125${TGTS}:
126	@cd ${.CURDIR}; \
127		${_MAKE} ${.TARGET}
128
129# Set a reasonable default
130.MAIN:	all
131
132STARTTIME!= LC_ALL=C date
133#
134# world
135#
136# Attempt to rebuild and reinstall *everything*, with reasonable chance of
137# success, regardless of how old your existing system is.
138#
139world: upgrade_checks
140	@echo "--------------------------------------------------------------"
141	@echo ">>> make world started on ${STARTTIME}"
142	@echo "--------------------------------------------------------------"
143.if target(pre-world)
144	@echo
145	@echo "--------------------------------------------------------------"
146	@echo ">>> Making 'pre-world' target"
147	@echo "--------------------------------------------------------------"
148	@cd ${.CURDIR}; ${_MAKE} pre-world
149.endif
150	@cd ${.CURDIR}; ${_MAKE} buildworld
151	@cd ${.CURDIR}; ${_MAKE} -B installworld
152.if target(post-world)
153	@echo
154	@echo "--------------------------------------------------------------"
155	@echo ">>> Making 'post-world' target"
156	@echo "--------------------------------------------------------------"
157	@cd ${.CURDIR}; ${_MAKE} post-world
158.endif
159	@echo
160	@echo "--------------------------------------------------------------"
161	@echo ">>> make world completed on `LC_ALL=C date`"
162	@echo "                   (started ${STARTTIME})"
163	@echo "--------------------------------------------------------------"
164
165#
166# kernel
167#
168# Short hand for `make buildkernel installkernel'
169#
170kernel: buildkernel installkernel
171
172#
173# Perform a few tests to determine if the installed tools are adequate
174# for building the world.
175#
176upgrade_checks:
177	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
178	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
179	then \
180	    (cd ${.CURDIR} && make make); \
181	fi
182
183#
184# Upgrade make(1) to the current version using the installed
185# headers, libraries and tools.
186#
187MMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
188		DESTDIR= \
189		INSTALL="sh ${.CURDIR}/tools/install.sh"
190MMAKE=		${MMAKEENV} make \
191		-D_UPGRADING \
192		-DNOMAN -DNOSHARED \
193		-DNO_CPU_CFLAGS -DNO_WERROR
194
195make: .PHONY
196	@echo
197	@echo "--------------------------------------------------------------"
198	@echo ">>> Building an up-to-date make(1)"
199	@echo "--------------------------------------------------------------"
200	@cd ${.CURDIR}/usr.bin/make; \
201		${MMAKE} obj && \
202		${MMAKE} depend && \
203		${MMAKE} all && \
204		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
205
206#
207# universe
208#
209# Attempt to rebuild *everything* for all supported architectures,
210# with reasonable chance of success, regardless of how old your
211# existing system is.
212#
213i386_mach=	pc98
214universe:
215	@echo "--------------------------------------------------------------"
216	@echo ">>> make universe started on ${STARTTIME}"
217	@echo "--------------------------------------------------------------"
218.for arch in i386 sparc64 alpha ia64
219.for mach in ${arch} ${${arch}_mach}
220	@echo ">> ${mach} started on `LC_ALL=C date`"
221	-cd ${.CURDIR} && ${MAKE} buildworld \
222	    TARGET_ARCH=${arch} TARGET=${mach} \
223	    __MAKE_CONF=/dev/null \
224	    > _.${mach}.buildworld 2>&1
225	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
226.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
227	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
228	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
229.endif
230	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
231	@echo ">> ${mach} completed on `LC_ALL=C date`"
232.endfor
233.endfor
234	@echo "--------------------------------------------------------------"
235	@echo ">>> make universe completed on `LC_ALL=C date`"
236	@echo "                      (started ${STARTTIME})"
237	@echo "--------------------------------------------------------------"
238
239KERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
240		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
241
242buildkernels:
243.for kernel in ${KERNCONFS}
244	-cd ${.CURDIR} && ${MAKE} buildkernel \
245	    KERNCONF=${kernel} \
246	    __MAKE_CONF=/dev/null \
247	    > _.${TARGET}.${kernel} 2>&1
248.endfor
249