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