]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
This commit was generated by cvs2svn to compensate for changes in r115982,
[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}/sbin)
70 SUBDIR+= sbin
71 .endif
72 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
73 SUBDIR+= secure
74 .endif
75 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
76 SUBDIR+= share
77 .endif
78 .if exists(${.CURDIR}/sys)
79 SUBDIR+= sys
80 .endif
81 .if exists(${.CURDIR}/usr.bin)
82 SUBDIR+= usr.bin
83 .endif
84 .if exists(${.CURDIR}/usr.sbin)
85 SUBDIR+= usr.sbin
86 .endif
87
88 # etc must be last for "distribute" to work
89 .if exists(${.CURDIR}/etc)
90 SUBDIR+= etc
91 .endif
92
93 # These are last, since it is nice to at least get the base system
94 # rebuilt before you do them.
95 .if defined(LOCAL_DIRS)
96 .for _DIR in ${LOCAL_DIRS}
97 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
98 SUBDIR+= ${_DIR}
99 .endif
100 .endfor
101 .endif
102
103 .if defined(SUBDIR_OVERRIDE)
104 SUBDIR=         ${SUBDIR_OVERRIDE}
105 .endif
106
107 .if defined(NOCLEANDIR)
108 CLEANDIR=       clean cleandepend
109 .else
110 CLEANDIR=       cleandir
111 .endif
112
113 CVS?=           cvs
114 SUP?=           /usr/local/bin/cvsup
115 SUPFLAGS?=      -g -L 2 -P -
116 .if defined(SUPHOST)
117 SUPFLAGS+=      -h ${SUPHOST}
118 .endif
119
120 MAKEOBJDIRPREFIX?=      /usr/obj
121 .if !defined(OSRELDATE)
122 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
123                 /usr/include/osreldate.h
124 .endif
125 TARGET_ARCH?=   ${MACHINE_ARCH}
126 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
127 TARGET?=        ${MACHINE}
128 TARGET_CPUTYPE?=${CPUTYPE}
129 .else
130 TARGET?=        ${TARGET_ARCH}
131 TARGET_CPUTYPE?=
132 .endif
133 .if !empty(TARGET_CPUTYPE)
134 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
135 .else
136 _TARGET_CPUTYPE=dummy
137 .endif
138 _CPUTYPE!=      ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
139                 CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
140 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
141 .error CPUTYPE global should be set with ?=.
142 .endif
143 .if make(buildworld)
144 BUILD_ARCH!=    sysctl -n hw.machine_arch
145 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
146 .error To cross-build, set TARGET_ARCH.
147 .endif
148 .endif
149 .if ${MACHINE} == ${TARGET}
150 OBJTREE=        ${MAKEOBJDIRPREFIX}
151 .else
152 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
153 .endif
154 WORLDTMP=       ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
155 # /usr/games added for fortune which depend on strfile
156 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
157 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
158 STRICTTMPPATH=  ${BPATH}:${XPATH}
159 TMPPATH=        ${STRICTTMPPATH}:${PATH}
160
161 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
162
163 #
164 # Building a world goes through the following stages
165 #
166 # 1. legacy stage [BMAKE]
167 #       This stage is responsible for creating compatibility
168 #       shims that are needed by the bootstrap-tools,
169 #       build-tools and cross-tools stages.
170 # 1. bootstrap-tools stage [BMAKE]
171 #       This stage is responsible for creating programs that
172 #       are needed for backward compatibility reasons. They
173 #       are not built as cross-tools.
174 # 2. build-tools stage [TMAKE]
175 #       This stage is responsible for creating the object
176 #       tree and building any tools that are needed during
177 #       the build process.
178 # 3. cross-tools stage [XMAKE]
179 #       This stage is responsible for creating any tools that
180 #       are needed for cross-builds. A cross-compiler is one
181 #       of them.
182 # 4. world stage [WMAKE]
183 #       This stage actually builds the world.
184 # 5. install stage (optional) [IMAKE]
185 #       This stage installs a previously built world.
186 #
187
188 BOOTSTRAPPING?= 0
189
190 # Common environment for world related stages
191 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
192                 MACHINE_ARCH=${TARGET_ARCH} \
193                 MACHINE=${TARGET} \
194                 CPUTYPE=${TARGET_CPUTYPE} \
195                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
196                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
197                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
198
199 # bootstrap-tools stage
200 BMAKEENV=       DESTDIR= \
201                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
202                 PATH=${BPATH}:${PATH} \
203                 WORLDTMP=${WORLDTMP} \
204                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
205 .if ${BOOTSTRAPPING} < 501100
206 BMAKEENV+=      CSTD=
207 .endif
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 ! `grep -q '^smmsp:' /etc/passwd`; then \
377                 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
378                 false; \
379         fi
380         @if ! `grep -q '^smmsp:' /etc/group`; 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:
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 ${BOOTSTRAPPING} < 500019
671 _kbdcontrol=    usr.sbin/kbdcontrol
672 .endif
673
674 bootstrap-tools:
675 .for _tool in ${_strfile} usr.bin/colldef \
676     usr.bin/makewhatis usr.bin/rpcgen ${_uudecode} \
677     ${_xargs} usr.bin/xinstall ${_yacc} \
678     usr.sbin/config ${_kbdcontrol} \
679     ${_gperf} ${_groff} gnu/usr.bin/texinfo
680         @${ECHODIR} "===> ${_tool}"; \
681                 cd ${.CURDIR}/${_tool}; \
682                 ${MAKE} DIRPRFX=${_tool}/ obj; \
683                 ${MAKE} DIRPRFX=${_tool}/ depend; \
684                 ${MAKE} DIRPRFX=${_tool}/ all; \
685                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
686 .endfor
687
688 #
689 # build-tools: Build special purpose build tools
690 #
691 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
692 _aicasm= sys/modules/aic7xxx/aicasm
693 .endif
694
695 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
696 _share= share/syscons/scrnmaps
697 .endif
698
699 .if !defined(NO_FORTRAN)
700 _fortran= gnu/usr.bin/cc/f771
701 .endif
702
703 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
704     !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
705 _libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
706     kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
707 .endif
708
709 build-tools:
710 .for _tool in bin/csh bin/sh gnu/usr.bin/cc/cc_tools ${_fortran} \
711     ${_libkrb5} lib/libncurses ${_share} \
712     ${_aicasm} usr.bin/awk usr.bin/file usr.sbin/sysinstall
713         @${ECHODIR} "===> ${_tool}"; \
714                 cd ${.CURDIR}/${_tool}; \
715                 ${MAKE} DIRPRFX=${_tool}/ obj; \
716                 ${MAKE} DIRPRFX=${_tool}/ build-tools
717 .endfor
718
719 #
720 # cross-tools: Build cross-building tools
721 #
722 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
723 _elf2exe=       usr.sbin/elf2exe
724 .endif
725
726 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
727 _btxld= usr.sbin/btxld
728 .if defined(RELEASEDIR)
729 _kgzip= usr.sbin/kgzip
730 .endif
731 .endif
732
733 .if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
734     ${BOOTSTRAPPING} < 500037
735 _elf2aout=      usr.bin/elf2aout
736 .endif
737
738 .if defined(RELEASEDIR)
739 _crunchide=     usr.sbin/crunch/crunchide
740 .endif
741
742 _xlint= usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
743
744 cross-tools:
745 .for _tool in ${_btxld} ${_elf2aout} ${_elf2exe} \
746     gnu/usr.bin/binutils ${_crunchide} \
747     gnu/usr.bin/cc ${_xlint} ${_kgzip}
748         @${ECHODIR} "===> ${_tool}"; \
749                 cd ${.CURDIR}/${_tool}; \
750                 ${MAKE} DIRPRFX=${_tool}/ obj; \
751                 ${MAKE} DIRPRFX=${_tool}/ depend; \
752                 ${MAKE} DIRPRFX=${_tool}/ all; \
753                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
754 .endfor
755
756 #
757 # hierarchy - ensure that all the needed directories are present
758 #
759 hierarchy:
760         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
761
762 #
763 # libraries - build all libraries, and install them under ${DESTDIR}.
764 #
765 # The list of libraries with dependents (${_prebuild_libs}) and their
766 # interdependencies (__L) are built automatically by the
767 # ${.CURDIR}/tools/make_libdeps.sh script.
768 #
769 libraries:
770         cd ${.CURDIR}; \
771             ${MAKE} -f Makefile.inc1 _startup_libs; \
772             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
773             ${MAKE} -f Makefile.inc1 _generic_libs;
774
775 # These dependencies are not automatically generated:
776 #
777 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
778 # shared libraries for ELF.
779 #
780 _startup_libs=  gnu/lib/csu gnu/lib/libgcc
781 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
782 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
783 .else
784 _startup_libs+= lib/csu/${MACHINE_ARCH}
785 .endif
786
787 _prebuild_libs=
788
789 _generic_libs=  gnu/lib
790
791 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
792     !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
793 _prebuild_libs+=        kerberos5/lib/libasn1
794 _prebuild_libs+=        kerberos5/lib/libgssapi
795 _prebuild_libs+=        kerberos5/lib/libkrb5
796 _prebuild_libs+=        kerberos5/lib/libroken
797 _generic_libs+= kerberos5/lib
798 .endif
799
800 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
801                 lib/libkvm lib/libmd \
802                 lib/libncurses lib/libopie lib/libpam lib/libradius \
803                 lib/librpcsvc \
804                 lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
805                 lib/libz lib/msun
806
807 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
808 lib/libypclnt__L: lib/librpcsvc__L
809
810 _generic_libs+= lib
811
812 .if !defined(NOCRYPT)
813 .if !defined(NO_OPENSSL)
814 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
815 .if !defined(NO_OPENSSH)
816 _prebuild_libs+=        secure/lib/libssh
817 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
818 .endif
819 .endif
820 _generic_libs+= secure/lib
821 .endif
822
823 _generic_libs+= usr.bin/lex/lib
824
825 .if ${MACHINE_ARCH} == "i386"
826 _generic_libs+= usr.sbin/pcvt/keycap
827 .endif
828
829 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
830 ${_lib}__L: .PHONY
831 .if exists(${.CURDIR}/${_lib})
832         @${ECHODIR} "===> ${_lib}"; \
833                 cd ${.CURDIR}/${_lib}; \
834                 ${MAKE} DIRPRFX=${_lib}/ depend; \
835                 ${MAKE} DIRPRFX=${_lib}/ all; \
836                 ${MAKE} DIRPRFX=${_lib}/ install
837 .endif
838 .endfor
839
840 # libpam is special: we need to build static PAM modules before
841 # static PAM library, and dynamic PAM library before dynamic PAM
842 # modules.
843 lib/libpam__L: .PHONY
844         @${ECHODIR} "===> lib/libpam"; \
845                 cd ${.CURDIR}/lib/libpam; \
846                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
847                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
848                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
849
850 _startup_libs: ${_startup_libs:S/$/__L/}
851 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
852 _generic_libs: ${_generic_libs:S/$/__L/}
853
854 .for __target in all clean cleandepend cleandir depend includes obj
855 .for entry in ${SUBDIR}
856 ${entry}.${__target}__D: .PHONY
857         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
858                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
859                 edir=${entry}.${MACHINE_ARCH}; \
860                 cd ${.CURDIR}/$${edir}; \
861         else \
862                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
863                 edir=${entry}; \
864                 cd ${.CURDIR}/$${edir}; \
865         fi; \
866         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
867 .endfor
868 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
869 .endfor
870
871 .include <bsd.subdir.mk>