]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Sort.
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 #       -DNO_CLEAN do not clean at all
7 #       -DNO_SHARE do not go into share subdir
8 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
12 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
13 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
14 #       TARGET="machine" to crossbuild world for a different machine type
15
16 #
17 # The intended user-driven targets are:
18 # buildworld  - rebuild *everything*, including glue to help do upgrades
19 # installworld- install everything built by "buildworld"
20 # doxygen     - build API documentation of the kernel
21 # update      - convenient way to update your source tree (eg: cvsup/cvs)
22 #
23 # Standard targets (not defined here) are documented in the makefiles in
24 # /usr/share/mk.  These include:
25 #               obj depend all install clean cleandepend cleanobj
26
27 .include <bsd.own.mk>
28
29 # We must do share/info early so that installation of info `dir'
30 # entries works correctly.  Do it first since it is less likely to
31 # grow dependencies on include and lib than vice versa.
32 #
33 # We must do lib/ and libexec/ before bin/, because if installworld
34 # installs a new /bin/sh, the 'make' command will *immediately*
35 # use that new version.  And the new (dynamically-linked) /bin/sh
36 # will expect to find appropriate libraries in /lib and /libexec.
37 #
38 SUBDIR= share/info lib libexec
39 SUBDIR+=bin
40 .if ${MK_GAMES} != "no"
41 SUBDIR+=games
42 .endif
43 .if ${MK_CDDL} != "no"
44 SUBDIR+=cddl
45 .endif
46 SUBDIR+=gnu include
47 .if ${MK_KERBEROS} != "no"
48 SUBDIR+=kerberos5
49 .endif
50 .if ${MK_RESCUE} != "no"
51 SUBDIR+=rescue
52 .endif
53 SUBDIR+=sbin
54 .if ${MK_CRYPT} != "no"
55 SUBDIR+=secure
56 .endif
57 .if !defined(NO_SHARE)
58 SUBDIR+=share
59 .endif
60 SUBDIR+=sys usr.bin usr.sbin
61 #
62 # We must do etc/ last for install/distribute to work.
63 #
64 SUBDIR+=etc
65
66 # These are last, since it is nice to at least get the base system
67 # rebuilt before you do them.
68 .for _DIR in ${LOCAL_DIRS}
69 .if exists(${.CURDIR}/${_DIR}/Makefile)
70 SUBDIR+= ${_DIR}
71 .endif
72 .endfor
73
74 .if defined(SUBDIR_OVERRIDE)
75 SUBDIR=         ${SUBDIR_OVERRIDE}
76 .endif
77
78 .if defined(NOCLEAN)
79 NO_CLEAN=       ${NOCLEAN}
80 .endif
81 .if defined(NO_CLEANDIR)
82 CLEANDIR=       clean cleandepend
83 .else
84 CLEANDIR=       cleandir
85 .endif
86
87 CVS?=           cvs
88 CVSFLAGS?=      -A -P -d -I!
89 SUP?=           /usr/bin/csup
90 SUPFLAGS?=      -g -L 2
91 .if defined(SUPHOST)
92 SUPFLAGS+=      -h ${SUPHOST}
93 .endif
94
95 MAKEOBJDIRPREFIX?=      /usr/obj
96 .if !defined(OSRELDATE)
97 .if exists(/usr/include/osreldate.h)
98 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
99                 /usr/include/osreldate.h
100 .else
101 OSRELDATE=      0
102 .endif
103 .endif
104
105 # Guess machine architecture from machine type, and vice versa.
106 .if !defined(TARGET_ARCH) && defined(TARGET)
107 TARGET_ARCH=    ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
108 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
109     ${TARGET_ARCH} != ${MACHINE_ARCH}
110 TARGET=         ${TARGET_ARCH}
111 .endif
112 # Otherwise, default to current machine type and architecture.
113 TARGET?=        ${MACHINE}
114 TARGET_ARCH?=   ${MACHINE_ARCH}
115
116 KNOWN_ARCHES?=  amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
117 .if ${TARGET} == ${TARGET_ARCH}
118 _t=             ${TARGET}
119 .else
120 _t=             ${TARGET_ARCH}/${TARGET}
121 .endif
122 .for _t in ${_t}
123 .if empty(KNOWN_ARCHES:M${_t})
124 .error Unknown target ${TARGET_ARCH}:${TARGET}.
125 .endif
126 .endfor
127
128 .if ${TARGET} == ${MACHINE}
129 TARGET_CPUTYPE?=${CPUTYPE}
130 .else
131 TARGET_CPUTYPE?=
132 .endif
133
134 .if !empty(TARGET_CPUTYPE)
135 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
136 .else
137 _TARGET_CPUTYPE=dummy
138 .endif
139 _CPUTYPE!=      MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
140                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
141 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
142 .error CPUTYPE global should be set with ?=.
143 .endif
144 .if make(buildworld)
145 BUILD_ARCH!=    uname -p
146 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
147 .error To cross-build, set TARGET_ARCH.
148 .endif
149 .endif
150 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
151 OBJTREE=        ${MAKEOBJDIRPREFIX}
152 .else
153 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
154 .endif
155 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
156 # /usr/games added for fortune which depend on strfile
157 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
158 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
159 STRICTTMPPATH=  ${BPATH}:${XPATH}
160 TMPPATH=        ${STRICTTMPPATH}:${PATH}
161
162 #
163 # Avoid running mktemp(1) unless actually needed.
164 # It may not be functional, e.g., due to new ABI
165 # when in the middle of installing over this system.
166 #
167 .if make(distributeworld) || make(installworld)
168 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
169 .endif
170
171 #
172 # Building a world goes through the following stages
173 #
174 # 1. legacy stage [BMAKE]
175 #       This stage is responsible for creating compatibility
176 #       shims that are needed by the bootstrap-tools,
177 #       build-tools and cross-tools stages.
178 # 1. bootstrap-tools stage [BMAKE]
179 #       This stage is responsible for creating programs that
180 #       are needed for backward compatibility reasons. They
181 #       are not built as cross-tools.
182 # 2. build-tools stage [TMAKE]
183 #       This stage is responsible for creating the object
184 #       tree and building any tools that are needed during
185 #       the build process.
186 # 3. cross-tools stage [XMAKE]
187 #       This stage is responsible for creating any tools that
188 #       are needed for cross-builds. A cross-compiler is one
189 #       of them.
190 # 4. world stage [WMAKE]
191 #       This stage actually builds the world.
192 # 5. install stage (optional) [IMAKE]
193 #       This stage installs a previously built world.
194 #
195
196 BOOTSTRAPPING?= 0
197
198 # Common environment for world related stages
199 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
200                 MACHINE_ARCH=${TARGET_ARCH} \
201                 MACHINE=${TARGET} \
202                 CPUTYPE=${TARGET_CPUTYPE} \
203                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
204                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
205                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
206
207 # bootstrap-tools stage
208 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
209                 PATH=${BPATH}:${PATH} \
210                 WORLDTMP=${WORLDTMP} \
211                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
212 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
213                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
214                 DESTDIR= \
215                 BOOTSTRAPPING=${OSRELDATE} \
216                 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
217                 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
218                 -DNO_CPU_CFLAGS -DNO_WARNS
219
220 # build-tools stage
221 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
222                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
223                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
224                 DESTDIR= \
225                 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
226
227 # cross-tools stage
228 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
229                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
230                 -DWITHOUT_GDB
231
232 # world stage
233 WMAKEENV=       ${CROSSENV} \
234                 _SHLIBDIRPREFIX=${WORLDTMP} \
235                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
236                 PATH=${TMPPATH}
237 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
238
239 .if ${TARGET_ARCH} == "amd64"
240 # 32 bit world
241 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
242
243 .if empty(TARGET_CPUTYPE)
244 LIB32CPUTYPE=   k8
245 .else
246 LIB32CPUTYPE=   ${TARGET_CPUTYPE}
247 .endif
248 LIB32FLAGS=     -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
249                 -iprefix ${LIB32TMP}/usr/ \
250                 -L${LIB32TMP}/usr/lib32 \
251                 -B${LIB32TMP}/usr/lib32
252
253 # Yes, the flags are redundant.
254 LIB32WMAKEENV=  MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
255                 _SHLIBDIRPREFIX=${LIB32TMP} \
256                 MACHINE=i386 \
257                 MACHINE_ARCH=i386 \
258                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
259                 PATH=${TMPPATH} \
260                 CC="${CC} ${LIB32FLAGS}" \
261                 CXX="${CXX} ${LIB32FLAGS}" \
262                 OBJC="${OBJC} ${LIB32FLAGS}" \
263                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
264                 AS="${AS} --32" \
265                 LIBDIR=/usr/lib32 \
266                 SHLIBDIR=/usr/lib32
267
268 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
269                 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
270                 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
271 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
272 .endif
273
274 # install stage
275 IMAKEENV=       ${CROSSENV}
276 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
277 .if empty(.MAKEFLAGS:M-n)
278 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
279                 LD_LIBRARY_PATH=${INSTALLTMP} \
280                 PATH_LOCALE=${INSTALLTMP}/locale
281 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
282 .else
283 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
284 .endif
285
286 # kernel stage
287 KMAKEENV=       ${WMAKEENV}
288 KMAKE=          ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
289
290 #
291 # buildworld
292 #
293 # Attempt to rebuild the entire system, with reasonable chance of
294 # success, regardless of how old your existing system is.
295 #
296 _worldtmp:
297 .if ${.CURDIR:C/[^,]//g} != ""
298 #       The m4 build of sendmail files doesn't like it if ',' is used
299 #       anywhere in the path of it's files.
300         @echo
301         @echo "*** Error: path to source tree contains a comma ','"
302         @echo
303         false
304 .endif
305         @echo
306         @echo "--------------------------------------------------------------"
307         @echo ">>> Rebuilding the temporary build tree"
308         @echo "--------------------------------------------------------------"
309 .if !defined(NO_CLEAN)
310         rm -rf ${WORLDTMP}
311 .if ${TARGET_ARCH} == "amd64"
312         rm -rf ${LIB32TMP}
313 .endif
314 .else
315         rm -rf ${WORLDTMP}/legacy/usr/include
316 #       XXX - These three can depend on any header file.
317         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
318         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
319         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
320 .endif
321 .for _dir in \
322     usr/bin usr/games usr/include/sys usr/lib \
323     usr/libexec usr/sbin usr/share/dict \
324     usr/share/groff_font/devX100 \
325     usr/share/groff_font/devX100-12 \
326     usr/share/groff_font/devX75 \
327     usr/share/groff_font/devX75-12 \
328     usr/share/groff_font/devascii \
329     usr/share/groff_font/devcp1047 \
330     usr/share/groff_font/devdvi \
331     usr/share/groff_font/devhtml \
332     usr/share/groff_font/devkoi8-r \
333     usr/share/groff_font/devlatin1 \
334     usr/share/groff_font/devlbp \
335     usr/share/groff_font/devlj4 \
336     usr/share/groff_font/devps \
337     usr/share/groff_font/devutf8 \
338     usr/share/tmac/mdoc usr/share/tmac/mm
339         mkdir -p ${WORLDTMP}/legacy/${_dir}
340 .endfor
341 .for _dir in \
342     lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
343     usr/libexec usr/sbin usr/share/misc
344         mkdir -p ${WORLDTMP}/${_dir}
345 .endfor
346         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
347             -p ${WORLDTMP}/usr/include >/dev/null
348         ln -sf ${.CURDIR}/sys ${WORLDTMP}
349 .if ${MK_BIND_LIBS} != "no"
350         mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
351             -p ${WORLDTMP}/usr/include >/dev/null
352 .endif
353 _legacy:
354         @echo
355         @echo "--------------------------------------------------------------"
356         @echo ">>> stage 1.1: legacy release compatibility shims"
357         @echo "--------------------------------------------------------------"
358         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
359 _bootstrap-tools:
360         @echo
361         @echo "--------------------------------------------------------------"
362         @echo ">>> stage 1.2: bootstrap tools"
363         @echo "--------------------------------------------------------------"
364         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
365 _cleanobj:
366 .if !defined(NO_CLEAN)
367         @echo
368         @echo "--------------------------------------------------------------"
369         @echo ">>> stage 2.1: cleaning up the object tree"
370         @echo "--------------------------------------------------------------"
371         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
372 .if ${TARGET_ARCH} == "amd64"
373         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
374 .endif
375 .endif
376 _obj:
377         @echo
378         @echo "--------------------------------------------------------------"
379         @echo ">>> stage 2.2: rebuilding the object tree"
380         @echo "--------------------------------------------------------------"
381         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
382 _build-tools:
383         @echo
384         @echo "--------------------------------------------------------------"
385         @echo ">>> stage 2.3: build tools"
386         @echo "--------------------------------------------------------------"
387         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
388 _cross-tools:
389         @echo
390         @echo "--------------------------------------------------------------"
391         @echo ">>> stage 3: cross tools"
392         @echo "--------------------------------------------------------------"
393         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
394 _includes:
395         @echo
396         @echo "--------------------------------------------------------------"
397         @echo ">>> stage 4.1: building includes"
398         @echo "--------------------------------------------------------------"
399         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
400 _libraries:
401         @echo
402         @echo "--------------------------------------------------------------"
403         @echo ">>> stage 4.2: building libraries"
404         @echo "--------------------------------------------------------------"
405         ${_+_}cd ${.CURDIR}; \
406             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
407             -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
408 _depend:
409         @echo
410         @echo "--------------------------------------------------------------"
411         @echo ">>> stage 4.3: make dependencies"
412         @echo "--------------------------------------------------------------"
413         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
414 everything:
415         @echo
416         @echo "--------------------------------------------------------------"
417         @echo ">>> stage 4.4: building everything"
418         @echo "--------------------------------------------------------------"
419         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
420 .if ${TARGET_ARCH} == "amd64"
421 build32:
422         @echo
423         @echo "--------------------------------------------------------------"
424         @echo ">>> stage 5.1: building 32 bit shim libraries"
425         @echo "--------------------------------------------------------------"
426 .for _dir in \
427     usr/include usr/lib32 usr/share/misc
428         mkdir -p ${LIB32TMP}/${_dir}
429 .endfor
430         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
431             -p ${LIB32TMP}/usr/include >/dev/null
432         mkdir -p ${WORLDTMP}
433         ln -sf ${.CURDIR}/sys ${WORLDTMP}
434 .if ${MK_KERBEROS} != "no"
435 .for _t in obj depend all
436         cd ${.CURDIR}/kerberos5/tools; \
437             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
438 .endfor
439 .endif
440 .for _t in obj includes
441         cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
442         cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
443 .if ${MK_CDDL} != "no"
444         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
445 .endif
446         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
447 .if ${MK_CRYPT} != "no"
448         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
449 .endif
450 .if ${MK_KERBEROS} != "no"
451         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
452 .endif
453 .endfor
454 .for _dir in usr.bin/lex/lib
455         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
456 .endfor
457 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
458         cd ${.CURDIR}/${_dir}; \
459             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
460 .endfor
461         cd ${.CURDIR}; \
462             ${LIB32WMAKE} -f Makefile.inc1 libraries
463 .for _t in obj depend all
464         cd ${.CURDIR}/libexec/rtld-elf; \
465             PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
466 .endfor
467
468 distribute32 install32:
469 .if make(distribute32)
470         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
471 .else
472         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
473 .endif
474         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
475         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
476 .if ${MK_CRYPT} != "no"
477         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
478 .endif
479         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
480 .endif
481
482
483 WMAKE_TGTS=
484 .if !defined(SUBDIR_OVERRIDE)
485 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
486 .endif
487 WMAKE_TGTS+=    _cleanobj _obj _build-tools
488 .if !defined(SUBDIR_OVERRIDE)
489 WMAKE_TGTS+=    _cross-tools
490 .endif
491 WMAKE_TGTS+=    _includes _libraries _depend everything
492 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
493 WMAKE_TGTS+=    build32
494 .endif
495
496 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
497 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
498
499 buildworld_prologue:
500         @echo "--------------------------------------------------------------"
501         @echo ">>> World build started on `LC_ALL=C date`"
502         @echo "--------------------------------------------------------------"
503
504 buildworld_epilogue:
505         @echo
506         @echo "--------------------------------------------------------------"
507         @echo ">>> World build completed on `LC_ALL=C date`"
508         @echo "--------------------------------------------------------------"
509
510 #
511 # We need to have this as a target because the indirection between Makefile
512 # and Makefile.inc1 causes the correct PATH to be used, rather than a
513 # modification of the current environment's PATH.  In addition, we need
514 # to quote multiword values.
515 #
516 buildenvvars:
517         @echo ${WMAKEENV:Q}
518
519 buildenv:
520         @echo Entering world for ${TARGET_ARCH}:${TARGET}
521         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
522
523 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
524 toolchain: ${TOOLCHAIN_TGTS}
525 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
526
527 #
528 # installcheck
529 #
530 # Checks to be sure system is ready for installworld/installkernel.
531 #
532 installcheck:
533
534 #
535 # Require DESTDIR to be set if installing for a different architecture.
536 #
537 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
538 .if !make(distributeworld)
539 installcheck: installcheck_DESTDIR
540 installcheck_DESTDIR:
541 .if !defined(DESTDIR) || empty(DESTDIR)
542         @echo "ERROR: Please set DESTDIR!"; \
543         false
544 .endif
545 .endif
546 .endif
547
548 #
549 # Check for missing UIDs/GIDs.
550 #
551 CHECK_UIDS=
552 CHECK_GIDS=     audit
553 .if ${MK_SENDMAIL} != "no"
554 CHECK_UIDS+=    smmsp
555 CHECK_GIDS+=    smmsp
556 .endif
557 .if ${MK_PF} != "no"
558 CHECK_UIDS+=    proxy
559 CHECK_GIDS+=    proxy authpf
560 .endif
561 installcheck: installcheck_UGID
562 installcheck_UGID:
563 .for uid in ${CHECK_UIDS}
564         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
565                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
566                 false; \
567         fi
568 .endfor
569 .for gid in ${CHECK_GIDS}
570         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
571                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
572                 false; \
573         fi
574 .endfor
575
576 #
577 # Required install tools to be saved in a scratch dir for safety.
578 #
579 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
580         date echo egrep find grep install-info \
581         ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
582         test true uname wc zic
583
584 #
585 # distributeworld
586 #
587 # Distributes everything compiled by a `buildworld'.
588 #
589 # installworld
590 #
591 # Installs everything compiled by a 'buildworld'.
592 #
593 distributeworld installworld: installcheck
594         mkdir -p ${INSTALLTMP}
595         progs=$$(for prog in ${ITOOLS}; do \
596                 if progpath=`which $$prog`; then \
597                         echo $$progpath; \
598                 else \
599                         echo "Required tool $$prog not found in PATH." >&2; \
600                         exit 1; \
601                 fi; \
602             done); \
603         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
604             while read line; do \
605                 set -- $$line; \
606                 if [ "$$2 $$3" != "not found" ]; then \
607                         echo $$2; \
608                 else \
609                         echo "Required library $$1 not found." >&2; \
610                         exit 1; \
611                 fi; \
612             done); \
613         cp $$libs $$progs ${INSTALLTMP}
614         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
615         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
616             ${IMAKEENV} rm -rf ${INSTALLTMP}
617
618 #
619 # reinstall
620 #
621 # If you have a build server, you can NFS mount the source and obj directories
622 # and do a 'make reinstall' on the *client* to install new binaries from the
623 # most recent server build.
624 #
625 reinstall:
626         @echo "--------------------------------------------------------------"
627         @echo ">>> Making hierarchy"
628         @echo "--------------------------------------------------------------"
629         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
630         @echo
631         @echo "--------------------------------------------------------------"
632         @echo ">>> Installing everything"
633         @echo "--------------------------------------------------------------"
634         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
635 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
636         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
637 .endif
638
639 redistribute:
640         @echo "--------------------------------------------------------------"
641         @echo ">>> Distributing everything"
642         @echo "--------------------------------------------------------------"
643         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
644 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
645         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
646 .endif
647
648 distrib-dirs distribution:
649         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
650
651 #
652 # buildkernel and installkernel
653 #
654 # Which kernels to build and/or install is specified by setting
655 # KERNCONF. If not defined a GENERIC kernel is built/installed.
656 # Only the existing (depending TARGET) config files are used
657 # for building kernels and only the first of these is designated
658 # as the one being installed.
659 #
660 # Note that we have to use TARGET instead of TARGET_ARCH when
661 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
662 # be set to cross-build, we have to make sure TARGET is set
663 # properly.
664
665 .if !defined(KERNCONF) && defined(KERNEL)
666 KERNCONF=       ${KERNEL}
667 KERNWARN=
668 .else
669 KERNCONF?=      GENERIC
670 .endif
671 INSTKERNNAME?=  kernel
672
673 KERNSRCDIR?=    ${.CURDIR}/sys
674 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
675 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
676 KERNCONFDIR?=   ${KRNLCONFDIR}
677
678 BUILDKERNELS=
679 INSTALLKERNEL=
680 .for _kernel in ${KERNCONF}
681 .if exists(${KERNCONFDIR}/${_kernel})
682 BUILDKERNELS+=  ${_kernel}
683 .if empty(INSTALLKERNEL)
684 INSTALLKERNEL= ${_kernel}
685 .endif
686 .endif
687 .endfor
688
689 #
690 # buildkernel
691 #
692 # Builds all kernels defined by BUILDKERNELS.
693 #
694 buildkernel:
695 .if empty(BUILDKERNELS)
696         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
697         false
698 .endif
699 .if defined(KERNWARN)
700         @echo "--------------------------------------------------------------"
701         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
702         @echo "--------------------------------------------------------------"
703         @sleep 3
704 .endif
705         @echo
706 .for _kernel in ${BUILDKERNELS}
707         @echo "--------------------------------------------------------------"
708         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
709         @echo "--------------------------------------------------------------"
710         @echo "===> ${_kernel}"
711         mkdir -p ${KRNLOBJDIR}
712 .if !defined(NO_KERNELCONFIG)
713         @echo
714         @echo "--------------------------------------------------------------"
715         @echo ">>> stage 1: configuring the kernel"
716         @echo "--------------------------------------------------------------"
717         cd ${KRNLCONFDIR}; \
718                 PATH=${TMPPATH} \
719                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
720                         ${KERNCONFDIR}/${_kernel}
721 .endif
722 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
723         @echo
724         @echo "--------------------------------------------------------------"
725         @echo ">>> stage 2.1: cleaning up the object tree"
726         @echo "--------------------------------------------------------------"
727         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
728 .endif
729         @echo
730         @echo "--------------------------------------------------------------"
731         @echo ">>> stage 2.2: rebuilding the object tree"
732         @echo "--------------------------------------------------------------"
733         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
734         @echo
735         @echo "--------------------------------------------------------------"
736         @echo ">>> stage 2.3: build tools"
737         @echo "--------------------------------------------------------------"
738         cd ${KRNLOBJDIR}/${_kernel}; \
739             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
740             ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
741 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
742 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
743 .for target in obj depend all
744         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
745             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
746             ${MAKE} -DNO_CPU_CFLAGS ${target}
747 .endfor
748 .endif
749 .if !defined(NO_KERNELDEPEND)
750         @echo
751         @echo "--------------------------------------------------------------"
752         @echo ">>> stage 3.1: making dependencies"
753         @echo "--------------------------------------------------------------"
754         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
755 .endif
756         @echo
757         @echo "--------------------------------------------------------------"
758         @echo ">>> stage 3.2: building everything"
759         @echo "--------------------------------------------------------------"
760         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
761         @echo "--------------------------------------------------------------"
762         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
763         @echo "--------------------------------------------------------------"
764 .endfor
765
766 #
767 # installkernel, etc.
768 #
769 # Install the kernel defined by INSTALLKERNEL
770 #
771 installkernel installkernel.debug \
772 reinstallkernel reinstallkernel.debug: installcheck
773 .if empty(INSTALLKERNEL)
774         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
775         false
776 .endif
777         @echo "--------------------------------------------------------------"
778         @echo ">>> Installing kernel"
779         @echo "--------------------------------------------------------------"
780         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
781             ${CROSSENV} PATH=${TMPPATH} \
782             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
783
784 #
785 # doxygen
786 #
787 # Build the API documentation with doxygen
788 #
789 doxygen:
790         @if [ ! -x `/usr/bin/which doxygen` ]; then \
791                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
792                 exit 1; \
793         fi
794         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
795
796 #
797 # update
798 #
799 # Update the source tree, by running cvsup and/or running cvs to update to the
800 # latest copy.
801 #
802 update:
803 .if defined(SUP_UPDATE)
804         @echo "--------------------------------------------------------------"
805         @echo ">>> Running ${SUP}"
806         @echo "--------------------------------------------------------------"
807 .if defined(SUPFILE)
808         @${SUP} ${SUPFLAGS} ${SUPFILE}
809 .endif
810 .if defined(SUPFILE1)
811         @${SUP} ${SUPFLAGS} ${SUPFILE1}
812 .endif
813 .if defined(SUPFILE2)
814         @${SUP} ${SUPFLAGS} ${SUPFILE2}
815 .endif
816 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
817         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
818 .endif
819 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
820         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
821 .endif
822 .endif
823 .if defined(CVS_UPDATE)
824         @echo "--------------------------------------------------------------"
825         @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
826         @echo "--------------------------------------------------------------"
827         cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
828 .endif
829
830 #
831 # ------------------------------------------------------------------------
832 #
833 # From here onwards are utility targets used by the 'make world' and
834 # related targets.  If your 'world' breaks, you may like to try to fix
835 # the problem and manually run the following targets to attempt to
836 # complete the build.  Beware, this is *not* guaranteed to work, you
837 # need to have a pretty good grip on the current state of the system
838 # to attempt to manually finish it.  If in doubt, 'make world' again.
839 #
840
841 #
842 # legacy: Build compatibility shims for the next three targets
843 #
844 legacy:
845 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
846         @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
847         false
848 .endif
849 .for _tool in tools/build
850         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
851             cd ${.CURDIR}/${_tool}; \
852             ${MAKE} DIRPRFX=${_tool}/ obj; \
853             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
854             ${MAKE} DIRPRFX=${_tool}/ depend; \
855             ${MAKE} DIRPRFX=${_tool}/ all; \
856             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
857 .endfor
858
859 #
860 # bootstrap-tools: Build tools needed for compatibility
861 #
862 .if ${MK_GAMES} != "no"
863 _strfile=       games/fortune/strfile
864 .endif
865
866 .if ${MK_CXX} != "no"
867 _gperf=         gnu/usr.bin/gperf
868 .if ${BOOTSTRAPPING} < 700004
869 _groff=         gnu/usr.bin/groff
870 .else
871 _groff=         gnu/usr.bin/groff/tmac
872 .endif
873 .endif
874
875 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
876 _ar=            usr.bin/ar
877 .endif
878
879 .if ${BOOTSTRAPPING} < 800013
880 _mklocale=      usr.bin/mklocale
881 .endif
882
883 .if ${BOOTSTRAPPING} < 700018
884 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
885 .endif
886
887 .if ${MK_RESCUE} != "no" && \
888     ${BOOTSTRAPPING} < 700026
889 _crunchgen=     usr.sbin/crunch/crunchgen
890 .endif
891
892 bootstrap-tools:
893 .for _tool in \
894     ${_strfile} \
895     ${_gperf} \
896     ${_groff} \
897     ${_ar} \
898     usr.bin/lorder \
899     usr.bin/makewhatis \
900     ${_mklocale} \
901     usr.bin/rpcgen \
902     usr.bin/xinstall \
903     ${_gensnmptree} \
904     usr.sbin/config \
905     ${_crunchgen}
906         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
907                 cd ${.CURDIR}/${_tool}; \
908                 ${MAKE} DIRPRFX=${_tool}/ obj; \
909                 ${MAKE} DIRPRFX=${_tool}/ depend; \
910                 ${MAKE} DIRPRFX=${_tool}/ all; \
911                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
912 .endfor
913
914 #
915 # build-tools: Build special purpose build tools
916 #
917 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
918 _aicasm= sys/modules/aic7xxx/aicasm
919 .endif
920
921 .if !defined(NO_SHARE)
922 _share= share/syscons/scrnmaps
923 .endif
924
925 .if ${MK_KERBEROS} != "no"
926 _kerberos5_tools= kerberos5/tools
927 .endif
928
929 .if ${MK_RESCUE} != "no"
930 _rescue= rescue/rescue
931 .endif
932
933 build-tools:
934 .for _tool in \
935     bin/csh \
936     bin/sh \
937     ${_rescue} \
938     lib/ncurses/ncurses \
939     lib/ncurses/ncursesw \
940     ${_share} \
941     ${_aicasm} \
942     usr.bin/awk \
943     lib/libmagic \
944     usr.sbin/sysinstall
945         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
946                 cd ${.CURDIR}/${_tool}; \
947                 ${MAKE} DIRPRFX=${_tool}/ obj; \
948                 ${MAKE} DIRPRFX=${_tool}/ build-tools
949 .endfor
950 .for _tool in \
951     gnu/usr.bin/cc/cc_tools \
952     ${_kerberos5_tools}
953         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
954                 cd ${.CURDIR}/${_tool}; \
955                 ${MAKE} DIRPRFX=${_tool}/ obj; \
956                 ${MAKE} DIRPRFX=${_tool}/ depend; \
957                 ${MAKE} DIRPRFX=${_tool}/ all
958 .endfor
959
960 #
961 # cross-tools: Build cross-building tools
962 #
963 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
964 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
965 _btxld=         usr.sbin/btxld
966 .endif
967 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
968 _crunchide=     usr.sbin/crunch/crunchide
969 .endif
970 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
971 _kgzip=         usr.sbin/kgzip
972 .endif
973 .endif
974
975 .if make(cross-tools) && ${BOOTSTRAPPING} < 700044
976 .MAKEFLAGS+=    -D_WITH_GNUAR
977 .endif
978
979 cross-tools:
980 .for _tool in \
981     gnu/usr.bin/binutils \
982     gnu/usr.bin/cc \
983     usr.bin/sed \
984     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
985     ${_btxld} \
986     ${_crunchide} \
987     ${_kgzip}
988         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
989                 cd ${.CURDIR}/${_tool}; \
990                 ${MAKE} DIRPRFX=${_tool}/ obj; \
991                 ${MAKE} DIRPRFX=${_tool}/ depend; \
992                 ${MAKE} DIRPRFX=${_tool}/ all; \
993                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
994 .endfor
995
996 #
997 # hierarchy - ensure that all the needed directories are present
998 #
999 hierarchy:
1000         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
1001
1002 #
1003 # libraries - build all libraries, and install them under ${DESTDIR}.
1004 #
1005 # The list of libraries with dependents (${_prebuild_libs}) and their
1006 # interdependencies (__L) are built automatically by the
1007 # ${.CURDIR}/tools/make_libdeps.sh script.
1008 #
1009 libraries:
1010         cd ${.CURDIR}; \
1011             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1012             ${MAKE} -f Makefile.inc1 _startup_libs; \
1013             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1014             ${MAKE} -f Makefile.inc1 _generic_libs;
1015
1016 #
1017 # static libgcc.a prerequisite for shared libc
1018 #
1019 _prereq_libs= gnu/lib/libgcc
1020
1021 # These dependencies are not automatically generated:
1022 #
1023 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1024 # all shared libraries for ELF.
1025 #
1026 _startup_libs=  gnu/lib/csu
1027 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1028 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1029 .else
1030 _startup_libs+= lib/csu/${MACHINE_ARCH}
1031 .endif
1032 _startup_libs+= gnu/lib/libgcc
1033 _startup_libs+= lib/libc
1034
1035 gnu/lib/libgcc__L: lib/libc__L
1036
1037 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1038                 ${_kerberos5_lib_libroken} \
1039                 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1040                 ${_lib_libgssapi} ${_lib_libipx} \
1041                 lib/libkiconv lib/libkvm lib/libmd \
1042                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1043                 lib/libopie lib/libpam ${_default_thread_lib} \
1044                 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1045                 ${_lib_libypclnt} lib/libz lib/msun \
1046                 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1047                 ${_secure_lib_libssl}
1048
1049 .if ${MK_LIBTHR} != "no" && ${MK_LIBKSE} != "no"
1050 _default_thread_lib=    lib/${DEFAULT_THREAD_LIB}
1051 .elif ${MK_LIBTHR} != "no"
1052 _default_thread_lib=    lib/libthr
1053 .elif ${MK_LIBKSE} != "no"
1054 _default_thread_lib=    lib/libkse
1055 .endif
1056
1057 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1058
1059 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1060
1061 .if ${MK_CDDL} != "no"
1062 _cddl_lib= cddl/lib
1063 .endif
1064
1065 .if ${MK_CRYPT} != "no"
1066 .if ${MK_OPENSSL} != "no"
1067 _secure_lib_libcrypto= secure/lib/libcrypto
1068 _secure_lib_libssl= secure/lib/libssl
1069 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1070 .if ${MK_OPENSSH} != "no"
1071 _secure_lib_libssh= secure/lib/libssh
1072 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1073 .if ${MK_KERBEROS} != "no"
1074 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1075     kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1076     kerberos5/lib/libroken__L
1077 .endif
1078 .endif
1079 .endif
1080 _secure_lib=    secure/lib
1081 .endif
1082
1083 .if ${MK_IPX} != "no"
1084 _lib_libipx=    lib/libipx
1085 .endif
1086
1087 .if ${MK_KERBEROS} != "no"
1088 _kerberos5_lib= kerberos5/lib
1089 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1090 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1091 _kerberos5_lib_libroken= kerberos5/lib/libroken
1092 _lib_libgssapi= lib/libgssapi
1093 .endif
1094
1095 .if ${MK_NIS} != "no"
1096 _lib_libypclnt= lib/libypclnt
1097 .endif
1098
1099 .if ${MK_OPENSSL} == "no"
1100 lib/libradius__L: lib/libmd__L
1101 .endif
1102
1103 .for _lib in ${_prereq_libs}
1104 ${_lib}__PL: .PHONY
1105 .if exists(${.CURDIR}/${_lib})
1106         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1107                 cd ${.CURDIR}/${_lib}; \
1108                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1109                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1110                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1111                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1112 .endif
1113 .endfor
1114
1115 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1116 ${_lib}__L: .PHONY
1117 .if exists(${.CURDIR}/${_lib})
1118         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1119                 cd ${.CURDIR}/${_lib}; \
1120                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1121                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1122                 ${MAKE} DIRPRFX=${_lib}/ all; \
1123                 ${MAKE} DIRPRFX=${_lib}/ install
1124 .endif
1125 .endfor
1126
1127 # libpam is special: we need to build static PAM modules before
1128 # static PAM library, and dynamic PAM library before dynamic PAM
1129 # modules.
1130 lib/libpam__L: .PHONY
1131         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1132                 cd ${.CURDIR}/lib/libpam; \
1133                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1134                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1135                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1136                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1137
1138 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1139 _startup_libs: ${_startup_libs:S/$/__L/}
1140 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1141 _generic_libs: ${_generic_libs:S/$/__L/}
1142
1143 .for __target in all clean cleandepend cleandir depend includes obj
1144 .for entry in ${SUBDIR}
1145 ${entry}.${__target}__D: .PHONY
1146         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1147                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1148                 edir=${entry}.${MACHINE_ARCH}; \
1149                 cd ${.CURDIR}/$${edir}; \
1150         else \
1151                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1152                 edir=${entry}; \
1153                 cd ${.CURDIR}/$${edir}; \
1154         fi; \
1155         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1156 .endfor
1157 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1158 .endfor
1159
1160 .include <bsd.subdir.mk>
1161
1162 .if make(check-old) || make(check-old-dirs) || \
1163     make(check-old-files) || make(check-old-libs) || \
1164     make(delete-old) || make(delete-old-dirs) || \
1165     make(delete-old-files) || make(delete-old-libs)
1166
1167 #
1168 # check for / delete old files section
1169 #
1170
1171 .include "ObsoleteFiles.inc"
1172
1173 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1174 else you can not start such an application. Consult UPDATING for more \
1175 information regarding how to cope with the removal/revision bump of a \
1176 specific library."
1177
1178 .if !defined(BATCH_DELETE_OLD_FILES)
1179 RM_I=-i
1180 .else
1181 RM_I=-v
1182 .endif
1183
1184 delete-old-files:
1185         @echo ">>> Removing old files (only deletes safe to delete libs)"
1186 # Ask for every old file if the user really wants to remove it.
1187 # It's annoying, but better safe than sorry.
1188         @for file in ${OLD_FILES}; do \
1189                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1190                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1191                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1192                 fi; \
1193         done
1194 # Remove catpages without corresponding manpages.
1195         @3<&0; \
1196         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1197         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1198         while read catpage; do \
1199                 read manpage; \
1200                 if [ ! -e "$${manpage}" ]; then \
1201                         rm ${RM_I} $${catpage} <&3 ; \
1202                 fi; \
1203         done
1204         @echo ">>> Old files removed"
1205
1206 check-old-files:
1207         @echo ">>> Checking for old files"
1208         @for file in ${OLD_FILES}; do \
1209                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1210                         echo "${DESTDIR}/$${file}"; \
1211                 fi; \
1212         done
1213 # Check for catpages without corresponding manpages.
1214         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1215         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1216         while read catpage; do \
1217                 read manpage; \
1218                 if [ ! -e "$${manpage}" ]; then \
1219                         echo $${catpage} ; \
1220                 fi; \
1221         done
1222
1223 delete-old-libs:
1224         @echo ">>> Removing old libraries"
1225         @echo "${OLD_LIBS_MESSAGE}" | fmt
1226         @for file in ${OLD_LIBS}; do \
1227                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1228                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1229                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1230                 fi; \
1231         done
1232         @echo ">>> Old libraries removed"
1233
1234 check-old-libs:
1235         @echo ">>> Checking for old libraries"
1236         @for file in ${OLD_LIBS}; do \
1237                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1238                         echo "${DESTDIR}/$${file}"; \
1239                 fi; \
1240         done
1241
1242 delete-old-dirs:
1243         @echo ">>> Removing old directories"
1244         @for dir in ${OLD_DIRS}; do \
1245                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1246                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1247                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1248                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1249                 fi; \
1250         done
1251         @echo ">>> Old directories removed"
1252
1253 check-old-dirs:
1254         @echo ">>> Checking for old directories"
1255         @for dir in ${OLD_DIRS}; do \
1256                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1257                         echo "${DESTDIR}/$${dir}"; \
1258                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1259                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1260                 fi; \
1261         done
1262
1263 delete-old: delete-old-files delete-old-dirs
1264         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1265
1266 check-old: check-old-files check-old-libs check-old-dirs
1267         @echo "To remove old files and directories run '${MAKE} delete-old'."
1268         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1269
1270 .endif
1271
1272 #
1273 # showconfig - show build configuration.
1274 #
1275 showconfig:
1276         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort