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