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, no kernel.
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 # doxygen - Build API documentation of the kernel, needs doxygen.
19 # update - Convenient way to update your source tree (cvs).
20 # check-old - List obsolete directories/files/libraries.
21 # check-old-dirs - List obsolete directories.
22 # check-old-files - List obsolete files.
23 # check-old-libs - List obsolete libraries.
24 # delete-old - Delete obsolete directories/files.
25 # delete-old-dirs - Delete obsolete directories.
26 # delete-old-files - Delete obsolete files.
27 # delete-old-libs - Delete obsolete libraries.
28 # toolchains - Build a toolchain for all world and kernel targets.
30 # This makefile is simple by design. The FreeBSD make automatically reads
31 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
32 # command line. By keeping this makefile simple, it doesn't matter too
33 # much how different the installed mk files are from those in the source
34 # tree. This makefile executes a child make process, forcing it to use
35 # the mk files from the source tree which are supposed to DTRT.
37 # The user-driven targets (as listed above) are implemented in Makefile.inc1.
39 # If you want to build your system from source be sure that /usr/obj has
40 # at least 800MB of diskspace available.
42 # For individuals wanting to build from the sources currently on their
43 # system, the simple instructions are:
45 # 1. `cd /usr/src' (or to the directory containing your source tree).
46 # 2. Define `HISTORICAL_MAKE_WORLD' variable (see README).
49 # For individuals wanting to upgrade their sources (even if only a
50 # delta of a few days):
52 # 1. `cd /usr/src' (or to the directory containing your source tree).
53 # 2. `make buildworld'
54 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
55 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
56 # [steps 3. & 4. can be combined by using the "kernel" target]
57 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
59 # 7. `make installworld'
60 # 8. `make delete-old'
61 # 9. `mergemaster' (you may wish to use -i, along with -U or -F).
63 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
65 # See src/UPDATING `COMMON ITEMS' for more complete information.
67 # If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
68 # cross build world for other machine types using the buildworld target,
69 # and once the world is built you can cross build a kernel using the
72 # Define the user-driven targets. These are listed here in alphabetical
73 # order, but that's not important.
75 # Targets that begin with underscore are internal targets intended for
76 # developer convenience only. They are intentionally not documented and
77 # completely subject to change without notice.
79 # For more information, see the build(7) manual page.
81 TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
82 check-old check-old-dirs check-old-files check-old-libs \
83 checkdpadd clean cleandepend cleandir \
84 delete-old delete-old-dirs delete-old-files delete-old-libs \
85 depend distribute distributeworld distrib-dirs distribution doxygen \
86 everything hierarchy install installcheck installkernel \
87 installkernel.debug reinstallkernel reinstallkernel.debug \
88 installworld kernel-toolchain libraries lint maninstall \
89 obj objlink regress rerelease showconfig tags toolchain update \
90 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
91 _build-tools _cross-tools _includes _libraries _depend \
92 build32 distribute32 install32 xdev xdev-build xdev-install
93 TGTS+= ${SUBDIR_TARGETS}
95 BITGTS= files includes
96 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
99 .ORDER: buildworld installworld
100 .ORDER: buildworld distributeworld
101 .ORDER: buildworld buildkernel
102 .ORDER: buildkernel installkernel
103 .ORDER: buildkernel installkernel.debug
104 .ORDER: buildkernel reinstallkernel
105 .ORDER: buildkernel reinstallkernel.debug
107 PATH= /sbin:/bin:/usr/sbin:/usr/bin
108 MAKEOBJDIRPREFIX?= /usr/obj
109 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
110 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
111 -f /dev/null -V MAKEOBJDIRPREFIX dummy
112 .if !empty(_MAKEOBJDIRPREFIX)
113 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
114 (in make.conf(5)) or command-line variable.
116 MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
118 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
119 -m ${.CURDIR}/share/mk
121 .if defined(.PARSEDIR)
122 # don't pass -J to fmake
123 _MAKE= PATH=${PATH} MAKEFLAGS="${MAKEFLAGS:N-J:N1*,1*}" ${BINMAKE} -f Makefile.inc1
125 _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1
129 # Make sure we have an up-to-date make(1). Only world and buildworld
130 # should do this as those are the initial targets used for upgrades.
131 # The user can define ALWAYS_CHECK_MAKE to have this check performed
134 .if defined(ALWAYS_CHECK_MAKE)
135 ${TGTS}: upgrade_checks
137 buildworld: upgrade_checks
141 # This 'cleanworld' target is not included in TGTS, because it is not a
142 # recursive target. All of the work for it is done right here. It is
143 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
144 # created by bsd.obj.mk, except that we don't want to .include that file
147 # In the following, the first 'rm' in a series will usually remove all
148 # files and directories. If it does not, then there are probably some
149 # files with file flags set, so this unsets them and tries the 'rm' a
150 # second time. There are situations where this target will be cleaning
151 # some directories via more than one method, but that duplication is
152 # needed to correctly handle all the possible situations. Removing all
153 # files without file flags set in the first 'rm' instance saves time,
154 # because 'chflags' will need to operate on fewer files afterwards.
156 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
158 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
159 .if exists(${BW_CANONICALOBJDIR}/)
160 -rm -rf ${BW_CANONICALOBJDIR}/*
161 -chflags -R 0 ${BW_CANONICALOBJDIR}
162 rm -rf ${BW_CANONICALOBJDIR}/*
164 # To be safe in this case, fall back to a 'make cleandir'
165 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
168 -chflags -R 0 ${.OBJDIR}
173 # Handle the user-driven targets, using the source relative mk files.
177 ${_+_}@cd ${.CURDIR}; \
180 # Set a reasonable default
183 STARTTIME!= LC_ALL=C date
184 CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s; echo
185 .if !empty(CHECK_TIME)
186 .error check your date/time: ${STARTTIME}
189 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
193 # Attempt to rebuild and reinstall everything. This target is not to be
194 # used for upgrading an existing FreeBSD system, because the kernel is
195 # not included. One can argue that this target doesn't build everything
198 world: upgrade_checks
199 @echo "--------------------------------------------------------------"
200 @echo ">>> make world started on ${STARTTIME}"
201 @echo "--------------------------------------------------------------"
202 .if target(pre-world)
204 @echo "--------------------------------------------------------------"
205 @echo ">>> Making 'pre-world' target"
206 @echo "--------------------------------------------------------------"
207 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
209 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
210 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
211 .if target(post-world)
213 @echo "--------------------------------------------------------------"
214 @echo ">>> Making 'post-world' target"
215 @echo "--------------------------------------------------------------"
216 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
219 @echo "--------------------------------------------------------------"
220 @echo ">>> make world completed on `LC_ALL=C date`"
221 @echo " (started ${STARTTIME})"
222 @echo "--------------------------------------------------------------"
225 @echo "WARNING: make world will overwrite your existing FreeBSD"
226 @echo "installation without also building and installing a new"
227 @echo "kernel. This can be dangerous. Please read the handbook,"
228 @echo "'Rebuilding world', for how to upgrade your system."
229 @echo "Define DESTDIR to where you want to install FreeBSD,"
230 @echo "including /, to override this warning and proceed as usual."
232 @echo "Bailing out now..."
239 # Short hand for `make buildkernel installkernel'
241 kernel: buildkernel installkernel
244 # Perform a few tests to determine if the installed tools are adequate
245 # for building the world.
248 @if ! (cd ${.CURDIR}/tools/build/make_check && \
249 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
250 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
252 (cd ${.CURDIR} && ${MAKE} make); \
256 # Upgrade make(1) to the current version using the installed
257 # headers, libraries and tools. Also, allow the location of
258 # the system bsdmake-like utility to be overridden.
260 MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
262 INSTALL="sh ${.CURDIR}/tools/install.sh"
263 MMAKE= ${MMAKEENV} ${MAKE} \
265 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
266 -DNO_CPU_CFLAGS -DNO_WERROR
270 @echo "--------------------------------------------------------------"
271 @echo ">>> Building an up-to-date make(1)"
272 @echo "--------------------------------------------------------------"
273 ${_+_}@cd ${.CURDIR}/usr.bin/make; \
277 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
280 @cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe
283 @cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe
288 # Attempt to rebuild *everything* for all supported architectures,
289 # with a reasonable chance of success, regardless of how old your
290 # existing system is.
292 .if make(universe) || make(universe_kernels) || make(tinderbox)
293 TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
295 .if defined(UNIVERSE_TARGET)
296 MAKE_JUST_WORLDS= YES
298 UNIVERSE_TARGET?= buildworld
300 KERNSRCDIR?= ${.CURDIR}/sys
302 .if defined(DOING_TINDERBOX)
303 FAILFILE=${.CURDIR}/_.tinderbox.failed
304 MAKEFAIL=tee -a ${FAILFILE}
309 universe: universe_prologue upgrade_checks
311 @echo "--------------------------------------------------------------"
312 @echo ">>> make universe started on ${STARTTIME}"
313 @echo "--------------------------------------------------------------"
314 .if defined(DOING_TINDERBOX)
317 .for target in ${TARGETS}
318 universe: universe_${target}
319 .ORDER: universe_prologue upgrade_checks universe_${target}_prologue universe_${target} universe_epilogue
321 @echo ">> ${target} started on `LC_ALL=C date`"
322 .if !defined(MAKE_JUST_KERNELS)
323 @echo ">> ${target} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
324 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
325 ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
327 > _.${target}.${UNIVERSE_TARGET} 2>&1 || \
328 (echo "${target} ${UNIVERSE_TARGET} failed," \
329 "check _.${target}.${UNIVERSE_TARGET} for details" | ${MAKEFAIL}))
330 @echo ">> ${target} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
332 .if !defined(MAKE_JUST_WORLDS)
333 .if exists(${KERNSRCDIR}/${target}/conf/NOTES)
334 @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
335 ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
336 (echo "${target} 'make LINT' failed," \
337 "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
339 @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \
342 @echo ">> ${target} completed on `LC_ALL=C date`"
344 universe_kernels: universe_kernconfs
348 KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
349 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
350 ! -name DEFAULTS ! -name NOTES
352 .for kernel in ${KERNCONFS}
353 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
354 ${MAKE} ${JFLAG} buildkernel \
357 > _.${TARGET}.${kernel} 2>&1 || \
358 (echo "${TARGET} ${kernel} kernel failed," \
359 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
361 universe: universe_epilogue
363 @echo "--------------------------------------------------------------"
364 @echo ">>> make universe completed on `LC_ALL=C date`"
365 @echo " (started ${STARTTIME})"
366 @echo "--------------------------------------------------------------"
367 .if defined(DOING_TINDERBOX)
368 @if [ -e ${FAILFILE} ] ; then \
369 echo "Tinderbox failed:" ;\