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