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