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