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