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