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