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