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