]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Style nit.
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_KERBEROS Do not build Heimdal (Kerberos 5)
6 #       -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
7 #       -DNOCLEAN do not clean at all
8 #       -DNOCRYPT will prevent building of crypt versions
9 #       -DNOMAN do not build the manual pages
10 #       -DNOPROFILE do not build profiled libraries
11 #       -DNOGAMES do not go into games subdir
12 #       -DNOSHARE do not go into share subdir
13 #       -DNOINFO do not make or install info files
14 #       -DNOLIBC_R do not build libc_r.
15 #       -DNO_FORTRAN do not build g77 and related libraries.
16 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
17 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
18 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
19 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
20 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
21 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
22 #       TARGET_ARCH="arch" to crossbuild world to a different arch
23
24 #
25 # The intended user-driven targets are:
26 # buildworld  - rebuild *everything*, including glue to help do upgrades
27 # installworld- install everything built by "buildworld"
28 # update      - convenient way to update your source tree (eg: sup/cvs)
29 # most        - build user commands, no libraries or include files
30 # installmost - install user commands, no libraries or include files
31 #
32 # Standard targets (not defined here) are documented in the makefiles in
33 # /usr/share/mk.  These include:
34 #               obj depend all install clean cleandepend cleanobj
35
36 # Put initial settings here.
37 SUBDIR=
38
39 # We must do share/info early so that installation of info `dir'
40 # entries works correctly.  Do it first since it is less likely to
41 # grow dependencies on include and lib than vice versa.
42 .if exists(${.CURDIR}/share/info)
43 SUBDIR+= share/info
44 .endif
45
46 .if exists(${.CURDIR}/include)
47 SUBDIR+= include
48 .endif
49 .if exists(${.CURDIR}/lib)
50 SUBDIR+= lib
51 .endif
52
53 .if exists(${.CURDIR}/bin)
54 SUBDIR+= bin
55 .endif
56 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
57 SUBDIR+= games
58 .endif
59 .if exists(${.CURDIR}/gnu)
60 SUBDIR+= gnu
61 .endif
62 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
63     !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
64 SUBDIR+= kerberos5
65 .endif
66 .if exists(${.CURDIR}/libexec)
67 SUBDIR+= libexec
68 .endif
69 .if exists(${.CURDIR}/rescue) && defined(RESCUE)
70 SUBDIR+= rescue
71 .endif
72 .if exists(${.CURDIR}/sbin)
73 SUBDIR+= sbin
74 .endif
75 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
76 SUBDIR+= secure
77 .endif
78 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
79 SUBDIR+= share
80 .endif
81 .if exists(${.CURDIR}/sys)
82 SUBDIR+= sys
83 .endif
84 .if exists(${.CURDIR}/usr.bin)
85 SUBDIR+= usr.bin
86 .endif
87 .if exists(${.CURDIR}/usr.sbin)
88 SUBDIR+= usr.sbin
89 .endif
90
91 # etc must be last for "distribute" to work
92 .if exists(${.CURDIR}/etc)
93 SUBDIR+= etc
94 .endif
95
96 # These are last, since it is nice to at least get the base system
97 # rebuilt before you do them.
98 .if defined(LOCAL_DIRS)
99 .for _DIR in ${LOCAL_DIRS}
100 .if exists(${.CURDIR}/${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
101 SUBDIR+= ${_DIR}
102 .endif
103 .endfor
104 .endif
105
106 .if defined(SUBDIR_OVERRIDE)
107 SUBDIR=         ${SUBDIR_OVERRIDE}
108 .endif
109
110 .if defined(NOCLEANDIR)
111 CLEANDIR=       clean cleandepend
112 .else
113 CLEANDIR=       cleandir
114 .endif
115
116 CVS?=           cvs
117 SUP?=           /usr/local/bin/cvsup
118 SUPFLAGS?=      -g -L 2 -P -
119 .if defined(SUPHOST)
120 SUPFLAGS+=      -h ${SUPHOST}
121 .endif
122
123 MAKEOBJDIRPREFIX?=      /usr/obj
124 .if !defined(OSRELDATE)
125 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
126                 /usr/include/osreldate.h
127 .endif
128 TARGET_ARCH?=   ${MACHINE_ARCH}
129 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
130 TARGET?=        ${MACHINE}
131 TARGET_CPUTYPE?=${CPUTYPE}
132 .else
133 TARGET?=        ${TARGET_ARCH}
134 TARGET_CPUTYPE?=
135 .endif
136 .if !empty(TARGET_CPUTYPE)
137 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
138 .else
139 _TARGET_CPUTYPE=dummy
140 .endif
141 _CPUTYPE!=      ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
142                 CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
143 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
144 .error CPUTYPE global should be set with ?=.
145 .endif
146 .if make(buildworld)
147 BUILD_ARCH!=    sysctl -n hw.machine_arch
148 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
149 .error To cross-build, set TARGET_ARCH.
150 .endif
151 .endif
152 .if ${MACHINE} == ${TARGET}
153 OBJTREE=        ${MAKEOBJDIRPREFIX}
154 .else
155 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
156 .endif
157 WORLDTMP=       ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
158 # /usr/games added for fortune which depend on strfile
159 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
160 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
161 STRICTTMPPATH=  ${BPATH}:${XPATH}
162 TMPPATH=        ${STRICTTMPPATH}:${PATH}
163
164 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
165
166 #
167 # Building a world goes through the following stages
168 #
169 # 1. legacy stage [BMAKE]
170 #       This stage is responsible for creating compatibility
171 #       shims that are needed by the bootstrap-tools,
172 #       build-tools and cross-tools stages.
173 # 1. bootstrap-tools stage [BMAKE]
174 #       This stage is responsible for creating programs that
175 #       are needed for backward compatibility reasons. They
176 #       are not built as cross-tools.
177 # 2. build-tools stage [TMAKE]
178 #       This stage is responsible for creating the object
179 #       tree and building any tools that are needed during
180 #       the build process.
181 # 3. cross-tools stage [XMAKE]
182 #       This stage is responsible for creating any tools that
183 #       are needed for cross-builds. A cross-compiler is one
184 #       of them.
185 # 4. world stage [WMAKE]
186 #       This stage actually builds the world.
187 # 5. install stage (optional) [IMAKE]
188 #       This stage installs a previously built world.
189 #
190
191 BOOTSTRAPPING?= 0
192
193 # Common environment for world related stages
194 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
195                 MACHINE_ARCH=${TARGET_ARCH} \
196                 MACHINE=${TARGET} \
197                 CPUTYPE=${TARGET_CPUTYPE} \
198                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
199                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
200                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
201
202 # bootstrap-tools stage
203 BMAKEENV=       DESTDIR= \
204                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
205                 PATH=${BPATH}:${PATH} \
206                 WORLDTMP=${WORLDTMP} \
207                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
208 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
209                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
210                 BOOTSTRAPPING=${OSRELDATE} \
211                 -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
212                 -DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
213
214 # build-tools stage
215 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
216                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
217                 BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
218
219 # cross-tools stage
220 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
221
222 # world stage
223 WMAKEENV=       ${CROSSENV} \
224                 DESTDIR=${WORLDTMP} \
225                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
226                 PATH=${TMPPATH}
227 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1
228
229 # install stage
230 IMAKEENV=       ${CROSSENV} \
231                 PATH=${STRICTTMPPATH}:${INSTALLTMP}
232 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
233
234 # kernel stage
235 KMAKEENV=       ${WMAKEENV}
236
237 #
238 # buildworld
239 #
240 # Attempt to rebuild the entire system, with reasonable chance of
241 # success, regardless of how old your existing system is.
242 #
243 _worldtmp:
244 .if ${.CURDIR:C/[^,]//g} != ""
245 #       The m4 build of sendmail files doesn't like it if ',' is used
246 #       anywhere in the path of it's files.
247         @echo
248         @echo "*** Error: path to source tree contains a comma ','"
249         @echo
250         @false
251 .endif
252         @echo
253         @echo "--------------------------------------------------------------"
254         @echo ">>> Rebuilding the temporary build tree"
255         @echo "--------------------------------------------------------------"
256 .if !defined(NOCLEAN)
257         rm -rf ${WORLDTMP}
258 .else
259         rm -rf ${WORLDTMP}/legacy/usr/include
260         # XXX - These two can depend on any header file.
261         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
262         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
263 .endif
264 .for _dir in \
265     usr/bin usr/games usr/include/sys usr/lib \
266     usr/libexec usr/sbin usr/share/dict \
267     usr/share/groff_font/devX100 \
268     usr/share/groff_font/devX100-12 \
269     usr/share/groff_font/devX75 \
270     usr/share/groff_font/devX75-12 \
271     usr/share/groff_font/devascii \
272     usr/share/groff_font/devcp1047 \
273     usr/share/groff_font/devdvi \
274     usr/share/groff_font/devhtml \
275     usr/share/groff_font/devkoi8-r \
276     usr/share/groff_font/devlatin1 \
277     usr/share/groff_font/devlbp \
278     usr/share/groff_font/devlj4 \
279     usr/share/groff_font/devps \
280     usr/share/groff_font/devutf8 \
281     usr/share/tmac/mdoc usr/share/tmac/mm
282         mkdir -p ${WORLDTMP}/legacy/${_dir}
283 .endfor
284 .for _dir in \
285     usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
286     usr/libexec usr/share/misc
287         mkdir -p ${WORLDTMP}/${_dir}
288 .endfor
289         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
290             -p ${WORLDTMP}/usr/include
291         ln -sf ${.CURDIR}/sys ${WORLDTMP}
292 _legacy:
293         @echo
294         @echo "--------------------------------------------------------------"
295         @echo ">>> stage 1: legacy release compatibility shims"
296         @echo "--------------------------------------------------------------"
297         cd ${.CURDIR}; ${BMAKE} legacy
298 _bootstrap-tools:
299         @echo
300         @echo "--------------------------------------------------------------"
301         @echo ">>> stage 1: bootstrap tools"
302         @echo "--------------------------------------------------------------"
303         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
304 _cleanobj:
305 .if !defined(NOCLEAN)
306         @echo
307         @echo "--------------------------------------------------------------"
308         @echo ">>> stage 2: cleaning up the object tree"
309         @echo "--------------------------------------------------------------"
310         cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
311 .endif
312 _obj:
313         @echo
314         @echo "--------------------------------------------------------------"
315         @echo ">>> stage 2: rebuilding the object tree"
316         @echo "--------------------------------------------------------------"
317         cd ${.CURDIR}; ${WMAKE} par-obj
318 _build-tools:
319         @echo
320         @echo "--------------------------------------------------------------"
321         @echo ">>> stage 2: build tools"
322         @echo "--------------------------------------------------------------"
323         cd ${.CURDIR}; ${TMAKE} build-tools
324 _cross-tools:
325         @echo
326         @echo "--------------------------------------------------------------"
327         @echo ">>> stage 3: cross tools"
328         @echo "--------------------------------------------------------------"
329         cd ${.CURDIR}; ${XMAKE} cross-tools
330 _includes:
331         @echo
332         @echo "--------------------------------------------------------------"
333         @echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
334         @echo "--------------------------------------------------------------"
335         cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
336 _libraries:
337         @echo
338         @echo "--------------------------------------------------------------"
339         @echo ">>> stage 4: building libraries"
340         @echo "--------------------------------------------------------------"
341         cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
342 _depend:
343         @echo
344         @echo "--------------------------------------------------------------"
345         @echo ">>> stage 4: make dependencies"
346         @echo "--------------------------------------------------------------"
347         cd ${.CURDIR}; ${WMAKE} par-depend
348 everything:
349         @echo
350         @echo "--------------------------------------------------------------"
351         @echo ">>> stage 4: building everything.."
352         @echo "--------------------------------------------------------------"
353         cd ${.CURDIR}; ${WMAKE} par-all
354
355
356 WMAKE_TGTS=
357 .if !defined(SUBDIR_OVERRIDE)
358 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
359 .endif
360 WMAKE_TGTS+=    _cleanobj _obj _build-tools
361 .if !defined(SUBDIR_OVERRIDE)
362 WMAKE_TGTS+=    _cross-tools
363 .endif
364 WMAKE_TGTS+=    _includes _libraries _depend everything
365
366 buildworld: ${WMAKE_TGTS}
367 .ORDER: ${WMAKE_TGTS}
368
369 #
370 # installcheck
371 #
372 # Checks to be sure system is ready for installworld
373 #
374 installcheck:
375 .if !defined(NO_SENDMAIL)
376         @if ! `id -u smmsp > /dev/null`; then \
377                 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
378                 false; \
379         fi
380         @if ! `id -g smmsp > /dev/null`; then \
381                 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
382                 false; \
383         fi
384 .endif
385 .if ${TARGET_ARCH} == ${MACHINE_ARCH} && !defined(DISTDIR) && \
386     (!defined(DESTDIR) || empty(DESTDIR) || ${DESTDIR} == "/")
387         @echo "Checking to see if your booted kernel is fresh enough.."
388         ${.OBJDIR}/bin/sh/sh -c \
389             'echo "Testing installed kernel for new sigaction(2) syscall"'
390         @echo "Seems ok.."
391 .endif
392
393 #
394 # distributeworld
395 #
396 # Distributes everything compiled by a `buildworld'.
397 #
398 # installworld
399 #
400 # Installs everything compiled by a 'buildworld'.
401 #
402 distributeworld installworld: installcheck
403         mkdir -p ${INSTALLTMP}
404         for prog in [ awk cap_mkdb cat chflags chmod chown \
405             date echo egrep find grep \
406             ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
407             test true uname wc zic; do \
408                 cp `which $$prog` ${INSTALLTMP}; \
409         done
410         cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
411         rm -rf ${INSTALLTMP}
412
413 #
414 # reinstall
415 #
416 # If you have a build server, you can NFS mount the source and obj directories
417 # and do a 'make reinstall' on the *client* to install new binaries from the
418 # most recent server build.
419 #
420 reinstall:
421         @echo "--------------------------------------------------------------"
422         @echo ">>> Making hierarchy"
423         @echo "--------------------------------------------------------------"
424         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
425         @echo
426         @echo "--------------------------------------------------------------"
427         @echo ">>> Installing everything.."
428         @echo "--------------------------------------------------------------"
429         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
430 .if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
431         @echo
432         @echo "--------------------------------------------------------------"
433         @echo ">>> Rebuilding man page indices"
434         @echo "--------------------------------------------------------------"
435         cd ${.CURDIR}/share/man; ${MAKE} makedb
436 .endif
437
438 redistribute:
439         @echo "--------------------------------------------------------------"
440         @echo ">>> Distributing everything.."
441         @echo "--------------------------------------------------------------"
442         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
443
444 #
445 # buildkernel and installkernel
446 #
447 # Which kernels to build and/or install is specified by setting
448 # KERNCONF. If not defined a GENERIC kernel is built/installed.
449 # Only the existing (depending TARGET) config files are used
450 # for building kernels and only the first of these is designated
451 # as the one being installed.
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)
459 KERNCONF=       ${KERNEL}
460 KERNWARN=       yes
461 .else
462 KERNCONF?=      GENERIC
463 .endif
464 INSTKERNNAME?=  kernel
465
466 KERNSRCDIR?=    ${.CURDIR}/sys
467 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
468 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
469 KERNCONFDIR?=   ${KRNLCONFDIR}
470
471 BUILDKERNELS=
472 INSTALLKERNEL=
473 .for _kernel in ${KERNCONF}
474 .if exists(${KERNCONFDIR}/${_kernel})
475 BUILDKERNELS+=  ${_kernel}
476 .if empty(INSTALLKERNEL)
477 INSTALLKERNEL= ${_kernel}
478 .endif
479 .endif
480 .endfor
481
482 #
483 # buildkernel
484 #
485 # Builds all kernels defined by BUILDKERNELS.
486 #
487 buildkernel:
488 .if empty(BUILDKERNELS)
489         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
490         @false
491 .endif
492 .if defined(KERNWARN)
493         @echo "--------------------------------------------------------------"
494         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
495         @echo "--------------------------------------------------------------"
496         @sleep 3
497 .endif
498         @echo
499 .for _kernel in ${BUILDKERNELS}
500         @echo "--------------------------------------------------------------"
501         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
502         @echo "--------------------------------------------------------------"
503         @echo "===> ${_kernel}"
504         mkdir -p ${KRNLOBJDIR}
505 .if !defined(NO_KERNELCONFIG)
506         cd ${KRNLCONFDIR}; \
507                 PATH=${TMPPATH} \
508                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
509                         ${KERNCONFDIR}/${_kernel}
510 .endif
511 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
512         cd ${KRNLOBJDIR}/${_kernel}; \
513             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
514 .endif
515         cd ${KRNLOBJDIR}/${_kernel}; \
516             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
517             ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
518         cd ${KRNLOBJDIR}/${_kernel}; \
519             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
520 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
521 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
522 .for target in obj depend all
523         cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
524             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
525             ${MAKE} -DNO_CPU_CFLAGS ${target}
526 .endfor
527 .endif
528 .if !defined(NO_KERNELDEPEND)
529         cd ${KRNLOBJDIR}/${_kernel}; \
530             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
531 .endif
532         cd ${KRNLOBJDIR}/${_kernel}; \
533             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
534         @echo "--------------------------------------------------------------"
535         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
536         @echo "--------------------------------------------------------------"
537 .endfor
538
539 #
540 # installkernel
541 #
542 # Install the kernel defined by INSTALLKERNEL
543 #
544 installkernel reinstallkernel installkernel.debug reinstallkernel.debug:
545 .if empty(INSTALLKERNEL)
546         @echo "ERROR: No kernel \"${KERNCONF}\" to install."
547         @false
548 .endif
549         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
550             ${CROSSENV} PATH=${TMPPATH} \
551             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
552
553 #
554 # update
555 #
556 # Update the source tree, by running sup and/or running cvs to update to the
557 # latest copy.
558 #
559 update:
560 .if defined(SUP_UPDATE)
561         @echo "--------------------------------------------------------------"
562         @echo ">>> Running ${SUP}"
563         @echo "--------------------------------------------------------------"
564 .if defined(SUPFILE)
565         @${SUP} ${SUPFLAGS} ${SUPFILE}
566 .endif
567 .if defined(SUPFILE1)
568         @${SUP} ${SUPFLAGS} ${SUPFILE1}
569 .endif
570 .if defined(SUPFILE2)
571         @${SUP} ${SUPFLAGS} ${SUPFILE2}
572 .endif
573 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
574         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
575 .endif
576 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
577         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
578 .endif
579 .endif
580 .if defined(CVS_UPDATE)
581         @echo "--------------------------------------------------------------"
582         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
583         @echo "--------------------------------------------------------------"
584         cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
585 .endif
586
587 #
588 # most
589 #
590 # Build most of the user binaries on the existing system libs and includes.
591 #
592 most:
593         @echo "--------------------------------------------------------------"
594         @echo ">>> Building programs only"
595         @echo "--------------------------------------------------------------"
596 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
597         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ all
598 .endfor
599
600 #
601 # installmost
602 #
603 # Install the binaries built by the 'most' target.  This does not include
604 # libraries or include files.
605 #
606 installmost:
607         @echo "--------------------------------------------------------------"
608         @echo ">>> Installing programs only"
609         @echo "--------------------------------------------------------------"
610 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
611         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ install
612 .endfor
613
614 #
615 # ------------------------------------------------------------------------
616 #
617 # From here onwards are utility targets used by the 'make world' and
618 # related targets.  If your 'world' breaks, you may like to try to fix
619 # the problem and manually run the following targets to attempt to
620 # complete the build.  Beware, this is *not* guaranteed to work, you
621 # need to have a pretty good grip on the current state of the system
622 # to attempt to manually finish it.  If in doubt, 'make world' again.
623 #
624
625 #
626 # legacy: Build compatibility shims for the next three targets
627 #
628 legacy:
629 .for _tool in tools/build
630         @${ECHODIR} "===> ${_tool}"; \
631             cd ${.CURDIR}/${_tool}; \
632             ${MAKE} DIRPRFX=${_tool}/ obj; \
633             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
634             ${MAKE} DIRPRFX=${_tool}/ depend; \
635             ${MAKE} DIRPRFX=${_tool}/ all; \
636             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
637 .endfor
638
639 #
640 # bootstrap-tools: Build tools needed for compatibility
641 #
642 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
643 _strfile=       games/fortune/strfile
644 .endif
645
646 .if !defined(NO_CXX)
647 _gperf= gnu/usr.bin/gperf
648 .if ${BOOTSTRAPPING} < 500113
649 _groff=         gnu/usr.bin/groff
650 .else
651 _groff=         gnu/usr.bin/groff/tmac
652 .endif
653 .endif
654
655 .if ${BOOTSTRAPPING} < 450005 || \
656     ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
657 _uudecode=      usr.bin/uudecode
658 .endif
659
660 .if ${BOOTSTRAPPING} < 430002 || \
661     ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
662 _xargs=         usr.bin/xargs
663 .endif
664
665 .if ${BOOTSTRAPPING} < 430002 || \
666     ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
667 _yacc=          usr.bin/yacc
668 .endif
669
670 .if defined(RESCUE) && \
671     ${BOOTSTRAPPING} < 501100
672 _crunchgen=     usr.sbin/crunch/crunchgen
673 .endif
674
675 .if ${BOOTSTRAPPING} < 500019
676 _kbdcontrol=    usr.sbin/kbdcontrol
677 .endif
678
679 bootstrap-tools:
680 .for _tool in \
681     ${_strfile} \
682     ${_gperf} \
683     ${_groff} \
684     gnu/usr.bin/texinfo \
685     usr.bin/colldef \
686     usr.bin/makewhatis \
687     usr.bin/rpcgen \
688     ${_uudecode} \
689     ${_xargs} \
690     usr.bin/xinstall \
691     ${_yacc} \
692     usr.sbin/config \
693     ${_crunchgen} \
694     ${_kbdcontrol}
695         @${ECHODIR} "===> ${_tool}"; \
696                 cd ${.CURDIR}/${_tool}; \
697                 ${MAKE} DIRPRFX=${_tool}/ obj; \
698                 ${MAKE} DIRPRFX=${_tool}/ depend; \
699                 ${MAKE} DIRPRFX=${_tool}/ all; \
700                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
701 .endfor
702
703 #
704 # build-tools: Build special purpose build tools
705 #
706 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
707 _aicasm= sys/modules/aic7xxx/aicasm
708 .endif
709
710 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
711 _share= share/syscons/scrnmaps
712 .endif
713
714 .if !defined(NO_FORTRAN)
715 _fortran= gnu/usr.bin/cc/f771
716 .endif
717
718 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
719     !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
720 _libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
721     kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
722 .endif
723
724 build-tools:
725 .for _tool in \
726     bin/csh \
727     bin/sh \
728     gnu/usr.bin/cc/cc_tools \
729     ${_fortran} \
730     ${_libkrb5} \
731     lib/libncurses \
732     ${_share} \
733     ${_aicasm} \
734     usr.bin/awk \
735     usr.bin/file \
736     usr.sbin/sysinstall
737         @${ECHODIR} "===> ${_tool}"; \
738                 cd ${.CURDIR}/${_tool}; \
739                 ${MAKE} DIRPRFX=${_tool}/ obj; \
740                 ${MAKE} DIRPRFX=${_tool}/ build-tools
741 .endfor
742
743 #
744 # cross-tools: Build cross-building tools
745 #
746 .if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
747     ${BOOTSTRAPPING} < 500037
748 _elf2aout=      usr.bin/elf2aout
749 .endif
750
751 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
752 _btxld=         usr.sbin/btxld
753 .endif
754
755 .if (defined(RESCUE) || \
756     defined(RELEASEDIR)) && \
757     (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
758 _crunchide=     usr.sbin/crunch/crunchide
759 .endif
760
761 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
762 _elf2exe=       usr.sbin/elf2exe
763 .endif
764
765 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
766     defined(RELEASEDIR)
767 _kgzip=         usr.sbin/kgzip
768 .endif
769
770 cross-tools:
771 .for _tool in \
772     gnu/usr.bin/binutils \
773     gnu/usr.bin/cc \
774     ${_elf2aout} \
775     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
776     ${_btxld} \
777     ${_crunchide} \
778     ${_elf2exe} \
779     ${_kgzip}
780         @${ECHODIR} "===> ${_tool}"; \
781                 cd ${.CURDIR}/${_tool}; \
782                 ${MAKE} DIRPRFX=${_tool}/ obj; \
783                 ${MAKE} DIRPRFX=${_tool}/ depend; \
784                 ${MAKE} DIRPRFX=${_tool}/ all; \
785                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
786 .endfor
787
788 #
789 # hierarchy - ensure that all the needed directories are present
790 #
791 hierarchy:
792         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
793
794 #
795 # libraries - build all libraries, and install them under ${DESTDIR}.
796 #
797 # The list of libraries with dependents (${_prebuild_libs}) and their
798 # interdependencies (__L) are built automatically by the
799 # ${.CURDIR}/tools/make_libdeps.sh script.
800 #
801 libraries:
802         cd ${.CURDIR}; \
803             ${MAKE} -f Makefile.inc1 _startup_libs; \
804             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
805             ${MAKE} -f Makefile.inc1 _generic_libs;
806
807 # These dependencies are not automatically generated:
808 #
809 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
810 # shared libraries for ELF.
811 #
812 # lib/libc (libc_pic.a) must be built before lib/libpthread.
813 #
814 _startup_libs=  gnu/lib/csu gnu/lib/libgcc
815 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
816 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
817 .else
818 _startup_libs+= lib/csu/${MACHINE_ARCH}
819 .endif
820
821 _prebuild_libs=
822 _generic_libs=  gnu/lib
823
824 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
825     !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
826 _prebuild_libs+=        kerberos5/lib/libasn1
827 _prebuild_libs+=        kerberos5/lib/libgssapi
828 _prebuild_libs+=        kerberos5/lib/libkrb5
829 _prebuild_libs+=        kerberos5/lib/libroken
830 _generic_libs+= kerberos5/lib
831 .endif
832
833 .if !defined(NOLIBPTHREAD)
834 _prebuild_libs+= lib/libc
835 .endif
836 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
837                 lib/libkvm lib/libmd \
838                 lib/libncurses lib/libopie lib/libpam lib/libradius \
839                 lib/librpcsvc \
840                 lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
841                 lib/libz lib/msun
842
843 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
844 lib/libypclnt__L: lib/librpcsvc__L
845
846 _generic_libs+= lib
847
848 .if !defined(NOCRYPT)
849 .if !defined(NO_OPENSSL)
850 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
851 .if !defined(NO_OPENSSH)
852 _prebuild_libs+=        secure/lib/libssh
853 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
854 .endif
855 .endif
856 _generic_libs+= secure/lib
857 .endif
858
859 _generic_libs+= usr.bin/lex/lib
860
861 .if ${MACHINE_ARCH} == "i386"
862 _generic_libs+= usr.sbin/pcvt/keycap
863 .endif
864
865 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
866 ${_lib}__L: .PHONY
867 .if exists(${.CURDIR}/${_lib})
868         @${ECHODIR} "===> ${_lib}"; \
869                 cd ${.CURDIR}/${_lib}; \
870                 ${MAKE} DIRPRFX=${_lib}/ depend; \
871                 ${MAKE} DIRPRFX=${_lib}/ all; \
872                 ${MAKE} DIRPRFX=${_lib}/ install
873 .endif
874 .endfor
875
876 # libpam is special: we need to build static PAM modules before
877 # static PAM library, and dynamic PAM library before dynamic PAM
878 # modules.
879 lib/libpam__L: .PHONY
880         @${ECHODIR} "===> lib/libpam"; \
881                 cd ${.CURDIR}/lib/libpam; \
882                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
883                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
884                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
885
886 _startup_libs: ${_startup_libs:S/$/__L/}
887 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
888 _generic_libs: ${_generic_libs:S/$/__L/}
889
890 .for __target in all clean cleandepend cleandir depend includes obj
891 .for entry in ${SUBDIR}
892 ${entry}.${__target}__D: .PHONY
893         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
894                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
895                 edir=${entry}.${MACHINE_ARCH}; \
896                 cd ${.CURDIR}/$${edir}; \
897         else \
898                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
899                 edir=${entry}; \
900                 cd ${.CURDIR}/$${edir}; \
901         fi; \
902         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
903 .endfor
904 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
905 .endfor
906
907 .include <bsd.subdir.mk>