4 # The user-driven targets are:
6 # universe - *Really* build *everything* (buildworld and
7 # all kernels on all architectures).
8 # tinderbox - Same as universe, but presents a list of failed build
9 # targets and exits with an error if there were any.
10 # buildworld - Rebuild *everything*, including glue to help do
12 # installworld - Install everything built by "buildworld".
13 # world - buildworld + installworld, no kernel.
14 # buildkernel - Rebuild the kernel and the kernel-modules.
15 # installkernel - Install the kernel and the kernel-modules.
17 # reinstallkernel - Reinstall the kernel and the kernel-modules.
18 # reinstallkernel.debug
19 # kernel - buildkernel + installkernel.
20 # kernel-toolchain - Builds the subset of world necessary to build a kernel
21 # doxygen - Build API documentation of the kernel, needs doxygen.
22 # update - Convenient way to update your source tree(s).
23 # check-old - List obsolete directories/files/libraries.
24 # check-old-dirs - List obsolete directories.
25 # check-old-files - List obsolete files.
26 # check-old-libs - List obsolete libraries.
27 # delete-old - Delete obsolete directories/files.
28 # delete-old-dirs - Delete obsolete directories.
29 # delete-old-files - Delete obsolete files.
30 # delete-old-libs - Delete obsolete libraries.
31 # targets - Print a list of supported TARGET/TARGET_ARCH pairs
32 # for world and kernel targets.
33 # toolchains - Build a toolchain for all world and kernel targets.
35 # This makefile is simple by design. The FreeBSD make automatically reads
36 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
37 # command line. By keeping this makefile simple, it doesn't matter too
38 # much how different the installed mk files are from those in the source
39 # tree. This makefile executes a child make process, forcing it to use
40 # the mk files from the source tree which are supposed to DTRT.
42 # Most of the user-driven targets (as listed above) are implemented in
43 # Makefile.inc1. The exceptions are universe, tinderbox and targets.
45 # If you want to build your system from source be sure that /usr/obj has
46 # at least 1GB of diskspace available. A complete 'universe' build requires
47 # about 15GB of space.
49 # For individuals wanting to build from the sources currently on their
50 # system, the simple instructions are:
52 # 1. `cd /usr/src' (or to the directory containing your source tree).
53 # 2. Define `HISTORICAL_MAKE_WORLD' variable (see README).
56 # For individuals wanting to upgrade their sources (even if only a
57 # delta of a few days):
59 # 1. `cd /usr/src' (or to the directory containing your source tree).
60 # 2. `make buildworld'
61 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
62 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
63 # [steps 3. & 4. can be combined by using the "kernel" target]
64 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
66 # 7. `make installworld'
67 # 8. `make delete-old'
68 # 9. `mergemaster' (you may wish to use -i, along with -U or -F).
70 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
72 # See src/UPDATING `COMMON ITEMS' for more complete information.
74 # If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
75 # cross build world for other machine types using the buildworld target,
76 # and once the world is built you can cross build a kernel using the
79 # Define the user-driven targets. These are listed here in alphabetical
80 # order, but that's not important.
82 # Targets that begin with underscore are internal targets intended for
83 # developer convenience only. They are intentionally not documented and
84 # completely subject to change without notice.
86 # For more information, see the build(7) manual page.
88 TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
89 check-old check-old-dirs check-old-files check-old-libs \
90 checkdpadd clean cleandepend cleandir \
91 delete-old delete-old-dirs delete-old-files delete-old-libs \
92 depend distribute distributekernel distributekernel.debug \
93 distributeworld distrib-dirs distribution doxygen \
94 everything hierarchy install installcheck installkernel \
95 installkernel.debug packagekernel packageworld \
96 reinstallkernel reinstallkernel.debug \
97 installworld kernel-toolchain libraries lint maninstall \
98 obj objlink regress rerelease showconfig tags toolchain update \
99 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
100 _build-tools _cross-tools _includes _libraries _depend \
101 build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
103 TGTS+= ${SUBDIR_TARGETS}
105 BITGTS= files includes
106 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
109 .ORDER: buildworld installworld
110 .ORDER: buildworld distributeworld
111 .ORDER: buildworld buildkernel
112 .ORDER: buildkernel installkernel
113 .ORDER: buildkernel installkernel.debug
114 .ORDER: buildkernel reinstallkernel
115 .ORDER: buildkernel reinstallkernel.debug
117 PATH= /sbin:/bin:/usr/sbin:/usr/bin
118 MAKEOBJDIRPREFIX?= /usr/obj
119 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
120 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
121 -f /dev/null -V MAKEOBJDIRPREFIX dummy
122 .if !empty(_MAKEOBJDIRPREFIX)
123 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
124 (in make.conf(5)) or command-line variable.
126 MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
128 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
129 -m ${.CURDIR}/share/mk
131 .if defined(.PARSEDIR)
132 # don't pass -J to fmake
133 _MAKE= PATH=${PATH} MAKEFLAGS="${MAKEFLAGS:N-J:N1*,1*}" ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
135 _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
138 # Guess machine architecture from machine type, and vice versa.
139 .if !defined(TARGET_ARCH) && defined(TARGET)
140 _TARGET_ARCH= ${TARGET:S/pc98/i386/:S/mips/mipsel/}
141 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
142 ${TARGET_ARCH} != ${MACHINE_ARCH}
143 _TARGET= ${TARGET_ARCH:C/mips.*e[lb]/mips/:C/armeb/arm/}
145 # Legacy names, for a transition period mips:mips -> mipsel:mips
146 .if defined(TARGET) && defined(TARGET_ARCH) && \
147 ${TARGET_ARCH} == "mips" && ${TARGET} == "mips"
148 .warning "TARGET_ARCH of mips is deprecated in favor of mipsel or mipseb"
149 .if defined(TARGET_BIG_ENDIAN)
155 # arm with TARGET_BIG_ENDIAN -> armeb
156 .if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
157 .warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated. use armeb"
160 .if defined(TARGET) && !defined(_TARGET)
163 .if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
164 _TARGET_ARCH=${TARGET_ARCH}
166 # Otherwise, default to current machine type and architecture.
168 _TARGET_ARCH?= ${MACHINE_ARCH}
171 # Make sure we have an up-to-date make(1). Only world and buildworld
172 # should do this as those are the initial targets used for upgrades.
173 # The user can define ALWAYS_CHECK_MAKE to have this check performed
176 .if defined(ALWAYS_CHECK_MAKE)
177 ${TGTS}: upgrade_checks
179 buildworld: upgrade_checks
183 # This 'cleanworld' target is not included in TGTS, because it is not a
184 # recursive target. All of the work for it is done right here. It is
185 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
186 # created by bsd.obj.mk, except that we don't want to .include that file
189 # In the following, the first 'rm' in a series will usually remove all
190 # files and directories. If it does not, then there are probably some
191 # files with file flags set, so this unsets them and tries the 'rm' a
192 # second time. There are situations where this target will be cleaning
193 # some directories via more than one method, but that duplication is
194 # needed to correctly handle all the possible situations. Removing all
195 # files without file flags set in the first 'rm' instance saves time,
196 # because 'chflags' will need to operate on fewer files afterwards.
198 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
200 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
201 .if exists(${BW_CANONICALOBJDIR}/)
202 -rm -rf ${BW_CANONICALOBJDIR}/*
203 -chflags -R 0 ${BW_CANONICALOBJDIR}
204 rm -rf ${BW_CANONICALOBJDIR}/*
206 # To be safe in this case, fall back to a 'make cleandir'
207 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
210 -chflags -R 0 ${.OBJDIR}
215 # Handle the user-driven targets, using the source relative mk files.
219 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
221 # Set a reasonable default
224 STARTTIME!= LC_ALL=C date
225 CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
226 .if !empty(CHECK_TIME)
227 .error check your date/time: ${STARTTIME}
230 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
234 # Attempt to rebuild and reinstall everything. This target is not to be
235 # used for upgrading an existing FreeBSD system, because the kernel is
236 # not included. One can argue that this target doesn't build everything
239 world: upgrade_checks
240 @echo "--------------------------------------------------------------"
241 @echo ">>> make world started on ${STARTTIME}"
242 @echo "--------------------------------------------------------------"
243 .if target(pre-world)
245 @echo "--------------------------------------------------------------"
246 @echo ">>> Making 'pre-world' target"
247 @echo "--------------------------------------------------------------"
248 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
250 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
251 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
252 .if target(post-world)
254 @echo "--------------------------------------------------------------"
255 @echo ">>> Making 'post-world' target"
256 @echo "--------------------------------------------------------------"
257 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
260 @echo "--------------------------------------------------------------"
261 @echo ">>> make world completed on `LC_ALL=C date`"
262 @echo " (started ${STARTTIME})"
263 @echo "--------------------------------------------------------------"
266 @echo "WARNING: make world will overwrite your existing FreeBSD"
267 @echo "installation without also building and installing a new"
268 @echo "kernel. This can be dangerous. Please read the handbook,"
269 @echo "'Rebuilding world', for how to upgrade your system."
270 @echo "Define DESTDIR to where you want to install FreeBSD,"
271 @echo "including /, to override this warning and proceed as usual."
273 @echo "Bailing out now..."
280 # Short hand for `make buildkernel installkernel'
282 kernel: buildkernel installkernel
285 # Perform a few tests to determine if the installed tools are adequate
286 # for building the world.
289 @if ! (cd ${.CURDIR}/tools/build/make_check && \
290 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
291 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
293 (cd ${.CURDIR} && ${MAKE} make); \
297 # Upgrade make(1) to the current version using the installed
298 # headers, libraries and tools. Also, allow the location of
299 # the system bsdmake-like utility to be overridden.
301 MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
303 INSTALL="sh ${.CURDIR}/tools/install.sh"
304 MMAKE= ${MMAKEENV} ${MAKE} \
306 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
307 -DNO_CPU_CFLAGS -DNO_WERROR
311 @echo "--------------------------------------------------------------"
312 @echo ">>> Building an up-to-date make(1)"
313 @echo "--------------------------------------------------------------"
314 ${_+_}@cd ${.CURDIR}/usr.bin/make; \
318 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
321 @cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe
324 @cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe
329 # Attempt to rebuild *everything* for all supported architectures,
330 # with a reasonable chance of success, regardless of how old your
331 # existing system is.
333 .if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
334 TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
335 TARGET_ARCHES_arm?= arm armeb
336 TARGET_ARCHES_mips?= mipsel mipseb mips64el mips64eb mipsn32eb
337 TARGET_ARCHES_powerpc?= powerpc powerpc64
338 TARGET_ARCHES_pc98?= i386
339 .for target in ${TARGETS}
340 TARGET_ARCHES_${target}?= ${target}
343 .if defined(UNIVERSE_TARGET)
344 MAKE_JUST_WORLDS= YES
346 UNIVERSE_TARGET?= buildworld
348 KERNSRCDIR?= ${.CURDIR}/sys
351 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
352 .for target in ${TARGETS}
353 .for target_arch in ${TARGET_ARCHES_${target}}
354 @echo " ${target}/${target_arch}"
358 .if defined(DOING_TINDERBOX)
359 FAILFILE=${.CURDIR}/_.tinderbox.failed
360 MAKEFAIL=tee -a ${FAILFILE}
365 universe: universe_prologue upgrade_checks
367 @echo "--------------------------------------------------------------"
368 @echo ">>> make universe started on ${STARTTIME}"
369 @echo "--------------------------------------------------------------"
370 .if defined(DOING_TINDERBOX)
373 .for target in ${TARGETS}
374 universe: universe_${target}
375 .ORDER: universe_prologue upgrade_checks universe_${target}_prologue universe_${target} universe_epilogue
376 universe_${target}: universe_${target}_prologue
377 universe_${target}_prologue:
378 @echo ">> ${target} started on `LC_ALL=C date`"
379 .if !defined(MAKE_JUST_KERNELS)
380 .for target_arch in ${TARGET_ARCHES_${target}}
381 universe_${target}: universe_${target}_${target_arch}
382 universe_${target}_${target_arch}: universe_${target}_prologue
383 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
384 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
385 ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
387 TARGET_ARCH=${target_arch} \
388 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
389 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
390 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
392 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
395 .if !defined(MAKE_JUST_WORLDS)
396 .if exists(${KERNSRCDIR}/${target}/conf/NOTES)
397 @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
398 ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
399 (echo "${target} 'make LINT' failed," \
400 "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
402 @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \
405 @echo ">> ${target} completed on `LC_ALL=C date`"
407 universe_kernels: universe_kernconfs
411 KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
412 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
413 ! -name DEFAULTS ! -name NOTES
415 .for kernel in ${KERNCONFS}
416 TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
417 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
418 grep -v WARNING: | cut -f 2
419 .if empty(TARGET_ARCH_${kernel})
420 .error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old."
422 universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
423 universe_kernconf_${TARGET}_${kernel}:
424 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
425 ${MAKE} ${JFLAG} buildkernel \
427 TARGET_ARCH=${TARGET_ARCH_${kernel}} \
429 > _.${TARGET}.${kernel} 2>&1 || \
430 (echo "${TARGET} ${kernel} kernel failed," \
431 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
433 universe: universe_epilogue
435 @echo "--------------------------------------------------------------"
436 @echo ">>> make universe completed on `LC_ALL=C date`"
437 @echo " (started ${STARTTIME})"
438 @echo "--------------------------------------------------------------"
439 .if defined(DOING_TINDERBOX)
440 @if [ -e ${FAILFILE} ] ; then \
441 echo "Tinderbox failed:" ;\