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