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