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