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