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_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
59 # cross build world for other architectures 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 TGTS= all all-man buildenv buildkernel buildworld check-old checkdpadd \
71 clean cleandepend cleandir delete-old delete-old-libs depend \
72 distribute distributeworld distrib-dirs distribution everything \
73 hierarchy install installcheck installkernel installkernel.debug\
74 reinstallkernel reinstallkernel.debug installworld \
75 kernel-toolchain libraries lint maninstall \
76 obj objlink regress rerelease tags toolchain update \
77 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
78 _build-tools _cross-tools _includes _libraries _depend \
79 build32 distribute32 install32
81 BITGTS= files includes
82 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
85 .ORDER: buildworld installworld
86 .ORDER: buildworld distributeworld
87 .ORDER: buildworld buildkernel
88 .ORDER: buildkernel installkernel
89 .ORDER: buildkernel installkernel.debug
90 .ORDER: buildkernel reinstallkernel
91 .ORDER: buildkernel reinstallkernel.debug
93 PATH= /sbin:/bin:/usr/sbin:/usr/bin
94 MAKEOBJDIRPREFIX?= /usr/obj
95 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
96 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \
97 -f /dev/null -V MAKEOBJDIRPREFIX dummy
98 .if !empty(_MAKEOBJDIRPREFIX)
99 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
100 (in /etc/make.conf) or command-line variable.
102 MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
104 `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
105 -m ${.CURDIR}/share/mk
106 _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1
109 # Make sure we have an up-to-date make(1). Only world and buildworld
110 # should do this as those are the initial targets used for upgrades.
111 # The user can define ALWAYS_CHECK_MAKE to have this check performed
114 .if defined(ALWAYS_CHECK_MAKE)
115 ${TGTS}: upgrade_checks
117 buildworld: upgrade_checks
121 # This 'cleanworld' target is not included in TGTS, because it is not a
122 # recursive target. All of the work for it is done right here. It is
123 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
124 # created by bsd.obj.mk, except that we don't want to .include that file
127 # In the following, the first 'rm' in a series will usually remove all
128 # files and directories. If it does not, then there are probably some
129 # files with chflags set, so this unsets them and tries the 'rm' a
130 # second time. There are situations where this target will be cleaning
131 # some directories via more than one method, but that duplication is
132 # needed to correctly handle all the possible situations.
134 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
136 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
137 .if exists(${BW_CANONICALOBJDIR}/)
138 -rm -rf ${BW_CANONICALOBJDIR}/*
139 chflags -R 0 ${BW_CANONICALOBJDIR}
140 rm -rf ${BW_CANONICALOBJDIR}/*
142 # To be safe in this case, fall back to a 'make cleandir'
143 ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
146 chflags -R 0 ${.OBJDIR}
151 # Handle the user-driven targets, using the source relative mk files.
155 ${_+_}@cd ${.CURDIR}; \
158 # Set a reasonable default
161 STARTTIME!= LC_ALL=C date
163 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
167 # Attempt to rebuild and reinstall everything. This target is not to be
168 # used for upgrading an existing FreeBSD system, because the kernel is
169 # not included. One can argue that this target doesn't build everything
172 world: upgrade_checks
173 @echo "--------------------------------------------------------------"
174 @echo ">>> make world started on ${STARTTIME}"
175 @echo "--------------------------------------------------------------"
176 .if target(pre-world)
178 @echo "--------------------------------------------------------------"
179 @echo ">>> Making 'pre-world' target"
180 @echo "--------------------------------------------------------------"
181 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
183 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
184 ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
185 .if target(post-world)
187 @echo "--------------------------------------------------------------"
188 @echo ">>> Making 'post-world' target"
189 @echo "--------------------------------------------------------------"
190 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
193 @echo "--------------------------------------------------------------"
194 @echo ">>> make world completed on `LC_ALL=C date`"
195 @echo " (started ${STARTTIME})"
196 @echo "--------------------------------------------------------------"
199 @echo "WARNING: make world will overwrite your existing FreeBSD"
200 @echo "installation without also building and installing a new"
201 @echo "kernel. This can be dangerous. Please read the handbook,"
202 @echo "'Rebuilding world', for how to upgrade your system."
203 @echo "Define DESTDIR to where you want to install FreeBSD,"
204 @echo "including /, to override this warning and proceed as usual."
205 @echo "You may get the historical 'make world' behavior by defining"
206 @echo "HISTORICAL_MAKE_WORLD. You should understand the implications"
207 @echo "before doing this."
209 @echo "Bailing out now..."
216 # Short hand for `make buildkernel installkernel'
218 kernel: buildkernel installkernel
221 # Perform a few tests to determine if the installed tools are adequate
222 # for building the world.
225 @if ! (cd ${.CURDIR}/tools/build/make_check && \
226 PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
227 PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
229 (cd ${.CURDIR} && make make); \
233 # Upgrade make(1) to the current version using the installed
234 # headers, libraries and tools.
236 MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
238 INSTALL="sh ${.CURDIR}/tools/install.sh"
239 MMAKE= ${MMAKEENV} make \
241 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
242 -DNO_CPU_CFLAGS -DNO_WERROR
246 @echo "--------------------------------------------------------------"
247 @echo ">>> Building an up-to-date make(1)"
248 @echo "--------------------------------------------------------------"
249 ${_+_}@cd ${.CURDIR}/usr.bin/make; \
253 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
258 # Attempt to rebuild *everything* for all supported architectures,
259 # with a reasonable chance of success, regardless of how old your
260 # existing system is.
263 universe: universe_prologue
265 @echo "--------------------------------------------------------------"
266 @echo ">>> make universe started on ${STARTTIME}"
267 @echo "--------------------------------------------------------------"
268 .for target in i386 i386:pc98 sparc64 alpha ia64 amd64
269 .for arch in ${target:C/:.*$//}
270 .for mach in ${target:C/^.*://}
271 KERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \
272 find [A-Z]*[A-Z] -type f -maxdepth 0
273 KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/}
274 universe: universe_${mach}
275 .ORDER: universe_prologue universe_${mach} universe_epilogue
277 @echo ">> ${mach} started on `LC_ALL=C date`"
278 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \
279 TARGET_ARCH=${arch} TARGET=${mach} \
280 __MAKE_CONF=/dev/null \
281 > _.${mach}.buildworld 2>&1
282 @echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
283 .if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
284 -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
285 > ${.CURDIR}/_.${mach}.makeLINT 2>&1
287 .for kernel in ${KERNCONFS}
288 -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \
289 TARGET_ARCH=${arch} TARGET=${mach} \
291 __MAKE_CONF=/dev/null \
292 > _.${mach}.${kernel} 2>&1
294 @echo ">> ${mach} completed on `LC_ALL=C date`"
298 universe: universe_epilogue
300 @echo "--------------------------------------------------------------"
301 @echo ">>> make universe completed on `LC_ALL=C date`"
302 @echo " (started ${STARTTIME})"
303 @echo "--------------------------------------------------------------"