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.
34 # xdev - xdev-build + xdev-install for the architecture
35 # specified with XDEV and XDEV_ARCH.
36 # xdev-build - Build cross-development tools.
37 # xdev-install - Install cross-development tools.
39 # This makefile is simple by design. The FreeBSD make automatically reads
40 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
41 # command line. By keeping this makefile simple, it doesn't matter too
42 # much how different the installed mk files are from those in the source
43 # tree. This makefile executes a child make process, forcing it to use
44 # the mk files from the source tree which are supposed to DTRT.
46 # Most of the user-driven targets (as listed above) are implemented in
47 # Makefile.inc1. The exceptions are universe, tinderbox and targets.
49 # If you want to build your system from source be sure that /usr/obj has
50 # at least 1GB of diskspace available. A complete 'universe' build requires
51 # about 15GB of space.
53 # For individuals wanting to build from the sources currently on their
54 # system, the simple instructions are:
56 # 1. `cd /usr/src' (or to the directory containing your source tree).
57 # 2. Define `HISTORICAL_MAKE_WORLD' variable (see README).
60 # For individuals wanting to upgrade their sources (even if only a
61 # delta of a few days):
63 # 1. `cd /usr/src' (or to the directory containing your source tree).
64 # 2. `make buildworld'
65 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
66 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
67 # [steps 3. & 4. can be combined by using the "kernel" target]
68 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
70 # 7. `make installworld'
71 # 8. `make delete-old'
72 # 9. `mergemaster' (you may wish to use -i, along with -U or -F).
74 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
76 # See src/UPDATING `COMMON ITEMS' for more complete information.
78 # If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
79 # cross build world for other machine types using the buildworld target,
80 # and once the world is built you can cross build a kernel using the
83 # Define the user-driven targets. These are listed here in alphabetical
84 # order, but that's not important.
86 # Targets that begin with underscore are internal targets intended for
87 # developer convenience only. They are intentionally not documented and
88 # completely subject to change without notice.
90 # For more information, see the build(7) manual page.
92 TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
93 check-old check-old-dirs check-old-files check-old-libs \
94 checkdpadd clean cleandepend cleandir \
95 delete-old delete-old-dirs delete-old-files delete-old-libs \
96 depend distribute distributekernel distributekernel.debug \
97 distributeworld distrib-dirs distribution doxygen \
98 everything hier hierarchy install installcheck installkernel \
99 installkernel.debug packagekernel packageworld \
100 reinstallkernel reinstallkernel.debug \
101 installworld kernel-toolchain libraries lint maninstall \
102 obj objlink regress rerelease showconfig tags toolchain update \
103 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
104 _build-tools _cross-tools _includes _libraries _depend \
105 build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
107 TGTS+= ${SUBDIR_TARGETS}
109 BITGTS= files includes
110 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
113 .ORDER: buildworld installworld
114 .ORDER: buildworld distributeworld
115 .ORDER: buildworld buildkernel
116 .ORDER: buildkernel installkernel
117 .ORDER: buildkernel installkernel.debug
118 .ORDER: buildkernel reinstallkernel
119 .ORDER: buildkernel reinstallkernel.debug
121 PATH= /sbin:/bin:/usr/sbin:/usr/bin
122 MAKEOBJDIRPREFIX?= /usr/obj
123 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
124 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
125 -f /dev/null -V MAKEOBJDIRPREFIX dummy
126 .if !empty(_MAKEOBJDIRPREFIX)
127 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
128 (in make.conf(5)) or command-line variable.
130 MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
132 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
133 -m ${.CURDIR}/share/mk
135 .if defined(.PARSEDIR)
136 # don't pass -J to fmake
137 _MAKE= PATH=${PATH} MAKEFLAGS="${MAKEFLAGS:N-J:N1*,1*}" ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
139 _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
142 # Guess machine architecture from machine type, and vice versa.
143 .if !defined(TARGET_ARCH) && defined(TARGET)
144 _TARGET_ARCH= ${TARGET:S/pc98/i386/:S/mips/mipsel/}
145 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
146 ${TARGET_ARCH} != ${MACHINE_ARCH}
147 _TARGET= ${TARGET_ARCH:C/mips.*e[lb]/mips/:C/armeb/arm/}
149 # Legacy names, for a transition period mips:mips -> mipsel:mips
150 .if defined(TARGET) && defined(TARGET_ARCH) && \
151 ${TARGET_ARCH} == "mips" && ${TARGET} == "mips"
152 .warning "TARGET_ARCH of mips is deprecated in favor of mipsel or mipseb"
153 .if defined(TARGET_BIG_ENDIAN)
159 # arm with TARGET_BIG_ENDIAN -> armeb
160 .if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
161 .warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated. use armeb"
164 .if defined(TARGET) && !defined(_TARGET)
167 .if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
168 _TARGET_ARCH=${TARGET_ARCH}
170 # Otherwise, default to current machine type and architecture.
172 _TARGET_ARCH?= ${MACHINE_ARCH}
175 # Make sure we have an up-to-date make(1). Only world and buildworld
176 # should do this as those are the initial targets used for upgrades.
177 # The user can define ALWAYS_CHECK_MAKE to have this check performed
180 .if defined(ALWAYS_CHECK_MAKE)
181 ${TGTS}: upgrade_checks
183 buildworld: upgrade_checks
187 # This 'cleanworld' target is not included in TGTS, because it is not a
188 # recursive target. All of the work for it is done right here. It is
189 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
190 # created by bsd.obj.mk, except that we don't want to .include that file
193 # In the following, the first 'rm' in a series will usually remove all
194 # files and directories. If it does not, then there are probably some
195 # files with file flags set, so this unsets them and tries the 'rm' a
196 # second time. There are situations where this target will be cleaning
197 # some directories via more than one method, but that duplication is
198 # needed to correctly handle all the possible situations. Removing all
199 # files without file flags set in the first 'rm' instance saves time,
200 # because 'chflags' will need to operate on fewer files afterwards.
202 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
204 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
205 .if exists(${BW_CANONICALOBJDIR}/)
206 -rm -rf ${BW_CANONICALOBJDIR}/*
207 -chflags -R 0 ${BW_CANONICALOBJDIR}
208 rm -rf ${BW_CANONICALOBJDIR}/*
210 # To be safe in this case, fall back to a 'make cleandir'
211 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
214 -chflags -R 0 ${.OBJDIR}
219 # Handle the user-driven targets, using the source relative mk files.
223 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
225 # The historic default "all" target creates files which may cause stale
226 # or (in the cross build case) unlinkable results. Fail with an error
227 # when no target is given. The users can explicitly specify "all"
228 # if they want the historic behavior.
233 @echo "Explicit target required (use \"all\" for historic behavior)"
237 STARTTIME!= LC_ALL=C date
238 CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
239 .if !empty(CHECK_TIME)
240 .error check your date/time: ${STARTTIME}
243 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
247 # Attempt to rebuild and reinstall everything. This target is not to be
248 # used for upgrading an existing FreeBSD system, because the kernel is
249 # not included. One can argue that this target doesn't build everything
252 world: upgrade_checks
253 @echo "--------------------------------------------------------------"
254 @echo ">>> make world started on ${STARTTIME}"
255 @echo "--------------------------------------------------------------"
256 .if target(pre-world)
258 @echo "--------------------------------------------------------------"
259 @echo ">>> Making 'pre-world' target"
260 @echo "--------------------------------------------------------------"
261 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
263 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
264 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
265 .if target(post-world)
267 @echo "--------------------------------------------------------------"
268 @echo ">>> Making 'post-world' target"
269 @echo "--------------------------------------------------------------"
270 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
273 @echo "--------------------------------------------------------------"
274 @echo ">>> make world completed on `LC_ALL=C date`"
275 @echo " (started ${STARTTIME})"
276 @echo "--------------------------------------------------------------"
279 @echo "WARNING: make world will overwrite your existing FreeBSD"
280 @echo "installation without also building and installing a new"
281 @echo "kernel. This can be dangerous. Please read the handbook,"
282 @echo "'Rebuilding world', for how to upgrade your system."
283 @echo "Define DESTDIR to where you want to install FreeBSD,"
284 @echo "including /, to override this warning and proceed as usual."
286 @echo "Bailing out now..."
293 # Short hand for `make buildkernel installkernel'
295 kernel: buildkernel installkernel
298 # Perform a few tests to determine if the installed tools are adequate
299 # for building the world.
302 @if ! (cd ${.CURDIR}/tools/build/make_check && \
303 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
304 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
306 (cd ${.CURDIR} && ${MAKE} make); \
310 # Upgrade make(1) to the current version using the installed
311 # headers, libraries and tools. Also, allow the location of
312 # the system bsdmake-like utility to be overridden.
314 MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
316 INSTALL="sh ${.CURDIR}/tools/install.sh"
317 MMAKE= ${MMAKEENV} ${MAKE} \
319 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
320 -DNO_CPU_CFLAGS -DNO_WERROR
324 @echo "--------------------------------------------------------------"
325 @echo ">>> Building an up-to-date make(1)"
326 @echo "--------------------------------------------------------------"
327 ${_+_}@cd ${.CURDIR}/usr.bin/make; \
331 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
334 @cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe
337 @cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe
342 # Attempt to rebuild *everything* for all supported architectures,
343 # with a reasonable chance of success, regardless of how old your
344 # existing system is.
346 .if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
347 TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
348 TARGET_ARCHES_arm?= arm armeb
349 TARGET_ARCHES_mips?= mipsel mipseb mips64el mips64eb mipsn32eb
350 TARGET_ARCHES_powerpc?= powerpc powerpc64
351 TARGET_ARCHES_pc98?= i386
352 .for target in ${TARGETS}
353 TARGET_ARCHES_${target}?= ${target}
356 .if defined(UNIVERSE_TARGET)
357 MAKE_JUST_WORLDS= YES
359 UNIVERSE_TARGET?= buildworld
361 KERNSRCDIR?= ${.CURDIR}/sys
364 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
365 .for target in ${TARGETS}
366 .for target_arch in ${TARGET_ARCHES_${target}}
367 @echo " ${target}/${target_arch}"
371 .if defined(DOING_TINDERBOX)
372 FAILFILE=${.CURDIR}/_.tinderbox.failed
373 MAKEFAIL=tee -a ${FAILFILE}
378 universe: universe_prologue upgrade_checks
380 @echo "--------------------------------------------------------------"
381 @echo ">>> make universe started on ${STARTTIME}"
382 @echo "--------------------------------------------------------------"
383 .if defined(DOING_TINDERBOX)
386 .for target in ${TARGETS}
387 universe: universe_${target}
388 .ORDER: universe_prologue upgrade_checks universe_${target}_prologue universe_${target} universe_epilogue
389 universe_${target}: universe_${target}_prologue
390 universe_${target}_prologue:
391 @echo ">> ${target} started on `LC_ALL=C date`"
392 .if !defined(MAKE_JUST_KERNELS)
393 .for target_arch in ${TARGET_ARCHES_${target}}
394 universe_${target}: universe_${target}_${target_arch}
395 universe_${target}_${target_arch}: universe_${target}_prologue
396 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
397 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
398 ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
400 TARGET_ARCH=${target_arch} \
401 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
402 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
403 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
405 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
408 .if !defined(MAKE_JUST_WORLDS)
409 .if exists(${KERNSRCDIR}/${target}/conf/NOTES)
410 @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
411 ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
412 (echo "${target} 'make LINT' failed," \
413 "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
415 @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \
418 @echo ">> ${target} completed on `LC_ALL=C date`"
420 universe_kernels: universe_kernconfs
424 KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
425 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
426 ! -name DEFAULTS ! -name NOTES
428 .for kernel in ${KERNCONFS}
429 TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
430 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
431 grep -v WARNING: | cut -f 2
432 .if empty(TARGET_ARCH_${kernel})
433 .error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old."
435 universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
436 universe_kernconf_${TARGET}_${kernel}:
437 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
438 ${MAKE} ${JFLAG} buildkernel \
440 TARGET_ARCH=${TARGET_ARCH_${kernel}} \
442 > _.${TARGET}.${kernel} 2>&1 || \
443 (echo "${TARGET} ${kernel} kernel failed," \
444 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
446 universe: universe_epilogue
448 @echo "--------------------------------------------------------------"
449 @echo ">>> make universe completed on `LC_ALL=C date`"
450 @echo " (started ${STARTTIME})"
451 @echo "--------------------------------------------------------------"
452 .if defined(DOING_TINDERBOX)
453 @if [ -e ${FAILFILE} ] ; then \
454 echo "Tinderbox failed:" ;\