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).
19 # check-old - Print a list of old files/directories in the system.
20 # delete-old - Delete obsolete files and directories interactively.
21 # delete-old-libs - Delete obsolete libraries interactively.
23 # This makefile is simple by design. The FreeBSD make automatically reads
24 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
25 # command line. By keeping this makefile simple, it doesn't matter too
26 # much how different the installed mk files are from those in the source
27 # tree. This makefile executes a child make process, forcing it to use
28 # the mk files from the source tree which are supposed to DTRT.
30 # The user-driven targets (as listed above) are implemented in Makefile.inc1.
32 # If you want to build your system from source be sure that /usr/obj has
33 # at least 400MB of diskspace available.
35 # For individuals wanting to build from the sources currently on their
36 # system, the simple instructions are:
38 # 1. `cd /usr/src' (or to the directory containing your source tree).
41 # For individuals wanting to upgrade their sources (even if only a
42 # delta of a few days):
44 # 1. `cd /usr/src' (or to the directory containing your source tree).
45 # 2. `make buildworld'
46 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
47 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
48 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
50 # 7. `make installworld'
51 # 8. `make delete-old'
54 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
56 # See src/UPDATING `COMMON ITEMS' for more complete information.
58 # If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
59 # cross build world for other machine types using the buildworld target,
60 # and once the world is built you can cross build a kernel using the
63 # Define the user-driven targets. These are listed here in alphabetical
64 # order, but that's not important.
66 # Targets that begin with underscore are internal targets intended for
67 # developer convenience only. They are intentionally not documented and
68 # completely subject to change without notice.
70 # For more information, see the build(7) manual page.
72 TGTS= all all-man buildenv buildkernel buildworld check-old checkdpadd \
73 clean cleandepend cleandir delete-old delete-old-libs depend \
74 distribute distributeworld distrib-dirs distribution everything \
75 hierarchy install installcheck installkernel installkernel.debug\
76 reinstallkernel reinstallkernel.debug installworld \
77 kernel-toolchain libraries lint maninstall \
78 obj objlink regress rerelease tags toolchain update \
79 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
80 _build-tools _cross-tools _includes _libraries _depend \
81 build32 distribute32 install32
83 BITGTS= files includes
84 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
87 .ORDER: buildworld installworld
88 .ORDER: buildworld distributeworld
89 .ORDER: buildworld buildkernel
90 .ORDER: buildkernel installkernel
91 .ORDER: buildkernel installkernel.debug
92 .ORDER: buildkernel reinstallkernel
93 .ORDER: buildkernel reinstallkernel.debug
95 PATH= /sbin:/bin:/usr/sbin:/usr/bin
96 MAKEOBJDIRPREFIX?= /usr/obj
97 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
98 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
99 -f /dev/null -V MAKEOBJDIRPREFIX dummy
100 .if !empty(_MAKEOBJDIRPREFIX)
101 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
102 (in make.conf(5)) or command-line variable.
104 MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
106 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
107 -m ${.CURDIR}/share/mk
108 _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1
111 # Make sure we have an up-to-date make(1). Only world and buildworld
112 # should do this as those are the initial targets used for upgrades.
113 # The user can define ALWAYS_CHECK_MAKE to have this check performed
116 .if defined(ALWAYS_CHECK_MAKE)
117 ${TGTS}: upgrade_checks
119 buildworld: upgrade_checks
123 # This 'cleanworld' target is not included in TGTS, because it is not a
124 # recursive target. All of the work for it is done right here. It is
125 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
126 # created by bsd.obj.mk, except that we don't want to .include that file
129 # In the following, the first 'rm' in a series will usually remove all
130 # files and directories. If it does not, then there are probably some
131 # files with chflags set, so this unsets them and tries the 'rm' a
132 # second time. There are situations where this target will be cleaning
133 # some directories via more than one method, but that duplication is
134 # needed to correctly handle all the possible situations.
136 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
138 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
139 .if exists(${BW_CANONICALOBJDIR}/)
140 -rm -rf ${BW_CANONICALOBJDIR}/*
141 chflags -R 0 ${BW_CANONICALOBJDIR}
142 rm -rf ${BW_CANONICALOBJDIR}/*
144 # To be safe in this case, fall back to a 'make cleandir'
145 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
148 chflags -R 0 ${.OBJDIR}
153 # Handle the user-driven targets, using the source relative mk files.
157 ${_+_}@cd ${.CURDIR}; \
160 # Set a reasonable default
163 STARTTIME!= LC_ALL=C date
165 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
169 # Attempt to rebuild and reinstall everything. This target is not to be
170 # used for upgrading an existing FreeBSD system, because the kernel is
171 # not included. One can argue that this target doesn't build everything
174 world: upgrade_checks
175 @echo "--------------------------------------------------------------"
176 @echo ">>> make world started on ${STARTTIME}"
177 @echo "--------------------------------------------------------------"
178 .if target(pre-world)
180 @echo "--------------------------------------------------------------"
181 @echo ">>> Making 'pre-world' target"
182 @echo "--------------------------------------------------------------"
183 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
185 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
186 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
187 .if target(post-world)
189 @echo "--------------------------------------------------------------"
190 @echo ">>> Making 'post-world' target"
191 @echo "--------------------------------------------------------------"
192 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
195 @echo "--------------------------------------------------------------"
196 @echo ">>> make world completed on `LC_ALL=C date`"
197 @echo " (started ${STARTTIME})"
198 @echo "--------------------------------------------------------------"
201 @echo "WARNING: make world will overwrite your existing FreeBSD"
202 @echo "installation without also building and installing a new"
203 @echo "kernel. This can be dangerous. Please read the handbook,"
204 @echo "'Rebuilding world', for how to upgrade your system."
205 @echo "Define DESTDIR to where you want to install FreeBSD,"
206 @echo "including /, to override this warning and proceed as usual."
207 @echo "You may get the historical 'make world' behavior by defining"
208 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications"
209 @echo "before doing this."
211 @echo "Bailing out now..."
218 # Short hand for `make buildkernel installkernel'
220 kernel: buildkernel installkernel
223 # Perform a few tests to determine if the installed tools are adequate
224 # for building the world.
227 @if ! (cd ${.CURDIR}/tools/build/make_check && \
228 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
229 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
231 (cd ${.CURDIR} && make make); \
235 # Upgrade make(1) to the current version using the installed
236 # headers, libraries and tools.
238 MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
240 INSTALL="sh ${.CURDIR}/tools/install.sh"
241 MMAKE= ${MMAKEENV} make \
243 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
244 -DNO_CPU_CFLAGS -DNO_WERROR
248 @echo "--------------------------------------------------------------"
249 @echo ">>> Building an up-to-date make(1)"
250 @echo "--------------------------------------------------------------"
251 ${_+_}@cd ${.CURDIR}/usr.bin/make; \
255 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
260 # Attempt to rebuild *everything* for all supported architectures,
261 # with a reasonable chance of success, regardless of how old your
262 # existing system is.
265 universe: universe_prologue
267 @echo "--------------------------------------------------------------"
268 @echo ">>> make universe started on ${STARTTIME}"
269 @echo "--------------------------------------------------------------"
270 .for target in alpha amd64 i386 ia64 pc98 powerpc sparc64
271 KERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \
272 find [A-Z]*[A-Z] -type f -maxdepth 0 \
273 ! -name DEFAULTS ! -name LINT
274 KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/}
275 universe: universe_${target}
276 .ORDER: universe_prologue universe_${target} universe_epilogue
278 @echo ">> ${target} started on `LC_ALL=C date`"
279 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \
281 __MAKE_CONF=/dev/null \
282 > _.${target}.buildworld 2>&1
283 @echo ">> ${target} buildworld completed on `LC_ALL=C date`"
284 .if exists(${.CURDIR}/sys/${target}/conf/NOTES)
285 -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \
286 > ${.CURDIR}/_.${target}.makeLINT 2>&1
288 .for kernel in ${KERNCONFS}
289 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \
292 __MAKE_CONF=/dev/null \
293 > _.${target}.${kernel} 2>&1
295 @echo ">> ${target} completed on `LC_ALL=C date`"
297 universe: universe_epilogue
299 @echo "--------------------------------------------------------------"
300 @echo ">>> make universe completed on `LC_ALL=C date`"
301 @echo " (started ${STARTTIME})"
302 @echo "--------------------------------------------------------------"