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