iconv sync 10/x: FreeBSD SVN 258316 + 283406 + 283418
[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 an X86_64_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} == "x86_64"
595 KERNCONF?=      X86_64_GENERIC
596 .endif
597 .endif
598 INSTKERNNAME?=  kernel
599
600 KRNLSRCDIR=     ${.CURDIR}/sys
601 KRNLCONFDIR=    ${KRNLSRCDIR}/config
602 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
603 KERNCONFDIR?=   ${KRNLCONFDIR}
604
605 BUILDKERNELS=
606 INSTALLKERNEL=
607 .for _kernel in ${KERNCONF}
608 .if exists(${KERNCONFDIR}/${_kernel})
609 BUILDKERNELS+=  ${_kernel}
610 .if empty(INSTALLKERNEL)
611 INSTALLKERNEL= ${_kernel}
612 .endif
613 .endif
614 .endfor
615
616 # kernel version numbers survive rm -rf
617 #
618 .for _kernel in ${BUILDKERNELS}
619 .if exists(${KRNLOBJDIR}/${_kernel}/version)
620 KERNEL_VERSION_${_kernel} != cat ${KRNLOBJDIR}/${_kernel}/version
621 .endif
622 .endfor
623
624 #
625 # buildkernel
626 #
627 # Builds all kernels defined by BUILDKERNELS.
628 #
629 bk_tools:
630         @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
631             echo "You must buildworld before buildkernel.  If you wish"; \
632             echo "to build a kernel using native tools, config it manually"; \
633             echo "or use the nativekernel target if you are in a rush"; \
634             /usr/bin/false; \
635         fi
636
637 maybe_bk_tools:
638 .for _kernel in ${BUILDKERNELS}
639         @if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
640             if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
641                 echo "The kernel was build using buildworld tools which no" ; \
642                 echo "longer appear to exist, quickkernel failed!" ; \
643                 /usr/bin/false; \
644             fi; \
645         fi
646 .endfor
647
648 bk_build_list:
649 .if empty(BUILDKERNELS)
650         @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
651         @echo ">>> Did you move your kernel configs from i386/conf to config/?"
652         @false
653 .endif
654
655 bk_kernwarn:
656 .if defined(KERNWARN)
657         @echo "--------------------------------------------------------------"
658         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
659         @echo "--------------------------------------------------------------"
660         @sleep 3
661 .endif
662         @echo
663
664 # The buildkernel target rebuilds the specified kernels from scratch
665 # using the crossbuild tools generated by the last buildworld.  It is
666 # the safest (but also the most time consuming) way to build a new kernel.
667 #
668 buildkernel:    bk_tools bk_build_list bk_kernwarn
669 .for _kernel in ${BUILDKERNELS}
670         @echo "--------------------------------------------------------------"
671         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
672         @echo "--------------------------------------------------------------"
673         @echo "===> ${_kernel}"
674 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
675         rm -rf ${KRNLOBJDIR}/${_kernel}
676 .else
677         @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
678                 echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
679                 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
680 .endif
681         mkdir -p ${KRNLOBJDIR}
682 .if !defined(NO_KERNELCONFIG)
683         cd ${KRNLCONFDIR}; \
684                 PATH=${STRICTTMPPATH} \
685                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
686                         ${KERNCONFDIR}/${_kernel}
687 .endif
688 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
689         echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
690 .endif
691         touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
692 .if !defined(NO_KERNELDEPEND)
693         cd ${KRNLOBJDIR}/${_kernel}; \
694             ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
695 .endif
696         cd ${KRNLOBJDIR}/${_kernel}; \
697             ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
698         @echo "--------------------------------------------------------------"
699         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
700         @echo "--------------------------------------------------------------"
701 .endfor
702
703 # The nativekernel target rebuilds the specified kernels from scratch
704 # using the system's standard compiler rather than using the crossbuild
705 # tools generated by the last buildworld.  This is fairly safe if your
706 # system is reasonable up-to-date.
707 #
708 nativekernel:   bk_build_list bk_kernwarn
709 .for _kernel in ${BUILDKERNELS}
710         @echo "--------------------------------------------------------------"
711         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
712         @echo "--------------------------------------------------------------"
713         @echo "===> ${_kernel}"
714 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
715         rm -rf ${KRNLOBJDIR}/${_kernel}
716 .else
717         @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
718                 echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
719                 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
720 .endif
721         mkdir -p ${KRNLOBJDIR}
722 .if !defined(NO_KERNELCONFIG)
723         cd ${KRNLCONFDIR}; \
724                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
725                         ${KERNCONFDIR}/${_kernel}
726 .endif
727 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
728         echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
729 .endif
730         touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
731         cd ${KRNLOBJDIR}/${_kernel}; \
732             MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
733             make -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
734 .if !defined(NO_KERNELDEPEND)
735         cd ${KRNLOBJDIR}/${_kernel}; \
736             make KERNEL=${INSTKERNNAME} depend
737 .endif
738         cd ${KRNLOBJDIR}/${_kernel}; \
739             make KERNEL=${INSTKERNNAME} all
740         @echo "--------------------------------------------------------------"
741         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
742         @echo "--------------------------------------------------------------"
743 .endfor
744
745 # The quickkernel target rebuilds the specified kernels as quickly
746 # as possible.  It will use the native tools or the buildworld cross tools
747 # based on whether the kernel was originally generated via buildkernel or
748 # nativekernel.  Config is rerun but the object hierarchy is not rebuilt,
749 # nor is the make depend step run.
750 #
751 quickkernel:    maybe_bk_tools bk_build_list bk_kernwarn
752 .for _kernel in ${BUILDKERNELS}
753         @echo "--------------------------------------------------------------"
754         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
755         @echo "--------------------------------------------------------------"
756         @echo "===> ${_kernel}"
757 .if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
758 .if !defined(NO_KERNELCONFIG)
759         cd ${KRNLCONFDIR}; \
760                 PATH=${STRICTTMPPATH} \
761                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
762                         ${KERNCONFDIR}/${_kernel}
763 .endif
764         cd ${KRNLOBJDIR}/${_kernel}; \
765             ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
766 .else
767 .if !defined(NO_KERNELCONFIG)
768         cd ${KRNLCONFDIR}; \
769             config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
770                 ${KERNCONFDIR}/${_kernel}
771 .endif
772         cd ${KRNLOBJDIR}/${_kernel}; \
773             make KERNEL=${INSTKERNNAME} all
774 .endif
775         @echo "--------------------------------------------------------------"
776         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
777         @echo "--------------------------------------------------------------"
778 .endfor
779
780
781 # installkernel
782 #
783 # Install the kernel defined by INSTALLKERNEL
784 #
785 installkernel reinstallkernel:
786         @echo "--------------------------------------------------------------"
787         @echo ">>> Kernel install for ${INSTALLKERNEL} started on `LC_ALL=C date`"
788         @echo "--------------------------------------------------------------"
789 .if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run)
790         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
791             ${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
792 .else
793         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
794             make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
795 .endif
796
797 #
798 # most
799 #
800 # Build most of the user binaries on the existing system libs and includes.
801 #
802 most:
803         @echo "--------------------------------------------------------------"
804         @echo ">>> Building programs only"
805         @echo "--------------------------------------------------------------"
806 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
807         cd ${.CURDIR}/${_dir};          make DIRPRFX=${_dir}/ all
808 .endfor
809
810 #
811 # installmost
812 #
813 # Install the binaries built by the 'most' target.  This does not include
814 # libraries or include files.
815 #
816 installmost:
817         @echo "--------------------------------------------------------------"
818         @echo ">>> Installing programs only"
819         @echo "--------------------------------------------------------------"
820 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
821         cd ${.CURDIR}/${_dir};          make DIRPRFX=${_dir}/ install
822 .endfor
823
824 #
825 # ------------------------------------------------------------------------
826 #
827 # From here onwards are utility targets used by the 'make world' and
828 # related targets.  If your 'world' breaks, you may like to try to fix
829 # the problem and manually run the following targets to attempt to
830 # complete the build.  Beware, this is *not* guaranteed to work, you
831 # need to have a pretty good grip on the current state of the system
832 # to attempt to manually finish it.  If in doubt, 'make world' again.
833 #
834
835 # bootstrap-tools: Build all tools required to build all tools.  Note that
836 # order is important in a number of cases and also note that the bootstrap
837 # and build tools stages have access to earlier binaries they themselves
838 # had generated.
839 #
840 # patch:        older patch's do not have -i.  This program must be built
841 #               first so other bootstrap tools that need to apply patches
842 #               can use it.
843 # [x]install:   dependancies on various new install features
844 # rpcgen:       old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
845 #               envs are not compatible with older objformat binaries.
846 #
847 .if exists(${.CURDIR}/games) && !defined(NO_GAMES)
848 _strfile=       games/fortune/strfile
849 .endif
850
851 # BSTRAPDIRS1 - must be built in strict order, no parallelism
852 #
853 # order is very important. yacc before m4 before flex.  flex exec's m4,
854 # m4's parser file needs the latest byacc (insanity!).
855 #
856 BSTRAPDIRS1= ${_strfile} \
857         usr.bin/patch \
858         bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \
859         bin/test bin/cat bin/ln bin/mv bin/csh bin/expr bin/sh \
860         bin/hostname bin/kill \
861         usr.bin/yacc usr.bin/m4 usr.bin/colldef \
862         usr.bin/uudecode usr.bin/xinstall \
863         usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
864         usr.bin/find usr.bin/flex
865
866 # BSTRAPDIRS2 - may built in parallel
867 #
868 BSTRAPDIRS2= \
869         usr.bin/sed usr.bin/uname usr.bin/touch \
870         usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
871         usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
872         usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
873         usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
874         usr.bin/cap_mkdb usr.bin/true usr.bin/false \
875         usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
876         usr.bin/tail usr.bin/unifdef usr.bin/tic \
877         usr.sbin/chown usr.sbin/mtree usr.sbin/config \
878         usr.sbin/btxld usr.sbin/zic usr.sbin/makewhatis \
879         gnu/usr.bin/grep usr.bin/sort usr.bin/gzip usr.bin/bzip2 \
880         usr.bin/mkcsmapper usr.bin/mkesdb usr.bin/crunch
881
882 bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
883         touch ${BTOOLSDEST}/.bootstrap_done
884
885 bootstrap-tools-before:
886         ${LN} -fs /bin/date ${BTOOLSDEST}/bin/date
887
888 bootstrap-tools-targets1: ${BSTRAPDIRS1:S/^/bstrap-/}
889
890 bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/}
891
892 .ORDER: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
893
894 .ORDER: ${BSTRAPDIRS1:S/^/bstrap-/}
895
896 .for _tool in ${BSTRAPDIRS1} ${BSTRAPDIRS2}
897 bstrap-${_tool}!
898         ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
899                 cd ${.CURDIR}/${_tool}; \
900                 make DIRPRFX=${_tool}/ obj; \
901                 make DIRPRFX=${_tool}/ depend; \
902                 make DIRPRFX=${_tool}/ all; \
903                 make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
904 .endfor
905
906 # build-tools: Build special purpose build tools.
907 #
908 # XXX we may be able to remove or consolidate this into bootstrap-tools
909 # now that we have the native helper (.nx/.no) infrastructure.
910 #
911 .if exists(${.CURDIR}/share) && !defined(NO_SHARE)
912 _share= share/syscons/scrnmaps
913 .endif
914
915 _gcc_common_cross= lib/libz gnu/usr.bin/gmp gnu/usr.bin/mpfr gnu/usr.bin/mpc
916 _gcc50_cross= gnu/usr.bin/cc50
917 _gcc50_tools= gnu/usr.bin/cc50/cc_prep gnu/usr.bin/cc50/cc_tools
918 .if !defined(NO_ALTCOMPILER)
919 _gcc47_cross= gnu/usr.bin/cc47
920 _gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
921 .endif
922 _custom_cross= libexec/customcc
923 _binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
924
925 BTOOLSDIRS= ${_gcc47_tools} ${_gcc50_tools} ${_share}
926
927 build-tools: build-tools-targets
928         touch ${BTOOLSDEST}/.build_done
929
930 build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
931
932 .ORDER: ${_gcc47_tools:S/^/btools-/}
933 .ORDER: ${_gcc50_tools:S/^/btools-/}
934
935 .for _tool in ${BTOOLSDIRS}
936 btools-${_tool}!
937         ${ECHODIR} "===> ${_tool} (build-tools)"; \
938                 cd ${.CURDIR}/${_tool}; \
939                 make DIRPRFX=${_tool}/ obj; \
940                 make DIRPRFX=${_tool}/ depend; \
941                 make DIRPRFX=${_tool}/ all; \
942                 make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
943 .endfor
944
945 #
946 # cross-tools: Build cross-building tools
947 #
948 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
949 _btxld= usr.sbin/btxld
950 .endif
951
952 CTOOLSDIRS= ${_btxld} ${_binutils} \
953                 usr.bin/objformat usr.bin/crunch/crunchide \
954                 ${_gcc_common_cross} \
955                 ${_gcc47_cross} ${_gcc50_cross} ${_custom_cross}
956
957 cross-tools: cross-tools-targets
958         touch ${CTOOLSDEST}/.cross_done
959
960 cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}
961
962 .for _tool in ${CTOOLSDIRS}
963 ctools-${_tool}!
964         ${ECHODIR} "===> ${_tool} (cross-tools)"; \
965                 cd ${.CURDIR}/${_tool}; \
966                 make DIRPRFX=${_tool}/ obj; \
967                 make DIRPRFX=${_tool}/ depend; \
968                 make DIRPRFX=${_tool}/ all; \
969                 make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
970 .endfor
971
972 #
973 # hierarchy - ensure that all the needed directories are present
974 #
975 hierarchy:
976         cd ${.CURDIR}/etc;              make distrib-dirs
977
978 #
979 # libraries - build all libraries, and install them under ${DESTDIR}.
980 #
981 # The list of libraries with dependents (${_prebuild_libs}) and their
982 # interdependencies (__L) are built automatically by the
983 # ${.CURDIR}/tools/make_libdeps.sh script.
984 #
985 # .makeenv does not work when bootstrapping from 4.x, so we must be sure
986 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
987 #
988 libraries:
989         cd ${.CURDIR}; \
990             HOST_CCVER=${HOST_CCVER} CCVER=gcc50 \
991                 make -f Makefile.inc1 _startup_libs50 -DSYSBUILD;
992 .if !defined(NO_ALTCOMPILER)
993         cd ${.CURDIR}; \
994             HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
995                 make -f Makefile.inc1 _startup_libs47 -DSYSBUILD;
996 .endif
997         cd ${.CURDIR}; \
998             make -f Makefile.inc1 _startup_libs -DSYSBUILD; \
999             make -f Makefile.inc1 _prebuild_libs -DSYSBUILD; \
1000             make -f Makefile.inc1 _generic_libs -DSYSBUILD;
1001         touch ${WORLDDEST}/.libraries_done
1002
1003 # These dependencies are not automatically generated:
1004 #
1005 # gnu/lib/${CCVER}/libgcc and gnu/lib/${CCVER}/csu must be built before all
1006 # shared libraries for ELF.  The target for _startup_libsXX is
1007 # specifically built using gccXX.
1008 #
1009 _startup_libs47=        gnu/usr.bin/cc47/cc_prep \
1010                         gnu/usr.bin/cc47/cc_tools \
1011                         gnu/lib/gcc47/csu \
1012                         gnu/lib/gcc47/libgcc \
1013                         gnu/lib/gcc47/libgcc_eh \
1014                         gnu/lib/gcc47/libgcc_pic
1015 _startup_libs50=        gnu/usr.bin/cc50/cc_prep \
1016                         gnu/usr.bin/cc50/cc_tools \
1017                         gnu/lib/gcc50/csu \
1018                         gnu/lib/gcc50/libgcc \
1019                         gnu/lib/gcc50/libgcc_eh \
1020                         gnu/lib/gcc50/libgcc_pic
1021 _startup_libs=          lib/csu lib/libc lib/libc_rtld
1022
1023 _prebuild_libs=         lib/libbz2 lib/liblzma lib/libz
1024 _prebuild_libs+=        lib/libutil
1025
1026 _prebuild_libs+=        lib/libpcap
1027
1028 _generic_libs=  gnu/lib
1029
1030 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
1031                 lib/libncurses/libncurses lib/libopie
1032
1033 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
1034
1035 _generic_libs+= lib
1036
1037 .if !defined(NO_CRYPT)
1038 .if !defined(NO_OPENSSL)
1039 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
1040 .if !defined(NO_OPENSSH)
1041 _prebuild_libs+=        secure/lib/libssh
1042 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
1043 .endif
1044 .endif
1045 _generic_libs+= secure/lib
1046 .endif
1047
1048 _prebuild_libs+= lib/libradius lib/libsbuf lib/libtacplus lib/libm \
1049                 lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \
1050                 lib/libpthread lib/libprop lib/libdevattr
1051
1052 _generic_libs+= usr.bin/flex/lib
1053
1054 .for _lib in ${_startup_libs47} ${_startup_libs50} \
1055                 ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
1056 ${_lib}__L: .PHONY
1057 .if exists(${.CURDIR}/${_lib})
1058         ${ECHODIR} "===> ${_lib}"; \
1059                 cd ${.CURDIR}/${_lib}; \
1060                 make DIRPRFX=${_lib}/ depend; \
1061                 make DIRPRFX=${_lib}/ all; \
1062                 make DIRPRFX=${_lib}/ install
1063 .endif
1064 .endfor
1065
1066 _startup_libs: ${_startup_libs:S/$/__L/}
1067 _startup_libs47: ${_startup_libs47:S/$/__L/}
1068 _startup_libs50: ${_startup_libs50:S/$/__L/}
1069 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1070 _generic_libs: ${_generic_libs:S/$/__L/}
1071
1072 # library targets must be ordered because there are inter-library
1073 # races (e.g. generation of tconfig.h)
1074 #
1075 .ORDER: ${_startup_libs47:S/$/__L/}
1076 .ORDER: ${_startup_libs50:S/$/__L/}
1077 .ORDER: ${_startup_libs:S/$/__L/}
1078 .ORDER: ${_prebuild_libs:S/$/__L/}
1079 .ORDER: ${_generic_libs:S/$/__L/}
1080
1081 .for __target in clean cleandepend cleandir obj depend includes
1082 .for entry in ${SUBDIR}
1083 ${entry}.${__target}__D: .PHONY
1084         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1085                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
1086                 edir=${entry}.${MACHINE_ARCH}; \
1087                 cd ${.CURDIR}/$${edir}; \
1088         else \
1089                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
1090                 edir=${entry}; \
1091                 cd ${.CURDIR}/$${edir}; \
1092         fi; \
1093         make ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1094 .endfor
1095 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1096 .ORDER: ${SUBDIR:S/$/.${__target}__D/}
1097 .endfor
1098 .ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
1099
1100 # The wmake target is used by /usr/bin/wmake to run make in a
1101 # world build environment.
1102 #
1103 wmake:
1104         @echo '${WMAKEENV} make ${WMAKE_ARGS} -DSYSBUILD'
1105
1106 wmakeenv:
1107         @echo '${WMAKEENV} /bin/sh'
1108
1109 bmake:
1110         @echo '${BMAKEENV} make ${BMAKE_ARGS} -DSYSBUILD'
1111
1112 bmakeenv:
1113         @echo '${BMAKEENV} /bin/sh'
1114
1115 tmake:
1116         @echo '${TMAKEENV} make ${TMAKE_ARGS} -DSYSBUILD'
1117
1118 tmakeenv:
1119         @echo '${TMAKEENV} /bin/sh'
1120
1121 xmake:
1122         @echo '${XMAKEENV} make ${XMAKE_ARGS} -DSYSBUILD'
1123
1124 xmakeenv:
1125         @echo '${XMAKEENV} /bin/sh'
1126
1127 backupworld: backup-clean
1128         @mkdir -p ${WORLD_BACKUP}
1129 .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1130      exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1131      exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1132         tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1133                 --options gzip:compression-level=1 \
1134                 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1135 .endif
1136
1137 backupworld-auto:
1138 .if !defined(NO_BACKUP)
1139         rm -f ${AUTO_BACKUP}/binaries.tar.gz
1140         @mkdir -p ${AUTO_BACKUP}
1141 .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1142      exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1143      exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1144         /usr/bin/tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1145                 --options gzip:compression-level=1 \
1146                 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1147 .endif
1148 .endif
1149
1150 backup-auto-clean:
1151         rm -f ${AUTO_BACKUP}/binaries.tar.gz
1152
1153 backup-clean:
1154         rm -f ${WORLD_BACKUP}/binaries.tar.gz
1155
1156 restoreworld:
1157 .if !exists(${WORLD_BACKUP}/binaries.tar.gz)
1158         @echo "There does not seem to be a valid archive present."
1159 .else
1160         @echo "Restoring system binaries from manual backup archive..."
1161         @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1162                 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1163                 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1164         tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1165 .endif
1166
1167 restoreworld-auto:
1168 .if !exists(${AUTO_BACKUP}/binaries.tar.gz)
1169         @echo "There does not seem to be a valid archive present."
1170 .else
1171         @echo "Restoring system binaries from auto-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 ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1176 .endif
1177
1178 # Take advantage of bmake error response
1179 #
1180 MAKE_PRINT_VAR_ON_ERROR= \
1181         .CURDIR \
1182         .OBJDIR \
1183         LD_LIBRARY_PATH \
1184         MACHINE_ARCH \
1185         MACHINE \
1186         MAKEFILE \
1187         .TARGETS \
1188         .ERROR_TARGET \
1189         .MAKE.LEVEL
1190
1191 .include <bsd.subdir.mk>