]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - Makefile
Fix named(8) DNSSEC validation Denial of Service.
[FreeBSD/releng/8.2.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/libraries.
25 # delete-old-dirs     - Delete obsolete directories.
26 # delete-old-files    - Delete obsolete files.
27 # delete-old-libs     - Delete obsolete libraries.
28 #
29 # This makefile is simple by design. The FreeBSD make automatically reads
30 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
31 # command line. By keeping this makefile simple, it doesn't matter too
32 # much how different the installed mk files are from those in the source
33 # tree. This makefile executes a child make process, forcing it to use
34 # the mk files from the source tree which are supposed to DTRT.
35 #
36 # The user-driven targets (as listed above) are implemented in Makefile.inc1.
37 #
38 # If you want to build your system from source be sure that /usr/obj has
39 # at least 800MB of diskspace available.
40 #
41 # For individuals wanting to build from the sources currently on their
42 # system, the simple instructions are:
43 #
44 # 1.  `cd /usr/src'  (or to the directory containing your source tree).
45 # 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
46 # 3.  `make world'
47 #
48 # For individuals wanting to upgrade their sources (even if only a
49 # delta of a few days):
50 #
51 #  1.  `cd /usr/src'       (or to the directory containing your source tree).
52 #  2.  `make buildworld'
53 #  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
54 #  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
55 #       [steps 3. & 4. can be combined by using the "kernel" target]
56 #  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
57 #  6.  `mergemaster -p'
58 #  7.  `make installworld'
59 #  8.  `make delete-old'
60 #  9.  `mergemaster'                         (you may wish to use -U or -ai).
61 # 10.  `reboot'
62 # 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
63 #
64 # See src/UPDATING `COMMON ITEMS' for more complete information.
65 #
66 # If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
67 # cross build world for other machine types using the buildworld target,
68 # and once the world is built you can cross build a kernel using the
69 # buildkernel target.
70 #
71 # Define the user-driven targets. These are listed here in alphabetical
72 # order, but that's not important.
73 #
74 # Targets that begin with underscore are internal targets intended for
75 # developer convenience only.  They are intentionally not documented and
76 # completely subject to change without notice.
77 #
78 # For more information, see the build(7) manual page.
79 #
80 TGTS=   all all-man buildenv buildenvvars buildkernel buildworld \
81         check-old check-old-dirs check-old-files check-old-libs \
82         checkdpadd clean cleandepend cleandir \
83         delete-old delete-old-dirs delete-old-files delete-old-libs \
84         depend distribute distributeworld distrib-dirs distribution doxygen \
85         everything hierarchy install installcheck installkernel \
86         installkernel.debug reinstallkernel reinstallkernel.debug \
87         installworld kernel-toolchain libraries lint maninstall \
88         obj objlink regress rerelease showconfig tags toolchain update \
89         _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
90         _build-tools _cross-tools _includes _libraries _depend \
91         build32 distribute32 install32 xdev xdev-build xdev-install
92 TGTS+=  ${SUBDIR_TARGETS}
93
94 BITGTS= files includes
95 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
96 TGTS+=  ${BITGTS}
97
98 .ORDER: buildworld installworld
99 .ORDER: buildworld distributeworld
100 .ORDER: buildworld buildkernel
101 .ORDER: buildkernel installkernel
102 .ORDER: buildkernel installkernel.debug
103 .ORDER: buildkernel reinstallkernel
104 .ORDER: buildkernel reinstallkernel.debug
105
106 PATH=   /sbin:/bin:/usr/sbin:/usr/bin
107 MAKEOBJDIRPREFIX?=      /usr/obj
108 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
109     ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
110     -f /dev/null -V MAKEOBJDIRPREFIX dummy
111 .if !empty(_MAKEOBJDIRPREFIX)
112 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
113         (in make.conf(5)) or command-line variable.
114 .endif
115 MAKEPATH=       ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
116 BINMAKE= \
117         `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
118         -m ${.CURDIR}/share/mk
119 _MAKE=  PATH=${PATH} ${BINMAKE} -f Makefile.inc1
120
121 #
122 # Make sure we have an up-to-date make(1). Only world and buildworld
123 # should do this as those are the initial targets used for upgrades.
124 # The user can define ALWAYS_CHECK_MAKE to have this check performed
125 # for all targets.
126 #
127 .if defined(ALWAYS_CHECK_MAKE)
128 ${TGTS}: upgrade_checks
129 .else
130 buildworld: upgrade_checks
131 .endif
132
133 #
134 # This 'cleanworld' target is not included in TGTS, because it is not a
135 # recursive target.  All of the work for it is done right here.   It is
136 # expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
137 # created by bsd.obj.mk, except that we don't want to .include that file
138 # in this makefile.  
139 #
140 # In the following, the first 'rm' in a series will usually remove all
141 # files and directories.  If it does not, then there are probably some
142 # files with chflags set, so this unsets them and tries the 'rm' a
143 # second time.  There are situations where this target will be cleaning
144 # some directories via more than one method, but that duplication is
145 # needed to correctly handle all the possible situations.
146 #
147 BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
148 cleanworld:
149 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
150 .if exists(${BW_CANONICALOBJDIR}/)
151         -rm -rf ${BW_CANONICALOBJDIR}/*
152         -chflags -R 0 ${BW_CANONICALOBJDIR}
153         rm -rf ${BW_CANONICALOBJDIR}/*
154 .endif
155         #   To be safe in this case, fall back to a 'make cleandir'
156         ${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
157 .else
158         -rm -rf ${.OBJDIR}/*
159         -chflags -R 0 ${.OBJDIR}
160         rm -rf ${.OBJDIR}/*
161 .endif
162
163 #
164 # Handle the user-driven targets, using the source relative mk files.
165 #
166
167 ${TGTS}:
168         ${_+_}@cd ${.CURDIR}; \
169                 ${_MAKE} ${.TARGET}
170
171 # Set a reasonable default
172 .MAIN:  all
173
174 STARTTIME!= LC_ALL=C date
175 CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0
176 .if !empty(CHECK_TIME)
177 .error check your date/time: ${STARTTIME}
178 .endif
179
180 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
181 #
182 # world
183 #
184 # Attempt to rebuild and reinstall everything. This target is not to be
185 # used for upgrading an existing FreeBSD system, because the kernel is
186 # not included. One can argue that this target doesn't build everything
187 # then.
188 #
189 world: upgrade_checks
190         @echo "--------------------------------------------------------------"
191         @echo ">>> make world started on ${STARTTIME}"
192         @echo "--------------------------------------------------------------"
193 .if target(pre-world)
194         @echo
195         @echo "--------------------------------------------------------------"
196         @echo ">>> Making 'pre-world' target"
197         @echo "--------------------------------------------------------------"
198         ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
199 .endif
200         ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
201         ${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
202 .if target(post-world)
203         @echo
204         @echo "--------------------------------------------------------------"
205         @echo ">>> Making 'post-world' target"
206         @echo "--------------------------------------------------------------"
207         ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
208 .endif
209         @echo
210         @echo "--------------------------------------------------------------"
211         @echo ">>> make world completed on `LC_ALL=C date`"
212         @echo "                   (started ${STARTTIME})"
213         @echo "--------------------------------------------------------------"
214 .else
215 world:
216         @echo "WARNING: make world will overwrite your existing FreeBSD"
217         @echo "installation without also building and installing a new"
218         @echo "kernel.  This can be dangerous.  Please read the handbook,"
219         @echo "'Rebuilding world', for how to upgrade your system."
220         @echo "Define DESTDIR to where you want to install FreeBSD,"
221         @echo "including /, to override this warning and proceed as usual."
222         @echo ""
223         @echo "Bailing out now..."
224         @false
225 .endif
226
227 #
228 # kernel
229 #
230 # Short hand for `make buildkernel installkernel'
231 #
232 kernel: buildkernel installkernel
233
234 #
235 # Perform a few tests to determine if the installed tools are adequate
236 # for building the world.
237 #
238 upgrade_checks:
239         @if ! (cd ${.CURDIR}/tools/build/make_check && \
240             PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
241             PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
242         then \
243             (cd ${.CURDIR} && ${MAKE} make); \
244         fi
245
246 #
247 # Upgrade make(1) to the current version using the installed
248 # headers, libraries and tools.  Also, allow the location of
249 # the system bsdmake-like utility to be overridden.
250 #
251 MMAKEENV=       MAKEOBJDIRPREFIX=${MAKEPATH} \
252                 DESTDIR= \
253                 INSTALL="sh ${.CURDIR}/tools/install.sh"
254 MMAKE=          ${MMAKEENV} ${MAKE} \
255                 -D_UPGRADING \
256                 -DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
257                 -DNO_CPU_CFLAGS -DNO_WERROR
258
259 make: .PHONY
260         @echo
261         @echo "--------------------------------------------------------------"
262         @echo ">>> Building an up-to-date make(1)"
263         @echo "--------------------------------------------------------------"
264         ${_+_}@cd ${.CURDIR}/usr.bin/make; \
265                 ${MMAKE} obj && \
266                 ${MMAKE} depend && \
267                 ${MMAKE} all && \
268                 ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
269
270 tinderbox:
271         cd ${.CURDIR} && \
272                 DOING_TINDERBOX=YES ${MAKE} ${JFLAG} universe
273
274 #
275 # universe
276 #
277 # Attempt to rebuild *everything* for all supported architectures,
278 # with a reasonable chance of success, regardless of how old your
279 # existing system is.
280 #
281 .if make(universe) || make(universe_kernels) || make(tinderbox)
282 TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 sun4v
283
284 .if defined(DOING_TINDERBOX)
285 FAILFILE=tinderbox.failed
286 MAKEFAIL=tee -a ${FAILFILE}
287 .else
288 MAKEFAIL=cat
289 .endif
290
291 universe: universe_prologue
292 universe_prologue:
293         @echo "--------------------------------------------------------------"
294         @echo ">>> make universe started on ${STARTTIME}"
295         @echo "--------------------------------------------------------------"
296 .if defined(DOING_TINDERBOX)
297         rm -f ${FAILFILE}
298 .endif
299 .for target in ${TARGETS}
300 universe: universe_${target}
301 .ORDER: universe_prologue universe_${target} universe_epilogue
302 universe_${target}:
303 .if !defined(MAKE_JUST_KERNELS)
304         @echo ">> ${target} started on `LC_ALL=C date`"
305         @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
306             ${MAKE} ${JFLAG} buildworld \
307             TARGET=${target} \
308             > _.${target}.buildworld 2>&1 || \
309             (echo "${target} world failed," \
310             "check _.${target}.buildworld for details" | ${MAKEFAIL}))
311         @echo ">> ${target} buildworld completed on `LC_ALL=C date`"
312 .endif
313 .if !defined(MAKE_JUST_WORLDS)
314 .if exists(${.CURDIR}/sys/${target}/conf/NOTES)
315         @(cd ${.CURDIR}/sys/${target}/conf && env __MAKE_CONF=/dev/null \
316             ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
317             (echo "${target} 'make LINT' failed," \
318             "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
319 .endif
320         @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \
321             universe_kernels
322 .endif
323         @echo ">> ${target} completed on `LC_ALL=C date`"
324 .endfor
325 universe_kernels: universe_kernconfs
326 .if !defined(TARGET)
327 TARGET!=        uname -m
328 .endif
329 KERNCONFS!=     cd ${.CURDIR}/sys/${TARGET}/conf && \
330                 find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
331                 ! -name DEFAULTS ! -name NOTES
332 universe_kernconfs:
333 .for kernel in ${KERNCONFS}
334         @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
335             ${MAKE} ${JFLAG} buildkernel \
336             TARGET=${TARGET} \
337             KERNCONF=${kernel} \
338             > _.${TARGET}.${kernel} 2>&1 || \
339             (echo "${TARGET} ${kernel} kernel failed," \
340             "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
341 .endfor
342 universe: universe_epilogue
343 universe_epilogue:
344         @echo "--------------------------------------------------------------"
345         @echo ">>> make universe completed on `LC_ALL=C date`"
346         @echo "                      (started ${STARTTIME})"
347         @echo "--------------------------------------------------------------"
348 .if defined(DOING_TINDERBOX)
349         @if [ -e ${FAILFILE} ] ; then \
350                 echo "Tinderbox failed:" ;\
351                 cat ${FAILFILE} ;\
352                 exit 1 ;\
353         fi
354 .endif
355 .endif