Tell awk where the arguments for the program ends and where the arguments for
[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 $
44831353 3# $DragonFly: src/Makefile.inc1,v 1.29 2004/04/05 05:30:10 dillon Exp $
984263bc
MD
4#
5# Make command line options:
984263bc
MD
6# -DMAKE_KERBEROS5 to build Kerberos5
7# -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8# -DNOCLEAN do not clean at all
9# -DNOCRYPT will prevent building of crypt versions
10# -DNOMAN do not build the manual pages
11# -DNOPROFILE do not build profiled libraries
984263bc
MD
12# -DNOGAMES do not go into games subdir
13# -DNOSHARE do not go into share subdir
14# -DNOINFO do not make or install info files
15# -DNOLIBC_R do not build libc_r.
16# -DNO_FORTRAN do not build g77 and related libraries.
17# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
18# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
19# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
20# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
21# -DNO_DOCUPDATE do not update doc in ${MAKE} update
22# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
23# TARGET_ARCH="arch" to crossbuild world to a different arch
984263bc
MD
24#
25# The intended user-driven targets are:
1397f94a 26#
984263bc 27# buildworld - rebuild *everything*, including glue to help do upgrades
1397f94a
MD
28# quickworld - skip the glue and do a depend+build on the meat
29# realquickworld - skip the glue and depend stages and just build the meat
30# crossworld - only build the glue (particularly the cross-build environment)
984263bc
MD
31# installworld- install everything built by "buildworld"
32# update - convenient way to update your source tree (eg: sup/cvs)
33# most - build user commands, no libraries or include files
34# installmost - install user commands, no libraries or include files
35#
36# Standard targets (not defined here) are documented in the makefiles in
37# /usr/share/mk. These include:
38# obj depend all install clean cleandepend cleanobj
39
40# Put initial settings here.
41SUBDIR=
42
43# We must do share/info early so that installation of info `dir'
44# entries works correctly. Do it first since it is less likely to
45# grow dependencies on include and lib than vice versa.
46.if exists(${.CURDIR}/share/info)
47SUBDIR+= share/info
48.endif
49
50# We must do include and lib early so that the perl *.ph generation
51# works correctly as it uses the header files installed by this.
52.if exists(${.CURDIR}/include)
53SUBDIR+= include
54.endif
55.if exists(${.CURDIR}/lib)
56SUBDIR+= lib
57.endif
17d0fefe
MD
58# This exists simply to ensure that the obj dir hierarchy is
59# intact for nrelease, allowing the nrelease Makefile's to
60# reference ${.OBJDIR}.
61#
62.if exists(${.CURDIR}/nrelease)
63SUBDIR+= nrelease
64.endif
984263bc
MD
65
66.if exists(${.CURDIR}/bin)
67SUBDIR+= bin
68.endif
69.if exists(${.CURDIR}/games) && !defined(NOGAMES)
70SUBDIR+= games
71.endif
72.if exists(${.CURDIR}/gnu)
73SUBDIR+= gnu
74.endif
984263bc
MD
75.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
76 !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
77SUBDIR+= kerberos5
78.endif
79.if exists(${.CURDIR}/libexec)
80SUBDIR+= libexec
81.endif
82.if exists(${.CURDIR}/sbin)
83SUBDIR+= sbin
84.endif
de347b31 85.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
984263bc
MD
86SUBDIR+= secure
87.endif
88.if exists(${.CURDIR}/share) && !defined(NOSHARE)
89SUBDIR+= share
90.endif
91.if exists(${.CURDIR}/sys)
92SUBDIR+= sys
93.endif
94.if exists(${.CURDIR}/usr.bin)
95SUBDIR+= usr.bin
96.endif
97.if exists(${.CURDIR}/usr.sbin)
98SUBDIR+= usr.sbin
99.endif
100
101# etc must be last for "distribute" to work
102.if exists(${.CURDIR}/etc)
103SUBDIR+= etc
104.endif
105
106# These are last, since it is nice to at least get the base system
107# rebuilt before you do them.
108.if defined(LOCAL_DIRS)
109.for _DIR in ${LOCAL_DIRS}
110.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
111SUBDIR+= ${_DIR}
112.endif
113.endfor
114.endif
115
116.if defined(SUBDIR_OVERRIDE)
117SUBDIR= ${SUBDIR_OVERRIDE}
118.endif
119
120.if defined(NOCLEANDIR)
121CLEANDIR= clean cleandepend
122.else
123CLEANDIR= cleandir
124.endif
125
126SUP?= /usr/local/bin/cvsup
127SUPFLAGS?= -g -L 2 -P -
128.if defined(SUPHOST)
129SUPFLAGS+= -h ${SUPHOST}
130.endif
131
1397f94a
MD
132# Object directory base in primary make. Note that when we rerun make
133# from inside this file we change MAKEOBJDIRPREFIX to the appropriate
134# subdirectory because the rest of the build system needs it that way.
135# The original object directory base is saved in OBJTREE.
136#
984263bc 137MAKEOBJDIRPREFIX?= /usr/obj
1397f94a
MD
138OBJTREE?= ${MAKEOBJDIRPREFIX}
139
140# Used for stage installs and pathing
141#
142DESTDIRBASE?= ${OBJTREE}${.CURDIR}
143
984263bc
MD
144TARGET_ARCH?= ${MACHINE_ARCH}
145.if ${TARGET_ARCH} == ${MACHINE_ARCH}
146TARGET?= ${MACHINE}
147.else
148TARGET?= ${TARGET_ARCH}
149.endif
150.if make(buildworld)
151BUILD_ARCH!= sysctl -n hw.machine_arch
152.if ${MACHINE_ARCH} != ${BUILD_ARCH}
153.error To cross-build, set TARGET_ARCH.
154.endif
155.endif
1397f94a
MD
156
157# BTOOLS (Natively built) All non-cross-development tools that the
158# main build needs. This includes things like 'mkdir' and 'rm'.
159# We will not use the native system's exec path once we start
160# on WORLD. (bootstrap-tools and build-tools or BTOOLS)
161#
162# CTOOLS (Natively built) Cross development tools which are specific
163# to the target architecture.
164#
165# WORLD (Cross built) Our ultimate buildworld, using only BTOOLS and
166# CTOOLS.
167#
168# MACHINE_ARCH Architecture we are building on
169# TARGET_ARCH Architecture we are building for
170#
171BTOOLSDEST= ${DESTDIRBASE}/btools_${MACHINE_ARCH}
172CTOOLSDEST= ${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH}
173WORLDDEST= ${DESTDIRBASE}/world_${TARGET_ARCH}
174
175# The strict temporary command path contains all binaries required
176# by the buildworld system after the cross-tools stage.
177#
178STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
984263bc
MD
179
180TMPDIR?= /tmp
181TMPPID!= echo $$$$
984263bc
MD
182
183#
184# Building a world goes through the following stages
185#
186# 1. bootstrap-tool stage [BMAKE]
187# This stage is responsible for creating programs that
188# are needed for backward compatibility reasons. They
189# are not built as cross-tools.
190# 2. build-tool stage [TMAKE]
191# This stage is responsible for creating the object
192# tree and building any tools that are needed during
193# the build process.
194# 3. cross-tool stage [XMAKE]
195# This stage is responsible for creating any tools that
196# are needed for cross-builds. A cross-compiler is one
197# of them.
198# 4. world stage [WMAKE]
199# This stage actually builds the world.
200# 5. install stage (optional) [IMAKE]
201# This stage installs a previously built world.
202#
203
984263bc 204# bootstrap-tool stage
1397f94a
MD
205#
206BMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
207 OBJTREE=${OBJTREE} \
44831353 208 DESTDIR=${BTOOLSDEST} \
984263bc 209 INSTALL="sh ${.CURDIR}/tools/install.sh"
1397f94a 210
984263bc
MD
211BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
212 -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
213 -DNO_WERROR
214
215# build-tool stage
1397f94a
MD
216#
217TMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
218 OBJTREE=${OBJTREE} \
984263bc
MD
219 DESTDIR= \
220 INSTALL="sh ${.CURDIR}/tools/install.sh"
1397f94a
MD
221
222TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
223 -DNO_FORTRAN
984263bc
MD
224
225# cross-tool stage
1397f94a
MD
226#
227# note: TOOLS_PREFIX points to the obj root holding the cross
44831353
MD
228# compiler binaries, while USRDATA_PREFIX points to the obj root
229# holding the target environment (and also determines where cross-built
230# libraries, crt*.o, and include files are installed).
1397f94a
MD
231#
232XMAKEENV= MAKEOBJDIRPREFIX=${CTOOLSDEST} \
233 OBJTREE=${OBJTREE} \
234 DESTDIR=${CTOOLSDEST} \
235 INSTALL="sh ${.CURDIR}/tools/install.sh" \
236 TOOLS_PREFIX=${CTOOLSDEST} \
237 USRDATA_PREFIX=${WORLDDEST}
238
44831353
MD
239XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
240 -DBOOTSTRAPPING
1397f94a
MD
241
242# world stage, note the strict path and note that TOOLS_PREFIX is left
243# unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
244# which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
245# for both binary and library paths, even though it is being compiled to
246# WORLDDEST. None of the programs in the world stage are ever actually
247# executed during the buildworld/installworld.
248#
249CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \
250 OBJTREE=${OBJTREE} \
251 MACHINE_ARCH=${TARGET_ARCH} \
252 MACHINE=${TARGET} \
253 OBJFORMAT_PATH=${CTOOLSDEST} \
254 PERL5LIB=${WORLDDEST}/usr/libdata/perl/5.00503 \
c02263c2
MD
255 GROFF_BIN_PATH=${BTOOLSDEST}/usr/bin \
256 GROFF_FONT_PATH=${BTOOLSDEST}/usr/share/groff_font \
257 GROFF_TMAC_PATH=${BTOOLSDEST}/usr/share/tmac
984263bc 258
984263bc 259WMAKEENV= ${CROSSENV} \
1397f94a 260 DESTDIR=${WORLDDEST} \
984263bc 261 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1397f94a
MD
262 PATH=${STRICTTMPPATH}
263
984263bc
MD
264WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1
265
266# install stage
b07b69cc 267#
984263bc 268IMAKEENV= ${CROSSENV} \
1397f94a 269 PATH=${STRICTTMPPATH}
984263bc
MD
270IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
271
272# kernel stage
b07b69cc
MD
273#
274KMAKEENV= ${WMAKEENV}
984263bc 275
984263bc
MD
276# buildworld
277#
278# Attempt to rebuild the entire system, with reasonable chance of
279# success, regardless of how old your existing system is.
280#
281_worldtmp:
282 @echo
283 @echo "--------------------------------------------------------------"
284 @echo ">>> Rebuilding the temporary build tree"
285 @echo "--------------------------------------------------------------"
286.if !defined(NOCLEAN)
1397f94a 287 rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
984263bc
MD
288.else
289 # XXX - These two can depend on any header file.
290 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
291 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
292.endif
1397f94a
MD
293 mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
294.for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
295 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
296 -p ${_dir}/ > /dev/null
297 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
298 -p ${_dir}/usr > /dev/null
984263bc 299.endfor
1397f94a
MD
300 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
301 -p ${WORLDDEST}/usr/include > /dev/null
302 ln -sf ${.CURDIR}/sys ${WORLDDEST}
303
984263bc
MD
304_bootstrap-tools:
305 @echo
306 @echo "--------------------------------------------------------------"
307 @echo ">>> stage 1: bootstrap tools"
308 @echo "--------------------------------------------------------------"
309 cd ${.CURDIR}; ${BMAKE} bootstrap-tools
310_cleanobj:
984263bc
MD
311 @echo
312 @echo "--------------------------------------------------------------"
1397f94a 313 @echo ">>> stage 2a: cleaning up the object tree"
984263bc
MD
314 @echo "--------------------------------------------------------------"
315 cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
984263bc
MD
316_obj:
317 @echo
318 @echo "--------------------------------------------------------------"
1397f94a 319 @echo ">>> stage 2b: rebuilding the object tree"
984263bc
MD
320 @echo "--------------------------------------------------------------"
321 cd ${.CURDIR}; ${WMAKE} par-obj
322_build-tools:
323 @echo
324 @echo "--------------------------------------------------------------"
1397f94a 325 @echo ">>> stage 2c: build tools"
984263bc
MD
326 @echo "--------------------------------------------------------------"
327 cd ${.CURDIR}; ${TMAKE} build-tools
328_cross-tools:
329 @echo
330 @echo "--------------------------------------------------------------"
331 @echo ">>> stage 3: cross tools"
332 @echo "--------------------------------------------------------------"
333 cd ${.CURDIR}; ${XMAKE} cross-tools
334_includes:
335 @echo
336 @echo "--------------------------------------------------------------"
1397f94a 337 @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
984263bc
MD
338 @echo "--------------------------------------------------------------"
339 cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
340_libraries:
341 @echo
342 @echo "--------------------------------------------------------------"
1397f94a 343 @echo ">>> stage 4b: building libraries"
984263bc
MD
344 @echo "--------------------------------------------------------------"
345 cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
346_depend:
347 @echo
348 @echo "--------------------------------------------------------------"
1397f94a 349 @echo ">>> stage 4c: make dependencies"
984263bc
MD
350 @echo "--------------------------------------------------------------"
351 cd ${.CURDIR}; ${WMAKE} par-depend
352everything:
353 @echo
354 @echo "--------------------------------------------------------------"
1397f94a 355 @echo ">>> stage 4d: building everything.."
984263bc
MD
356 @echo "--------------------------------------------------------------"
357 cd ${.CURDIR}; ${WMAKE} all
358
1397f94a
MD
359# note: buildworld no longer depends on _cleanobj because we rm -rf the
360# entire object tree and built the bootstrap tools in a different location.
361#
362# buildworld - build everything from scratch
363# quickworld - skip the bootstrap, build, and cross-build steps
364# realquickworld - skip the bootstrap, build, crossbuild, and depend step.
365#
366# note: we include _obj in realquickworld to prevent accidental creation
367# of files in /usr/src.
984263bc
MD
368
369WMAKE_TGTS=
370.if !defined(SUBDIR_OVERRIDE)
371WMAKE_TGTS+= _worldtmp _bootstrap-tools
372.endif
1397f94a 373WMAKE_TGTS+= _obj _build-tools
984263bc
MD
374.if !defined(SUBDIR_OVERRIDE)
375WMAKE_TGTS+= _cross-tools
376.endif
377WMAKE_TGTS+= _includes _libraries _depend everything
378
379buildworld: ${WMAKE_TGTS}
1397f94a
MD
380
381quickworld: _obj _includes _libraries _depend everything
382
383realquickworld: _obj _includes _libraries everything
384
385crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
386
984263bc
MD
387.ORDER: ${WMAKE_TGTS}
388
389#
390# installcheck
391#
392# Checks to be sure system is ready for installworld
393#
394installcheck:
395.if !defined(NO_SENDMAIL)
72ac4ef4 396 @if ! `id -u smmsp > /dev/null`; then \
984263bc
MD
397 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
398 false; \
399 fi
72ac4ef4 400 @if ! `id -g smmsp > /dev/null`; then \
984263bc
MD
401 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
402 false; \
403 fi
404.endif
405
406#
407# distributeworld
408#
409# Distributes everything compiled by a `buildworld'.
410#
411# installworld
412#
413# Installs everything compiled by a 'buildworld'.
414#
415distributeworld installworld: installcheck
984263bc 416 cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
984263bc
MD
417
418#
419# reinstall
420#
421# If you have a build server, you can NFS mount the source and obj directories
422# and do a 'make reinstall' on the *client* to install new binaries from the
423# most recent server build.
424#
425reinstall:
426 @echo "--------------------------------------------------------------"
427 @echo ">>> Making hierarchy"
428 @echo "--------------------------------------------------------------"
429 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
430 @echo
431 @echo "--------------------------------------------------------------"
432 @echo ">>> Installing everything.."
433 @echo "--------------------------------------------------------------"
434 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
435.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
436 @echo
437 @echo "--------------------------------------------------------------"
438 @echo ">>> Rebuilding man page indices"
439 @echo "--------------------------------------------------------------"
440 cd ${.CURDIR}/share/man; ${MAKE} makedb
441.endif
442
443redistribute:
444 @echo "--------------------------------------------------------------"
445 @echo ">>> Distributing everything.."
446 @echo "--------------------------------------------------------------"
447 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
448
449#
450# buildkernel and installkernel
451#
452# Which kernels to build and/or install is specified by setting
453# KERNCONF. If not defined a GENERIC kernel is built/installed.
454# Only the existing (depending TARGET) config files are used
455# for building kernels and only the first of these is designated
456# as the one being installed.
457#
458# Note that we have to use TARGET instead of TARGET_ARCH when
459# we're in kernel-land. Since only TARGET_ARCH is (expected) to
460# be set to cross-build, we have to make sure TARGET is set
461# properly.
462
463.if !defined(KERNCONF) && defined(KERNEL)
464KERNCONF= ${KERNEL}
465KERNWARN= yes
466.else
467KERNCONF?= GENERIC
468.endif
469INSTKERNNAME?= kernel
470
471KRNLSRCDIR= ${.CURDIR}/sys
472KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
473KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
474KERNCONFDIR?= ${KRNLCONFDIR}
475
476BUILDKERNELS=
477INSTALLKERNEL=
478.for _kernel in ${KERNCONF}
479.if exists(${KERNCONFDIR}/${_kernel})
480BUILDKERNELS+= ${_kernel}
481.if empty(INSTALLKERNEL)
482INSTALLKERNEL= ${_kernel}
483.endif
484.endif
485.endfor
486
487#
488# buildkernel
489#
490# Builds all kernels defined by BUILDKERNELS.
491#
e05c8c84
MD
492check_buildworld_tools:
493 @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
494 echo "You must buildworld before buildkernel. If you wish"; \
495 echo "to build a kernel using native tools, config it manually"; \
496 echo "or use the nativekernel target if you are in a rush"; \
497 exit 1; \
498 fi
499
500buildkernel: check_buildworld_tools
984263bc
MD
501.if empty(BUILDKERNELS)
502 @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
503 @false
504.endif
505.if defined(KERNWARN)
506 @echo "--------------------------------------------------------------"
507 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
508 @echo "--------------------------------------------------------------"
509 @sleep 3
510.endif
511 @echo
512.for _kernel in ${BUILDKERNELS}
513 @echo "--------------------------------------------------------------"
514 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
515 @echo "--------------------------------------------------------------"
516 @echo "===> ${_kernel}"
e05c8c84
MD
517 @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
518 echo "REMOVING OLD NATIVEKERNEL BUILD"; \
519 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
984263bc
MD
520 mkdir -p ${KRNLOBJDIR}
521.if !defined(NO_KERNELCONFIG)
522 cd ${KRNLCONFDIR}; \
1397f94a 523 PATH=${STRICTTMPPATH} \
984263bc
MD
524 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
525 ${KERNCONFDIR}/${_kernel}
526.endif
e05c8c84 527 touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
984263bc
MD
528.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
529 cd ${KRNLOBJDIR}/${_kernel}; \
530 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
531.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
532 cd ${KRNLOBJDIR}/${_kernel}; \
533 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
534.endif
535.endif
536 cd ${KRNLOBJDIR}/${_kernel}; \
9f3906fd
MD
537 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
538 ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
984263bc
MD
539.if !defined(NO_KERNELDEPEND)
540 cd ${KRNLOBJDIR}/${_kernel}; \
541 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
542.endif
543 cd ${KRNLOBJDIR}/${_kernel}; \
544 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
545 @echo "--------------------------------------------------------------"
546 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
547 @echo "--------------------------------------------------------------"
548.endfor
549
e05c8c84
MD
550# The nativekernel target is for when you are impatient and want to
551# build a kernel without building the world first.
552#
553nativekernel:
554.if empty(BUILDKERNELS)
555 @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
556 @false
557.endif
558.if defined(KERNWARN)
559 @echo "--------------------------------------------------------------"
560 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
561 @echo "--------------------------------------------------------------"
562 @sleep 3
563.endif
564 @echo
565.for _kernel in ${BUILDKERNELS}
566 @echo "--------------------------------------------------------------"
567 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
568 @echo "--------------------------------------------------------------"
569 @echo "===> ${_kernel}"
570 @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
571 echo "REMOVING OLD BUILDKERNEL BUILD"; \
572 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
573 mkdir -p ${KRNLOBJDIR}
574.if !defined(NO_KERNELCONFIG)
575 cd ${KRNLCONFDIR}; \
576 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
577 ${KERNCONFDIR}/${_kernel}
578.endif
579 touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
580.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
581 cd ${KRNLOBJDIR}/${_kernel}; \
582 ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
583.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
584 cd ${KRNLOBJDIR}/${_kernel}; \
585 ${MAKE} KERNEL=${INSTKERNNAME} cleandir
586.endif
587.endif
588 cd ${KRNLOBJDIR}/${_kernel}; \
589 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
590 ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
591.if !defined(NO_KERNELDEPEND)
592 cd ${KRNLOBJDIR}/${_kernel}; \
593 ${MAKE} KERNEL=${INSTKERNNAME} depend
594.endif
595 cd ${KRNLOBJDIR}/${_kernel}; \
596 ${MAKE} KERNEL=${INSTKERNNAME} all
597 @echo "--------------------------------------------------------------"
598 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
599 @echo "--------------------------------------------------------------"
600.endfor
601
984263bc
MD
602#
603# installkernel
604#
605# Install the kernel defined by INSTALLKERNEL
606#
607installkernel reinstallkernel:
608 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
609 ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
610
611#
612# update
613#
614# Update the source tree, by running sup and/or running cvs to update to the
615# latest copy.
616#
617update:
618.if defined(SUP_UPDATE)
619 @echo "--------------------------------------------------------------"
620 @echo ">>> Running ${SUP}"
621 @echo "--------------------------------------------------------------"
622.if defined(SUPFILE)
623 @${SUP} ${SUPFLAGS} ${SUPFILE}
624.endif
625.if defined(SUPFILE1)
626 @${SUP} ${SUPFLAGS} ${SUPFILE1}
627.endif
628.if defined(SUPFILE2)
629 @${SUP} ${SUPFLAGS} ${SUPFILE2}
630.endif
631.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
632 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
633.endif
634.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
635 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
636.endif
637.endif
638.if defined(CVS_UPDATE)
639 @echo "--------------------------------------------------------------"
640 @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
641 @echo "--------------------------------------------------------------"
642 cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
643.endif
644
645#
646# most
647#
648# Build most of the user binaries on the existing system libs and includes.
649#
650most:
651 @echo "--------------------------------------------------------------"
652 @echo ">>> Building programs only"
653 @echo "--------------------------------------------------------------"
654.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
655 cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ all
656.endfor
657
658#
659# installmost
660#
661# Install the binaries built by the 'most' target. This does not include
662# libraries or include files.
663#
664installmost:
665 @echo "--------------------------------------------------------------"
666 @echo ">>> Installing programs only"
667 @echo "--------------------------------------------------------------"
668.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
669 cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ install
670.endfor
671
672#
673# ------------------------------------------------------------------------
674#
675# From here onwards are utility targets used by the 'make world' and
676# related targets. If your 'world' breaks, you may like to try to fix
677# the problem and manually run the following targets to attempt to
678# complete the build. Beware, this is *not* guaranteed to work, you
679# need to have a pretty good grip on the current state of the system
680# to attempt to manually finish it. If in doubt, 'make world' again.
681#
682
1397f94a 683# bootstrap-tools: Build all tools required to build all tools.
984263bc 684#
17030342
MD
685# [x]install: dependancies on various new install features
686# rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
687# envs are not compatible with older objformat binaries.
688#
984263bc
MD
689.if exists(${.CURDIR}/games) && !defined(NOGAMES)
690_strfile= games/fortune/strfile
691.endif
692
693bootstrap-tools:
1397f94a
MD
694.for _tool in ${_strfile} \
695 bin/chmod bin/cp bin/dd bin/mkdir bin/rm bin/echo bin/test \
696 bin/cat bin/date bin/ln bin/mv bin/csh bin/expr bin/sh bin/ls \
b07b69cc 697 bin/hostname bin/kill \
1397f94a
MD
698 sbin/sysctl \
699 usr.bin/yacc usr.bin/colldef usr.bin/uudecode usr.bin/xinstall \
700 usr.bin/m4 usr.bin/rpcgen usr.bin/make gnu/usr.bin/awk usr.bin/file \
701 usr.bin/find usr.bin/lex usr.bin/sed usr.bin/uname usr.bin/touch \
702 usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
703 usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
704 usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
b07b69cc 705 usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
1397f94a 706 usr.bin/vi usr.bin/cap_mkdb usr.bin/vgrind usr.bin/true usr.bin/false \
c02263c2 707 usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
1397f94a 708 usr.sbin/chown usr.sbin/mtree usr.sbin/config \
8a48ec64 709 usr.sbin/btxld usr.sbin/pwd_mkdb usr.sbin/zic usr.sbin/makewhatis \
1397f94a
MD
710 gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo \
711 gnu/usr.bin/grep gnu/usr.bin/sort gnu/usr.bin/patch \
f0f3e4e6 712 gnu/usr.bin/gzip
1397f94a 713 ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
984263bc
MD
714 cd ${.CURDIR}/${_tool}; \
715 ${MAKE} DIRPRFX=${_tool}/ obj; \
716 ${MAKE} DIRPRFX=${_tool}/ depend; \
717 ${MAKE} DIRPRFX=${_tool}/ all; \
1397f94a 718 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
984263bc 719.endfor
e05c8c84 720 touch ${BTOOLSDEST}/.bootstrap_done
984263bc 721
17030342
MD
722# build-tools: Build special purpose build tools. gcc2 related tools are
723# only built under the i386 architecture. Other architectures are
724# gcc3-only.
984263bc 725#
1397f94a
MD
726# XXX we may be able to remove or consolidate this into bootstrap-tools
727# now that we have the native helper (.nx/.no) infrastructure.
728#
984263bc
MD
729.if exists(${.CURDIR}/games) && !defined(NOGAMES)
730_games= games/adventure games/hack games/phantasia
731.endif
732
733.if exists(${.CURDIR}/share) && !defined(NOSHARE)
734_share= share/syscons/scrnmaps
735.endif
736
17030342
MD
737_gcc3_cross= gnu/usr.bin/cc3
738_gcc3_tools= gnu/usr.bin/cc3/cc_tools
739.if ${MACHINE_ARCH} == "i386" && ${TARGET_ARCH} == "i386"
740_gcc2_cross= gnu/usr.bin/cc
741_gcc2_tools= gnu/usr.bin/cc/cc_tools
742_binutils= gnu/usr.bin/binutils gnu/usr.bin/binutils214
743.else
744_binutils= gnu/usr.bin/binutils214
745.endif
746
984263bc 747.if !defined(NO_FORTRAN)
17030342 748.if ${TARGET_ARCH} == "i386"
984263bc 749_fortran= gnu/usr.bin/cc/f771
17030342
MD
750.else
751_fortran= gnu/usr.bin/cc3/f771
752.endif
984263bc
MD
753.endif
754
755.if !defined(NOPERL)
756_perl= gnu/usr.bin/perl/miniperl
757.endif
758
984263bc
MD
759.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
760 !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
761_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
762 kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
763.endif
764
765.if defined(RELEASEDIR)
766_sysinstall= release/sysinstall
767.endif
768
769build-tools:
1397f94a 770.for _tool in ${_gcc2_tools} ${_gcc3_tools} \
17030342 771 ${_fortran} ${_perl} ${_libroken4} ${_libkrb5} \
1397f94a
MD
772 ${_share} ${_sysinstall}
773 ${ECHODIR} "===> ${_tool} (build-tools)"; \
984263bc
MD
774 cd ${.CURDIR}/${_tool}; \
775 ${MAKE} DIRPRFX=${_tool}/ obj; \
1397f94a
MD
776 ${MAKE} DIRPRFX=${_tool}/ depend; \
777 ${MAKE} DIRPRFX=${_tool}/ all; \
778 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
984263bc 779.endfor
e05c8c84 780 touch ${BTOOLSDEST}/.build_done
984263bc
MD
781
782#
783# cross-tools: Build cross-building tools
784#
785.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
786_elf2exe= usr.sbin/elf2exe
787.endif
788
789.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
790_btxld= usr.sbin/btxld
791.endif
792
793cross-tools:
17030342
MD
794.for _tool in ${_btxld} ${_elf2exe} ${_binutils} \
795 usr.bin/objformat usr.sbin/crunch/crunchide \
796 ${_gcc2_cross} ${_gcc3_cross}
1397f94a 797 ${ECHODIR} "===> ${_tool} (cross-tools)"; \
984263bc
MD
798 cd ${.CURDIR}/${_tool}; \
799 ${MAKE} DIRPRFX=${_tool}/ obj; \
800 ${MAKE} DIRPRFX=${_tool}/ depend; \
801 ${MAKE} DIRPRFX=${_tool}/ all; \
1397f94a 802 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
984263bc 803.endfor
e05c8c84 804 touch ${CTOOLSDEST}/.cross_done
984263bc
MD
805
806#
807# hierarchy - ensure that all the needed directories are present
808#
809hierarchy:
810 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
811
812#
813# libraries - build all libraries, and install them under ${DESTDIR}.
814#
815# The list of libraries with dependents (${_prebuild_libs}) and their
816# interdependencies (__L) are built automatically by the
817# ${.CURDIR}/tools/make_libdeps.sh script.
818#
5228fe46
MD
819# .makeenv does not work when bootstrapping from 4.x, so we must be sure
820# to specify the correct CCVER or 'cc' will not exec the correct compiler.
821#
984263bc
MD
822libraries:
823 cd ${.CURDIR}; \
5228fe46
MD
824 CCVER=gcc2 ${MAKE} -f Makefile.inc1 _startup_libs2; \
825 CCVER=gcc3 ${MAKE} -f Makefile.inc1 _startup_libs3; \
984263bc
MD
826 ${MAKE} -f Makefile.inc1 _startup_libs; \
827 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
828 ${MAKE} -f Makefile.inc1 _generic_libs;
e05c8c84 829 touch ${WORLDDEST}/.libraries_done
984263bc
MD
830
831# These dependencies are not automatically generated:
832#
833# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
5228fe46
MD
834# shared libraries for ELF. The targets for _startup_libs{2,3} are
835# specifically built using gcc{2,3}.
984263bc 836#
5228fe46
MD
837_startup_libs2= gnu/lib/gcc2/csu gnu/lib/gcc2/libgcc
838_startup_libs3= gnu/lib/gcc3/csu gnu/lib/gcc3/libgcc
aa8d5dcb
DR
839.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
840_startup_libs= lib/csu/${MACHINE_ARCH}-elf
984263bc 841.else
5228fe46 842_startup_libs= lib/csu/${MACHINE_ARCH}
984263bc 843.endif
1397f94a 844_startup_libs+= lib/libc
984263bc
MD
845
846_prebuild_libs=
847
848_generic_libs= gnu/lib
849
850.if !defined(NOPERL)
851_generic_libs+= gnu/usr.bin/perl/libperl
852.endif
853
854.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
855_prebuild_libs+= kerberos5/lib/libasn1
856_prebuild_libs+= kerberos5/lib/libgssapi
857_prebuild_libs+= kerberos5/lib/libkrb5
858_prebuild_libs+= kerberos5/lib/libroken
859_generic_libs+= kerberos5/lib
860.endif
861
984263bc
MD
862_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
863 lib/libncurses lib/libopie lib/libradius lib/libskey \
864 lib/libtacplus lib/libutil \
865 lib/libz lib/msun
866
867lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
868lib/libskey__L: lib/libcrypt__L lib/libmd__L
869
870_generic_libs+= lib
871
de347b31 872.if !defined(NOCRYPT)
984263bc
MD
873.if !defined(NO_OPENSSL)
874_prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
875.if !defined(NO_OPENSSH)
876_prebuild_libs+= secure/lib/libssh
877secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
878.endif
879.endif
880_generic_libs+= secure/lib
881.endif
882
883_generic_libs+= usr.bin/lex/lib
884
885.if ${MACHINE_ARCH} == "i386"
886_generic_libs+= usr.sbin/pcvt/keycap
887.endif
888
5228fe46
MD
889.for _lib in ${_startup_libs2} ${_startup_libs3} ${_startup_libs} \
890 ${_prebuild_libs} ${_generic_libs}
984263bc
MD
891${_lib}__L: .PHONY
892.if exists(${.CURDIR}/${_lib})
893 ${ECHODIR} "===> ${_lib}"; \
894 cd ${.CURDIR}/${_lib}; \
895 ${MAKE} DIRPRFX=${_lib}/ depend; \
896 ${MAKE} DIRPRFX=${_lib}/ all; \
897 ${MAKE} DIRPRFX=${_lib}/ install
898.endif
899.endfor
900
17030342
MD
901# only mess with gcc2 for i386 architectures.
902#
984263bc 903_startup_libs: ${_startup_libs:S/$/__L/}
17030342 904.if ${TARGET_ARCH} == "i386"
5228fe46 905_startup_libs2: ${_startup_libs2:S/$/__L/}
17030342
MD
906.else
907_startup_libs2:
908.endif
5228fe46 909_startup_libs3: ${_startup_libs3:S/$/__L/}
984263bc
MD
910_prebuild_libs: ${_prebuild_libs:S/$/__L/}
911_generic_libs: ${_generic_libs:S/$/__L/}
912
1397f94a
MD
913# library targets must be ordered because there are inter-library
914# races (e.g. generation of tconfig.h)
915#
916.ORDER: ${_startup_libs2:S/$/__L/}
917.ORDER: ${_startup_libs3:S/$/__L/}
918.ORDER: ${_startup_libs:S/$/__L/}
919.ORDER: ${_prebuild_libs:S/$/__L/}
920.ORDER: ${_generic_libs:S/$/__L/}
921
922.for __target in clean cleandepend cleandir obj depend includes
984263bc
MD
923.for entry in ${SUBDIR}
924${entry}.${__target}__D: .PHONY
925 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
926 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
927 edir=${entry}.${MACHINE_ARCH}; \
928 cd ${.CURDIR}/$${edir}; \
929 else \
930 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
931 edir=${entry}; \
932 cd ${.CURDIR}/$${edir}; \
933 fi; \
934 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
935.endfor
936par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1397f94a 937.ORDER: ${SUBDIR:S/$/.${__target}__D/}
984263bc 938.endfor
1397f94a 939.ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
984263bc 940
cb0f1574
MD
941# The wmake target is used by /usr/bin/wmake to run make in a
942# world build environment.
943#
944wmake:
1397f94a 945 @echo '${WMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${WMAKE_ARGS}'
cb0f1574 946
5c7da0d7
MD
947wmakeenv:
948 @echo '${WMAKEENV} /bin/sh'
949
1397f94a
MD
950bmake:
951 @echo '${BMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${BMAKE_ARGS}'
952
17030342
MD
953bmakeenv:
954 @echo '${BMAKEENV} /bin/sh'
955
1397f94a
MD
956tmake:
957 @echo '${TMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${TMAKE_ARGS}'
958
17030342
MD
959tmakeenv:
960 @echo '${TMAKEENV} /bin/sh'
961
984263bc 962.include <bsd.subdir.mk>
cb0f1574 963