1 |
# |
2 |
# $FreeBSD: src/Makefile,v 1.319.2.2 2006/01/07 19:40:08 netchild Exp $ |
3 |
# $MidnightBSD: src/Makefile,v 1.9 2011/03/15 01:56:14 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 |
# 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 |
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 chflags 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. |
147 |
# |
148 |
BW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} |
149 |
cleanworld: |
150 |
.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} |
151 |
.if exists(${BW_CANONICALOBJDIR}/) |
152 |
-rm -rf ${BW_CANONICALOBJDIR}/* |
153 |
-chflags -R 0 ${BW_CANONICALOBJDIR} |
154 |
rm -rf ${BW_CANONICALOBJDIR}/* |
155 |
.endif |
156 |
# To be safe in this case, fall back to a 'make cleandir' |
157 |
${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir |
158 |
.else |
159 |
-rm -rf ${.OBJDIR}/* |
160 |
-chflags -R 0 ${.OBJDIR} |
161 |
rm -rf ${.OBJDIR}/* |
162 |
.endif |
163 |
|
164 |
# |
165 |
# Handle the user-driven targets, using the source relative mk files. |
166 |
# |
167 |
|
168 |
${TGTS}: |
169 |
${_+_}@cd ${.CURDIR}; \ |
170 |
${_MAKE} ${.TARGET} |
171 |
|
172 |
# Set a reasonable default |
173 |
.MAIN: all |
174 |
|
175 |
STARTTIME!= LC_ALL=C date |
176 |
|
177 |
.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR) |
178 |
# |
179 |
# world |
180 |
# |
181 |
# Attempt to rebuild and reinstall everything. This target is not to be |
182 |
# used for upgrading an existing MidnightBSD system, because the kernel is |
183 |
# not included. One can argue that this target doesn't build everything |
184 |
# then. |
185 |
# |
186 |
world: upgrade_checks |
187 |
@echo "--------------------------------------------------------------" |
188 |
@echo ">>> make world started on ${STARTTIME}" |
189 |
@echo "--------------------------------------------------------------" |
190 |
.if target(pre-world) |
191 |
@echo |
192 |
@echo "--------------------------------------------------------------" |
193 |
@echo ">>> Making 'pre-world' target" |
194 |
@echo "--------------------------------------------------------------" |
195 |
${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world |
196 |
.endif |
197 |
${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld |
198 |
${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld |
199 |
.if target(post-world) |
200 |
@echo |
201 |
@echo "--------------------------------------------------------------" |
202 |
@echo ">>> Making 'post-world' target" |
203 |
@echo "--------------------------------------------------------------" |
204 |
${_+_}@cd ${.CURDIR}; ${_MAKE} post-world |
205 |
.endif |
206 |
@echo |
207 |
@echo "--------------------------------------------------------------" |
208 |
@echo ">>> make world completed on `LC_ALL=C date`" |
209 |
@echo " (started ${STARTTIME})" |
210 |
@echo "--------------------------------------------------------------" |
211 |
.else |
212 |
world: |
213 |
@echo "WARNING: make world will overwrite your existing MidnightBSD" |
214 |
@echo "installation without also building and installing a new" |
215 |
@echo "kernel. This can be dangerous. Please read the handbook," |
216 |
@echo "'Rebuilding world', for how to upgrade your system." |
217 |
@echo "Define DESTDIR to where you want to install MidnightBSD," |
218 |
@echo "including /, to override this warning and proceed as usual." |
219 |
@echo "" |
220 |
@echo "Bailing out now..." |
221 |
@false |
222 |
.endif |
223 |
|
224 |
# |
225 |
# kernel |
226 |
# |
227 |
# Short hand for `make buildkernel installkernel' |
228 |
# |
229 |
kernel: buildkernel installkernel |
230 |
|
231 |
# |
232 |
# Perform a few tests to determine if the installed tools are adequate |
233 |
# for building the world. |
234 |
# |
235 |
upgrade_checks: |
236 |
@if ! (cd ${.CURDIR}/tools/build/make_check && \ |
237 |
PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ |
238 |
PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ |
239 |
then \ |
240 |
(cd ${.CURDIR} && make make); \ |
241 |
fi |
242 |
|
243 |
# |
244 |
# Upgrade make(1) to the current version using the installed |
245 |
# headers, libraries and tools. |
246 |
# |
247 |
MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ |
248 |
DESTDIR= \ |
249 |
INSTALL="sh ${.CURDIR}/tools/install.sh" |
250 |
MMAKE= ${MMAKEENV} make \ |
251 |
-D_UPGRADING \ |
252 |
-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \ |
253 |
-DNO_CPU_CFLAGS -DNO_WERROR |
254 |
|
255 |
make: .PHONY |
256 |
@echo |
257 |
@echo "--------------------------------------------------------------" |
258 |
@echo ">>> Building an up-to-date make(1)" |
259 |
@echo "--------------------------------------------------------------" |
260 |
${_+_}@cd ${.CURDIR}/usr.bin/make; \ |
261 |
${MMAKE} obj && \ |
262 |
${MMAKE} depend && \ |
263 |
${MMAKE} all && \ |
264 |
${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= |
265 |
|
266 |
# |
267 |
# universe |
268 |
# |
269 |
# Attempt to rebuild *everything* for all supported architectures, |
270 |
# with a reasonable chance of success, regardless of how old your |
271 |
# existing system is. |
272 |
# |
273 |
.if make(universe) |
274 |
TARGETS?=amd64 i386 sparc64 |
275 |
|
276 |
universe: universe_prologue |
277 |
universe_prologue: |
278 |
@echo "--------------------------------------------------------------" |
279 |
@echo ">>> make universe started on ${STARTTIME}" |
280 |
@echo "--------------------------------------------------------------" |
281 |
.for target in ${TARGETS} |
282 |
KERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \ |
283 |
find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \ |
284 |
! -name DEFAULTS ! -name LINT |
285 |
KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} |
286 |
universe: universe_${target} |
287 |
.ORDER: universe_prologue universe_${target} universe_epilogue |
288 |
universe_${target}: |
289 |
.if !defined(MAKE_JUST_KERNELS) |
290 |
@echo ">> ${target} started on `LC_ALL=C date`" |
291 |
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ |
292 |
${MAKE} ${JFLAG} buildworld \ |
293 |
TARGET=${target} \ |
294 |
> _.${target}.buildworld 2>&1 || \ |
295 |
echo "${target} world failed," \ |
296 |
"check _.${target}.buildworld for details") |
297 |
@echo ">> ${target} buildworld completed on `LC_ALL=C date`" |
298 |
.endif |
299 |
.if exists(${.CURDIR}/sys/${target}/conf/NOTES) |
300 |
@(cd ${.CURDIR}/sys/${target}/conf && env __MAKE_CONF=/dev/null \ |
301 |
${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ |
302 |
echo "${target} 'make LINT' failed," \ |
303 |
"check _.${target}.makeLINT for details") |
304 |
.endif |
305 |
.for kernel in ${KERNCONFS} |
306 |
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ |
307 |
${MAKE} ${JFLAG} buildkernel \ |
308 |
TARGET=${target} \ |
309 |
KERNCONF=${kernel} \ |
310 |
> _.${target}.${kernel} 2>&1 || \ |
311 |
echo "${target} ${kernel} kernel failed," \ |
312 |
"check _.${target}.${kernel} for details") |
313 |
.endfor |
314 |
@echo ">> ${target} completed on `LC_ALL=C date`" |
315 |
.endfor |
316 |
universe: universe_epilogue |
317 |
universe_epilogue: |
318 |
@echo "--------------------------------------------------------------" |
319 |
@echo ">>> make universe completed on `LC_ALL=C date`" |
320 |
@echo " (started ${STARTTIME})" |
321 |
@echo "--------------------------------------------------------------" |
322 |
.endif |