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