Makefile revision 116679
1#
2# $FreeBSD: head/Makefile 116679 2003-06-22 10:01:03Z simokawa $
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# most                - Build user commands, no libraries or include files.
20# installmost         - Install user commands, no libraries or include files.
21#
22# This makefile is simple by design. The FreeBSD make automatically reads
23# the /usr/share/mk/sys.mk unless the -m argument is specified on the
24# command line. By keeping this makefile simple, it doesn't matter too
25# much how different the installed mk files are from those in the source
26# tree. This makefile executes a child make process, forcing it to use
27# the mk files from the source tree which are supposed to DTRT.
28#
29# The user-driven targets (as listed above) are implemented in Makefile.inc1.
30#
31# If you want to build your system from source be sure that /usr/obj has
32# at least 400MB of diskspace available.
33#
34# For individuals wanting to build from the sources currently on their
35# system, the simple instructions are:
36#
37# 1.  `cd /usr/src'  (or to the directory containing your source tree).
38# 2.  `make world'
39#
40# For individuals wanting to upgrade their sources (even if only a
41# delta of a few days):
42#
43# 1.  `cd /usr/src'       (or to the directory containing your source tree).
44# 2.  `make buildworld'
45# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
46# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
47# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
48# 6.  `mergemaster -p'
49# 7.  `make installworld'
50# 8.  `mergemaster'
51# 9.  `reboot'
52#
53# See src/UPDATING `COMMON ITEMS' for more complete information.
54#
55# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
56# cross build world for other architectures using the buildworld target,
57# and once the world is built you can cross build a kernel using the
58# buildkernel target.
59#
60# Define the user-driven targets. These are listed here in alphabetical
61# order, but that's not important.
62#
63TGTS=	all all-man buildkernel buildworld checkdpadd clean \
64	cleandepend cleandir depend distribute distributeworld everything \
65	hierarchy install installcheck installkernel installkernel.debug\
66	reinstallkernel reinstallkernel.debug installmost installworld \
67	libraries lint maninstall \
68	mk most obj objlink regress rerelease tags update
69
70BITGTS=	files includes
71BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
72
73.ORDER: buildworld installworld
74.ORDER: buildworld distributeworld
75.ORDER: buildworld buildkernel
76.ORDER: buildkernel installkernel
77.ORDER: buildkernel installkernel.debug
78.ORDER: buildkernel reinstallkernel
79.ORDER: buildkernel reinstallkernel.debug
80
81PATH=	/sbin:/bin:/usr/sbin:/usr/bin
82MAKEOBJDIRPREFIX?=	/usr/obj
83MAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
84_MAKE=	PATH=${PATH} \
85	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
86	-m ${.CURDIR}/share/mk -f Makefile.inc1
87
88#
89# Handle the user-driven targets, using the source relative mk files.
90#
91${TGTS} ${BITGTS}: upgrade_checks
92	@cd ${.CURDIR}; \
93		${_MAKE} ${.TARGET}
94
95# Set a reasonable default
96.MAIN:	all
97
98STARTTIME!= LC_ALL=C date
99#
100# world
101#
102# Attempt to rebuild and reinstall *everything*, with reasonable chance of
103# success, regardless of how old your existing system is.
104#
105world: upgrade_checks
106	@echo "--------------------------------------------------------------"
107	@echo ">>> elf make world started on ${STARTTIME}"
108	@echo "--------------------------------------------------------------"
109.if target(pre-world)
110	@echo
111	@echo "--------------------------------------------------------------"
112	@echo ">>> Making 'pre-world' target"
113	@echo "--------------------------------------------------------------"
114	@cd ${.CURDIR}; ${_MAKE} pre-world
115.endif
116	@cd ${.CURDIR}; ${_MAKE} buildworld
117	@cd ${.CURDIR}; ${_MAKE} -B installworld
118.if target(post-world)
119	@echo
120	@echo "--------------------------------------------------------------"
121	@echo ">>> Making 'post-world' target"
122	@echo "--------------------------------------------------------------"
123	@cd ${.CURDIR}; ${_MAKE} post-world
124.endif
125	@echo
126	@echo "--------------------------------------------------------------"
127	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
128	@echo "--------------------------------------------------------------"
129
130#
131# kernel
132#
133# Short hand for `make buildkernel installkernel'
134#
135kernel: buildkernel installkernel
136
137#
138# Perform a few tests to determine if the installed tools are adequate
139# for building the world.
140#
141upgrade_checks:
142	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
143	    PATH=${PATH} ${MAKE} 2>/dev/null); \
144	then \
145	    (cd ${.CURDIR} && make make); \
146	fi
147
148#
149# Upgrade make(1) to the current version using the installed
150# headers, libraries and tools.
151#
152MMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
153		DESTDIR= \
154		INSTALL="sh ${.CURDIR}/tools/install.sh"
155MMAKE=		${MMAKEENV} make \
156		-D_UPGRADING \
157		-DNOMAN -DNOSHARED \
158		-DNO_CPU_CFLAGS -DNO_WERROR
159
160make:
161	@echo
162	@echo "--------------------------------------------------------------"
163	@echo " Building an up-to-date make(1)"
164	@echo "--------------------------------------------------------------"
165	@cd ${.CURDIR}/usr.bin/make; \
166		${MMAKE} obj && \
167		${MMAKE} depend && \
168		${MMAKE} all && \
169		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
170
171#
172# universe
173#
174# Attempt to rebuild *everything* for all supported architectures,
175# with reasonable chance of success, regardless of how old your
176# existing system is.
177#
178i386_mach=	pc98
179universe:
180	@echo "--------------------------------------------------------------"
181	@echo ">>> make universe started on ${STARTTIME}"
182	@echo "--------------------------------------------------------------"
183.for arch in i386 sparc64 alpha ia64
184.for mach in ${arch} ${${arch}_mach}
185	@echo ">> ${mach} started on `LC_ALL=C date`"
186	-cd ${.CURDIR} && ${MAKE} buildworld \
187	    TARGET_ARCH=${arch} TARGET=${mach} \
188	    __MAKE_CONF=/dev/null \
189	    > _.${mach}.buildworld 2>&1
190	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
191.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
192	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
193	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
194.endif
195	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
196	@echo ">> ${mach} completed on `LC_ALL=C date`"
197.endfor
198.endfor
199	@echo "--------------------------------------------------------------"
200	@printf ">>> make universe completed on `LC_ALL=C date`\n                      (started ${STARTTIME})\n"
201	@echo "--------------------------------------------------------------"
202
203KERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
204		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
205
206buildkernels:
207.for kernel in ${KERNCONFS}
208	-cd ${.CURDIR} && ${MAKE} buildkernel \
209	    KERNCONF=${kernel} \
210	    __MAKE_CONF=/dev/null \
211	    > _.${TARGET}.${kernel} 2>&1
212.endfor
213