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