Makefile revision 117234
1148330Snetchild#
2148330Snetchild# $FreeBSD: head/Makefile 117234 2003-07-04 17:35:26Z ru $
3148330Snetchild#
4148330Snetchild# The user-driven targets are:
5148330Snetchild#
6148330Snetchild# universe            - *Really* build *everything* (buildworld and
7148330Snetchild#                       all kernels on all architectures).
8148330Snetchild# buildworld          - Rebuild *everything*, including glue to help do
9148330Snetchild#                       upgrades.
10148330Snetchild# installworld        - Install everything built by "buildworld".
11148330Snetchild# world               - buildworld + installworld.
12148330Snetchild# buildkernel         - Rebuild the kernel and the kernel-modules.
13148330Snetchild# installkernel       - Install the kernel and the kernel-modules.
14148543Snetchild# installkernel.debug
15148543Snetchild# reinstallkernel     - Reinstall the kernel and the kernel-modules.
16148330Snetchild# reinstallkernel.debug
17189977Sbrueffer# kernel              - buildkernel + installkernel.
18189977Sbrueffer# update              - Convenient way to update your source tree (cvs).
19189585Sthompsa# most                - Build user commands, no libraries or include files.
20189585Sthompsa# installmost         - Install user commands, no libraries or include files.
21189607Sthompsa#
22189607Sthompsa# This makefile is simple by design. The FreeBSD make automatically reads
23189607Sthompsa# the /usr/share/mk/sys.mk unless the -m argument is specified on the
24189585Sthompsa# command line. By keeping this makefile simple, it doesn't matter too
25189092Sed# much how different the installed mk files are from those in the source
26189092Sed# tree. This makefile executes a child make process, forcing it to use
27188948Sthompsa# the mk files from the source tree which are supposed to DTRT.
28189000Sthompsa#
29189000Sthompsa# The user-driven targets (as listed above) are implemented in Makefile.inc1.
30189000Sthompsa#
31189000Sthompsa# If you want to build your system from source be sure that /usr/obj has
32189000Sthompsa# at least 400MB of diskspace available.
33189000Sthompsa#
34189000Sthompsa# For individuals wanting to build from the sources currently on their
35189000Sthompsa# system, the simple instructions are:
36189000Sthompsa#
37189000Sthompsa# 1.  `cd /usr/src'  (or to the directory containing your source tree).
38189000Sthompsa# 2.  `make world'
39189000Sthompsa#
40189000Sthompsa# For individuals wanting to upgrade their sources (even if only a
41189000Sthompsa# delta of a few days):
42188948Sthompsa#
43188948Sthompsa# 1.  `cd /usr/src'       (or to the directory containing your source tree).
44188948Sthompsa# 2.  `make buildworld'
45188948Sthompsa# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
46188948Sthompsa# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
47188948Sthompsa# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
48188948Sthompsa# 6.  `mergemaster -p'
49188948Sthompsa# 7.  `make installworld'
50188948Sthompsa# 8.  `mergemaster'
51188948Sthompsa# 9.  `reboot'
52188948Sthompsa#
53188948Sthompsa# See src/UPDATING `COMMON ITEMS' for more complete information.
54188948Sthompsa#
55188948Sthompsa# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
56188948Sthompsa# cross build world for other architectures using the buildworld target,
57188948Sthompsa# and once the world is built you can cross build a kernel using the
58188948Sthompsa# buildkernel target.
59188948Sthompsa#
60188948Sthompsa# Define the user-driven targets. These are listed here in alphabetical
61188948Sthompsa# order, but that's not important.
62188948Sthompsa#
63188948SthompsaTGTS=	all all-man buildkernel buildworld checkdpadd clean \
64188948Sthompsa	cleandepend cleandir depend distribute distributeworld everything \
65188948Sthompsa	hierarchy install installcheck installkernel installkernel.debug\
66188948Sthompsa	reinstallkernel reinstallkernel.debug installmost installworld \
67188948Sthompsa	libraries lint maninstall \
68188948Sthompsa	mk most obj objlink regress rerelease tags update
69188948Sthompsa
70188948SthompsaBITGTS=	files includes
71188948SthompsaBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
72188948Sthompsa
73188948Sthompsa.ORDER: buildworld installworld
74188948Sthompsa.ORDER: buildworld distributeworld
75188948Sthompsa.ORDER: buildworld buildkernel
76188948Sthompsa.ORDER: buildkernel installkernel
77188948Sthompsa.ORDER: buildkernel installkernel.debug
78188948Sthompsa.ORDER: buildkernel reinstallkernel
79188948Sthompsa.ORDER: buildkernel reinstallkernel.debug
80188948Sthompsa
81188948SthompsaPATH=	/sbin:/bin:/usr/sbin:/usr/bin
82188948SthompsaMAKEOBJDIRPREFIX?=	/usr/obj
83188948SthompsaMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
84188652SedBINMAKE= \
85188652Sed	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
86188652Sed	-m ${.CURDIR}/share/mk
87188652Sed_MAKE=	PATH=${PATH} ${BINMAKE} -f Makefile.inc1
88188102Sgabor
89188102Sgabor#
90187694Santoine# Handle the user-driven targets, using the source relative mk files.
91187694Santoine#
92187694Santoine${TGTS} ${BITGTS}: upgrade_checks
93187694Santoine	@cd ${.CURDIR}; \
94187694Santoine		${_MAKE} ${.TARGET}
95186716Santoine
96186716Santoine# Set a reasonable default
97186437Sbz.MAIN:	all
98186437Sbz
99185472SantoineSTARTTIME!= LC_ALL=C date
100185472Santoine#
101185472Santoine# world
102185472Santoine#
103185472Santoine# Attempt to rebuild and reinstall *everything*, with reasonable chance of
104183442Sed# success, regardless of how old your existing system is.
105183442Sed#
106183442Sedworld: upgrade_checks
107183442Sed	@echo "--------------------------------------------------------------"
108183442Sed	@echo ">>> elf make world started on ${STARTTIME}"
109183442Sed	@echo "--------------------------------------------------------------"
110183113Sattilio.if target(pre-world)
111183235Santoine	@echo
112183235Santoine	@echo "--------------------------------------------------------------"
113183026Santoine	@echo ">>> Making 'pre-world' target"
114183026Santoine	@echo "--------------------------------------------------------------"
115182105Sed	@cd ${.CURDIR}; ${_MAKE} pre-world
116182105Sed.endif
117182518Santoine	@cd ${.CURDIR}; ${_MAKE} buildworld
118182518Santoine	@cd ${.CURDIR}; ${_MAKE} -B installworld
119182518Santoine.if target(post-world)
120182518Santoine	@echo
121182518Santoine	@echo "--------------------------------------------------------------"
122182518Santoine	@echo ">>> Making 'post-world' target"
123182518Santoine	@echo "--------------------------------------------------------------"
124182518Santoine	@cd ${.CURDIR}; ${_MAKE} post-world
125182518Santoine.endif
126182518Santoine	@echo
127182518Santoine	@echo "--------------------------------------------------------------"
128182518Santoine	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
129182518Santoine	@echo "--------------------------------------------------------------"
130182518Santoine
131182518Santoine#
132182518Santoine# kernel
133182518Santoine#
134182518Santoine# Short hand for `make buildkernel installkernel'
135181905Sed#
136181905Sedkernel: buildkernel installkernel
137181905Sed
138180800Sed#
139180800Sed# Perform a few tests to determine if the installed tools are adequate
140180614Smarcel# for building the world.
141180614Smarcel#
142180614Smarcelupgrade_checks:
143180614Smarcel	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
144180614Smarcel	    PATH=${PATH} ${MAKE} >/dev/null 2>&1); \
145180614Smarcel	then \
146180331Smarcel	    (cd ${.CURDIR} && make make); \
147180331Smarcel	fi
148180331Smarcel
149180331Smarcel#
150180331Smarcel# Upgrade make(1) to the current version using the installed
151180267Sjhb# headers, libraries and tools.
152180267Sjhb#
153180267SjhbMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
154180265Sjhb		DESTDIR= \
155180265Sjhb		INSTALL="sh ${.CURDIR}/tools/install.sh"
156180265SjhbMMAKE=		${MMAKEENV} make \
157180259Sjhb		-D_UPGRADING \
158180259Sjhb		-DNOMAN -DNOSHARED \
159180259Sjhb		-DNO_CPU_CFLAGS -DNO_WERROR
160180259Sjhb
161180259Sjhbmake:
162180257Sjhb	@echo
163180257Sjhb	@echo "--------------------------------------------------------------"
164180257Sjhb	@echo ">>> Building an up-to-date make(1)"
165180259Sjhb	@echo "--------------------------------------------------------------"
166180257Sjhb	@cd ${.CURDIR}/usr.bin/make; \
167180257Sjhb		${MMAKE} obj && \
168180248Smarcel		${MMAKE} depend && \
169180248Smarcel		${MMAKE} all && \
170180248Smarcel		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
171180248Smarcel
172180248Smarcel#
173180230Smarcel# universe
174180230Smarcel#
175180230Smarcel# Attempt to rebuild *everything* for all supported architectures,
176180230Smarcel# with reasonable chance of success, regardless of how old your
177180230Smarcel# existing system is.
178180230Smarcel#
179180230Smarceli386_mach=	pc98
180180230Smarceluniverse:
181180159Sdanger	@echo "--------------------------------------------------------------"
182180159Sdanger	@echo ">>> make universe started on ${STARTTIME}"
183180159Sdanger	@echo "--------------------------------------------------------------"
184180496Santoine.for arch in i386 sparc64 alpha ia64
185180496Santoine.for mach in ${arch} ${${arch}_mach}
186180496Santoine	@echo ">> ${mach} started on `LC_ALL=C date`"
187180496Santoine	-cd ${.CURDIR} && ${MAKE} buildworld \
188179784Sed	    TARGET_ARCH=${arch} TARGET=${mach} \
189179784Sed	    __MAKE_CONF=/dev/null \
190179784Sed	    > _.${mach}.buildworld 2>&1
191179784Sed	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
192179784Sed.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
193179692Smarcel	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
194179692Smarcel	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
195179692Smarcel.endif
196179315Sbz	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
197179315Sbz	@echo ">> ${mach} completed on `LC_ALL=C date`"
198179315Sbz.endfor
199179315Sbz.endfor
200179315Sbz	@echo "--------------------------------------------------------------"
201179315Sbz	@printf ">>> make universe completed on `LC_ALL=C date`\n                      (started ${STARTTIME})\n"
202179315Sbz	@echo "--------------------------------------------------------------"
203179315Sbz
204179315SbzKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
205179315Sbz		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
206179315Sbz
207179315Sbzbuildkernels:
208179315Sbz.for kernel in ${KERNCONFS}
209179315Sbz	-cd ${.CURDIR} && ${MAKE} buildkernel \
210179315Sbz	    KERNCONF=${kernel} \
211179315Sbz	    __MAKE_CONF=/dev/null \
212179315Sbz	    > _.${TARGET}.${kernel} 2>&1
213179315Sbz.endfor
214179315Sbz