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