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