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