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