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