rc.d: Introduce 'dhcp_client' to wrap over dhclient and dhcpcd
[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} \
9b724c0d 298 WORLDBUILD=1 \
123dec51 299 BINUTILSVER=${WORLD_BINUTILSVER}
984263bc 300
984263bc 301WMAKEENV= ${CROSSENV} \
1397f94a 302 DESTDIR=${WORLDDEST} \
aa8dd846 303 _SHLIBDIRPREFIX=${WORLDDEST} \
984263bc 304 INSTALL="sh ${.CURDIR}/tools/install.sh" \
e92bae40 305 M4=${BTOOLSDEST}/usr/bin/m4 \
1397f94a
MD
306 PATH=${STRICTTMPPATH}
307
7a1f111f 308WMAKE= ${WMAKEENV} make -f Makefile.inc1 -DSYSBUILD
984263bc
MD
309
310# install stage
b07b69cc 311#
984263bc 312IMAKEENV= ${CROSSENV} \
1397f94a 313 PATH=${STRICTTMPPATH}
7a1f111f 314IMAKE= ${IMAKEENV} make -f Makefile.inc1 -DSYSBUILD
984263bc
MD
315
316# kernel stage
b07b69cc
MD
317#
318KMAKEENV= ${WMAKEENV}
984263bc 319
984263bc
MD
320# buildworld
321#
322# Attempt to rebuild the entire system, with reasonable chance of
323# success, regardless of how old your existing system is.
324#
2cde9453
SS
325_worldtmp: _cleantmp _mtreetmp
326.ORDER: _cleantmp _mtreetmp
327
328_cleantmp:
984263bc
MD
329 @echo
330 @echo "--------------------------------------------------------------"
331 @echo ">>> Rebuilding the temporary build tree"
332 @echo "--------------------------------------------------------------"
333.if !defined(NOCLEAN)
1397f94a 334 rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
984263bc
MD
335.else
336 # XXX - These two can depend on any header file.
337 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
338 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
339.endif
2cde9453
SS
340
341_mtreetmp:
1397f94a
MD
342 mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
343.for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
344 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
345 -p ${_dir}/ > /dev/null
346 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
347 -p ${_dir}/usr > /dev/null
984263bc 348.endfor
1397f94a
MD
349 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
350 -p ${WORLDDEST}/usr/include > /dev/null
062db326 351 ${LN} -sf ${.CURDIR}/sys ${WORLDDEST}
1397f94a 352
9b724c0d
MD
353_bwinit:
354 @echo "--------------------------------------------------------------"
355 @echo ">>> starting buildworld target"
356 @echo "--------------------------------------------------------------"
984263bc
MD
357_bootstrap-tools:
358 @echo
359 @echo "--------------------------------------------------------------"
360 @echo ">>> stage 1: bootstrap tools"
361 @echo "--------------------------------------------------------------"
362 cd ${.CURDIR}; ${BMAKE} bootstrap-tools
363_cleanobj:
984263bc
MD
364 @echo
365 @echo "--------------------------------------------------------------"
1397f94a 366 @echo ">>> stage 2a: cleaning up the object tree"
984263bc
MD
367 @echo "--------------------------------------------------------------"
368 cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
984263bc
MD
369_obj:
370 @echo
371 @echo "--------------------------------------------------------------"
1397f94a 372 @echo ">>> stage 2b: rebuilding the object tree"
984263bc
MD
373 @echo "--------------------------------------------------------------"
374 cd ${.CURDIR}; ${WMAKE} par-obj
375_build-tools:
376 @echo
377 @echo "--------------------------------------------------------------"
1397f94a 378 @echo ">>> stage 2c: build tools"
984263bc
MD
379 @echo "--------------------------------------------------------------"
380 cd ${.CURDIR}; ${TMAKE} build-tools
381_cross-tools:
382 @echo
383 @echo "--------------------------------------------------------------"
384 @echo ">>> stage 3: cross tools"
385 @echo "--------------------------------------------------------------"
386 cd ${.CURDIR}; ${XMAKE} cross-tools
387_includes:
388 @echo
389 @echo "--------------------------------------------------------------"
1397f94a 390 @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
984263bc
MD
391 @echo "--------------------------------------------------------------"
392 cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
393_libraries:
394 @echo
395 @echo "--------------------------------------------------------------"
1397f94a 396 @echo ">>> stage 4b: building libraries"
984263bc 397 @echo "--------------------------------------------------------------"
d4f4a127 398 cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOMAN -DNOFSCHG libraries
984263bc
MD
399_depend:
400 @echo
401 @echo "--------------------------------------------------------------"
1397f94a 402 @echo ">>> stage 4c: make dependencies"
984263bc
MD
403 @echo "--------------------------------------------------------------"
404 cd ${.CURDIR}; ${WMAKE} par-depend
405everything:
406 @echo
407 @echo "--------------------------------------------------------------"
1397f94a 408 @echo ">>> stage 4d: building everything.."
984263bc
MD
409 @echo "--------------------------------------------------------------"
410 cd ${.CURDIR}; ${WMAKE} all
9b724c0d
MD
411_rescue:
412 @echo
24c1eacf 413 @echo "--------------------------------------------------------------"
9b724c0d
MD
414 @echo ">>> stage 5a: building rescue topology"
415 @echo "--------------------------------------------------------------"
416 cd ${.CURDIR}; ${WMAKE} quickrescue
417_initrd:
418 @echo
24c1eacf 419 @echo "--------------------------------------------------------------"
9b724c0d
MD
420 @echo ">>> stage 5b: building initrd topology"
421 @echo "--------------------------------------------------------------"
422 cd ${.CURDIR}; ${WMAKE} quickinitrd
24c1eacf
JM
423_bwdone:
424 @echo "--------------------------------------------------------------"
425 @echo ">>> buildworld target complete"
426 @echo "--------------------------------------------------------------"
427_qwinit:
428 @echo "--------------------------------------------------------------"
429 @echo ">>> starting quickworld target"
430 @echo "--------------------------------------------------------------"
431_qwdone:
432 @echo "--------------------------------------------------------------"
433 @echo ">>> quickworld target complete"
434 @echo "--------------------------------------------------------------"
435_iwinit:
436 @echo "--------------------------------------------------------------"
437 @echo ">>> starting installworld target"
438 @echo "--------------------------------------------------------------"
984263bc 439
1397f94a
MD
440# note: buildworld no longer depends on _cleanobj because we rm -rf the
441# entire object tree and built the bootstrap tools in a different location.
442#
443# buildworld - build everything from scratch
444# quickworld - skip the bootstrap, build, and cross-build steps
445# realquickworld - skip the bootstrap, build, crossbuild, and depend step.
446#
447# note: we include _obj in realquickworld to prevent accidental creation
448# of files in /usr/src.
984263bc 449
c08b39fe 450WMAKE_TGTS=
984263bc
MD
451.if !defined(SUBDIR_OVERRIDE)
452WMAKE_TGTS+= _worldtmp _bootstrap-tools
453.endif
1397f94a 454WMAKE_TGTS+= _obj _build-tools
984263bc
MD
455.if !defined(SUBDIR_OVERRIDE)
456WMAKE_TGTS+= _cross-tools
457.endif
458WMAKE_TGTS+= _includes _libraries _depend everything
9b724c0d
MD
459WMAKE_TGTS+= _rescue _initrd
460
461.if defined(WMAKE_TGTS_OVERRIDE)
462SUBDIR=
463WMAKE_TGTS= ${WMAKE_TGTS_OVERRIDE}
464.endif
465
466QMAKE_TGTS= _mtreetmp _obj _includes _libraries _depend everything
467QMAKE_TGTS+= _rescue _initrd
984263bc 468
24c1eacf 469buildworld: _bwinit ${WMAKE_TGTS} _bwdone
1397f94a 470
9b724c0d 471quickworld: _qwinit ${QMAKE_TGTS} _qwdone
1397f94a 472
24c1eacf 473realquickworld: _qwinit _mtreetmp _obj _includes _libraries everything _qwdone
1397f94a
MD
474
475crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
476
24c1eacf 477.ORDER: _bwinit ${WMAKE_TGTS} _bwdone
9ce30817 478.ORDER: _obj _includes
24c1eacf 479.ORDER: _qwinit _mtreetmp _obj
61443441 480.ORDER: installcheck backupworld-auto
24c1eacf 481.ORDER: everything _qwdone
984263bc
MD
482
483#
484# installcheck
485#
c08b39fe 486# Checks to be sure system is ready for installworld
984263bc 487#
24c1eacf 488installcheck: _iwinit
3da8e88f
JM
489 @pw usershow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
490 @pw groupshow authpf || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
491 @pw groupshow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
108fa417 492.if !defined(OVERRIDE_CHECKS)
9b815a46 493.if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/"
3da8e88f 494 @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
495 @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
496.endif
9b815a46 497.endif
1516019b 498
984263bc
MD
499# installworld
500#
1516019b 501# Backs up the current world if ${AUTO_BACKUP} is writable.
984263bc 502# Installs everything compiled by a 'buildworld'.
e66f5ba7 503#
9b724c0d
MD
504.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
505DESTDIR_RESCUE=/
506.else
507DESTDIR_RESCUE=${DESTDIR}
508.endif
509
1516019b
MD
510installworld: installcheck
511 -@mkdir -p ${AUTO_BACKUP} > /dev/null 2>&1
512 @cd ${.CURDIR}; \
513 (touch ${AUTO_BACKUP}/.updating > /dev/null 2>&1 && \
514 ${IMAKE} backupworld-auto) || \
515 echo "Cannot write to ${AUTO_BACKUP} - world not backed up"
516
984263bc 517 cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
81f07c26
AL
518 ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc \
519 ${DESTDIR}/etc/upgrade/
520
9b724c0d 521.if !exists(${DESTDIR_RESCUE}/rescue/rescue)
81f07c26 522 @echo "--------------------------------------------------------------"
9b724c0d 523 @echo ">>> /rescue is empty, setting up"
3f2f08f6 524 @echo "--------------------------------------------------------------"
9b724c0d
MD
525 (cd ${.CURDIR} && make installrescue)
526.endif
527.if !exists(${DESTDIR_RESCUE}/boot/kernel/initrd.img.gz)
3f2f08f6 528 @echo "--------------------------------------------------------------"
9b724c0d 529 @echo ">>> /boot/kernel has no initrd.img.gz, setting up"
81f07c26 530 @echo "--------------------------------------------------------------"
9b724c0d 531 (cd ${.CURDIR} && make installinitrd)
81f07c26 532.endif
111cbfe4 533
917662e5 534 sync
24c1eacf
JM
535 @echo "--------------------------------------------------------------"
536 @echo ">>> installworld target complete"
537 @echo "--------------------------------------------------------------"
917662e5 538
9b724c0d
MD
539installrescue:
540 cpdup -i0 ${WORLDDEST}/rescue ${DESTDIR}/rescue
541
542installinitrd:
543 ${INSTALL} -o root -g wheel -m 644 \
544 ${WORLDDEST}/boot/kernel/initrd.img.gz ${DESTDIR}/boot/kernel/
545
108fa417
MD
546installworld-force:
547 @echo "Doing a forced installworld. This will install to a temporary directory,"
548 @echo "then copy the main binaries and libraries with a static cpdup to ${DESTDIR}/"
f12e2116 549 @echo "and finally will issue a normal installworld. Starting in 5 seconds.".
108fa417
MD
550 @echo "^C to abort."
551 sleep 1
552 rm -rf /usr/obj/temp > /dev/null 2>& 1 || chflags -R noschg /usr/obj/temp
553 rm -rf /usr/obj/temp
554 mkdir -p /usr/obj/temp/cpdup/bin
99a9a126 555 (cd ${.CURDIR}/bin/cpdup; make clean && make obj && make clean && make CFLAGS=-static all install DESTDIR=/usr/obj/temp/cpdup NOMAN=TRUE)
108fa417
MD
556 @echo "XXXXXXXXX Installing to temporary XXXXXXXXX"
557 @sleep 1
558 (cd ${.CURDIR}; ${MAKE} installworld DESTDIR=/usr/obj/temp > /dev/null 2>&1)
559 @echo "XXXXXXXXX Blasting binaries and libraries XXXXXXXXX"
560 @sleep 1
561 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/bin /bin
562 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/sbin /sbin
563 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/lib /lib
564 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/bin /usr/bin
565 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/sbin /usr/sbin
566 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/lib /usr/lib
567 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/libexec /libexec
568 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/libexec /usr/libexec
569 @echo "XXXXXXXXX Doing final installworld XXXXXXXX"
570 sleep 5
571 (cd ${.CURDIR}; ${MAKE} installworld OVERRIDE_CHECKS=TRUE)
572 (cd ${.CURDIR}; ${MAKE} upgrade OVERRIDE_CHECKS=TRUE)
573
984263bc
MD
574#
575# reinstall
576#
577# If you have a build server, you can NFS mount the source and obj directories
578# and do a 'make reinstall' on the *client* to install new binaries from the
579# most recent server build.
580#
581reinstall:
582 @echo "--------------------------------------------------------------"
583 @echo ">>> Making hierarchy"
584 @echo "--------------------------------------------------------------"
f8a75064 585 cd ${.CURDIR}; make -f Makefile.inc1 hierarchy
984263bc
MD
586 @echo
587 @echo "--------------------------------------------------------------"
588 @echo ">>> Installing everything.."
589 @echo "--------------------------------------------------------------"
f8a75064 590 cd ${.CURDIR}; make -f Makefile.inc1 install
984263bc 591
984263bc 592#
92c9dfec 593# buildkernel, nativekernel, quickkernel, realquickkernel, and installkernel
984263bc
MD
594#
595# Which kernels to build and/or install is specified by setting
dd7331fe 596# KERNCONF. If not defined an X86_64_GENERIC kernel is built/installed.
984263bc
MD
597# Only the existing (depending TARGET) config files are used
598# for building kernels and only the first of these is designated
599# as the one being installed.
600#
0ec18149 601# You can specify INSTALLSTRIPPED=1 if you wish the installed
c2c83759
MD
602# kernel and modules to be stripped of its debug info (required
603# symbols are left intact). You can specify INSTALLSTRIPPEDMODULES
604# if you only want to strip the modules of their debug info. These
605# only apply if you have DEBUG=-g in your kernel config or make line.
606#
984263bc
MD
607# Note that we have to use TARGET instead of TARGET_ARCH when
608# we're in kernel-land. Since only TARGET_ARCH is (expected) to
609# be set to cross-build, we have to make sure TARGET is set
610# properly.
611
612.if !defined(KERNCONF) && defined(KERNEL)
613KERNCONF= ${KERNEL}
614KERNWARN= yes
615.else
702a95cc
SS
616# XXX makeshift fix to build the right kernel for the (target) architecture
617# We should configure this in the platform files somehow
dd7331fe 618.if ${TARGET_ARCH} == "x86_64"
b2b3ffcd 619KERNCONF?= X86_64_GENERIC
702a95cc 620.endif
984263bc
MD
621.endif
622INSTKERNNAME?= kernel
623
624KRNLSRCDIR= ${.CURDIR}/sys
4e54470f 625KRNLCONFDIR= ${KRNLSRCDIR}/config
984263bc
MD
626KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
627KERNCONFDIR?= ${KRNLCONFDIR}
628
629BUILDKERNELS=
630INSTALLKERNEL=
631.for _kernel in ${KERNCONF}
632.if exists(${KERNCONFDIR}/${_kernel})
633BUILDKERNELS+= ${_kernel}
634.if empty(INSTALLKERNEL)
635INSTALLKERNEL= ${_kernel}
636.endif
637.endif
638.endfor
639
9a359590
MD
640# kernel version numbers survive rm -rf
641#
642.for _kernel in ${BUILDKERNELS}
643.if exists(${KRNLOBJDIR}/${_kernel}/version)
644KERNEL_VERSION_${_kernel} != cat ${KRNLOBJDIR}/${_kernel}/version
645.endif
646.endfor
647
984263bc
MD
648#
649# buildkernel
650#
651# Builds all kernels defined by BUILDKERNELS.
652#
fc7aca3e 653bk_tools:
e05c8c84
MD
654 @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
655 echo "You must buildworld before buildkernel. If you wish"; \
656 echo "to build a kernel using native tools, config it manually"; \
657 echo "or use the nativekernel target if you are in a rush"; \
3da8e88f 658 /usr/bin/false; \
c2c83759
MD
659 fi
660
661maybe_bk_tools:
662.for _kernel in ${BUILDKERNELS}
663 @if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
664 if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
665 echo "The kernel was build using buildworld tools which no" ; \
92c9dfec 666 echo "longer appear to exist, (real)quickkernel failed!" ; \
3da8e88f 667 /usr/bin/false; \
c2c83759
MD
668 fi; \
669 fi
670.endfor
e05c8c84 671
fc7aca3e 672bk_build_list:
984263bc 673.if empty(BUILDKERNELS)
08fafda6
SW
674 @echo ">>> ERROR: Missing kernel configuration file(s)."
675 @echo ">>> ${KERNCONF} not found in ${KERNCONFDIR}."
984263bc
MD
676 @false
677.endif
fc7aca3e
MD
678
679bk_kernwarn:
984263bc
MD
680.if defined(KERNWARN)
681 @echo "--------------------------------------------------------------"
682 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
683 @echo "--------------------------------------------------------------"
684 @sleep 3
685.endif
686 @echo
fc7aca3e
MD
687
688# The buildkernel target rebuilds the specified kernels from scratch
689# using the crossbuild tools generated by the last buildworld. It is
690# the safest (but also the most time consuming) way to build a new kernel.
691#
692buildkernel: bk_tools bk_build_list bk_kernwarn
984263bc
MD
693.for _kernel in ${BUILDKERNELS}
694 @echo "--------------------------------------------------------------"
695 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
696 @echo "--------------------------------------------------------------"
697 @echo "===> ${_kernel}"
fc7aca3e
MD
698.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
699 rm -rf ${KRNLOBJDIR}/${_kernel}
700.else
e05c8c84 701 @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
fc7aca3e 702 echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
e05c8c84 703 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
fc7aca3e 704.endif
984263bc
MD
705 mkdir -p ${KRNLOBJDIR}
706.if !defined(NO_KERNELCONFIG)
707 cd ${KRNLCONFDIR}; \
1397f94a 708 PATH=${STRICTTMPPATH} \
f8a75064 709 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
984263bc 710 ${KERNCONFDIR}/${_kernel}
9a359590
MD
711.endif
712.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
713 echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
984263bc 714.endif
e05c8c84 715 touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
984263bc
MD
716.if !defined(NO_KERNELDEPEND)
717 cd ${KRNLOBJDIR}/${_kernel}; \
f8a75064 718 ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
984263bc
MD
719.endif
720 cd ${KRNLOBJDIR}/${_kernel}; \
f8a75064 721 ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
984263bc
MD
722 @echo "--------------------------------------------------------------"
723 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
724 @echo "--------------------------------------------------------------"
725.endfor
726
fc7aca3e 727# The nativekernel target rebuilds the specified kernels from scratch
114580ac 728# using the system's standard compiler rather than using the crossbuild
fc7aca3e
MD
729# tools generated by the last buildworld. This is fairly safe if your
730# system is reasonable up-to-date.
e05c8c84 731#
fc7aca3e 732nativekernel: bk_build_list bk_kernwarn
e05c8c84
MD
733.for _kernel in ${BUILDKERNELS}
734 @echo "--------------------------------------------------------------"
735 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
736 @echo "--------------------------------------------------------------"
737 @echo "===> ${_kernel}"
fc7aca3e
MD
738.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
739 rm -rf ${KRNLOBJDIR}/${_kernel}
740.else
e05c8c84 741 @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
fc7aca3e 742 echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
e05c8c84 743 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
fc7aca3e 744.endif
e05c8c84
MD
745 mkdir -p ${KRNLOBJDIR}
746.if !defined(NO_KERNELCONFIG)
747 cd ${KRNLCONFDIR}; \
748 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
749 ${KERNCONFDIR}/${_kernel}
9a359590
MD
750.endif
751.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
752 echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
e05c8c84
MD
753.endif
754 touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
e05c8c84
MD
755.if !defined(NO_KERNELDEPEND)
756 cd ${KRNLOBJDIR}/${_kernel}; \
f8a75064 757 make KERNEL=${INSTKERNNAME} depend
e05c8c84
MD
758.endif
759 cd ${KRNLOBJDIR}/${_kernel}; \
f8a75064 760 make KERNEL=${INSTKERNNAME} all
e05c8c84
MD
761 @echo "--------------------------------------------------------------"
762 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
763 @echo "--------------------------------------------------------------"
764.endfor
765
92c9dfec 766# The (real)quickkernel target rebuilds the specified kernels as quickly
fc7aca3e
MD
767# as possible. It will use the native tools or the buildworld cross tools
768# based on whether the kernel was originally generated via buildkernel or
521f740e 769# nativekernel. Config is rerun but the object hierarchy is not rebuilt.
92c9dfec 770# realquickkernel skips the depend step (analogous to realquickworld).
984263bc 771#
92c9dfec 772quickkernel realquickkernel: maybe_bk_tools bk_build_list bk_kernwarn
fc7aca3e
MD
773.for _kernel in ${BUILDKERNELS}
774 @echo "--------------------------------------------------------------"
775 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
776 @echo "--------------------------------------------------------------"
777 @echo "===> ${_kernel}"
778.if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
779.if !defined(NO_KERNELCONFIG)
780 cd ${KRNLCONFDIR}; \
781 PATH=${STRICTTMPPATH} \
f8a75064 782 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
fc7aca3e 783 ${KERNCONFDIR}/${_kernel}
521f740e 784.endif
ef022cea 785.if !defined(NO_KERNELDEPEND) && !make(realquickkernel)
521f740e
SW
786 cd ${KRNLOBJDIR}/${_kernel}; \
787 ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
fc7aca3e
MD
788.endif
789 cd ${KRNLOBJDIR}/${_kernel}; \
f8a75064 790 ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
fc7aca3e
MD
791.else
792.if !defined(NO_KERNELCONFIG)
793 cd ${KRNLCONFDIR}; \
794 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
795 ${KERNCONFDIR}/${_kernel}
521f740e 796.endif
ef022cea 797.if !defined(NO_KERNELDEPEND) && !make(realquickkernel)
521f740e
SW
798 cd ${KRNLOBJDIR}/${_kernel}; \
799 make KERNEL=${INSTKERNNAME} depend
fc7aca3e
MD
800.endif
801 cd ${KRNLOBJDIR}/${_kernel}; \
f8a75064 802 make KERNEL=${INSTKERNNAME} all
fc7aca3e
MD
803.endif
804 @echo "--------------------------------------------------------------"
805 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
806 @echo "--------------------------------------------------------------"
807.endfor
808
809
984263bc
MD
810# installkernel
811#
812# Install the kernel defined by INSTALLKERNEL
813#
814installkernel reinstallkernel:
982b0507
MD
815 @echo "--------------------------------------------------------------"
816 @echo ">>> Kernel install for ${INSTALLKERNEL} started on `LC_ALL=C date`"
817 @echo "--------------------------------------------------------------"
818.if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run)
984263bc 819 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
f8a75064 820 ${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
c2c83759
MD
821.else
822 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
f8a75064 823 make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
c2c83759 824.endif
b11eb6ae
JM
825 @echo "--------------------------------------------------------------"
826 @echo ">>> Kernel install for ${INSTALLKERNEL} completed on `LC_ALL=C date`"
827 @echo "--------------------------------------------------------------"
984263bc 828
984263bc
MD
829#
830# ------------------------------------------------------------------------
831#
832# From here onwards are utility targets used by the 'make world' and
833# related targets. If your 'world' breaks, you may like to try to fix
834# the problem and manually run the following targets to attempt to
835# complete the build. Beware, this is *not* guaranteed to work, you
836# need to have a pretty good grip on the current state of the system
837# to attempt to manually finish it. If in doubt, 'make world' again.
838#
839
79aa78bc
MD
840# bootstrap-tools: Build all tools required to build all tools. Note that
841# order is important in a number of cases and also note that the bootstrap
842# and build tools stages have access to earlier binaries they themselves
843# had generated.
984263bc 844#
79aa78bc
MD
845# patch: older patch's do not have -i. This program must be built
846# first so other bootstrap tools that need to apply patches
847# can use it.
17030342
MD
848# [x]install: dependancies on various new install features
849# rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
850# envs are not compatible with older objformat binaries.
851#
984263bc 852
e92bae40
MD
853# BSTRAPDIRS1 - must be built in strict order, no parallelism
854#
f3dd7aaa
MD
855# order is very important. yacc before m4 before flex. flex exec's m4,
856# m4's parser file needs the latest byacc (insanity!).
857#
07917fe8 858BSTRAPDIRS1= \
d2e9c9d8
MD
859 usr.bin/patch \
860 bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \
30573b92 861 bin/test bin/cat bin/ln bin/mv bin/expr bin/sh \
d2e9c9d8 862 bin/hostname bin/kill \
3e668727 863 usr.bin/yacc usr.bin/m4 usr.bin/localedef \
f3dd7aaa
MD
864 usr.bin/uudecode usr.bin/xinstall \
865 usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
e92bae40
MD
866 usr.bin/find usr.bin/flex
867
868# BSTRAPDIRS2 - may built in parallel
869#
870BSTRAPDIRS2= \
871 usr.bin/sed usr.bin/uname usr.bin/touch \
d2e9c9d8
MD
872 usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
873 usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
874 usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
5e92dae6 875 usr.bin/uuencode usr.bin/cap_mkdb usr.bin/true usr.bin/false \
d2e9c9d8 876 usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
c2e4744e 877 usr.bin/tail usr.bin/unifdef \
d2e9c9d8 878 usr.sbin/chown usr.sbin/mtree usr.sbin/config \
9b724c0d 879 usr.sbin/zic usr.sbin/makewhatis usr.sbin/pwd_mkdb \
3f6af2cf 880 gnu/usr.bin/grep usr.bin/sort usr.bin/gzip \
9b724c0d 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}; \
99a9a126
SW
901 make DIRPRFX=${_tool}/ obj && \
902 make DIRPRFX=${_tool}/ depend && \
903 make DIRPRFX=${_tool}/ all && \
f8a75064 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#
8d7da424 912# XXX we should separate this into new Makefile.inc2.
913# Just to prepare for reduction of ORDER: that slows down parallel crossworld.
914
915# Make sure Makefile.inc1 logic is intact.
916.if !defined(WORLD_ALTCOMPILER)
891976b0 917.warning undefined WORLD_ALTCOMPILER
918.endif
8d7da424 919
2a89766a
MD
920# gcc80 is now the default compiler. See sys.mk for WORLD_ALTCOMPILER default
921# and this file for WORLD_CCVER.
922#
923_gcc47_cross= gnu/usr.bin/cc47
924_gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
925
b399af11
JM
926_gcc50_cross= gnu/usr.bin/cc50
927_gcc50_tools= gnu/usr.bin/cc50/cc_prep gnu/usr.bin/cc50/cc_tools
2a89766a
MD
928
929_gcc80_cross= gnu/usr.bin/cc80
930_gcc80_tools= gnu/usr.bin/cc80/cc_prep gnu/usr.bin/cc80/cc_tools
931
932_gcc_common_cross= lib/libz gnu/usr.bin/gmp gnu/usr.bin/mpfr gnu/usr.bin/mpc
933
4e8e707f 934.if !defined(NO_ALTCOMPILER)
8d7da424 935. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
8d7da424 936_altcompiler_cross+= ${_gcc47_cross}
8d7da424 937. endif
2a89766a
MD
938.endif
939
940.if !defined(NO_ALTCOMPILER)
941. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc50})
942_altcompiler_cross+= ${_gcc50_cross}
40f0590f 943. endif
4e8e707f 944.endif
2a89766a
MD
945
946#.if !defined(NO_ALTCOMPILER)
947#. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc80})
948#_altcompiler_cross+= ${_gcc80_cross}
949_basecompiler_cross+= ${_gcc80_cross}
950#. endif
951#.endif
952
c97b9141 953_custom_cross= libexec/customcc
123dec51 954_binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
17030342 955
d2e9c9d8
MD
956build-tools: build-tools-targets
957 touch ${BTOOLSDEST}/.build_done
958
959build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
960
984263bc
MD
961#
962# cross-tools: Build cross-building tools
963#
984263bc 964
d3cfb461 965CTOOLSDIRS= usr.bin/objformat
34ffaf06 966
967CTOOLSDIRS+= ${_binutils} \
fc7e83fa 968 ${_gcc_common_cross} \
8d7da424 969 ${_altcompiler_cross} \
2a89766a 970 ${_basecompiler_cross} ${_custom_cross}
d2e9c9d8
MD
971
972cross-tools: cross-tools-targets
973 touch ${CTOOLSDEST}/.cross_done
974
975cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}
976
977.for _tool in ${CTOOLSDIRS}
978ctools-${_tool}!
1397f94a 979 ${ECHODIR} "===> ${_tool} (cross-tools)"; \
984263bc 980 cd ${.CURDIR}/${_tool}; \
99a9a126
SW
981 make DIRPRFX=${_tool}/ obj && \
982 make DIRPRFX=${_tool}/ depend && \
983 make DIRPRFX=${_tool}/ all && \
f8a75064 984 make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
984263bc
MD
985.endfor
986
987#
988# hierarchy - ensure that all the needed directories are present
989#
990hierarchy:
f8a75064 991 cd ${.CURDIR}/etc; make distrib-dirs
984263bc
MD
992
993#
994# libraries - build all libraries, and install them under ${DESTDIR}.
995#
996# The list of libraries with dependents (${_prebuild_libs}) and their
997# interdependencies (__L) are built automatically by the
998# ${.CURDIR}/tools/make_libdeps.sh script.
999#
5228fe46
MD
1000# .makeenv does not work when bootstrapping from 4.x, so we must be sure
1001# to specify the correct CCVER or 'cc' will not exec the correct compiler.
1002#
2a89766a
MD
1003# NOTE: Allow duplicate build for WORLD_ALTCOMPILER=all for WORLD_CCVER,
1004# It will already be built so it won't cost any extra time. Please
1005# list all compilers in the ALTCOMPILER sequence, including the base
1006# compile.
1007#
984263bc 1008libraries:
4f5ea479 1009 cd ${.CURDIR}; \
2a89766a
MD
1010 HOST_CCVER=${HOST_CCVER} CCVER=${WORLD_CCVER} \
1011 make -f Makefile.inc1 ${_startup_libs_base} -DSYSBUILD -DLIBGCC_ONLY;
4e8e707f 1012.if !defined(NO_ALTCOMPILER)
8d7da424 1013. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
4e8e707f
JM
1014 cd ${.CURDIR}; \
1015 HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
11900578 1016 make -f Makefile.inc1 _startup_libs47 -DSYSBUILD -DLIBGCC_ONLY;
8d7da424 1017. endif
2a89766a
MD
1018. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc50})
1019 cd ${.CURDIR}; \
1020 HOST_CCVER=${HOST_CCVER} CCVER=gcc50 \
1021 make -f Makefile.inc1 _startup_libs50 -DSYSBUILD -DLIBGCC_ONLY;
1022. endif
40f0590f 1023. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc80})
1024 cd ${.CURDIR}; \
1025 HOST_CCVER=${HOST_CCVER} CCVER=gcc80 \
11900578 1026 make -f Makefile.inc1 _startup_libs80 -DSYSBUILD -DLIBGCC_ONLY;
40f0590f 1027. endif
6100d1de 1028.endif
29d48e65 1029 cd ${.CURDIR}; \
99a9a126
SW
1030 make -f Makefile.inc1 _startup_libs -DSYSBUILD && \
1031 make -f Makefile.inc1 _prebuild_libs -DSYSBUILD && \
1032 make -f Makefile.inc1 _generic_libs -DSYSBUILD && \
1033 touch ${WORLDDEST}/.libraries_done
984263bc
MD
1034
1035# These dependencies are not automatically generated:
1036#
fd8b66cd 1037# gnu/lib/${CCVER}/libgcc and gnu/lib/${CCVER}/csu must be built before all
4f5ea479
SS
1038# shared libraries for ELF. The target for _startup_libsXX is
1039# specifically built using gccXX.
984263bc 1040#
64ed7155
JM
1041_startup_libs47= gnu/usr.bin/cc47/cc_prep \
1042 gnu/usr.bin/cc47/cc_tools \
1043 gnu/lib/gcc47/csu \
f0140465
JM
1044 gnu/lib/gcc47/libgcc \
1045 gnu/lib/gcc47/libgcc_eh \
1046 gnu/lib/gcc47/libgcc_pic
2a89766a 1047
b399af11
JM
1048_startup_libs50= gnu/usr.bin/cc50/cc_prep \
1049 gnu/usr.bin/cc50/cc_tools \
1050 gnu/lib/gcc50/csu \
1051 gnu/lib/gcc50/libgcc \
1052 gnu/lib/gcc50/libgcc_eh \
1053 gnu/lib/gcc50/libgcc_pic
2a89766a 1054
40f0590f 1055_startup_libs80= gnu/usr.bin/cc80/cc_prep \
1056 gnu/usr.bin/cc80/cc_tools \
1057 gnu/lib/gcc80/csu \
1058 gnu/lib/gcc80/libgcc \
1059 gnu/lib/gcc80/libgcc_eh \
1060 gnu/lib/gcc80/libgcc_pic
2a89766a
MD
1061
1062# gcc80 is now the default compiler. See sys.mk for WORLD_ALTCOMPILER default.
1063#
40f0590f 1064.if !defined(NO_ALTCOMPILER)
2a89766a
MD
1065. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
1066_startup_libs_alt+= _startup_libs47
40f0590f 1067. endif
1068.endif
1069
2a89766a
MD
1070.if !defined(NO_ALTCOMPILER)
1071. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc50})
1072_startup_libs_alt+= _startup_libs50
1073. endif
1074.endif
1075
1076#.if !defined(NO_ALTCOMPILER)
1077#. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc80})
1078#_startup_libs_alt+= _startup_libs80
1079_startup_libs_base+= _startup_libs80
1080#. endif
1081#.endif
1082
e1da6819 1083_startup_libs= lib/csu lib/libc lib/libc_rtld
762087c8 1084lib/libc__L: lib/csu__L
984263bc 1085
d5f6378f 1086_prebuild_libs= lib/libbz2 lib/libz
0b153c05 1087_prebuild_libs+= lib/libutil
984263bc 1088
8edf9883 1089_prebuild_libs+= lib/libelf
e895e94d
BY
1090_prebuild_libs+= lib/libpcap
1091
984263bc
MD
1092_generic_libs= gnu/lib
1093
68ef81ed 1094_prebuild_libs+= lib/libcrypt lib/libmd \
e1e6cc6a 1095 lib/libncurses/libncurses
984263bc 1096
cd1ba70d 1097lib/libopie__L lib/libtacplus__L: lib/libmd__L
984263bc
MD
1098
1099_generic_libs+= lib
1100
0fe46dc6 1101_prebuild_libs+= lib/librecrypto lib/libressl
cd1ba70d 1102lib/libressl__L: lib/librecrypto__L
1103
0fe46dc6
MD
1104_prebuild_libs+= lib/libssh
1105lib/libssh__L: lib/librecrypto__L lib/libz__L
984263bc 1106
cd1ba70d 1107_prebuild_libs+= lib/libradius lib/libopie
1108lib/libradius__L: lib/librecrypto__L
1109lib/libopie__L: lib/librecrypto__L
e1e6cc6a 1110
cd1ba70d 1111_prebuild_libs+= lib/libsbuf lib/libtacplus lib/libm \
242be47e 1112 lib/libpam/libpam lib/libypclnt lib/lib${THREAD_LIB} \
d5f6378f 1113 lib/libpthread lib/liblzma lib/libprop lib/libdevattr
8edf9883 1114lib/liblzma__L: lib/libpthread__L
cd1ba70d 1115lib/libdevattr__L: lib/libprop__L
6d0e03f5 1116
f506e60d 1117_generic_libs+= usr.bin/flex/lib
984263bc 1118
2a89766a 1119.for _alib in ${_startup_libs_alt} ${_startup_libs_base}
8d7da424 1120__startup_alibs+= ${${_alib}}
1121.endfor
1122
2a89766a 1123.for _lib in ${__startup_alibs} \
4db2a28c 1124 ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
984263bc
MD
1125${_lib}__L: .PHONY
1126.if exists(${.CURDIR}/${_lib})
136141ba 1127 @${ECHODIR} "===> ${_lib}"; \
984263bc 1128 cd ${.CURDIR}/${_lib}; \
99a9a126
SW
1129 echo "STEP DEP ${_lib}" && \
1130 make DIRPRFX=${_lib}/ depend && \
1131 echo "STEP ALL ${_lib}" && \
1132 make DIRPRFX=${_lib}/ all && \
1133 echo "STEP INSTALL ${_lib}" && \
1134 make DIRPRFX=${_lib}/ install && \
e1e6cc6a 1135 echo "STEP DONE ${_lib}";
8d7da424 1136.else
1137.warning missing ${.CURDIR}/${_lib} directory.
984263bc
MD
1138.endif
1139.endfor
1140
1141_startup_libs: ${_startup_libs:S/$/__L/}
2a89766a 1142.for _alib in ${_startup_libs_alt} ${_startup_libs_base}
8d7da424 1143${_alib}: ${${_alib}:C/$/__L/}
1144.endfor
984263bc
MD
1145_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1146_generic_libs: ${_generic_libs:S/$/__L/}
1147
1397f94a
MD
1148# library targets must be ordered because there are inter-library
1149# races (e.g. generation of tconfig.h)
1150#
2a89766a 1151.for _alib in ${_startup_libs_base} ${_startup_libs_alt}
8d7da424 1152.ORDER: ${${_alib}:C/$/__L/}
1153.endfor
d03fffea 1154
1155# uncomment if there are missing dependencies
1156.if 0
1397f94a 1157.ORDER: ${_prebuild_libs:S/$/__L/}
d03fffea 1158# we can disable this one, no lib/* depend on libstdc++
1397f94a 1159.ORDER: ${_generic_libs:S/$/__L/}
d03fffea 1160.endif
1397f94a
MD
1161
1162.for __target in clean cleandepend cleandir obj depend includes
984263bc
MD
1163.for entry in ${SUBDIR}
1164${entry}.${__target}__D: .PHONY
1165 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1166 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
1167 edir=${entry}.${MACHINE_ARCH}; \
1168 cd ${.CURDIR}/$${edir}; \
1169 else \
1170 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
1171 edir=${entry}; \
1172 cd ${.CURDIR}/$${edir}; \
1173 fi; \
f8a75064 1174 make ${__target} DIRPRFX=${DIRPRFX}$${edir}/
984263bc 1175.endfor
8d7da424 1176par-${__target}: ${SUBDIR:C/$/.${__target}__D/}
1177.ORDER: ${SUBDIR:C/$/.${__target}__D/}
984263bc 1178.endfor
1397f94a 1179.ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
984263bc 1180
cb0f1574
MD
1181# The wmake target is used by /usr/bin/wmake to run make in a
1182# world build environment.
1183#
1184wmake:
7a1f111f 1185 @echo '${WMAKEENV} make ${WMAKE_ARGS} -DSYSBUILD'
cb0f1574 1186
5c7da0d7
MD
1187wmakeenv:
1188 @echo '${WMAKEENV} /bin/sh'
1189
1397f94a 1190bmake:
7a1f111f 1191 @echo '${BMAKEENV} make ${BMAKE_ARGS} -DSYSBUILD'
1397f94a 1192
17030342
MD
1193bmakeenv:
1194 @echo '${BMAKEENV} /bin/sh'
1195
1397f94a 1196tmake:
7a1f111f 1197 @echo '${TMAKEENV} make ${TMAKE_ARGS} -DSYSBUILD'
1397f94a 1198
17030342
MD
1199tmakeenv:
1200 @echo '${TMAKEENV} /bin/sh'
1201
66834c05 1202xmake:
7a1f111f 1203 @echo '${XMAKEENV} make ${XMAKE_ARGS} -DSYSBUILD'
66834c05
SS
1204
1205xmakeenv:
1206 @echo '${XMAKEENV} /bin/sh'
1207
2decc9b9 1208backupworld: backup-clean
7bee86c0 1209 @mkdir -p ${WORLD_BACKUP}
2decc9b9
JM
1210.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1211 exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1212 exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1213 tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1214 --options gzip:compression-level=1 \
1215 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1216.endif
61443441
JM
1217
1218backupworld-auto:
2decc9b9
JM
1219.if !defined(NO_BACKUP)
1220 rm -f ${AUTO_BACKUP}/binaries.tar.gz
61443441 1221 @mkdir -p ${AUTO_BACKUP}
2decc9b9
JM
1222.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1223 exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1224 exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
5738cc3a 1225 /usr/bin/tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
2decc9b9
JM
1226 --options gzip:compression-level=1 \
1227 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1228.endif
aaae54f7 1229.endif
7bee86c0 1230
2decc9b9
JM
1231backup-auto-clean:
1232 rm -f ${AUTO_BACKUP}/binaries.tar.gz
1233
1234backup-clean:
1235 rm -f ${WORLD_BACKUP}/binaries.tar.gz
1236
9b724c0d
MD
1237# Build and install the statically linked rescue tools, and create the
1238# initrd image.
1239#
1240rescue initrd quickrescue quickinitrd: .PHONY
1241 (cd ${.CURDIR}/initrd; make ${.TARGET})
1242
7bee86c0 1243restoreworld:
2decc9b9 1244.if !exists(${WORLD_BACKUP}/binaries.tar.gz)
7bee86c0
JM
1245 @echo "There does not seem to be a valid archive present."
1246.else
61443441 1247 @echo "Restoring system binaries from manual backup archive..."
2decc9b9
JM
1248 @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1249 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1250 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1251 tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
7bee86c0
JM
1252.endif
1253
61443441 1254restoreworld-auto:
2decc9b9 1255.if !exists(${AUTO_BACKUP}/binaries.tar.gz)
61443441
JM
1256 @echo "There does not seem to be a valid archive present."
1257.else
1258 @echo "Restoring system binaries from auto-backup archive..."
2decc9b9
JM
1259 @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1260 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1261 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1262 tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
61443441
JM
1263.endif
1264
3da8e88f
JM
1265# Take advantage of bmake error response
1266#
1267MAKE_PRINT_VAR_ON_ERROR= \
1268 .CURDIR \
1269 .OBJDIR \
81c85727
AL
1270 .TARGETS \
1271 .ERROR_TARGET \
1272 .MAKE.LEVEL \
1273 .MAKE.MODE \
1274 PATH \
3da8e88f
JM
1275 LD_LIBRARY_PATH \
1276 MACHINE_ARCH \
1277 MACHINE \
1278 MAKEFILE \
81c85727
AL
1279 MAKESYSPATH \
1280 MAKEOBJDIRPREFIX \
8d7da424 1281 WORLD_ALTCOMPILER \
81c85727
AL
1282 DESTDIR \
1283 SHELL .SHELL
1284.if ${.MAKE.LEVEL} > 0
1285MAKE_PRINT_VAR_ON_ERROR+= .MAKE.MAKEFILES .PATH
1286.endif
3da8e88f 1287
984263bc 1288.include <bsd.subdir.mk>