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