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