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