]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - Makefile
MFC r249316:
[FreeBSD/stable/8.git] / Makefile
1 #
2 # $FreeBSD$
3 #
4 # The user-driven targets are:
5 #
6 # universe            - *Really* build *everything* (buildworld and
7 #                       all kernels on all architectures).
8 # buildworld          - Rebuild *everything*, including glue to help do
9 #                       upgrades.
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.
14 # installkernel.debug
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.
29 #
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.
36 #
37 # The user-driven targets (as listed above) are implemented in Makefile.inc1.
38 #
39 # If you want to build your system from source be sure that /usr/obj has
40 # at least 800MB of diskspace available.
41 #
42 # For individuals wanting to build from the sources currently on their
43 # system, the simple instructions are:
44 #
45 # 1.  `cd /usr/src'  (or to the directory containing your source tree).
46 # 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
47 # 3.  `make world'
48 #
49 # For individuals wanting to upgrade their sources (even if only a
50 # delta of a few days):
51 #
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).
58 #  6.  `mergemaster -p'
59 #  7.  `make installworld'
60 #  8.  `make delete-old'
61 #  9.  `mergemaster'            (you may wish to use -i, along with -U or -F).
62 # 10.  `reboot'
63 # 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
64 #
65 # See src/UPDATING `COMMON ITEMS' for more complete information.
66 #
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
70 # buildkernel target.
71 #
72 # Define the user-driven targets. These are listed here in alphabetical
73 # order, but that's not important.
74 #
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.
78 #
79 # For more information, see the build(7) manual page.
80 #
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}
94
95 BITGTS= files includes
96 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
97 TGTS+=  ${BITGTS}
98
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
106
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.
115 .endif
116 MAKEPATH=       ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
117 BINMAKE= \
118         `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
119         -m ${.CURDIR}/share/mk
120 _MAKE=  PATH=${PATH} ${BINMAKE} -f Makefile.inc1
121
122 #
123 # Make sure we have an up-to-date make(1). Only world and buildworld
124 # should do this as those are the initial targets used for upgrades.
125 # The user can define ALWAYS_CHECK_MAKE to have this check performed
126 # for all targets.
127 #
128 .if defined(ALWAYS_CHECK_MAKE)
129 ${TGTS}: upgrade_checks
130 .else
131 buildworld: upgrade_checks
132 .endif
133
134 #
135 # This 'cleanworld' target is not included in TGTS, because it is not a
136 # recursive target.  All of the work for it is done right here.   It is
137 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
138 # created by bsd.obj.mk, except that we don't want to .include that file
139 # in this makefile.  
140 #
141 # In the following, the first 'rm' in a series will usually remove all
142 # files and directories.  If it does not, then there are probably some
143 # files with file flags set, so this unsets them and tries the 'rm' a
144 # second time.  There are situations where this target will be cleaning
145 # some directories via more than one method, but that duplication is
146 # needed to correctly handle all the possible situations.  Removing all
147 # files without file flags set in the first 'rm' instance saves time,
148 # because 'chflags' will need to operate on fewer files afterwards.
149 #
150 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
151 cleanworld:
152 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
153 .if exists(${BW_CANONICALOBJDIR}/)
154         -rm -rf ${BW_CANONICALOBJDIR}/*
155         -chflags -R 0 ${BW_CANONICALOBJDIR}
156         rm -rf ${BW_CANONICALOBJDIR}/*
157 .endif
158         #   To be safe in this case, fall back to a 'make cleandir'
159         ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
160 .else
161         -rm -rf ${.OBJDIR}/*
162         -chflags -R 0 ${.OBJDIR}
163         rm -rf ${.OBJDIR}/*
164 .endif
165
166 #
167 # Handle the user-driven targets, using the source relative mk files.
168 #
169
170 ${TGTS}:
171         ${_+_}@cd ${.CURDIR}; \
172                 ${_MAKE} ${.TARGET}
173
174 # Set a reasonable default
175 .MAIN:  all
176
177 STARTTIME!= LC_ALL=C date
178 CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s
179 .if !empty(CHECK_TIME)
180 .error check your date/time: ${STARTTIME}
181 .endif
182
183 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
184 #
185 # world
186 #
187 # Attempt to rebuild and reinstall everything. This target is not to be
188 # used for upgrading an existing FreeBSD system, because the kernel is
189 # not included. One can argue that this target doesn't build everything
190 # then.
191 #
192 world: upgrade_checks
193         @echo "--------------------------------------------------------------"
194         @echo ">>> make world started on ${STARTTIME}"
195         @echo "--------------------------------------------------------------"
196 .if target(pre-world)
197         @echo
198         @echo "--------------------------------------------------------------"
199         @echo ">>> Making 'pre-world' target"
200         @echo "--------------------------------------------------------------"
201         ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
202 .endif
203         ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
204         ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
205 .if target(post-world)
206         @echo
207         @echo "--------------------------------------------------------------"
208         @echo ">>> Making 'post-world' target"
209         @echo "--------------------------------------------------------------"
210         ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
211 .endif
212         @echo
213         @echo "--------------------------------------------------------------"
214         @echo ">>> make world completed on `LC_ALL=C date`"
215         @echo "                   (started ${STARTTIME})"
216         @echo "--------------------------------------------------------------"
217 .else
218 world:
219         @echo "WARNING: make world will overwrite your existing FreeBSD"
220         @echo "installation without also building and installing a new"
221         @echo "kernel.  This can be dangerous.  Please read the handbook,"
222         @echo "'Rebuilding world', for how to upgrade your system."
223         @echo "Define DESTDIR to where you want to install FreeBSD,"
224         @echo "including /, to override this warning and proceed as usual."
225         @echo ""
226         @echo "Bailing out now..."
227         @false
228 .endif
229
230 #
231 # kernel
232 #
233 # Short hand for `make buildkernel installkernel'
234 #
235 kernel: buildkernel installkernel
236
237 #
238 # Perform a few tests to determine if the installed tools are adequate
239 # for building the world.
240 #
241 upgrade_checks:
242         @if ! (cd ${.CURDIR}/tools/build/make_check && \
243             PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
244             PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
245         then \
246             (cd ${.CURDIR} && ${MAKE} make); \
247         fi
248
249 #
250 # Upgrade make(1) to the current version using the installed
251 # headers, libraries and tools.  Also, allow the location of
252 # the system bsdmake-like utility to be overridden.
253 #
254 MMAKEENV=       MAKEOBJDIRPREFIX=${MAKEPATH} \
255                 DESTDIR= \
256                 INSTALL="sh ${.CURDIR}/tools/install.sh"
257 MMAKE=          ${MMAKEENV} ${MAKE} \
258                 -D_UPGRADING \
259                 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
260                 -DNO_CPU_CFLAGS -DNO_WERROR
261
262 make: .PHONY
263         @echo
264         @echo "--------------------------------------------------------------"
265         @echo ">>> Building an up-to-date make(1)"
266         @echo "--------------------------------------------------------------"
267         ${_+_}@cd ${.CURDIR}/usr.bin/make; \
268                 ${MMAKE} obj && \
269                 ${MMAKE} depend && \
270                 ${MMAKE} all && \
271                 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
272
273 tinderbox:
274         @cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe
275
276 toolchains:
277         @cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe
278
279 #
280 # universe
281 #
282 # Attempt to rebuild *everything* for all supported architectures,
283 # with a reasonable chance of success, regardless of how old your
284 # existing system is.
285 #
286 .if make(universe) || make(universe_kernels) || make(tinderbox)
287 TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
288
289 .if defined(UNIVERSE_TARGET)
290 MAKE_JUST_WORLDS=       YES
291 .else
292 UNIVERSE_TARGET?=       buildworld
293 .endif
294 KERNSRCDIR?=            ${.CURDIR}/sys
295
296 .if defined(DOING_TINDERBOX)
297 FAILFILE=${.CURDIR}/_.tinderbox.failed
298 MAKEFAIL=tee -a ${FAILFILE}
299 .else
300 MAKEFAIL=cat
301 .endif
302
303 universe: universe_prologue upgrade_checks
304 universe_prologue:
305         @echo "--------------------------------------------------------------"
306         @echo ">>> make universe started on ${STARTTIME}"
307         @echo "--------------------------------------------------------------"
308 .if defined(DOING_TINDERBOX)
309         @rm -f ${FAILFILE}
310 .endif
311 .for target in ${TARGETS}
312 universe: universe_${target}
313 .ORDER: universe_prologue upgrade_checks universe_${target}_prologue universe_${target} universe_epilogue
314 universe_${target}:
315         @echo ">> ${target} started on `LC_ALL=C date`"
316 .if !defined(MAKE_JUST_KERNELS)
317         @echo ">> ${target} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
318         @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
319             ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
320             TARGET=${target} \
321             > _.${target}.${UNIVERSE_TARGET} 2>&1 || \
322             (echo "${target} ${UNIVERSE_TARGET} failed," \
323             "check _.${target}.${UNIVERSE_TARGET} for details" | ${MAKEFAIL}))
324         @echo ">> ${target} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
325 .endif
326 .if !defined(MAKE_JUST_WORLDS)
327 .if exists(${KERNSRCDIR}/${target}/conf/NOTES)
328         @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
329             ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
330             (echo "${target} 'make LINT' failed," \
331             "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
332 .endif
333         @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \
334             universe_kernels
335 .endif
336         @echo ">> ${target} completed on `LC_ALL=C date`"
337 .endfor
338 universe_kernels: universe_kernconfs
339 .if !defined(TARGET)
340 TARGET!=        uname -m
341 .endif
342 KERNCONFS!=     cd ${KERNSRCDIR}/${TARGET}/conf && \
343                 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
344                 ! -name DEFAULTS ! -name NOTES
345 universe_kernconfs:
346 .for kernel in ${KERNCONFS}
347         @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
348             ${MAKE} ${JFLAG} buildkernel \
349             TARGET=${TARGET} \
350             KERNCONF=${kernel} \
351             > _.${TARGET}.${kernel} 2>&1 || \
352             (echo "${TARGET} ${kernel} kernel failed," \
353             "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
354 .endfor
355 universe: universe_epilogue
356 universe_epilogue:
357         @echo "--------------------------------------------------------------"
358         @echo ">>> make universe completed on `LC_ALL=C date`"
359         @echo "                      (started ${STARTTIME})"
360         @echo "--------------------------------------------------------------"
361 .if defined(DOING_TINDERBOX)
362         @if [ -e ${FAILFILE} ] ; then \
363                 echo "Tinderbox failed:" ;\
364                 cat ${FAILFILE} ;\
365                 exit 1 ;\
366         fi
367 .endif
368 .endif