Fix a boot panic with the amd device. We inherited some busdma code from
[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 $
1a7434d5 3# $DragonFly: src/Makefile.inc1,v 1.39 2004/09/28 20:56:38 joerg 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
79aa78bc
MD
175# The bootstrap-tools path is used by the bootstrap-tools, build-tools, and
176# cross-tools stages to augment the existing command path to access newer
177# versions of certain utilities such as 'patch' that the cross-tools stage
178# might expect.
179#
180BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
181
1397f94a
MD
182# The strict temporary command path contains all binaries required
183# by the buildworld system after the cross-tools stage.
184#
185STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
984263bc
MD
186
187TMPDIR?= /tmp
188TMPPID!= echo $$$$
984263bc
MD
189
190#
191# Building a world goes through the following stages
192#
193# 1. bootstrap-tool stage [BMAKE]
194# This stage is responsible for creating programs that
195# are needed for backward compatibility reasons. They
196# are not built as cross-tools.
197# 2. build-tool stage [TMAKE]
198# This stage is responsible for creating the object
199# tree and building any tools that are needed during
200# the build process.
201# 3. cross-tool stage [XMAKE]
202# This stage is responsible for creating any tools that
203# are needed for cross-builds. A cross-compiler is one
204# of them.
205# 4. world stage [WMAKE]
206# This stage actually builds the world.
207# 5. install stage (optional) [IMAKE]
208# This stage installs a previously built world.
209#
210
984263bc 211# bootstrap-tool stage
1397f94a
MD
212#
213BMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
214 OBJTREE=${OBJTREE} \
44831353 215 DESTDIR=${BTOOLSDEST} \
79aa78bc 216 PATH=${BTOOLSPATH}:${PATH} \
984263bc 217 INSTALL="sh ${.CURDIR}/tools/install.sh"
1397f94a 218
984263bc
MD
219BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
220 -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
221 -DNO_WERROR
222
223# build-tool stage
1397f94a
MD
224#
225TMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
226 OBJTREE=${OBJTREE} \
984263bc 227 DESTDIR= \
79aa78bc 228 PATH=${BTOOLSPATH}:${PATH} \
984263bc 229 INSTALL="sh ${.CURDIR}/tools/install.sh"
1397f94a
MD
230
231TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
232 -DNO_FORTRAN
984263bc
MD
233
234# cross-tool stage
1397f94a
MD
235#
236# note: TOOLS_PREFIX points to the obj root holding the cross
44831353
MD
237# compiler binaries, while USRDATA_PREFIX points to the obj root
238# holding the target environment (and also determines where cross-built
239# libraries, crt*.o, and include files are installed).
1397f94a
MD
240#
241XMAKEENV= MAKEOBJDIRPREFIX=${CTOOLSDEST} \
242 OBJTREE=${OBJTREE} \
243 DESTDIR=${CTOOLSDEST} \
244 INSTALL="sh ${.CURDIR}/tools/install.sh" \
245 TOOLS_PREFIX=${CTOOLSDEST} \
79aa78bc
MD
246 USRDATA_PREFIX=${WORLDDEST} \
247 PATH=${BTOOLSPATH}:${PATH}
1397f94a 248
44831353
MD
249XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
250 -DBOOTSTRAPPING
1397f94a
MD
251
252# world stage, note the strict path and note that TOOLS_PREFIX is left
253# unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
254# which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
255# for both binary and library paths, even though it is being compiled to
256# WORLDDEST. None of the programs in the world stage are ever actually
257# executed during the buildworld/installworld.
258#
259CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \
260 OBJTREE=${OBJTREE} \
261 MACHINE_ARCH=${TARGET_ARCH} \
262 MACHINE=${TARGET} \
263 OBJFORMAT_PATH=${CTOOLSDEST} \
264 PERL5LIB=${WORLDDEST}/usr/libdata/perl/5.00503 \
c02263c2
MD
265 GROFF_BIN_PATH=${BTOOLSDEST}/usr/bin \
266 GROFF_FONT_PATH=${BTOOLSDEST}/usr/share/groff_font \
267 GROFF_TMAC_PATH=${BTOOLSDEST}/usr/share/tmac
984263bc 268
984263bc 269WMAKEENV= ${CROSSENV} \
1397f94a 270 DESTDIR=${WORLDDEST} \
984263bc 271 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1397f94a
MD
272 PATH=${STRICTTMPPATH}
273
984263bc
MD
274WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1
275
276# install stage
b07b69cc 277#
984263bc 278IMAKEENV= ${CROSSENV} \
1397f94a 279 PATH=${STRICTTMPPATH}
984263bc
MD
280IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
281
282# kernel stage
b07b69cc
MD
283#
284KMAKEENV= ${WMAKEENV}
984263bc 285
984263bc
MD
286# buildworld
287#
288# Attempt to rebuild the entire system, with reasonable chance of
289# success, regardless of how old your existing system is.
290#
291_worldtmp:
292 @echo
293 @echo "--------------------------------------------------------------"
294 @echo ">>> Rebuilding the temporary build tree"
295 @echo "--------------------------------------------------------------"
296.if !defined(NOCLEAN)
1397f94a 297 rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
984263bc
MD
298.else
299 # XXX - These two can depend on any header file.
300 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
301 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
302.endif
1397f94a
MD
303 mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
304.for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
305 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
306 -p ${_dir}/ > /dev/null
307 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
308 -p ${_dir}/usr > /dev/null
984263bc 309.endfor
1397f94a
MD
310 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
311 -p ${WORLDDEST}/usr/include > /dev/null
312 ln -sf ${.CURDIR}/sys ${WORLDDEST}
313
984263bc
MD
314_bootstrap-tools:
315 @echo
316 @echo "--------------------------------------------------------------"
317 @echo ">>> stage 1: bootstrap tools"
318 @echo "--------------------------------------------------------------"
319 cd ${.CURDIR}; ${BMAKE} bootstrap-tools
320_cleanobj:
984263bc
MD
321 @echo
322 @echo "--------------------------------------------------------------"
1397f94a 323 @echo ">>> stage 2a: cleaning up the object tree"
984263bc
MD
324 @echo "--------------------------------------------------------------"
325 cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
984263bc
MD
326_obj:
327 @echo
328 @echo "--------------------------------------------------------------"
1397f94a 329 @echo ">>> stage 2b: rebuilding the object tree"
984263bc
MD
330 @echo "--------------------------------------------------------------"
331 cd ${.CURDIR}; ${WMAKE} par-obj
332_build-tools:
333 @echo
334 @echo "--------------------------------------------------------------"
1397f94a 335 @echo ">>> stage 2c: build tools"
984263bc
MD
336 @echo "--------------------------------------------------------------"
337 cd ${.CURDIR}; ${TMAKE} build-tools
338_cross-tools:
339 @echo
340 @echo "--------------------------------------------------------------"
341 @echo ">>> stage 3: cross tools"
342 @echo "--------------------------------------------------------------"
343 cd ${.CURDIR}; ${XMAKE} cross-tools
344_includes:
345 @echo
346 @echo "--------------------------------------------------------------"
1397f94a 347 @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
984263bc
MD
348 @echo "--------------------------------------------------------------"
349 cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
350_libraries:
351 @echo
352 @echo "--------------------------------------------------------------"
1397f94a 353 @echo ">>> stage 4b: building libraries"
984263bc
MD
354 @echo "--------------------------------------------------------------"
355 cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
356_depend:
357 @echo
358 @echo "--------------------------------------------------------------"
1397f94a 359 @echo ">>> stage 4c: make dependencies"
984263bc
MD
360 @echo "--------------------------------------------------------------"
361 cd ${.CURDIR}; ${WMAKE} par-depend
362everything:
363 @echo
364 @echo "--------------------------------------------------------------"
1397f94a 365 @echo ">>> stage 4d: building everything.."
984263bc
MD
366 @echo "--------------------------------------------------------------"
367 cd ${.CURDIR}; ${WMAKE} all
368
1397f94a
MD
369# note: buildworld no longer depends on _cleanobj because we rm -rf the
370# entire object tree and built the bootstrap tools in a different location.
371#
372# buildworld - build everything from scratch
373# quickworld - skip the bootstrap, build, and cross-build steps
374# realquickworld - skip the bootstrap, build, crossbuild, and depend step.
375#
376# note: we include _obj in realquickworld to prevent accidental creation
377# of files in /usr/src.
984263bc
MD
378
379WMAKE_TGTS=
380.if !defined(SUBDIR_OVERRIDE)
381WMAKE_TGTS+= _worldtmp _bootstrap-tools
382.endif
1397f94a 383WMAKE_TGTS+= _obj _build-tools
984263bc
MD
384.if !defined(SUBDIR_OVERRIDE)
385WMAKE_TGTS+= _cross-tools
386.endif
387WMAKE_TGTS+= _includes _libraries _depend everything
388
389buildworld: ${WMAKE_TGTS}
1397f94a
MD
390
391quickworld: _obj _includes _libraries _depend everything
392
393realquickworld: _obj _includes _libraries everything
394
395crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
396
984263bc
MD
397.ORDER: ${WMAKE_TGTS}
398
399#
400# installcheck
401#
402# Checks to be sure system is ready for installworld
403#
404installcheck:
405.if !defined(NO_SENDMAIL)
72ac4ef4 406 @if ! `id -u smmsp > /dev/null`; then \
984263bc
MD
407 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
408 false; \
409 fi
72ac4ef4 410 @if ! `id -g smmsp > /dev/null`; then \
984263bc
MD
411 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
412 false; \
413 fi
414.endif
415
416#
417# distributeworld
418#
419# Distributes everything compiled by a `buildworld'.
420#
421# installworld
422#
423# Installs everything compiled by a 'buildworld'.
424#
425distributeworld installworld: installcheck
984263bc 426 cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
984263bc
MD
427
428#
429# reinstall
430#
431# If you have a build server, you can NFS mount the source and obj directories
432# and do a 'make reinstall' on the *client* to install new binaries from the
433# most recent server build.
434#
435reinstall:
436 @echo "--------------------------------------------------------------"
437 @echo ">>> Making hierarchy"
438 @echo "--------------------------------------------------------------"
439 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
440 @echo
441 @echo "--------------------------------------------------------------"
442 @echo ">>> Installing everything.."
443 @echo "--------------------------------------------------------------"
444 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
445.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
446 @echo
447 @echo "--------------------------------------------------------------"
448 @echo ">>> Rebuilding man page indices"
449 @echo "--------------------------------------------------------------"
450 cd ${.CURDIR}/share/man; ${MAKE} makedb
451.endif
452
453redistribute:
454 @echo "--------------------------------------------------------------"
455 @echo ">>> Distributing everything.."
456 @echo "--------------------------------------------------------------"
457 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
458
459#
fc7aca3e 460# buildkernel, nativekernel, quickkernel, and installkernel
984263bc
MD
461#
462# Which kernels to build and/or install is specified by setting
463# KERNCONF. If not defined a GENERIC kernel is built/installed.
464# Only the existing (depending TARGET) config files are used
465# for building kernels and only the first of these is designated
466# as the one being installed.
467#
468# Note that we have to use TARGET instead of TARGET_ARCH when
469# we're in kernel-land. Since only TARGET_ARCH is (expected) to
470# be set to cross-build, we have to make sure TARGET is set
471# properly.
472
473.if !defined(KERNCONF) && defined(KERNEL)
474KERNCONF= ${KERNEL}
475KERNWARN= yes
476.else
477KERNCONF?= GENERIC
478.endif
479INSTKERNNAME?= kernel
480
481KRNLSRCDIR= ${.CURDIR}/sys
482KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
483KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
484KERNCONFDIR?= ${KRNLCONFDIR}
485
486BUILDKERNELS=
487INSTALLKERNEL=
488.for _kernel in ${KERNCONF}
489.if exists(${KERNCONFDIR}/${_kernel})
490BUILDKERNELS+= ${_kernel}
491.if empty(INSTALLKERNEL)
492INSTALLKERNEL= ${_kernel}
493.endif
494.endif
495.endfor
496
497#
498# buildkernel
499#
500# Builds all kernels defined by BUILDKERNELS.
501#
fc7aca3e 502bk_tools:
e05c8c84
MD
503 @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
504 echo "You must buildworld before buildkernel. If you wish"; \
505 echo "to build a kernel using native tools, config it manually"; \
506 echo "or use the nativekernel target if you are in a rush"; \
507 exit 1; \
508 fi
509
fc7aca3e 510bk_build_list:
984263bc
MD
511.if empty(BUILDKERNELS)
512 @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
513 @false
514.endif
fc7aca3e
MD
515
516bk_kernwarn:
984263bc
MD
517.if defined(KERNWARN)
518 @echo "--------------------------------------------------------------"
519 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
520 @echo "--------------------------------------------------------------"
521 @sleep 3
522.endif
523 @echo
fc7aca3e
MD
524
525# The buildkernel target rebuilds the specified kernels from scratch
526# using the crossbuild tools generated by the last buildworld. It is
527# the safest (but also the most time consuming) way to build a new kernel.
528#
529buildkernel: bk_tools bk_build_list bk_kernwarn
984263bc
MD
530.for _kernel in ${BUILDKERNELS}
531 @echo "--------------------------------------------------------------"
532 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
533 @echo "--------------------------------------------------------------"
534 @echo "===> ${_kernel}"
fc7aca3e
MD
535.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
536 rm -rf ${KRNLOBJDIR}/${_kernel}
537.else
e05c8c84 538 @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
fc7aca3e 539 echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
e05c8c84 540 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
fc7aca3e 541.endif
984263bc
MD
542 mkdir -p ${KRNLOBJDIR}
543.if !defined(NO_KERNELCONFIG)
544 cd ${KRNLCONFDIR}; \
1397f94a 545 PATH=${STRICTTMPPATH} \
984263bc
MD
546 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
547 ${KERNCONFDIR}/${_kernel}
548.endif
e05c8c84 549 touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
984263bc 550 cd ${KRNLOBJDIR}/${_kernel}; \
9f3906fd
MD
551 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
552 ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
984263bc
MD
553.if !defined(NO_KERNELDEPEND)
554 cd ${KRNLOBJDIR}/${_kernel}; \
555 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
556.endif
557 cd ${KRNLOBJDIR}/${_kernel}; \
558 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
559 @echo "--------------------------------------------------------------"
560 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
561 @echo "--------------------------------------------------------------"
562.endfor
563
fc7aca3e
MD
564# The nativekernel target rebuilds the specified kernels from scratch
565# using the systems standard compiler rather then using the crossbuild
566# tools generated by the last buildworld. This is fairly safe if your
567# system is reasonable up-to-date.
e05c8c84 568#
fc7aca3e 569nativekernel: bk_build_list bk_kernwarn
e05c8c84
MD
570.for _kernel in ${BUILDKERNELS}
571 @echo "--------------------------------------------------------------"
572 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
573 @echo "--------------------------------------------------------------"
574 @echo "===> ${_kernel}"
fc7aca3e
MD
575.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
576 rm -rf ${KRNLOBJDIR}/${_kernel}
577.else
e05c8c84 578 @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
fc7aca3e 579 echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
e05c8c84 580 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
fc7aca3e 581.endif
e05c8c84
MD
582 mkdir -p ${KRNLOBJDIR}
583.if !defined(NO_KERNELCONFIG)
584 cd ${KRNLCONFDIR}; \
585 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
586 ${KERNCONFDIR}/${_kernel}
587.endif
588 touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
e05c8c84
MD
589 cd ${KRNLOBJDIR}/${_kernel}; \
590 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
591 ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
592.if !defined(NO_KERNELDEPEND)
593 cd ${KRNLOBJDIR}/${_kernel}; \
594 ${MAKE} KERNEL=${INSTKERNNAME} depend
595.endif
596 cd ${KRNLOBJDIR}/${_kernel}; \
597 ${MAKE} KERNEL=${INSTKERNNAME} all
598 @echo "--------------------------------------------------------------"
599 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
600 @echo "--------------------------------------------------------------"
601.endfor
602
fc7aca3e
MD
603# The quickkernel target rebuilds the specified kernels as quickly
604# as possible. It will use the native tools or the buildworld cross tools
605# based on whether the kernel was originally generated via buildkernel or
606# nativekernel. Config is rerun but the object hierarchy is not rebuilt,
607# nor is the make depend step run.
984263bc 608#
fc7aca3e
MD
609quickkernel: bk_tools bk_build_list bk_kernwarn
610.for _kernel in ${BUILDKERNELS}
611 @echo "--------------------------------------------------------------"
612 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
613 @echo "--------------------------------------------------------------"
614 @echo "===> ${_kernel}"
615.if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
616.if !defined(NO_KERNELCONFIG)
617 cd ${KRNLCONFDIR}; \
618 PATH=${STRICTTMPPATH} \
619 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
620 ${KERNCONFDIR}/${_kernel}
621.endif
622 cd ${KRNLOBJDIR}/${_kernel}; \
623 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
624.else
625.if !defined(NO_KERNELCONFIG)
626 cd ${KRNLCONFDIR}; \
627 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
628 ${KERNCONFDIR}/${_kernel}
629.endif
630 cd ${KRNLOBJDIR}/${_kernel}; \
631 ${MAKE} KERNEL=${INSTKERNNAME} all
632.endif
633 @echo "--------------------------------------------------------------"
634 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
635 @echo "--------------------------------------------------------------"
636.endfor
637
638
984263bc
MD
639# installkernel
640#
641# Install the kernel defined by INSTALLKERNEL
642#
643installkernel reinstallkernel:
644 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
645 ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
646
647#
648# update
649#
650# Update the source tree, by running sup and/or running cvs to update to the
651# latest copy.
652#
653update:
654.if defined(SUP_UPDATE)
655 @echo "--------------------------------------------------------------"
656 @echo ">>> Running ${SUP}"
657 @echo "--------------------------------------------------------------"
658.if defined(SUPFILE)
659 @${SUP} ${SUPFLAGS} ${SUPFILE}
660.endif
661.if defined(SUPFILE1)
662 @${SUP} ${SUPFLAGS} ${SUPFILE1}
663.endif
664.if defined(SUPFILE2)
665 @${SUP} ${SUPFLAGS} ${SUPFILE2}
666.endif
667.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
668 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
669.endif
670.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
671 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
672.endif
673.endif
674.if defined(CVS_UPDATE)
675 @echo "--------------------------------------------------------------"
676 @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
677 @echo "--------------------------------------------------------------"
678 cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
679.endif
680
681#
682# most
683#
684# Build most of the user binaries on the existing system libs and includes.
685#
686most:
687 @echo "--------------------------------------------------------------"
688 @echo ">>> Building programs only"
689 @echo "--------------------------------------------------------------"
690.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
691 cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ all
692.endfor
693
694#
695# installmost
696#
697# Install the binaries built by the 'most' target. This does not include
698# libraries or include files.
699#
700installmost:
701 @echo "--------------------------------------------------------------"
702 @echo ">>> Installing programs only"
703 @echo "--------------------------------------------------------------"
704.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
705 cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ install
706.endfor
707
708#
709# ------------------------------------------------------------------------
710#
711# From here onwards are utility targets used by the 'make world' and
712# related targets. If your 'world' breaks, you may like to try to fix
713# the problem and manually run the following targets to attempt to
714# complete the build. Beware, this is *not* guaranteed to work, you
715# need to have a pretty good grip on the current state of the system
716# to attempt to manually finish it. If in doubt, 'make world' again.
717#
718
79aa78bc
MD
719# bootstrap-tools: Build all tools required to build all tools. Note that
720# order is important in a number of cases and also note that the bootstrap
721# and build tools stages have access to earlier binaries they themselves
722# had generated.
984263bc 723#
79aa78bc
MD
724# patch: older patch's do not have -i. This program must be built
725# first so other bootstrap tools that need to apply patches
726# can use it.
17030342
MD
727# [x]install: dependancies on various new install features
728# rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
729# envs are not compatible with older objformat binaries.
730#
984263bc
MD
731.if exists(${.CURDIR}/games) && !defined(NOGAMES)
732_strfile= games/fortune/strfile
733.endif
734
735bootstrap-tools:
1397f94a 736.for _tool in ${_strfile} \
1a7434d5 737 usr.bin/patch \
1397f94a
MD
738 bin/chmod bin/cp bin/dd bin/mkdir bin/rm bin/echo bin/test \
739 bin/cat bin/date bin/ln bin/mv bin/csh bin/expr bin/sh bin/ls \
b07b69cc 740 bin/hostname bin/kill \
1397f94a
MD
741 sbin/sysctl \
742 usr.bin/yacc usr.bin/colldef usr.bin/uudecode usr.bin/xinstall \
471f8e4c 743 usr.bin/m4 usr.bin/rpcgen usr.bin/make usr.bin/awk usr.bin/file \
1397f94a
MD
744 usr.bin/find usr.bin/lex usr.bin/sed usr.bin/uname usr.bin/touch \
745 usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
746 usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
747 usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
b07b69cc 748 usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
1397f94a 749 usr.bin/vi usr.bin/cap_mkdb usr.bin/vgrind usr.bin/true usr.bin/false \
c02263c2 750 usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
1397f94a 751 usr.sbin/chown usr.sbin/mtree usr.sbin/config \
8a48ec64 752 usr.sbin/btxld usr.sbin/pwd_mkdb usr.sbin/zic usr.sbin/makewhatis \
1397f94a 753 gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo \
79aa78bc 754 gnu/usr.bin/grep gnu/usr.bin/sort \
2febcc6d 755 gnu/usr.bin/gzip usr.bin/bzip2
1397f94a 756 ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
984263bc
MD
757 cd ${.CURDIR}/${_tool}; \
758 ${MAKE} DIRPRFX=${_tool}/ obj; \
759 ${MAKE} DIRPRFX=${_tool}/ depend; \
760 ${MAKE} DIRPRFX=${_tool}/ all; \
1397f94a 761 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
984263bc 762.endfor
e05c8c84 763 touch ${BTOOLSDEST}/.bootstrap_done
984263bc 764
17030342
MD
765# build-tools: Build special purpose build tools. gcc2 related tools are
766# only built under the i386 architecture. Other architectures are
767# gcc3-only.
984263bc 768#
1397f94a
MD
769# XXX we may be able to remove or consolidate this into bootstrap-tools
770# now that we have the native helper (.nx/.no) infrastructure.
771#
984263bc
MD
772.if exists(${.CURDIR}/games) && !defined(NOGAMES)
773_games= games/adventure games/hack games/phantasia
774.endif
775
776.if exists(${.CURDIR}/share) && !defined(NOSHARE)
777_share= share/syscons/scrnmaps
778.endif
779
4db2a28c 780_gcc34_cross= gnu/usr.bin/cc34
c32e17fc 781_gcc34_tools= gnu/usr.bin/cc34/cc_prep gnu/usr.bin/cc34/cc_tools
17030342
MD
782.if ${MACHINE_ARCH} == "i386" && ${TARGET_ARCH} == "i386"
783_gcc2_cross= gnu/usr.bin/cc
784_gcc2_tools= gnu/usr.bin/cc/cc_tools
785_binutils= gnu/usr.bin/binutils gnu/usr.bin/binutils214
786.else
787_binutils= gnu/usr.bin/binutils214
788.endif
789
984263bc 790.if !defined(NO_FORTRAN)
17030342 791.if ${TARGET_ARCH} == "i386"
984263bc 792_fortran= gnu/usr.bin/cc/f771
17030342 793.else
4db2a28c 794_fortran= gnu/usr.bin/cc34/f771
17030342 795.endif
984263bc
MD
796.endif
797
798.if !defined(NOPERL)
799_perl= gnu/usr.bin/perl/miniperl
800.endif
801
984263bc
MD
802.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
803 !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
804_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
805 kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
806.endif
807
808.if defined(RELEASEDIR)
809_sysinstall= release/sysinstall
810.endif
811
812build-tools:
73e93a5d 813.for _tool in ${_gcc2_tools} ${_gcc34_tools} \
17030342 814 ${_fortran} ${_perl} ${_libroken4} ${_libkrb5} \
1397f94a
MD
815 ${_share} ${_sysinstall}
816 ${ECHODIR} "===> ${_tool} (build-tools)"; \
984263bc
MD
817 cd ${.CURDIR}/${_tool}; \
818 ${MAKE} DIRPRFX=${_tool}/ obj; \
1397f94a
MD
819 ${MAKE} DIRPRFX=${_tool}/ depend; \
820 ${MAKE} DIRPRFX=${_tool}/ all; \
821 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
984263bc 822.endfor
e05c8c84 823 touch ${BTOOLSDEST}/.build_done
984263bc
MD
824
825#
826# cross-tools: Build cross-building tools
827#
828.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
829_elf2exe= usr.sbin/elf2exe
830.endif
831
832.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
833_btxld= usr.sbin/btxld
834.endif
835
836cross-tools:
17030342
MD
837.for _tool in ${_btxld} ${_elf2exe} ${_binutils} \
838 usr.bin/objformat usr.sbin/crunch/crunchide \
73e93a5d 839 ${_gcc2_cross} ${_gcc34_cross}
1397f94a 840 ${ECHODIR} "===> ${_tool} (cross-tools)"; \
984263bc
MD
841 cd ${.CURDIR}/${_tool}; \
842 ${MAKE} DIRPRFX=${_tool}/ obj; \
843 ${MAKE} DIRPRFX=${_tool}/ depend; \
844 ${MAKE} DIRPRFX=${_tool}/ all; \
1397f94a 845 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
984263bc 846.endfor
e05c8c84 847 touch ${CTOOLSDEST}/.cross_done
984263bc
MD
848
849#
850# hierarchy - ensure that all the needed directories are present
851#
852hierarchy:
853 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
854
855#
856# libraries - build all libraries, and install them under ${DESTDIR}.
857#
858# The list of libraries with dependents (${_prebuild_libs}) and their
859# interdependencies (__L) are built automatically by the
860# ${.CURDIR}/tools/make_libdeps.sh script.
861#
5228fe46
MD
862# .makeenv does not work when bootstrapping from 4.x, so we must be sure
863# to specify the correct CCVER or 'cc' will not exec the correct compiler.
864#
984263bc
MD
865libraries:
866 cd ${.CURDIR}; \
4db2a28c
MD
867 HOST_CCVER=${HOST_CCVER} CCVER=gcc2 \
868 ${MAKE} -f Makefile.inc1 _startup_libs2; \
4db2a28c
MD
869 HOST_CCVER=${HOST_CCVER} CCVER=gcc34 \
870 ${MAKE} -f Makefile.inc1 _startup_libs34; \
984263bc
MD
871 ${MAKE} -f Makefile.inc1 _startup_libs; \
872 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
873 ${MAKE} -f Makefile.inc1 _generic_libs;
e05c8c84 874 touch ${WORLDDEST}/.libraries_done
984263bc
MD
875
876# These dependencies are not automatically generated:
877#
0fda1879 878# gnu/lib/libgcc and lib/csu must be built before all
5228fe46
MD
879# shared libraries for ELF. The targets for _startup_libs{2,3} are
880# specifically built using gcc{2,3}.
984263bc 881#
0fda1879 882_startup_libs2= gnu/lib/gcc2/libgcc
4db2a28c 883_startup_libs34= gnu/lib/gcc34/libgcc
aa8d5dcb
DR
884.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
885_startup_libs= lib/csu/${MACHINE_ARCH}-elf
984263bc 886.else
5228fe46 887_startup_libs= lib/csu/${MACHINE_ARCH}
984263bc 888.endif
0fda1879 889_startup_libs+= lib/csu/common lib/libc
984263bc
MD
890
891_prebuild_libs=
892
893_generic_libs= gnu/lib
894
895.if !defined(NOPERL)
896_generic_libs+= gnu/usr.bin/perl/libperl
897.endif
898
899.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
900_prebuild_libs+= kerberos5/lib/libasn1
901_prebuild_libs+= kerberos5/lib/libgssapi
902_prebuild_libs+= kerberos5/lib/libkrb5
903_prebuild_libs+= kerberos5/lib/libroken
904_generic_libs+= kerberos5/lib
905.endif
906
984263bc
MD
907_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
908 lib/libncurses lib/libopie lib/libradius lib/libskey \
909 lib/libtacplus lib/libutil \
910 lib/libz lib/msun
911
912lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
913lib/libskey__L: lib/libcrypt__L lib/libmd__L
914
915_generic_libs+= lib
916
de347b31 917.if !defined(NOCRYPT)
984263bc
MD
918.if !defined(NO_OPENSSL)
919_prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
920.if !defined(NO_OPENSSH)
921_prebuild_libs+= secure/lib/libssh
922secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
923.endif
924.endif
925_generic_libs+= secure/lib
926.endif
927
928_generic_libs+= usr.bin/lex/lib
929
930.if ${MACHINE_ARCH} == "i386"
931_generic_libs+= usr.sbin/pcvt/keycap
932.endif
933
4db2a28c
MD
934.for _lib in ${_startup_libs2} ${_startup_libs3} ${_startup_libs34} \
935 ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
984263bc
MD
936${_lib}__L: .PHONY
937.if exists(${.CURDIR}/${_lib})
938 ${ECHODIR} "===> ${_lib}"; \
939 cd ${.CURDIR}/${_lib}; \
940 ${MAKE} DIRPRFX=${_lib}/ depend; \
941 ${MAKE} DIRPRFX=${_lib}/ all; \
942 ${MAKE} DIRPRFX=${_lib}/ install
943.endif
944.endfor
945
17030342
MD
946# only mess with gcc2 for i386 architectures.
947#
984263bc 948_startup_libs: ${_startup_libs:S/$/__L/}
17030342 949.if ${TARGET_ARCH} == "i386"
5228fe46 950_startup_libs2: ${_startup_libs2:S/$/__L/}
17030342
MD
951.else
952_startup_libs2:
953.endif
5228fe46 954_startup_libs3: ${_startup_libs3:S/$/__L/}
4db2a28c 955_startup_libs34: ${_startup_libs34:S/$/__L/}
984263bc
MD
956_prebuild_libs: ${_prebuild_libs:S/$/__L/}
957_generic_libs: ${_generic_libs:S/$/__L/}
958
1397f94a
MD
959# library targets must be ordered because there are inter-library
960# races (e.g. generation of tconfig.h)
961#
962.ORDER: ${_startup_libs2:S/$/__L/}
963.ORDER: ${_startup_libs3:S/$/__L/}
4db2a28c 964.ORDER: ${_startup_libs34:S/$/__L/}
1397f94a
MD
965.ORDER: ${_startup_libs:S/$/__L/}
966.ORDER: ${_prebuild_libs:S/$/__L/}
967.ORDER: ${_generic_libs:S/$/__L/}
968
969.for __target in clean cleandepend cleandir obj depend includes
984263bc
MD
970.for entry in ${SUBDIR}
971${entry}.${__target}__D: .PHONY
972 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
973 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
974 edir=${entry}.${MACHINE_ARCH}; \
975 cd ${.CURDIR}/$${edir}; \
976 else \
977 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
978 edir=${entry}; \
979 cd ${.CURDIR}/$${edir}; \
980 fi; \
981 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
982.endfor
983par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1397f94a 984.ORDER: ${SUBDIR:S/$/.${__target}__D/}
984263bc 985.endfor
1397f94a 986.ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
984263bc 987
cb0f1574
MD
988# The wmake target is used by /usr/bin/wmake to run make in a
989# world build environment.
990#
991wmake:
1397f94a 992 @echo '${WMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${WMAKE_ARGS}'
cb0f1574 993
5c7da0d7
MD
994wmakeenv:
995 @echo '${WMAKEENV} /bin/sh'
996
1397f94a
MD
997bmake:
998 @echo '${BMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${BMAKE_ARGS}'
999
17030342
MD
1000bmakeenv:
1001 @echo '${BMAKEENV} /bin/sh'
1002
1397f94a
MD
1003tmake:
1004 @echo '${TMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${TMAKE_ARGS}'
1005
17030342
MD
1006tmakeenv:
1007 @echo '${TMAKEENV} /bin/sh'
1008
984263bc 1009.include <bsd.subdir.mk>
cb0f1574 1010