4 # The user-driven targets are:
6 # universe - *Really* build *everything* (buildworld and
7 # all kernels on all architectures).
8 # buildworld - Rebuild *everything*, including glue to help do
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.
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).
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.
27 # The user-driven targets (as listed above) are implemented in Makefile.inc1.
29 # If you want to build your system from source be sure that /usr/obj has
30 # at least 400MB of diskspace available.
32 # For individuals wanting to build from the sources currently on their
33 # system, the simple instructions are:
35 # 1. `cd /usr/src' (or to the directory containing your source tree).
38 # For individuals wanting to upgrade their sources (even if only a
39 # delta of a few days):
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).
47 # 7. `make installworld'
51 # See src/UPDATING `COMMON ITEMS' for more complete information.
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
58 # Define the user-driven targets. These are listed here in alphabetical
59 # order, but that's not important.
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.
65 TGTS= all all-man buildenv buildkernel buildworld checkdpadd clean \
66 cleandepend cleandir depend distribute distributeworld \
67 distribution everything \
68 hierarchy install installcheck installkernel installkernel.debug\
69 reinstallkernel reinstallkernel.debug installworld \
70 kernel-toolchain libraries lint maninstall \
71 obj objlink regress rerelease tags toolchain update \
72 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
73 _build-tools _cross-tools _includes _libraries _depend \
76 BITGTS= files includes
77 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
80 .ORDER: buildworld installworld
81 .ORDER: buildworld distributeworld
82 .ORDER: buildworld buildkernel
83 .ORDER: buildkernel installkernel
84 .ORDER: buildkernel installkernel.debug
85 .ORDER: buildkernel reinstallkernel
86 .ORDER: buildkernel reinstallkernel.debug
88 PATH= /sbin:/bin:/usr/sbin:/usr/bin
89 MAKEOBJDIRPREFIX?= /usr/obj
90 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
91 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \
92 -f /dev/null -V MAKEOBJDIRPREFIX dummy
93 .if !empty(_MAKEOBJDIRPREFIX)
94 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
95 (in /etc/make.conf) or command-line variable.
97 MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
99 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
100 -m ${.CURDIR}/share/mk
101 _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1
104 # Make sure we have an up-to-date make(1). Only world and buildworld
105 # should do this as those are the initial targets used for upgrades.
106 # The user can define ALWAYS_CHECK_MAKE to have this check performed
109 .if defined(ALWAYS_CHECK_MAKE)
110 ${TGTS}: upgrade_checks
112 buildworld: upgrade_checks
116 # This 'cleanworld' target is not included in TGTS, because it is not a
117 # recursive target. All of the work for it is done right here. It is
118 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
119 # created by bsd.obj.mk, except that we don't want to .include that file
122 # In the following, the first 'rm' in a series will usually remove all
123 # files and directories. If it does not, then there are probably some
124 # files with chflags set, so this unsets them and tries the 'rm' a
125 # second time. There are situations where this target will be cleaning
126 # some directories via more than one method, but that duplication is
127 # needed to correctly handle all the possible situations.
129 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
131 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
132 .if exists(${BW_CANONICALOBJDIR}/)
133 -rm -rf ${BW_CANONICALOBJDIR}/*
134 chflags -R 0 ${BW_CANONICALOBJDIR}
135 rm -rf ${BW_CANONICALOBJDIR}/*
137 # To be safe in this case, fall back to a 'make cleandir'
138 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
141 chflags -R 0 ${.OBJDIR}
146 # Handle the user-driven targets, using the source relative mk files.
150 ${_+_}@cd ${.CURDIR}; \
153 # Set a reasonable default
156 STARTTIME!= LC_ALL=C date
158 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
162 # Attempt to rebuild and reinstall everything. This target is not to be
163 # used for upgrading an existing FreeBSD system, because the kernel is
164 # not included. One can argue that this target doesn't build everything
167 world: upgrade_checks
168 @echo "--------------------------------------------------------------"
169 @echo ">>> make world started on ${STARTTIME}"
170 @echo "--------------------------------------------------------------"
171 .if target(pre-world)
173 @echo "--------------------------------------------------------------"
174 @echo ">>> Making 'pre-world' target"
175 @echo "--------------------------------------------------------------"
176 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
178 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
179 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
180 .if target(post-world)
182 @echo "--------------------------------------------------------------"
183 @echo ">>> Making 'post-world' target"
184 @echo "--------------------------------------------------------------"
185 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
188 @echo "--------------------------------------------------------------"
189 @echo ">>> make world completed on `LC_ALL=C date`"
190 @echo " (started ${STARTTIME})"
191 @echo "--------------------------------------------------------------"
194 @echo "WARNING: make world will overwrite your existing FreeBSD"
195 @echo "installation without also building and installing a new"
196 @echo "kernel. This can be dangerous. Please read the handbook,"
197 @echo "'Rebuilding world', for how to upgrade your system."
198 @echo "Define DESTDIR to where you want to install FreeBSD,"
199 @echo "including /, to override this warning and proceed as usual."
200 @echo "You may get the historical 'make world' behavior by defining"
201 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications"
202 @echo "before doing this."
204 @echo "Bailing out now..."
211 # Short hand for `make buildkernel installkernel'
213 kernel: buildkernel installkernel
216 # Perform a few tests to determine if the installed tools are adequate
217 # for building the world.
220 @if ! (cd ${.CURDIR}/tools/build/make_check && \
221 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
222 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
224 (cd ${.CURDIR} && make make); \
228 # Upgrade make(1) to the current version using the installed
229 # headers, libraries and tools.
231 MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
233 INSTALL="sh ${.CURDIR}/tools/install.sh"
234 MMAKE= ${MMAKEENV} make \
236 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
237 -DNO_CPU_CFLAGS -DNO_WERROR
241 @echo "--------------------------------------------------------------"
242 @echo ">>> Building an up-to-date make(1)"
243 @echo "--------------------------------------------------------------"
244 ${_+_}@cd ${.CURDIR}/usr.bin/make; \
248 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
253 # Attempt to rebuild *everything* for all supported architectures,
254 # with a reasonable chance of success, regardless of how old your
255 # existing system is.
257 universe: universe_prologue
259 @echo "--------------------------------------------------------------"
260 @echo ">>> make universe started on ${STARTTIME}"
261 @echo "--------------------------------------------------------------"
262 .for target in i386 i386:pc98 sparc64 alpha ia64 amd64
263 .for arch in ${target:C/:.*$//}
264 .for mach in ${target:C/^.*://}
265 universe: universe_${mach}
266 .ORDER: universe_prologue universe_${mach} universe_epilogue
268 @echo ">> ${mach} started on `LC_ALL=C date`"
269 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \
270 TARGET_ARCH=${arch} TARGET=${mach} \
271 __MAKE_CONF=/dev/null \
272 > _.${mach}.buildworld 2>&1
273 @echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
274 .if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
275 -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
276 > ${.CURDIR}/_.${mach}.makeLINT 2>&1
278 cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
279 @echo ">> ${mach} completed on `LC_ALL=C date`"
283 universe: universe_epilogue
285 @echo "--------------------------------------------------------------"
286 @echo ">>> make universe completed on `LC_ALL=C date`"
287 @echo " (started ${STARTTIME})"
288 @echo "--------------------------------------------------------------"
290 .if make(buildkernels)
291 KERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \
292 find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
294 .for kernel in ${KERNCONFS}
295 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \
297 __MAKE_CONF=/dev/null \
298 > _.${TARGET}.${kernel} 2>&1