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