Commit | Line | Data |
---|---|---|
984263bc MD |
1 | # |
2 | # $FreeBSD: src/Makefile.inc1,v 1.141.2.62 2003/04/06 19:54:00 dwmalone Exp $ | |
cecff5c1 MD |
3 | # |
4 | # Build-time options are documented in make.conf(5). | |
984263bc MD |
5 | # |
6 | # The intended user-driven targets are: | |
1397f94a | 7 | # |
984263bc | 8 | # buildworld - rebuild *everything*, including glue to help do upgrades |
1397f94a MD |
9 | # quickworld - skip the glue and do a depend+build on the meat |
10 | # realquickworld - skip the glue and depend stages and just build the meat | |
11 | # crossworld - only build the glue (particularly the cross-build environment) | |
984263bc | 12 | # installworld- install everything built by "buildworld" |
2decc9b9 JM |
13 | # backupworld - copies /bin /sbin /usr/bin /usr/sbin /usr/lib /usr/libexec |
14 | # to manual backup dir | |
917662e5 | 15 | # rescue - create rescue image |
2decc9b9 JM |
16 | # restoreworld- installs binaries from manual backup dir to world |
17 | # restoreworld-auto - installs binaries from auto-backup dir to world | |
984263bc MD |
18 | # most - build user commands, no libraries or include files |
19 | # installmost - install user commands, no libraries or include files | |
2decc9b9 JM |
20 | # backup-clean - delete backup from manual backup dir |
21 | # backup-auto-clean - delete backup from auto-backup dir | |
984263bc MD |
22 | # |
23 | # Standard targets (not defined here) are documented in the makefiles in | |
24 | # /usr/share/mk. These include: | |
25 | # obj depend all install clean cleandepend cleanobj | |
26 | ||
27 | # Put initial settings here. | |
28 | SUBDIR= | |
29 | ||
16dbe6a9 FT |
30 | # /libexec/ld-elf.so.2 needs to be installed first |
31 | # Otherwise, install(1) beeing a dynamically linked binary will fail | |
32 | # during the first upgrade from a static to a dynamic world | |
33 | .if exists(${.CURDIR}/libexec) | |
34 | SUBDIR+= libexec | |
35 | .endif | |
36 | ||
984263bc MD |
37 | # We must do include and lib early so that the perl *.ph generation |
38 | # works correctly as it uses the header files installed by this. | |
39 | .if exists(${.CURDIR}/include) | |
40 | SUBDIR+= include | |
41 | .endif | |
42 | .if exists(${.CURDIR}/lib) | |
43 | SUBDIR+= lib | |
44 | .endif | |
17d0fefe MD |
45 | # This exists simply to ensure that the obj dir hierarchy is |
46 | # intact for nrelease, allowing the nrelease Makefile's to | |
47 | # reference ${.OBJDIR}. | |
48 | # | |
49 | .if exists(${.CURDIR}/nrelease) | |
50 | SUBDIR+= nrelease | |
51 | .endif | |
984263bc MD |
52 | |
53 | .if exists(${.CURDIR}/bin) | |
54 | SUBDIR+= bin | |
55 | .endif | |
cecff5c1 | 56 | .if exists(${.CURDIR}/games) && !defined(NO_GAMES) |
984263bc MD |
57 | SUBDIR+= games |
58 | .endif | |
59 | .if exists(${.CURDIR}/gnu) | |
60 | SUBDIR+= gnu | |
61 | .endif | |
984263bc MD |
62 | .if exists(${.CURDIR}/sbin) |
63 | SUBDIR+= sbin | |
64 | .endif | |
cecff5c1 | 65 | .if exists(${.CURDIR}/secure) && !defined(NO_CRYPT) |
984263bc MD |
66 | SUBDIR+= secure |
67 | .endif | |
cecff5c1 | 68 | .if exists(${.CURDIR}/share) && !defined(NO_SHARE) |
984263bc MD |
69 | SUBDIR+= share |
70 | .endif | |
71 | .if exists(${.CURDIR}/sys) | |
72 | SUBDIR+= sys | |
73 | .endif | |
74 | .if exists(${.CURDIR}/usr.bin) | |
75 | SUBDIR+= usr.bin | |
76 | .endif | |
77 | .if exists(${.CURDIR}/usr.sbin) | |
78 | SUBDIR+= usr.sbin | |
79 | .endif | |
80 | ||
984263bc MD |
81 | .if exists(${.CURDIR}/etc) |
82 | SUBDIR+= etc | |
83 | .endif | |
84 | ||
85 | # These are last, since it is nice to at least get the base system | |
86 | # rebuilt before you do them. | |
87 | .if defined(LOCAL_DIRS) | |
88 | .for _DIR in ${LOCAL_DIRS} | |
89 | .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile) | |
90 | SUBDIR+= ${_DIR} | |
91 | .endif | |
92 | .endfor | |
93 | .endif | |
94 | ||
95 | .if defined(SUBDIR_OVERRIDE) | |
96 | SUBDIR= ${SUBDIR_OVERRIDE} | |
97 | .endif | |
98 | ||
99 | .if defined(NOCLEANDIR) | |
100 | CLEANDIR= clean cleandepend | |
101 | .else | |
102 | CLEANDIR= cleandir | |
103 | .endif | |
104 | ||
9974d917 SS |
105 | .if defined(NO_CLEAN) |
106 | NOCLEAN= # defined | |
107 | .endif | |
d0a8f509 | 108 | |
1397f94a MD |
109 | # Object directory base in primary make. Note that when we rerun make |
110 | # from inside this file we change MAKEOBJDIRPREFIX to the appropriate | |
111 | # subdirectory because the rest of the build system needs it that way. | |
112 | # The original object directory base is saved in OBJTREE. | |
113 | # | |
984263bc | 114 | MAKEOBJDIRPREFIX?= /usr/obj |
1397f94a MD |
115 | OBJTREE?= ${MAKEOBJDIRPREFIX} |
116 | ||
117 | # Used for stage installs and pathing | |
118 | # | |
75d86d8d | 119 | DESTDIRBASE:= ${OBJTREE}${.CURDIR} |
1397f94a | 120 | |
c89fd520 SS |
121 | # Remove DESTDIR from MAKEFLAGS. It is present in the environment |
122 | # anyhow, and we need to be able to override it for stage installs | |
123 | .MAKEFLAGS:= ${.MAKEFLAGS:NDESTDIR=*} | |
124 | ||
0756733f | 125 | # This section sets the tools used to build the world/kernel |
4e8e707f | 126 | WORLD_CCVER?= gcc50 |
0756733f | 127 | WORLD_LDVER?= ld.bfd |
408d50d5 | 128 | WORLD_BINUTILSVER?= binutils225 |
ded5c503 | 129 | |
7bee86c0 JM |
130 | # Set the backup parameters if they are not already defined |
131 | # | |
61443441 | 132 | WORLD_BACKUP?= /var/backups/world_backup |
2decc9b9 | 133 | AUTO_BACKUP?= ${OBJTREE}/world_backup/${DESTDIR} |
7bee86c0 | 134 | |
984263bc MD |
135 | TARGET_ARCH?= ${MACHINE_ARCH} |
136 | .if ${TARGET_ARCH} == ${MACHINE_ARCH} | |
137 | TARGET?= ${MACHINE} | |
138 | .else | |
139 | TARGET?= ${TARGET_ARCH} | |
140 | .endif | |
141 | .if make(buildworld) | |
142 | BUILD_ARCH!= sysctl -n hw.machine_arch | |
b2b3ffcd SS |
143 | |
144 | # temporary until everybody has converted to x86_64 | |
145 | .if ${BUILD_ARCH} == "amd64" | |
146 | BUILD_ARCH= x86_64 | |
147 | .endif | |
148 | ||
984263bc MD |
149 | .if ${MACHINE_ARCH} != ${BUILD_ARCH} |
150 | .error To cross-build, set TARGET_ARCH. | |
151 | .endif | |
152 | .endif | |
1397f94a | 153 | |
4d005c1d SS |
154 | # XXX this is ugly and we need to come up with a nicer solution |
155 | .if !defined(TARGET_PLATFORM) | |
579b67d2 | 156 | .if ${TARGET_ARCH} == "x86_64" |
4d005c1d SS |
157 | TARGET_PLATFORM= pc64 |
158 | .else | |
159 | .error Unknown target architecture. | |
160 | .endif | |
161 | .endif | |
0955fd91 | 162 | |
5f87b7d3 SZ |
163 | THREAD_LIB?= thread_xu |
164 | .if ${THREAD_LIB} == "c_r" | |
165 | .if defined(NO_LIBC_R) | |
166 | .error libc_r is chosen as the default thread library, but NO_LIBC_R is defined | |
167 | .endif | |
168 | .endif | |
169 | ||
1397f94a MD |
170 | # BTOOLS (Natively built) All non-cross-development tools that the |
171 | # main build needs. This includes things like 'mkdir' and 'rm'. | |
172 | # We will not use the native system's exec path once we start | |
173 | # on WORLD. (bootstrap-tools and build-tools or BTOOLS) | |
174 | # | |
175 | # CTOOLS (Natively built) Cross development tools which are specific | |
176 | # to the target architecture. | |
177 | # | |
178 | # WORLD (Cross built) Our ultimate buildworld, using only BTOOLS and | |
179 | # CTOOLS. | |
180 | # | |
0955fd91 MD |
181 | # MACHINE_PLATFORM Platform Architecture we are building on |
182 | # MACHINE Machine Architecture (usually the same as MACHINE_ARCH) | |
e2ea6619 MD |
183 | # MACHINE_ARCH Cpu Architecture we are building on |
184 | # | |
0955fd91 MD |
185 | # TARGET_PLATFORM Platform Architecture we are building for |
186 | # TARGET Machine Architecture we are building for | |
e2ea6619 | 187 | # TARGET_ARCH Cpu Architecture we are building for |
1397f94a MD |
188 | # |
189 | BTOOLSDEST= ${DESTDIRBASE}/btools_${MACHINE_ARCH} | |
190 | CTOOLSDEST= ${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH} | |
191 | WORLDDEST= ${DESTDIRBASE}/world_${TARGET_ARCH} | |
192 | ||
79aa78bc MD |
193 | # The bootstrap-tools path is used by the bootstrap-tools, build-tools, and |
194 | # cross-tools stages to augment the existing command path to access newer | |
195 | # versions of certain utilities such as 'patch' that the cross-tools stage | |
196 | # might expect. | |
197 | # | |
198 | BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games | |
199 | ||
1397f94a MD |
200 | # The strict temporary command path contains all binaries required |
201 | # by the buildworld system after the cross-tools stage. | |
202 | # | |
ee48961f | 203 | STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games:/usr/local/bin:/usr/pkg/bin |
984263bc MD |
204 | |
205 | TMPDIR?= /tmp | |
206 | TMPPID!= echo $$$$ | |
984263bc MD |
207 | |
208 | # | |
209 | # Building a world goes through the following stages | |
210 | # | |
211 | # 1. bootstrap-tool stage [BMAKE] | |
212 | # This stage is responsible for creating programs that | |
213 | # are needed for backward compatibility reasons. They | |
214 | # are not built as cross-tools. | |
215 | # 2. build-tool stage [TMAKE] | |
216 | # This stage is responsible for creating the object | |
217 | # tree and building any tools that are needed during | |
218 | # the build process. | |
219 | # 3. cross-tool stage [XMAKE] | |
220 | # This stage is responsible for creating any tools that | |
221 | # are needed for cross-builds. A cross-compiler is one | |
222 | # of them. | |
223 | # 4. world stage [WMAKE] | |
224 | # This stage actually builds the world. | |
225 | # 5. install stage (optional) [IMAKE] | |
226 | # This stage installs a previously built world. | |
227 | # | |
e92bae40 MD |
228 | # In all cases we must carefully adjust the environment so the proper |
229 | # tools and header files are used. | |
230 | # | |
231 | # NOTE: The M4 environment variable is used by the [f]lex binary to | |
232 | # override the location of the 'm4' binary. The override is | |
233 | # needed for certain buildworld version transitions, specifically | |
234 | # past a certain point in 3.3 because the older /usr/bin/m4 will | |
235 | # generate output that will blow up the newer [f]lex/yacc/bison | |
236 | # utilities. | |
237 | # | |
984263bc | 238 | |
984263bc | 239 | # bootstrap-tool stage |
1397f94a MD |
240 | # |
241 | BMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \ | |
242 | OBJTREE=${OBJTREE} \ | |
44831353 | 243 | DESTDIR=${BTOOLSDEST} \ |
79aa78bc | 244 | PATH=${BTOOLSPATH}:${PATH} \ |
e92bae40 | 245 | M4=${BTOOLSDEST}/usr/bin/m4 \ |
984263bc | 246 | INSTALL="sh ${.CURDIR}/tools/install.sh" |
1397f94a | 247 | |
f8a75064 | 248 | BMAKE= ${BMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \ |
d4f4a127 | 249 | -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \ |
7a1f111f | 250 | -DNO_WERROR -DNO_NLS -DSYSBUILD |
984263bc MD |
251 | |
252 | # build-tool stage | |
1397f94a MD |
253 | # |
254 | TMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \ | |
255 | OBJTREE=${OBJTREE} \ | |
984263bc | 256 | DESTDIR= \ |
79aa78bc | 257 | PATH=${BTOOLSPATH}:${PATH} \ |
e92bae40 | 258 | M4=${BTOOLSDEST}/usr/bin/m4 \ |
984263bc | 259 | INSTALL="sh ${.CURDIR}/tools/install.sh" |
1397f94a | 260 | |
7a1f111f JM |
261 | TMAKE= ${TMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \ |
262 | -DNOSHARED -DSYSBUILD | |
984263bc MD |
263 | |
264 | # cross-tool stage | |
1397f94a MD |
265 | # |
266 | # note: TOOLS_PREFIX points to the obj root holding the cross | |
44831353 MD |
267 | # compiler binaries, while USRDATA_PREFIX points to the obj root |
268 | # holding the target environment (and also determines where cross-built | |
269 | # libraries, crt*.o, and include files are installed). | |
1397f94a MD |
270 | # |
271 | XMAKEENV= MAKEOBJDIRPREFIX=${CTOOLSDEST} \ | |
272 | OBJTREE=${OBJTREE} \ | |
273 | DESTDIR=${CTOOLSDEST} \ | |
aa8dd846 | 274 | _SHLIBDIRPREFIX=${CTOOLSDEST} \ |
1397f94a MD |
275 | INSTALL="sh ${.CURDIR}/tools/install.sh" \ |
276 | TOOLS_PREFIX=${CTOOLSDEST} \ | |
79aa78bc | 277 | USRDATA_PREFIX=${WORLDDEST} \ |
738725bf | 278 | SELECT_LINKER=${WORLD_LDVER} \ |
e92bae40 | 279 | M4=${BTOOLSDEST}/usr/bin/m4 \ |
79aa78bc | 280 | PATH=${BTOOLSPATH}:${PATH} |
1397f94a | 281 | |
6254283a | 282 | XMAKE= ${XMAKEENV} make -f Makefile.inc1 -DNO_GDB \ |
7a1f111f | 283 | -DBOOTSTRAPPING -DNOSHARED -DSYSBUILD |
1397f94a MD |
284 | |
285 | # world stage, note the strict path and note that TOOLS_PREFIX is left | |
286 | # unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty, | |
287 | # which is primarily for the compiler so it targets / (e.g. /usr/<blah>) | |
288 | # for both binary and library paths, even though it is being compiled to | |
289 | # WORLDDEST. None of the programs in the world stage are ever actually | |
290 | # executed during the buildworld/installworld. | |
291 | # | |
292 | CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \ | |
293 | OBJTREE=${OBJTREE} \ | |
294 | MACHINE_ARCH=${TARGET_ARCH} \ | |
295 | MACHINE=${TARGET} \ | |
0955fd91 | 296 | MACHINE_PLATFORM=${TARGET_PLATFORM} \ |
ded5c503 | 297 | OBJFORMAT_PATH=${CTOOLSDEST} \ |
ce6fa878 | 298 | HOST_CCVER=${HOST_CCVER} \ |
123dec51 | 299 | CCVER=${WORLD_CCVER} \ |
0756733f | 300 | LDVER=${WORLD_LDVER} \ |
123dec51 | 301 | BINUTILSVER=${WORLD_BINUTILSVER} |
984263bc | 302 | |
984263bc | 303 | WMAKEENV= ${CROSSENV} \ |
1397f94a | 304 | DESTDIR=${WORLDDEST} \ |
aa8dd846 | 305 | _SHLIBDIRPREFIX=${WORLDDEST} \ |
984263bc | 306 | INSTALL="sh ${.CURDIR}/tools/install.sh" \ |
e92bae40 | 307 | M4=${BTOOLSDEST}/usr/bin/m4 \ |
1397f94a MD |
308 | PATH=${STRICTTMPPATH} |
309 | ||
7a1f111f | 310 | WMAKE= ${WMAKEENV} make -f Makefile.inc1 -DSYSBUILD |
984263bc MD |
311 | |
312 | # install stage | |
b07b69cc | 313 | # |
984263bc | 314 | IMAKEENV= ${CROSSENV} \ |
1397f94a | 315 | PATH=${STRICTTMPPATH} |
7a1f111f | 316 | IMAKE= ${IMAKEENV} make -f Makefile.inc1 -DSYSBUILD |
984263bc MD |
317 | |
318 | # kernel stage | |
b07b69cc MD |
319 | # |
320 | KMAKEENV= ${WMAKEENV} | |
984263bc | 321 | |
984263bc MD |
322 | # buildworld |
323 | # | |
324 | # Attempt to rebuild the entire system, with reasonable chance of | |
325 | # success, regardless of how old your existing system is. | |
326 | # | |
2cde9453 SS |
327 | _worldtmp: _cleantmp _mtreetmp |
328 | .ORDER: _cleantmp _mtreetmp | |
329 | ||
330 | _cleantmp: | |
984263bc MD |
331 | @echo |
332 | @echo "--------------------------------------------------------------" | |
333 | @echo ">>> Rebuilding the temporary build tree" | |
334 | @echo "--------------------------------------------------------------" | |
335 | .if !defined(NOCLEAN) | |
1397f94a | 336 | rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST} |
984263bc MD |
337 | .else |
338 | # XXX - These two can depend on any header file. | |
339 | rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c | |
340 | rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c | |
341 | .endif | |
2cde9453 SS |
342 | |
343 | _mtreetmp: | |
1397f94a MD |
344 | mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST} |
345 | .for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST} | |
346 | mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ | |
347 | -p ${_dir}/ > /dev/null | |
348 | mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ | |
349 | -p ${_dir}/usr > /dev/null | |
984263bc | 350 | .endfor |
1397f94a MD |
351 | mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ |
352 | -p ${WORLDDEST}/usr/include > /dev/null | |
062db326 | 353 | ${LN} -sf ${.CURDIR}/sys ${WORLDDEST} |
1397f94a | 354 | |
984263bc MD |
355 | _bootstrap-tools: |
356 | @echo | |
357 | @echo "--------------------------------------------------------------" | |
358 | @echo ">>> stage 1: bootstrap tools" | |
359 | @echo "--------------------------------------------------------------" | |
360 | cd ${.CURDIR}; ${BMAKE} bootstrap-tools | |
361 | _cleanobj: | |
984263bc MD |
362 | @echo |
363 | @echo "--------------------------------------------------------------" | |
1397f94a | 364 | @echo ">>> stage 2a: cleaning up the object tree" |
984263bc MD |
365 | @echo "--------------------------------------------------------------" |
366 | cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/} | |
984263bc MD |
367 | _obj: |
368 | @echo | |
369 | @echo "--------------------------------------------------------------" | |
1397f94a | 370 | @echo ">>> stage 2b: rebuilding the object tree" |
984263bc MD |
371 | @echo "--------------------------------------------------------------" |
372 | cd ${.CURDIR}; ${WMAKE} par-obj | |
373 | _build-tools: | |
374 | @echo | |
375 | @echo "--------------------------------------------------------------" | |
1397f94a | 376 | @echo ">>> stage 2c: build tools" |
984263bc MD |
377 | @echo "--------------------------------------------------------------" |
378 | cd ${.CURDIR}; ${TMAKE} build-tools | |
379 | _cross-tools: | |
380 | @echo | |
381 | @echo "--------------------------------------------------------------" | |
382 | @echo ">>> stage 3: cross tools" | |
383 | @echo "--------------------------------------------------------------" | |
384 | cd ${.CURDIR}; ${XMAKE} cross-tools | |
385 | _includes: | |
386 | @echo | |
387 | @echo "--------------------------------------------------------------" | |
1397f94a | 388 | @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include" |
984263bc MD |
389 | @echo "--------------------------------------------------------------" |
390 | cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes | |
391 | _libraries: | |
392 | @echo | |
393 | @echo "--------------------------------------------------------------" | |
1397f94a | 394 | @echo ">>> stage 4b: building libraries" |
984263bc | 395 | @echo "--------------------------------------------------------------" |
d4f4a127 | 396 | cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOMAN -DNOFSCHG libraries |
984263bc MD |
397 | _depend: |
398 | @echo | |
399 | @echo "--------------------------------------------------------------" | |
1397f94a | 400 | @echo ">>> stage 4c: make dependencies" |
984263bc MD |
401 | @echo "--------------------------------------------------------------" |
402 | cd ${.CURDIR}; ${WMAKE} par-depend | |
403 | everything: | |
404 | @echo | |
405 | @echo "--------------------------------------------------------------" | |
1397f94a | 406 | @echo ">>> stage 4d: building everything.." |
984263bc MD |
407 | @echo "--------------------------------------------------------------" |
408 | cd ${.CURDIR}; ${WMAKE} all | |
24c1eacf JM |
409 | _bwinit: |
410 | @echo "--------------------------------------------------------------" | |
411 | @echo ">>> starting buildworld target" | |
412 | @echo "--------------------------------------------------------------" | |
413 | _bwdone: | |
414 | @echo "--------------------------------------------------------------" | |
415 | @echo ">>> buildworld target complete" | |
416 | @echo "--------------------------------------------------------------" | |
417 | _qwinit: | |
418 | @echo "--------------------------------------------------------------" | |
419 | @echo ">>> starting quickworld target" | |
420 | @echo "--------------------------------------------------------------" | |
421 | _qwdone: | |
422 | @echo "--------------------------------------------------------------" | |
423 | @echo ">>> quickworld target complete" | |
424 | @echo "--------------------------------------------------------------" | |
425 | _iwinit: | |
426 | @echo "--------------------------------------------------------------" | |
427 | @echo ">>> starting installworld target" | |
428 | @echo "--------------------------------------------------------------" | |
984263bc | 429 | |
1397f94a MD |
430 | # note: buildworld no longer depends on _cleanobj because we rm -rf the |
431 | # entire object tree and built the bootstrap tools in a different location. | |
432 | # | |
433 | # buildworld - build everything from scratch | |
434 | # quickworld - skip the bootstrap, build, and cross-build steps | |
435 | # realquickworld - skip the bootstrap, build, crossbuild, and depend step. | |
436 | # | |
437 | # note: we include _obj in realquickworld to prevent accidental creation | |
438 | # of files in /usr/src. | |
984263bc | 439 | |
c08b39fe | 440 | WMAKE_TGTS= |
984263bc MD |
441 | .if !defined(SUBDIR_OVERRIDE) |
442 | WMAKE_TGTS+= _worldtmp _bootstrap-tools | |
443 | .endif | |
1397f94a | 444 | WMAKE_TGTS+= _obj _build-tools |
984263bc MD |
445 | .if !defined(SUBDIR_OVERRIDE) |
446 | WMAKE_TGTS+= _cross-tools | |
447 | .endif | |
448 | WMAKE_TGTS+= _includes _libraries _depend everything | |
449 | ||
24c1eacf | 450 | buildworld: _bwinit ${WMAKE_TGTS} _bwdone |
1397f94a | 451 | |
24c1eacf | 452 | quickworld: _qwinit _mtreetmp _obj _includes _libraries _depend everything _qwdone |
1397f94a | 453 | |
24c1eacf | 454 | realquickworld: _qwinit _mtreetmp _obj _includes _libraries everything _qwdone |
1397f94a MD |
455 | |
456 | crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools | |
457 | ||
24c1eacf | 458 | .ORDER: _bwinit ${WMAKE_TGTS} _bwdone |
9ce30817 | 459 | .ORDER: _obj _includes |
24c1eacf | 460 | .ORDER: _qwinit _mtreetmp _obj |
61443441 | 461 | .ORDER: installcheck backupworld-auto |
24c1eacf | 462 | .ORDER: everything _qwdone |
984263bc MD |
463 | |
464 | # | |
465 | # installcheck | |
466 | # | |
c08b39fe | 467 | # Checks to be sure system is ready for installworld |
984263bc | 468 | # |
24c1eacf | 469 | installcheck: _iwinit |
3da8e88f JM |
470 | @pw usershow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false) |
471 | @pw groupshow authpf || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false) | |
472 | @pw groupshow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false) | |
108fa417 | 473 | .if !defined(OVERRIDE_CHECKS) |
9b815a46 | 474 | .if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/" |
3da8e88f | 475 | @case `uname -r` in 1.2*|1.3-*|1.3.*|1.4.*|1.5.0-*|1.5.1-*|1.5.2-*|1.5.3-*) echo "You must upgrade your kernel to at least 1.5.4 and reboot before you can safely installworld, due to libc/system call ABI changes" ; /usr/bin/false ; esac |
108fa417 MD |
476 | @case `uname -r` in 1.*|2.*|3.0*|3.1*|3.2*|3.3*|3.4*|3.5*|3.6*) echo "Base is too old for a normal installworld, you need to use installworld-force" ; /usr/bin/false ; esac |
477 | .endif | |
9b815a46 | 478 | .endif |
1516019b | 479 | |
984263bc MD |
480 | # |
481 | # installworld | |
482 | # | |
1516019b | 483 | # Backs up the current world if ${AUTO_BACKUP} is writable. |
984263bc | 484 | # Installs everything compiled by a 'buildworld'. |
e66f5ba7 MD |
485 | # |
486 | # Includes sleep/sync safety before running mkinitrd. | |
1516019b MD |
487 | |
488 | installworld: installcheck | |
489 | -@mkdir -p ${AUTO_BACKUP} > /dev/null 2>&1 | |
490 | @cd ${.CURDIR}; \ | |
491 | (touch ${AUTO_BACKUP}/.updating > /dev/null 2>&1 && \ | |
492 | ${IMAKE} backupworld-auto) || \ | |
493 | echo "Cannot write to ${AUTO_BACKUP} - world not backed up" | |
494 | ||
984263bc | 495 | cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//} |
ec6483ce | 496 | ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc ${DESTDIR}/etc/upgrade/ |
917662e5 | 497 | sync |
24c1eacf JM |
498 | @echo "--------------------------------------------------------------" |
499 | @echo ">>> installworld target complete" | |
500 | @echo "--------------------------------------------------------------" | |
501 | @echo "If things work as expected after a full reboot, consider updating the rescue" | |
502 | @echo "image with 'make rescue'. Do not do it until after rebooting." | |
917662e5 | 503 | |
108fa417 MD |
504 | installworld-force: |
505 | @echo "Doing a forced installworld. This will install to a temporary directory," | |
506 | @echo "then copy the main binaries and libraries with a static cpdup to ${DESTDIR}/" | |
507 | @echo "and finally willl issue a normal installworld. Starting in 5 seconds.". | |
508 | @echo "^C to abort." | |
509 | sleep 1 | |
510 | rm -rf /usr/obj/temp > /dev/null 2>& 1 || chflags -R noschg /usr/obj/temp | |
511 | rm -rf /usr/obj/temp | |
512 | mkdir -p /usr/obj/temp/cpdup/bin | |
513 | (cd ${.CURDIR}/bin/cpdup; make clean; make obj; make clean; make CFLAGS=-static all install DESTDIR=/usr/obj/temp/cpdup NOMAN=TRUE) | |
514 | @echo "XXXXXXXXX Installing to temporary XXXXXXXXX" | |
515 | @sleep 1 | |
516 | (cd ${.CURDIR}; ${MAKE} installworld DESTDIR=/usr/obj/temp > /dev/null 2>&1) | |
517 | @echo "XXXXXXXXX Blasting binaries and libraries XXXXXXXXX" | |
518 | @sleep 1 | |
519 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/bin /bin | |
520 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/sbin /sbin | |
521 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/lib /lib | |
522 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/bin /usr/bin | |
523 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/sbin /usr/sbin | |
524 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/lib /usr/lib | |
525 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/libexec /libexec | |
526 | /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/libexec /usr/libexec | |
527 | @echo "XXXXXXXXX Doing final installworld XXXXXXXX" | |
528 | sleep 5 | |
529 | (cd ${.CURDIR}; ${MAKE} installworld OVERRIDE_CHECKS=TRUE) | |
530 | (cd ${.CURDIR}; ${MAKE} upgrade OVERRIDE_CHECKS=TRUE) | |
531 | ||
917662e5 MD |
532 | # Create a rescue image. We no longer do this automatically for several |
533 | # reasons, primarily that users have had serious issue with mismatched 'vn' | |
534 | # vs the kldload image that can crash the system. But also, the rescue image | |
535 | # is intended to be a rescue image, it is a bad idea to update it at the | |
536 | # same time the world is installed. | |
537 | # | |
538 | rescue: | |
a93ddcbb | 539 | mkinitrd -b ${DESTDIR}/boot |
984263bc MD |
540 | |
541 | # | |
542 | # reinstall | |
543 | # | |
544 | # If you have a build server, you can NFS mount the source and obj directories | |
545 | # and do a 'make reinstall' on the *client* to install new binaries from the | |
546 | # most recent server build. | |
547 | # | |
548 | reinstall: | |
549 | @echo "--------------------------------------------------------------" | |
550 | @echo ">>> Making hierarchy" | |
551 | @echo "--------------------------------------------------------------" | |
f8a75064 | 552 | cd ${.CURDIR}; make -f Makefile.inc1 hierarchy |
984263bc MD |
553 | @echo |
554 | @echo "--------------------------------------------------------------" | |
555 | @echo ">>> Installing everything.." | |
556 | @echo "--------------------------------------------------------------" | |
f8a75064 | 557 | cd ${.CURDIR}; make -f Makefile.inc1 install |
984263bc | 558 | |
984263bc | 559 | # |
fc7aca3e | 560 | # buildkernel, nativekernel, quickkernel, and installkernel |
984263bc MD |
561 | # |
562 | # Which kernels to build and/or install is specified by setting | |
dd7331fe | 563 | # KERNCONF. If not defined an X86_64_GENERIC kernel is built/installed. |
984263bc MD |
564 | # Only the existing (depending TARGET) config files are used |
565 | # for building kernels and only the first of these is designated | |
566 | # as the one being installed. | |
567 | # | |
c2c83759 MD |
568 | # You can specify INSTALLSTRIPPED=1 if you wish the installed |
569 | # kernel and modules to be stripped of its debug info (required | |
570 | # symbols are left intact). You can specify INSTALLSTRIPPEDMODULES | |
571 | # if you only want to strip the modules of their debug info. These | |
572 | # only apply if you have DEBUG=-g in your kernel config or make line. | |
573 | # | |
984263bc MD |
574 | # Note that we have to use TARGET instead of TARGET_ARCH when |
575 | # we're in kernel-land. Since only TARGET_ARCH is (expected) to | |
576 | # be set to cross-build, we have to make sure TARGET is set | |
577 | # properly. | |
578 | ||
579 | .if !defined(KERNCONF) && defined(KERNEL) | |
580 | KERNCONF= ${KERNEL} | |
581 | KERNWARN= yes | |
582 | .else | |
702a95cc SS |
583 | # XXX makeshift fix to build the right kernel for the (target) architecture |
584 | # We should configure this in the platform files somehow | |
dd7331fe | 585 | .if ${TARGET_ARCH} == "x86_64" |
b2b3ffcd | 586 | KERNCONF?= X86_64_GENERIC |
702a95cc | 587 | .endif |
984263bc MD |
588 | .endif |
589 | INSTKERNNAME?= kernel | |
590 | ||
591 | KRNLSRCDIR= ${.CURDIR}/sys | |
4e54470f | 592 | KRNLCONFDIR= ${KRNLSRCDIR}/config |
984263bc MD |
593 | KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR} |
594 | KERNCONFDIR?= ${KRNLCONFDIR} | |
595 | ||
596 | BUILDKERNELS= | |
597 | INSTALLKERNEL= | |
598 | .for _kernel in ${KERNCONF} | |
599 | .if exists(${KERNCONFDIR}/${_kernel}) | |
600 | BUILDKERNELS+= ${_kernel} | |
601 | .if empty(INSTALLKERNEL) | |
602 | INSTALLKERNEL= ${_kernel} | |
603 | .endif | |
604 | .endif | |
605 | .endfor | |
606 | ||
9a359590 MD |
607 | # kernel version numbers survive rm -rf |
608 | # | |
609 | .for _kernel in ${BUILDKERNELS} | |
610 | .if exists(${KRNLOBJDIR}/${_kernel}/version) | |
611 | KERNEL_VERSION_${_kernel} != cat ${KRNLOBJDIR}/${_kernel}/version | |
612 | .endif | |
613 | .endfor | |
614 | ||
984263bc MD |
615 | # |
616 | # buildkernel | |
617 | # | |
618 | # Builds all kernels defined by BUILDKERNELS. | |
619 | # | |
fc7aca3e | 620 | bk_tools: |
e05c8c84 MD |
621 | @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \ |
622 | echo "You must buildworld before buildkernel. If you wish"; \ | |
623 | echo "to build a kernel using native tools, config it manually"; \ | |
624 | echo "or use the nativekernel target if you are in a rush"; \ | |
3da8e88f | 625 | /usr/bin/false; \ |
c2c83759 MD |
626 | fi |
627 | ||
628 | maybe_bk_tools: | |
629 | .for _kernel in ${BUILDKERNELS} | |
630 | @if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \ | |
631 | if [ ! -f ${WORLDDEST}/.libraries_done ]; then \ | |
632 | echo "The kernel was build using buildworld tools which no" ; \ | |
633 | echo "longer appear to exist, quickkernel failed!" ; \ | |
3da8e88f | 634 | /usr/bin/false; \ |
c2c83759 MD |
635 | fi; \ |
636 | fi | |
637 | .endfor | |
e05c8c84 | 638 | |
fc7aca3e | 639 | bk_build_list: |
984263bc MD |
640 | .if empty(BUILDKERNELS) |
641 | @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})." | |
603cdb58 | 642 | @echo ">>> Did you move your kernel configs from i386/conf to config/?" |
984263bc MD |
643 | @false |
644 | .endif | |
fc7aca3e MD |
645 | |
646 | bk_kernwarn: | |
984263bc MD |
647 | .if defined(KERNWARN) |
648 | @echo "--------------------------------------------------------------" | |
649 | @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF=" | |
650 | @echo "--------------------------------------------------------------" | |
651 | @sleep 3 | |
652 | .endif | |
653 | @echo | |
fc7aca3e MD |
654 | |
655 | # The buildkernel target rebuilds the specified kernels from scratch | |
656 | # using the crossbuild tools generated by the last buildworld. It is | |
657 | # the safest (but also the most time consuming) way to build a new kernel. | |
658 | # | |
659 | buildkernel: bk_tools bk_build_list bk_kernwarn | |
984263bc MD |
660 | .for _kernel in ${BUILDKERNELS} |
661 | @echo "--------------------------------------------------------------" | |
662 | @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" | |
663 | @echo "--------------------------------------------------------------" | |
664 | @echo "===> ${_kernel}" | |
fc7aca3e MD |
665 | .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) |
666 | rm -rf ${KRNLOBJDIR}/${_kernel} | |
667 | .else | |
e05c8c84 | 668 | @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \ |
fc7aca3e | 669 | echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \ |
e05c8c84 | 670 | rm -rf ${KRNLOBJDIR}/${_kernel}; fi |
fc7aca3e | 671 | .endif |
984263bc MD |
672 | mkdir -p ${KRNLOBJDIR} |
673 | .if !defined(NO_KERNELCONFIG) | |
674 | cd ${KRNLCONFDIR}; \ | |
1397f94a | 675 | PATH=${STRICTTMPPATH} \ |
f8a75064 | 676 | config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ |
984263bc | 677 | ${KERNCONFDIR}/${_kernel} |
9a359590 MD |
678 | .endif |
679 | .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel}) | |
680 | echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version | |
984263bc | 681 | .endif |
e05c8c84 | 682 | touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run |
984263bc MD |
683 | .if !defined(NO_KERNELDEPEND) |
684 | cd ${KRNLOBJDIR}/${_kernel}; \ | |
f8a75064 | 685 | ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend |
984263bc MD |
686 | .endif |
687 | cd ${KRNLOBJDIR}/${_kernel}; \ | |
f8a75064 | 688 | ${KMAKEENV} make KERNEL=${INSTKERNNAME} all |
984263bc MD |
689 | @echo "--------------------------------------------------------------" |
690 | @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" | |
691 | @echo "--------------------------------------------------------------" | |
692 | .endfor | |
693 | ||
fc7aca3e | 694 | # The nativekernel target rebuilds the specified kernels from scratch |
114580ac | 695 | # using the system's standard compiler rather than using the crossbuild |
fc7aca3e MD |
696 | # tools generated by the last buildworld. This is fairly safe if your |
697 | # system is reasonable up-to-date. | |
e05c8c84 | 698 | # |
fc7aca3e | 699 | nativekernel: bk_build_list bk_kernwarn |
e05c8c84 MD |
700 | .for _kernel in ${BUILDKERNELS} |
701 | @echo "--------------------------------------------------------------" | |
702 | @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" | |
703 | @echo "--------------------------------------------------------------" | |
704 | @echo "===> ${_kernel}" | |
fc7aca3e MD |
705 | .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) |
706 | rm -rf ${KRNLOBJDIR}/${_kernel} | |
707 | .else | |
e05c8c84 | 708 | @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \ |
fc7aca3e | 709 | echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \ |
e05c8c84 | 710 | rm -rf ${KRNLOBJDIR}/${_kernel}; fi |
fc7aca3e | 711 | .endif |
e05c8c84 MD |
712 | mkdir -p ${KRNLOBJDIR} |
713 | .if !defined(NO_KERNELCONFIG) | |
714 | cd ${KRNLCONFDIR}; \ | |
715 | config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ | |
716 | ${KERNCONFDIR}/${_kernel} | |
9a359590 MD |
717 | .endif |
718 | .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel}) | |
719 | echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version | |
e05c8c84 MD |
720 | .endif |
721 | touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run | |
e05c8c84 MD |
722 | cd ${KRNLOBJDIR}/${_kernel}; \ |
723 | MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \ | |
f8a75064 | 724 | make -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile |
e05c8c84 MD |
725 | .if !defined(NO_KERNELDEPEND) |
726 | cd ${KRNLOBJDIR}/${_kernel}; \ | |
f8a75064 | 727 | make KERNEL=${INSTKERNNAME} depend |
e05c8c84 MD |
728 | .endif |
729 | cd ${KRNLOBJDIR}/${_kernel}; \ | |
f8a75064 | 730 | make KERNEL=${INSTKERNNAME} all |
e05c8c84 MD |
731 | @echo "--------------------------------------------------------------" |
732 | @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" | |
733 | @echo "--------------------------------------------------------------" | |
734 | .endfor | |
735 | ||
fc7aca3e MD |
736 | # The quickkernel target rebuilds the specified kernels as quickly |
737 | # as possible. It will use the native tools or the buildworld cross tools | |
738 | # based on whether the kernel was originally generated via buildkernel or | |
739 | # nativekernel. Config is rerun but the object hierarchy is not rebuilt, | |
740 | # nor is the make depend step run. | |
984263bc | 741 | # |
c2c83759 | 742 | quickkernel: maybe_bk_tools bk_build_list bk_kernwarn |
fc7aca3e MD |
743 | .for _kernel in ${BUILDKERNELS} |
744 | @echo "--------------------------------------------------------------" | |
745 | @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" | |
746 | @echo "--------------------------------------------------------------" | |
747 | @echo "===> ${_kernel}" | |
748 | .if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run) | |
749 | .if !defined(NO_KERNELCONFIG) | |
750 | cd ${KRNLCONFDIR}; \ | |
751 | PATH=${STRICTTMPPATH} \ | |
f8a75064 | 752 | config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ |
fc7aca3e MD |
753 | ${KERNCONFDIR}/${_kernel} |
754 | .endif | |
755 | cd ${KRNLOBJDIR}/${_kernel}; \ | |
f8a75064 | 756 | ${KMAKEENV} make KERNEL=${INSTKERNNAME} all |
fc7aca3e MD |
757 | .else |
758 | .if !defined(NO_KERNELCONFIG) | |
759 | cd ${KRNLCONFDIR}; \ | |
760 | config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ | |
761 | ${KERNCONFDIR}/${_kernel} | |
762 | .endif | |
763 | cd ${KRNLOBJDIR}/${_kernel}; \ | |
f8a75064 | 764 | make KERNEL=${INSTKERNNAME} all |
fc7aca3e MD |
765 | .endif |
766 | @echo "--------------------------------------------------------------" | |
767 | @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" | |
768 | @echo "--------------------------------------------------------------" | |
769 | .endfor | |
770 | ||
771 | ||
984263bc MD |
772 | # installkernel |
773 | # | |
774 | # Install the kernel defined by INSTALLKERNEL | |
775 | # | |
776 | installkernel reinstallkernel: | |
982b0507 MD |
777 | @echo "--------------------------------------------------------------" |
778 | @echo ">>> Kernel install for ${INSTALLKERNEL} started on `LC_ALL=C date`" | |
779 | @echo "--------------------------------------------------------------" | |
780 | .if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run) | |
984263bc | 781 | cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ |
f8a75064 | 782 | ${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//} |
c2c83759 MD |
783 | .else |
784 | cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ | |
f8a75064 | 785 | make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//} |
c2c83759 | 786 | .endif |
b11eb6ae JM |
787 | @echo "--------------------------------------------------------------" |
788 | @echo ">>> Kernel install for ${INSTALLKERNEL} completed on `LC_ALL=C date`" | |
789 | @echo "--------------------------------------------------------------" | |
984263bc | 790 | |
984263bc MD |
791 | # |
792 | # most | |
793 | # | |
794 | # Build most of the user binaries on the existing system libs and includes. | |
795 | # | |
796 | most: | |
797 | @echo "--------------------------------------------------------------" | |
798 | @echo ">>> Building programs only" | |
799 | @echo "--------------------------------------------------------------" | |
800 | .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin | |
f8a75064 | 801 | cd ${.CURDIR}/${_dir}; make DIRPRFX=${_dir}/ all |
984263bc MD |
802 | .endfor |
803 | ||
804 | # | |
805 | # installmost | |
806 | # | |
807 | # Install the binaries built by the 'most' target. This does not include | |
808 | # libraries or include files. | |
809 | # | |
810 | installmost: | |
811 | @echo "--------------------------------------------------------------" | |
812 | @echo ">>> Installing programs only" | |
813 | @echo "--------------------------------------------------------------" | |
814 | .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin | |
f8a75064 | 815 | cd ${.CURDIR}/${_dir}; make DIRPRFX=${_dir}/ install |
984263bc MD |
816 | .endfor |
817 | ||
818 | # | |
819 | # ------------------------------------------------------------------------ | |
820 | # | |
821 | # From here onwards are utility targets used by the 'make world' and | |
822 | # related targets. If your 'world' breaks, you may like to try to fix | |
823 | # the problem and manually run the following targets to attempt to | |
824 | # complete the build. Beware, this is *not* guaranteed to work, you | |
825 | # need to have a pretty good grip on the current state of the system | |
826 | # to attempt to manually finish it. If in doubt, 'make world' again. | |
827 | # | |
828 | ||
79aa78bc MD |
829 | # bootstrap-tools: Build all tools required to build all tools. Note that |
830 | # order is important in a number of cases and also note that the bootstrap | |
831 | # and build tools stages have access to earlier binaries they themselves | |
832 | # had generated. | |
984263bc | 833 | # |
79aa78bc MD |
834 | # patch: older patch's do not have -i. This program must be built |
835 | # first so other bootstrap tools that need to apply patches | |
836 | # can use it. | |
17030342 MD |
837 | # [x]install: dependancies on various new install features |
838 | # rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH | |
839 | # envs are not compatible with older objformat binaries. | |
840 | # | |
cecff5c1 | 841 | .if exists(${.CURDIR}/games) && !defined(NO_GAMES) |
984263bc MD |
842 | _strfile= games/fortune/strfile |
843 | .endif | |
844 | ||
e92bae40 MD |
845 | # BSTRAPDIRS1 - must be built in strict order, no parallelism |
846 | # | |
f3dd7aaa MD |
847 | # order is very important. yacc before m4 before flex. flex exec's m4, |
848 | # m4's parser file needs the latest byacc (insanity!). | |
849 | # | |
e92bae40 | 850 | BSTRAPDIRS1= ${_strfile} \ |
d2e9c9d8 MD |
851 | usr.bin/patch \ |
852 | bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \ | |
853 | bin/test bin/cat bin/ln bin/mv bin/csh bin/expr bin/sh \ | |
854 | bin/hostname bin/kill \ | |
f3dd7aaa MD |
855 | usr.bin/yacc usr.bin/m4 usr.bin/colldef \ |
856 | usr.bin/uudecode usr.bin/xinstall \ | |
857 | usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \ | |
e92bae40 MD |
858 | usr.bin/find usr.bin/flex |
859 | ||
860 | # BSTRAPDIRS2 - may built in parallel | |
861 | # | |
862 | BSTRAPDIRS2= \ | |
863 | usr.bin/sed usr.bin/uname usr.bin/touch \ | |
d2e9c9d8 MD |
864 | usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \ |
865 | usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \ | |
866 | usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \ | |
867 | usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \ | |
868 | usr.bin/cap_mkdb usr.bin/true usr.bin/false \ | |
869 | usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \ | |
8c4a123d | 870 | usr.bin/tail usr.bin/unifdef usr.bin/tic \ |
d2e9c9d8 MD |
871 | usr.sbin/chown usr.sbin/mtree usr.sbin/config \ |
872 | usr.sbin/btxld usr.sbin/zic usr.sbin/makewhatis \ | |
8af27ce3 JM |
873 | gnu/usr.bin/grep usr.bin/sort usr.bin/gzip usr.bin/bzip2 \ |
874 | usr.bin/mkcsmapper usr.bin/mkesdb usr.bin/crunch | |
d2e9c9d8 | 875 | |
e92bae40 | 876 | bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2 |
d2e9c9d8 MD |
877 | touch ${BTOOLSDEST}/.bootstrap_done |
878 | ||
879 | bootstrap-tools-before: | |
062db326 | 880 | ${LN} -fs /bin/date ${BTOOLSDEST}/bin/date |
d2e9c9d8 | 881 | |
e92bae40 MD |
882 | bootstrap-tools-targets1: ${BSTRAPDIRS1:S/^/bstrap-/} |
883 | ||
884 | bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/} | |
885 | ||
886 | .ORDER: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2 | |
d2e9c9d8 | 887 | |
e92bae40 | 888 | .ORDER: ${BSTRAPDIRS1:S/^/bstrap-/} |
d2e9c9d8 | 889 | |
e92bae40 | 890 | .for _tool in ${BSTRAPDIRS1} ${BSTRAPDIRS2} |
d2e9c9d8 | 891 | bstrap-${_tool}! |
1397f94a | 892 | ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \ |
984263bc | 893 | cd ${.CURDIR}/${_tool}; \ |
f8a75064 JM |
894 | make DIRPRFX=${_tool}/ obj; \ |
895 | make DIRPRFX=${_tool}/ depend; \ | |
896 | make DIRPRFX=${_tool}/ all; \ | |
897 | make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install | |
984263bc MD |
898 | .endfor |
899 | ||
bceb727e | 900 | # build-tools: Build special purpose build tools. |
984263bc | 901 | # |
1397f94a MD |
902 | # XXX we may be able to remove or consolidate this into bootstrap-tools |
903 | # now that we have the native helper (.nx/.no) infrastructure. | |
904 | # | |
cecff5c1 | 905 | .if exists(${.CURDIR}/share) && !defined(NO_SHARE) |
984263bc MD |
906 | _share= share/syscons/scrnmaps |
907 | .endif | |
908 | ||
b399af11 | 909 | _gcc_common_cross= lib/libz gnu/usr.bin/gmp gnu/usr.bin/mpfr gnu/usr.bin/mpc |
b399af11 JM |
910 | _gcc50_cross= gnu/usr.bin/cc50 |
911 | _gcc50_tools= gnu/usr.bin/cc50/cc_prep gnu/usr.bin/cc50/cc_tools | |
4e8e707f | 912 | .if !defined(NO_ALTCOMPILER) |
b399af11 | 913 | _gcc47_cross= gnu/usr.bin/cc47 |
f0140465 | 914 | _gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools |
4e8e707f | 915 | .endif |
c97b9141 | 916 | _custom_cross= libexec/customcc |
123dec51 | 917 | _binutils= gnu/usr.bin/${WORLD_BINUTILSVER} |
17030342 | 918 | |
b399af11 | 919 | BTOOLSDIRS= ${_gcc47_tools} ${_gcc50_tools} ${_share} |
d2e9c9d8 MD |
920 | |
921 | build-tools: build-tools-targets | |
922 | touch ${BTOOLSDEST}/.build_done | |
923 | ||
924 | build-tools-targets: ${BTOOLSDIRS:S/^/btools-/} | |
925 | ||
f0140465 | 926 | .ORDER: ${_gcc47_tools:S/^/btools-/} |
b399af11 | 927 | .ORDER: ${_gcc50_tools:S/^/btools-/} |
9ba72882 | 928 | |
d2e9c9d8 MD |
929 | .for _tool in ${BTOOLSDIRS} |
930 | btools-${_tool}! | |
1397f94a | 931 | ${ECHODIR} "===> ${_tool} (build-tools)"; \ |
984263bc | 932 | cd ${.CURDIR}/${_tool}; \ |
f8a75064 JM |
933 | make DIRPRFX=${_tool}/ obj; \ |
934 | make DIRPRFX=${_tool}/ depend; \ | |
935 | make DIRPRFX=${_tool}/ all; \ | |
936 | make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install | |
984263bc MD |
937 | .endfor |
938 | ||
939 | # | |
940 | # cross-tools: Build cross-building tools | |
941 | # | |
984263bc MD |
942 | .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386" |
943 | _btxld= usr.sbin/btxld | |
944 | .endif | |
945 | ||
fc7e83fa FT |
946 | CTOOLSDIRS= ${_btxld} ${_binutils} \ |
947 | usr.bin/objformat usr.bin/crunch/crunchide \ | |
948 | ${_gcc_common_cross} \ | |
b399af11 | 949 | ${_gcc47_cross} ${_gcc50_cross} ${_custom_cross} |
d2e9c9d8 MD |
950 | |
951 | cross-tools: cross-tools-targets | |
952 | touch ${CTOOLSDEST}/.cross_done | |
953 | ||
954 | cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/} | |
955 | ||
956 | .for _tool in ${CTOOLSDIRS} | |
957 | ctools-${_tool}! | |
1397f94a | 958 | ${ECHODIR} "===> ${_tool} (cross-tools)"; \ |
984263bc | 959 | cd ${.CURDIR}/${_tool}; \ |
f8a75064 JM |
960 | make DIRPRFX=${_tool}/ obj; \ |
961 | make DIRPRFX=${_tool}/ depend; \ | |
962 | make DIRPRFX=${_tool}/ all; \ | |
963 | make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install | |
984263bc MD |
964 | .endfor |
965 | ||
966 | # | |
967 | # hierarchy - ensure that all the needed directories are present | |
968 | # | |
969 | hierarchy: | |
f8a75064 | 970 | cd ${.CURDIR}/etc; make distrib-dirs |
984263bc MD |
971 | |
972 | # | |
973 | # libraries - build all libraries, and install them under ${DESTDIR}. | |
974 | # | |
975 | # The list of libraries with dependents (${_prebuild_libs}) and their | |
976 | # interdependencies (__L) are built automatically by the | |
977 | # ${.CURDIR}/tools/make_libdeps.sh script. | |
978 | # | |
5228fe46 MD |
979 | # .makeenv does not work when bootstrapping from 4.x, so we must be sure |
980 | # to specify the correct CCVER or 'cc' will not exec the correct compiler. | |
981 | # | |
984263bc | 982 | libraries: |
4f5ea479 | 983 | cd ${.CURDIR}; \ |
b399af11 | 984 | HOST_CCVER=${HOST_CCVER} CCVER=gcc50 \ |
7a1f111f | 985 | make -f Makefile.inc1 _startup_libs50 -DSYSBUILD; |
4e8e707f JM |
986 | .if !defined(NO_ALTCOMPILER) |
987 | cd ${.CURDIR}; \ | |
988 | HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \ | |
989 | make -f Makefile.inc1 _startup_libs47 -DSYSBUILD; | |
6100d1de | 990 | .endif |
29d48e65 | 991 | cd ${.CURDIR}; \ |
7a1f111f JM |
992 | make -f Makefile.inc1 _startup_libs -DSYSBUILD; \ |
993 | make -f Makefile.inc1 _prebuild_libs -DSYSBUILD; \ | |
994 | make -f Makefile.inc1 _generic_libs -DSYSBUILD; | |
e05c8c84 | 995 | touch ${WORLDDEST}/.libraries_done |
984263bc MD |
996 | |
997 | # These dependencies are not automatically generated: | |
998 | # | |
fd8b66cd | 999 | # gnu/lib/${CCVER}/libgcc and gnu/lib/${CCVER}/csu must be built before all |
4f5ea479 SS |
1000 | # shared libraries for ELF. The target for _startup_libsXX is |
1001 | # specifically built using gccXX. | |
984263bc | 1002 | # |
64ed7155 JM |
1003 | _startup_libs47= gnu/usr.bin/cc47/cc_prep \ |
1004 | gnu/usr.bin/cc47/cc_tools \ | |
1005 | gnu/lib/gcc47/csu \ | |
f0140465 JM |
1006 | gnu/lib/gcc47/libgcc \ |
1007 | gnu/lib/gcc47/libgcc_eh \ | |
1008 | gnu/lib/gcc47/libgcc_pic | |
b399af11 JM |
1009 | _startup_libs50= gnu/usr.bin/cc50/cc_prep \ |
1010 | gnu/usr.bin/cc50/cc_tools \ | |
1011 | gnu/lib/gcc50/csu \ | |
1012 | gnu/lib/gcc50/libgcc \ | |
1013 | gnu/lib/gcc50/libgcc_eh \ | |
1014 | gnu/lib/gcc50/libgcc_pic | |
e1da6819 | 1015 | _startup_libs= lib/csu lib/libc lib/libc_rtld |
984263bc | 1016 | |
59392a00 | 1017 | _prebuild_libs= lib/libbz2 lib/liblzma lib/libz |
0b153c05 | 1018 | _prebuild_libs+= lib/libutil |
984263bc | 1019 | |
e895e94d BY |
1020 | _prebuild_libs+= lib/libpcap |
1021 | ||
984263bc MD |
1022 | _generic_libs= gnu/lib |
1023 | ||
984263bc | 1024 | _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \ |
6d0e03f5 | 1025 | lib/libncurses/libncurses lib/libopie |
984263bc MD |
1026 | |
1027 | lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L | |
984263bc MD |
1028 | |
1029 | _generic_libs+= lib | |
1030 | ||
cecff5c1 | 1031 | .if !defined(NO_CRYPT) |
984263bc MD |
1032 | .if !defined(NO_OPENSSL) |
1033 | _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl | |
1034 | .if !defined(NO_OPENSSH) | |
1035 | _prebuild_libs+= secure/lib/libssh | |
1036 | secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L | |
1037 | .endif | |
1038 | .endif | |
1039 | _generic_libs+= secure/lib | |
1040 | .endif | |
1041 | ||
6d0e03f5 MD |
1042 | _prebuild_libs+= lib/libradius lib/libsbuf lib/libtacplus lib/libm \ |
1043 | lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \ | |
1044 | lib/libpthread lib/libprop lib/libdevattr | |
1045 | ||
f506e60d | 1046 | _generic_libs+= usr.bin/flex/lib |
984263bc | 1047 | |
b399af11 | 1048 | .for _lib in ${_startup_libs47} ${_startup_libs50} \ |
4db2a28c | 1049 | ${_startup_libs} ${_prebuild_libs} ${_generic_libs} |
984263bc MD |
1050 | ${_lib}__L: .PHONY |
1051 | .if exists(${.CURDIR}/${_lib}) | |
1052 | ${ECHODIR} "===> ${_lib}"; \ | |
1053 | cd ${.CURDIR}/${_lib}; \ | |
f8a75064 JM |
1054 | make DIRPRFX=${_lib}/ depend; \ |
1055 | make DIRPRFX=${_lib}/ all; \ | |
1056 | make DIRPRFX=${_lib}/ install | |
984263bc MD |
1057 | .endif |
1058 | .endfor | |
1059 | ||
1060 | _startup_libs: ${_startup_libs:S/$/__L/} | |
f0140465 | 1061 | _startup_libs47: ${_startup_libs47:S/$/__L/} |
b399af11 | 1062 | _startup_libs50: ${_startup_libs50:S/$/__L/} |
984263bc MD |
1063 | _prebuild_libs: ${_prebuild_libs:S/$/__L/} |
1064 | _generic_libs: ${_generic_libs:S/$/__L/} | |
1065 | ||
1397f94a MD |
1066 | # library targets must be ordered because there are inter-library |
1067 | # races (e.g. generation of tconfig.h) | |
1068 | # | |
f0140465 | 1069 | .ORDER: ${_startup_libs47:S/$/__L/} |
b399af11 | 1070 | .ORDER: ${_startup_libs50:S/$/__L/} |
1397f94a MD |
1071 | .ORDER: ${_startup_libs:S/$/__L/} |
1072 | .ORDER: ${_prebuild_libs:S/$/__L/} | |
1073 | .ORDER: ${_generic_libs:S/$/__L/} | |
1074 | ||
1075 | .for __target in clean cleandepend cleandir obj depend includes | |
984263bc MD |
1076 | .for entry in ${SUBDIR} |
1077 | ${entry}.${__target}__D: .PHONY | |
1078 | @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ | |
1079 | ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \ | |
1080 | edir=${entry}.${MACHINE_ARCH}; \ | |
1081 | cd ${.CURDIR}/$${edir}; \ | |
1082 | else \ | |
1083 | ${ECHODIR} "===> ${DIRPRFX}${entry}"; \ | |
1084 | edir=${entry}; \ | |
1085 | cd ${.CURDIR}/$${edir}; \ | |
1086 | fi; \ | |
f8a75064 | 1087 | make ${__target} DIRPRFX=${DIRPRFX}$${edir}/ |
984263bc MD |
1088 | .endfor |
1089 | par-${__target}: ${SUBDIR:S/$/.${__target}__D/} | |
1397f94a | 1090 | .ORDER: ${SUBDIR:S/$/.${__target}__D/} |
984263bc | 1091 | .endfor |
1397f94a | 1092 | .ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes |
984263bc | 1093 | |
cb0f1574 MD |
1094 | # The wmake target is used by /usr/bin/wmake to run make in a |
1095 | # world build environment. | |
1096 | # | |
1097 | wmake: | |
7a1f111f | 1098 | @echo '${WMAKEENV} make ${WMAKE_ARGS} -DSYSBUILD' |
cb0f1574 | 1099 | |
5c7da0d7 MD |
1100 | wmakeenv: |
1101 | @echo '${WMAKEENV} /bin/sh' | |
1102 | ||
1397f94a | 1103 | bmake: |
7a1f111f | 1104 | @echo '${BMAKEENV} make ${BMAKE_ARGS} -DSYSBUILD' |
1397f94a | 1105 | |
17030342 MD |
1106 | bmakeenv: |
1107 | @echo '${BMAKEENV} /bin/sh' | |
1108 | ||
1397f94a | 1109 | tmake: |
7a1f111f | 1110 | @echo '${TMAKEENV} make ${TMAKE_ARGS} -DSYSBUILD' |
1397f94a | 1111 | |
17030342 MD |
1112 | tmakeenv: |
1113 | @echo '${TMAKEENV} /bin/sh' | |
1114 | ||
66834c05 | 1115 | xmake: |
7a1f111f | 1116 | @echo '${XMAKEENV} make ${XMAKE_ARGS} -DSYSBUILD' |
66834c05 SS |
1117 | |
1118 | xmakeenv: | |
1119 | @echo '${XMAKEENV} /bin/sh' | |
1120 | ||
2decc9b9 | 1121 | backupworld: backup-clean |
7bee86c0 | 1122 | @mkdir -p ${WORLD_BACKUP} |
2decc9b9 JM |
1123 | .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \ |
1124 | exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \ | |
1125 | exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec)) | |
1126 | tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \ | |
1127 | --options gzip:compression-level=1 \ | |
1128 | sbin bin usr/sbin usr/bin usr/lib usr/libexec | |
1129 | .endif | |
61443441 JM |
1130 | |
1131 | backupworld-auto: | |
2decc9b9 JM |
1132 | .if !defined(NO_BACKUP) |
1133 | rm -f ${AUTO_BACKUP}/binaries.tar.gz | |
61443441 | 1134 | @mkdir -p ${AUTO_BACKUP} |
2decc9b9 JM |
1135 | .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \ |
1136 | exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \ | |
1137 | exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec)) | |
5738cc3a | 1138 | /usr/bin/tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \ |
2decc9b9 JM |
1139 | --options gzip:compression-level=1 \ |
1140 | sbin bin usr/sbin usr/bin usr/lib usr/libexec | |
1141 | .endif | |
aaae54f7 | 1142 | .endif |
7bee86c0 | 1143 | |
2decc9b9 JM |
1144 | backup-auto-clean: |
1145 | rm -f ${AUTO_BACKUP}/binaries.tar.gz | |
1146 | ||
1147 | backup-clean: | |
1148 | rm -f ${WORLD_BACKUP}/binaries.tar.gz | |
1149 | ||
7bee86c0 | 1150 | restoreworld: |
2decc9b9 | 1151 | .if !exists(${WORLD_BACKUP}/binaries.tar.gz) |
7bee86c0 JM |
1152 | @echo "There does not seem to be a valid archive present." |
1153 | .else | |
61443441 | 1154 | @echo "Restoring system binaries from manual backup archive..." |
2decc9b9 JM |
1155 | @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \ |
1156 | ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \ | |
1157 | ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec | |
1158 | tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ | |
7bee86c0 JM |
1159 | .endif |
1160 | ||
61443441 | 1161 | restoreworld-auto: |
2decc9b9 | 1162 | .if !exists(${AUTO_BACKUP}/binaries.tar.gz) |
61443441 JM |
1163 | @echo "There does not seem to be a valid archive present." |
1164 | .else | |
1165 | @echo "Restoring system binaries from auto-backup archive..." | |
2decc9b9 JM |
1166 | @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \ |
1167 | ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \ | |
1168 | ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec | |
1169 | tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ | |
61443441 JM |
1170 | .endif |
1171 | ||
3da8e88f JM |
1172 | # Take advantage of bmake error response |
1173 | # | |
1174 | MAKE_PRINT_VAR_ON_ERROR= \ | |
1175 | .CURDIR \ | |
1176 | .OBJDIR \ | |
3da8e88f JM |
1177 | LD_LIBRARY_PATH \ |
1178 | MACHINE_ARCH \ | |
1179 | MACHINE \ | |
1180 | MAKEFILE \ | |
1181 | .TARGETS \ | |
1182 | .ERROR_TARGET \ | |
61443441 | 1183 | .MAKE.LEVEL |
3da8e88f | 1184 | |
984263bc | 1185 | .include <bsd.subdir.mk> |