1 |
# |
2 |
# $FreeBSD: src/Makefile,v 1.319.2.2 2006/01/07 19:40:08 netchild Exp $ |
3 |
# $MidnightBSD: src/Makefile,v 1.7 2007/01/19 02:22:11 laffer1 Exp $ |
4 |
# |
5 |
# The user-driven targets are: |
6 |
# |
7 |
# universe - *Really* build *everything* (buildworld and |
8 |
# all kernels on all architectures). |
9 |
# buildworld - Rebuild *everything*, including glue to help do |
10 |
# upgrades. |
11 |
# installworld - Install everything built by "buildworld". |
12 |
# world - buildworld + installworld, no kernel. |
13 |
# buildkernel - Rebuild the kernel and the kernel-modules. |
14 |
# installkernel - Install the kernel and the kernel-modules. |
15 |
# installkernel.debug |
16 |
# reinstallkernel - Reinstall the kernel and the kernel-modules. |
17 |
# reinstallkernel.debug |
18 |
# kernel - buildkernel + installkernel. |
19 |
# doxygen - Build API documentation of the kernel, needs doxygen. |
20 |
# update - Convenient way to update your source tree (cvs). |
21 |
# check-old - List obsolete directories/files/libraries. |
22 |
# check-old-dirs - List obsolete directories. |
23 |
# check-old-files - List obsolete files. |
24 |
# check-old-libs - List obsolete libraries. |
25 |
# delete-old - Delete obsolete directories/files/libraries. |
26 |
# delete-old-dirs - Delete obsolete directories. |
27 |
# delete-old-files - Delete obsolete files. |
28 |
# delete-old-libs - Delete obsolete libraries. |
29 |
# |
30 |
# This makefile is simple by design. The MidnightBSD 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 400MB 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' |
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. amd64, 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 |
TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ |
80 |
check-old check-old-dirs check-old-files check-old-libs \ |
81 |
checkdpadd clean cleandepend cleandir \ |
82 |
delete-old delete-old-dirs delete-old-files delete-old-libs \ |
83 |
depend distribute distributeworld distrib-dirs distribution doxygen \ |
84 |
everything hierarchy install installcheck installkernel \ |
85 |
installkernel.debug reinstallkernel reinstallkernel.debug \ |
86 |
installworld kernel-toolchain libraries lint maninstall \ |
87 |
obj objlink regress rerelease showconfig tags toolchain update \ |
88 |
_worldtmp _legacy _bootstrap-tools _cleanobj _obj \ |
89 |
_build-tools _cross-tools _includes _libraries _depend \ |
90 |
build32 distribute32 install32 |
91 |
TGTS+= ${SUBDIR_TARGETS} |
92 |
|
93 |
BITGTS= files includes |
94 |
BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} |
95 |
TGTS+= ${BITGTS} |
96 |
|
97 |
.ORDER: buildworld installworld |
98 |
.ORDER: buildworld distributeworld |
99 |
.ORDER: buildworld buildkernel |
100 |
.ORDER: buildkernel installkernel |
101 |
.ORDER: buildkernel installkernel.debug |
102 |
.ORDER: buildkernel reinstallkernel |
103 |
.ORDER: buildkernel reinstallkernel.debug |
104 |
|
105 |
PATH= /sbin:/bin:/usr/sbin:/usr/bin |
106 |
MAKEOBJDIRPREFIX?= /usr/obj |
107 |
_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ |
108 |
${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ |
109 |
-f /dev/null -V MAKEOBJDIRPREFIX dummy |
110 |
.if !empty(_MAKEOBJDIRPREFIX) |
111 |
.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ |
112 |
(in make.conf(5)) or command-line variable. |
113 |
.endif |
114 |
MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} |
115 |
BINMAKE= \ |
116 |
`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ |
117 |
-m ${.CURDIR}/share/mk |
118 |
_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 |
119 |
|
120 |
# |
121 |
# Make sure we have an up-to-date make(1). Only world and buildworld |
122 |
# should do this as those are the initial targets used for upgrades. |
123 |
# The user can define ALWAYS_CHECK_MAKE to have this check performed |
124 |
# for all targets. |
125 |
# |
126 |
.if defined(ALWAYS_CHECK_MAKE) |
127 |
${TGTS}: upgrade_checks |
128 |
.else |
129 |
buildworld: upgrade_checks |
130 |
.endif |
131 |
|
132 |
# |
133 |
# This 'cleanworld' target is not included in TGTS, because it is not a |
134 |
# recursive target. All of the work for it is done right here. It is |
135 |
# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be |
136 |
# created by bsd.obj.mk, except that we don't want to .include that file |
137 |
# in this makefile. |
138 |
# |
139 |
# In the following, the first 'rm' in a series will usually remove all |
140 |
# files and directories. If it does not, then there are probably some |
141 |
# files with chflags set, so this unsets them and tries the 'rm' a |
142 |
# second time. There are situations where this target will be cleaning |
143 |
# some directories via more than one method, but that duplication is |
144 |
# needed to correctly handle all the possible situations. |
145 |
# |
146 |
BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} |
147 |
cleanworld: |
148 |
.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} |
149 |
.if exists(${BW_CANONICALOBJDIR}/) |
150 |
-rm -rf ${BW_CANONICALOBJDIR}/* |
151 |
-chflags -R 0 ${BW_CANONICALOBJDIR} |
152 |
rm -rf ${BW_CANONICALOBJDIR}/* |
153 |
.endif |
154 |
# To be safe in this case, fall back to a 'make cleandir' |
155 |
${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir |
156 |
.else |
157 |
-rm -rf ${.OBJDIR}/* |
158 |
-chflags -R 0 ${.OBJDIR} |
159 |
rm -rf ${.OBJDIR}/* |
160 |
.endif |
161 |
|
162 |
# |
163 |
# Handle the user-driven targets, using the source relative mk files. |
164 |
# |
165 |
|
166 |
${TGTS}: |
167 |
${_+_}@cd ${.CURDIR}; \ |
168 |
${_MAKE} ${.TARGET} |
169 |
|
170 |
# Set a reasonable default |
171 |
.MAIN: all |
172 |
|
173 |
STARTTIME!= LC_ALL=C date |
174 |
|
175 |
.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) |
176 |
# |
177 |
# world |
178 |
# |
179 |
# Attempt to rebuild and reinstall everything. This target is not to be |
180 |
# used for upgrading an existing MidnightBSD system, because the kernel is |
181 |
# not included. One can argue that this target doesn't build everything |
182 |
# then. |
183 |
# |
184 |
world: upgrade_checks |
185 |
@echo "--------------------------------------------------------------" |
186 |
@echo ">>> make world started on ${STARTTIME}" |
187 |
@echo "--------------------------------------------------------------" |
188 |
.if target(pre-world) |
189 |
@echo |
190 |
@echo "--------------------------------------------------------------" |
191 |
@echo ">>> Making 'pre-world' target" |
192 |
@echo "--------------------------------------------------------------" |
193 |
${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world |
194 |
.endif |
195 |
${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld |
196 |
${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld |
197 |
.if target(post-world) |
198 |
@echo |
199 |
@echo "--------------------------------------------------------------" |
200 |
@echo ">>> Making 'post-world' target" |
201 |
@echo "--------------------------------------------------------------" |
202 |
${_+_}@cd ${.CURDIR}; ${_MAKE} post-world |
203 |
.endif |
204 |
@echo |
205 |
@echo "--------------------------------------------------------------" |
206 |
@echo ">>> make world completed on `LC_ALL=C date`" |
207 |
@echo " (started ${STARTTIME})" |
208 |
@echo "--------------------------------------------------------------" |
209 |
.else |
210 |
world: |
211 |
@echo "WARNING: make world will overwrite your existing MidnightBSD" |
212 |
@echo "installation without also building and installing a new" |
213 |
@echo "kernel. This can be dangerous. Please read the handbook," |
214 |
@echo "'Rebuilding world', for how to upgrade your system." |
215 |
@echo "Define DESTDIR to where you want to install MidnightBSD," |
216 |
@echo "including /, to override this warning and proceed as usual." |
217 |
@echo "" |
218 |
@echo "Bailing out now..." |
219 |
@false |
220 |
.endif |
221 |
|
222 |
# |
223 |
# kernel |
224 |
# |
225 |
# Short hand for `make buildkernel installkernel' |
226 |
# |
227 |
kernel: buildkernel installkernel |
228 |
|
229 |
# |
230 |
# Perform a few tests to determine if the installed tools are adequate |
231 |
# for building the world. |
232 |
# |
233 |
upgrade_checks: |
234 |
@if ! (cd ${.CURDIR}/tools/build/make_check && \ |
235 |
PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ |
236 |
PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ |
237 |
then \ |
238 |
(cd ${.CURDIR} && make make); \ |
239 |
fi |
240 |
|
241 |
# |
242 |
# Upgrade make(1) to the current version using the installed |
243 |
# headers, libraries and tools. |
244 |
# |
245 |
MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ |
246 |
DESTDIR= \ |
247 |
INSTALL="sh ${.CURDIR}/tools/install.sh" |
248 |
MMAKE= ${MMAKEENV} make \ |
249 |
-D_UPGRADING \ |
250 |
-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ |
251 |
-DNO_CPU_CFLAGS -DNO_WERROR |
252 |
|
253 |
make: .PHONY |
254 |
@echo |
255 |
@echo "--------------------------------------------------------------" |
256 |
@echo ">>> Building an up-to-date make(1)" |
257 |
@echo "--------------------------------------------------------------" |
258 |
${_+_}@cd ${.CURDIR}/usr.bin/make; \ |
259 |
${MMAKE} obj && \ |
260 |
${MMAKE} depend && \ |
261 |
${MMAKE} all && \ |
262 |
${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= |
263 |
|
264 |
# |
265 |
# universe |
266 |
# |
267 |
# Attempt to rebuild *everything* for all supported architectures, |
268 |
# with a reasonable chance of success, regardless of how old your |
269 |
# existing system is. |
270 |
# |
271 |
.if make(universe) |
272 |
TARGETS?=amd64 i386 sparc64 sun4v |
273 |
|
274 |
universe: universe_prologue |
275 |
universe_prologue: |
276 |
@echo "--------------------------------------------------------------" |
277 |
@echo ">>> make universe started on ${STARTTIME}" |
278 |
@echo "--------------------------------------------------------------" |
279 |
.for target in ${TARGETS} |
280 |
KERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ |
281 |
find [A-Z]*[A-Z] -type f -maxdepth 0 \ |
282 |
! -name DEFAULTS ! -name LINT |
283 |
KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} |
284 |
universe: universe_${target} |
285 |
.ORDER: universe_prologue universe_${target} universe_epilogue |
286 |
universe_${target}: |
287 |
@echo ">> ${target} started on `LC_ALL=C date`" |
288 |
-cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ |
289 |
TARGET=${target} \ |
290 |
__MAKE_CONF=/dev/null \ |
291 |
> _.${target}.buildworld 2>&1 |
292 |
@echo ">> ${target} buildworld completed on `LC_ALL=C date`" |
293 |
.if exists(${.CURDIR}/sys/${target}/conf/NOTES) |
294 |
-cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ |
295 |
> ${.CURDIR}/_.${target}.makeLINT 2>&1 |
296 |
.endif |
297 |
.for kernel in ${KERNCONFS} |
298 |
-cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ |
299 |
TARGET=${target} \ |
300 |
KERNCONF=${kernel} \ |
301 |
__MAKE_CONF=/dev/null \ |
302 |
> _.${target}.${kernel} 2>&1 |
303 |
.endfor |
304 |
@echo ">> ${target} completed on `LC_ALL=C date`" |
305 |
.endfor |
306 |
universe: universe_epilogue |
307 |
universe_epilogue: |
308 |
@echo "--------------------------------------------------------------" |
309 |
@echo ">>> make universe completed on `LC_ALL=C date`" |
310 |
@echo " (started ${STARTTIME})" |
311 |
@echo "--------------------------------------------------------------" |
312 |
.endif |