2 # $Id: Makefile,v 1.149 1997/10/05 09:34:41 jkh Exp $
4 # Make command line options:
5 # -DCLOBBER will remove /usr/include
6 # -DMAKE_EBONES to build eBones (KerberosIV)
7 # -DALLLANG to build documentation for all languages
8 # (where available -- see share/doc/Makefile)
10 # -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
11 # -DNOCLEAN do not clean at all
12 # -DNOCRYPT will prevent building of crypt versions
13 # -DNOLKM do not build loadable kernel modules
14 # -DNOOBJDIR do not run ``${MAKE} obj''
15 # -DNOPROFILE do not build profiled libraries
16 # -DNOSECURE do not go into secure subdir
17 # -DNOGAMES do not go into games subdir
18 # -DNOSHARE do not go into share subdir
19 # -DNOINFO do not make or install info files
20 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
23 # The intended user-driven targets are:
24 # buildworld - rebuild *everything*, including glue to help do upgrades
25 # installworld- install everything built by "buildworld"
26 # world - buildworld + installworld
27 # update - convenient way to update your source tree (eg: sup/cvs)
28 # most - build user commands, no libraries or include files
29 # installmost - install user commands, no libraries or include files
31 # Standard targets (not defined here) are documented in the makefiles in
32 # /usr/share/mk. These include:
33 # obj depend all install clean cleandepend cleanobj
35 .if (!make(world)) && (!make(buildworld)) && (!make(installworld))
36 .MAKEFLAGS:= ${.MAKEFLAGS} -m ${.CURDIR}/share/mk
39 # Put initial settings here.
42 # We must do include and lib first so that the perl *.ph generation
43 # works correctly as it uses the header files installed by this.
54 .if exists(games) && !defined(NOGAMES)
60 .if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
69 .if exists(share) && !defined(NOSHARE)
81 .if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
84 .if exists(lkm) && !defined(NOLKM)
88 # etc must be last for "distribute" to work
89 .if exists(etc) && make(distribute)
93 # These are last, since it is nice to at least get the base system
94 # rebuilt before you do them.
95 .if defined(LOCAL_DIRS)
96 .for _DIR in ${LOCAL_DIRS}
97 .if exists(${_DIR}) & exists(${_DIR}/Makefile)
103 # Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
104 .if defined(NOOBJDIR)
113 .if defined(NOCLEANDIR)
124 # While building tools for bootstrapping, we dont need to waste time on
125 # profiled libraries or man pages. This speeds things up somewhat.
127 MK_FLAGS= -DNOINFO -DNOMAN -DNOPROFILE
132 # Attempt to rebuild and reinstall *everything*, with reasonable chance of
133 # success, regardless of how old your existing system is.
135 # >> Beware, it overwrites the local build environment! <<
138 @echo "--------------------------------------------------------------"
139 @echo "make world started on `LC_TIME=C date`"
140 @echo "--------------------------------------------------------------"
141 .if target(pre-world)
143 @echo "--------------------------------------------------------------"
144 @echo " Making 'pre-world' target"
145 @echo "--------------------------------------------------------------"
146 cd ${.CURDIR} && ${MAKE} pre-world
148 cd ${.CURDIR} && ${MAKE} buildworld
149 cd ${.CURDIR} && ${MAKE} -B installworld
150 .if target(post-world)
152 @echo "--------------------------------------------------------------"
153 @echo " Making 'post-world' target"
154 @echo "--------------------------------------------------------------"
155 cd ${.CURDIR} && ${MAKE} post-world
158 @echo "--------------------------------------------------------------"
159 @echo "make world completed on `LC_TIME=C date`"
160 @echo "--------------------------------------------------------------"
162 .if defined(MAKEOBJDIRPREFIX)
163 WORLDTMP= ${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
165 WORLDTMP= /usr/obj${.CURDIR}/tmp
167 STRICTTMPPATH= ${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
168 TMPPATH= ${STRICTTMPPATH}:${PATH}
170 # XXX COMPILER_PATH is needed for finding cc1, ld and as
171 # XXX GCC_EXEC_PREFIX is for *crt.o. It is probably unnecssary now
172 # tbat LIBRARY_PATH is set. We still can't use -nostdlib, since gcc
173 # wouldn't link *crt.o or libgcc if it were used.
174 # XXX LD_LIBRARY_PATH is for ld.so. It is also used by ld, although we don't
175 # want that - all compile-time library paths should be resolved by gcc.
176 # It fails for set[ug]id executables (are any used?).
177 COMPILER_ENV= BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
178 COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
179 GCC_EXEC_PREFIX=${WORLDTMP}/usr/lib/ \
180 LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
181 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
183 BMAKEENV= PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
184 XMAKEENV= PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
185 CC='cc -nostdinc' # XXX -nostdlib
187 # used to compile and install 'make' in temporary build tree
188 IBMAKE= ${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
190 BMAKE= ${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
191 # cross make used for compilation
192 XMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
193 # cross make used for final installation
194 IXMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
199 # Attempt to rebuild the entire system, with reasonable chance of
200 # success, regardless of how old your existing system is.
203 .if !defined(NOCLEAN)
205 @echo "--------------------------------------------------------------"
206 @echo " Cleaning up the temporary build tree"
207 @echo "--------------------------------------------------------------"
209 chflags -R noschg ${WORLDTMP}/
213 @echo "--------------------------------------------------------------"
215 @echo "--------------------------------------------------------------"
216 mkdir -p ${WORLDTMP}/usr/bin
217 cd ${.CURDIR}/usr.bin/make && \
218 ${IBMAKE} -I${.CURDIR}/share/mk -B ${CLEANDIR} ${OBJDIR} depend && \
219 ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all && \
220 ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} \
221 -B all install clean cleandepend
223 @echo "--------------------------------------------------------------"
224 @echo " Making hierarchy"
225 @echo "--------------------------------------------------------------"
226 cd ${.CURDIR} && ${BMAKE} hierarchy
227 .if !defined(NOCLEAN)
229 @echo "--------------------------------------------------------------"
230 @echo " Cleaning up the obj tree"
231 @echo "--------------------------------------------------------------"
232 cd ${.CURDIR} && ${BMAKE} par-${CLEANDIR}
234 .if !defined(NOOBJDIR)
236 @echo "--------------------------------------------------------------"
237 @echo " Rebuilding the obj tree"
238 @echo "--------------------------------------------------------------"
239 cd ${.CURDIR} && ${BMAKE} par-obj
242 @echo "--------------------------------------------------------------"
243 @echo " Rebuilding bootstrap tools"
244 @echo "--------------------------------------------------------------"
245 cd ${.CURDIR} && ${BMAKE} bootstrap
247 @echo "--------------------------------------------------------------"
248 @echo " Rebuilding tools necessary to build the include files"
249 @echo "--------------------------------------------------------------"
250 cd ${.CURDIR} && ${BMAKE} include-tools
252 @echo "--------------------------------------------------------------"
253 @echo " Rebuilding /usr/include"
254 @echo "--------------------------------------------------------------"
255 cd ${.CURDIR} && SHARED=symlinks ${BMAKE} includes
257 @echo "--------------------------------------------------------------"
258 @echo " Rebuilding tools needed to build the libraries"
259 @echo "--------------------------------------------------------------"
260 cd ${.CURDIR} && ${BMAKE} lib-tools
262 @echo "--------------------------------------------------------------"
263 @echo " Rebuilding /usr/lib"
264 @echo "--------------------------------------------------------------"
265 cd ${.CURDIR} && ${BMAKE} libraries
267 @echo "--------------------------------------------------------------"
268 @echo " Rebuilding all other tools needed to build the world"
269 @echo "--------------------------------------------------------------"
270 cd ${.CURDIR} && ${BMAKE} build-tools
272 @echo "--------------------------------------------------------------"
273 @echo " Rebuilding dependencies"
274 @echo "--------------------------------------------------------------"
275 cd ${.CURDIR} && ${XMAKE} ${.MAKEFLAGS} par-depend
277 @echo "--------------------------------------------------------------"
278 @echo " Building everything.."
279 @echo "--------------------------------------------------------------"
280 cd ${.CURDIR} && ${XMAKE} all
285 # Installs everything compiled by a 'buildworld'.
288 cd ${.CURDIR} && ${IXMAKE} reinstall
293 # If you have a build server, you can NFS mount the source and obj directories
294 # and do a 'make reinstall' on the *client* to install new binaries from the
295 # most recent server build.
298 @echo "--------------------------------------------------------------"
299 @echo " Making hierarchy"
300 @echo "--------------------------------------------------------------"
301 cd ${.CURDIR} && ${MAKE} hierarchy
303 @echo "--------------------------------------------------------------"
304 @echo " Installing everything.."
305 @echo "--------------------------------------------------------------"
306 cd ${.CURDIR} && ${MAKE} install
308 @echo "--------------------------------------------------------------"
309 @echo " Rebuilding man page indexes"
310 @echo "--------------------------------------------------------------"
311 cd ${.CURDIR}/share/man && ${MAKE} makedb
316 # Update the source tree, by running sup and/or running cvs to update to the
320 .if defined(SUP_UPDATE)
321 @echo "--------------------------------------------------------------"
323 @echo "--------------------------------------------------------------"
324 @${SUP} ${SUPFLAGS} ${SUPFILE}
325 .if defined(SUPFILE1)
326 @${SUP} ${SUPFLAGS} ${SUPFILE1}
328 .if defined(SUPFILE2)
329 @${SUP} ${SUPFLAGS} ${SUPFILE2}
332 .if defined(CVS_UPDATE)
333 @echo "--------------------------------------------------------------"
334 @echo "Updating /usr/src from cvs repository" ${CVSROOT}
335 @echo "--------------------------------------------------------------"
336 cd ${.CURDIR} && cvs -q update -P -d -r RELENG_2_2
342 # Build most of the user binaries on the existing system libs and includes.
345 @echo "--------------------------------------------------------------"
346 @echo " Building programs only"
347 @echo "--------------------------------------------------------------"
348 cd ${.CURDIR}/bin && ${MAKE} ${.MAKEFLAGS} all
349 cd ${.CURDIR}/sbin && ${MAKE} ${.MAKEFLAGS} all
350 cd ${.CURDIR}/libexec && ${MAKE} ${.MAKEFLAGS} all
351 cd ${.CURDIR}/usr.bin && ${MAKE} ${.MAKEFLAGS} all
352 cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
353 cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} all
354 cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} all
355 cd ${.CURDIR}/gnu/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
356 #.if defined(MAKE_EBONES) && !defined(NOCRYPT)
357 # cd ${.CURDIR}/eBones && ${MAKE} ${.MAKEFLAGS} most
359 #.if !defined(NOSECURE) && !defined(NOCRYPT)
360 # cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} most
366 # Install the binaries built by the 'most' target. This does not include
367 # libraries or include files.
370 @echo "--------------------------------------------------------------"
371 @echo " Installing programs only"
372 @echo "--------------------------------------------------------------"
373 cd ${.CURDIR}/bin && ${MAKE} ${.MAKEFLAGS} install
374 cd ${.CURDIR}/sbin && ${MAKE} ${.MAKEFLAGS} install
375 cd ${.CURDIR}/libexec && ${MAKE} ${.MAKEFLAGS} install
376 cd ${.CURDIR}/usr.bin && ${MAKE} ${.MAKEFLAGS} install
377 cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} install
378 cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} install
379 cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} install
380 cd ${.CURDIR}/gnu/usr.sbin && ${MAKE} ${.MAKEFLAGS} install
381 #.if defined(MAKE_EBONES) && !defined(NOCRYPT)
382 # cd ${.CURDIR}/eBones && ${MAKE} ${.MAKEFLAGS} installmost
384 #.if !defined(NOSECURE) && !defined(NOCRYPT)
385 # cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} installmost
389 # ------------------------------------------------------------------------
391 # From here onwards are utility targets used by the 'make world' and
392 # related targets. If your 'world' breaks, you may like to try to fix
393 # the problem and manually run the following targets to attempt to
394 # complete the build. Beware, this is *not* guaranteed to work, you
395 # need to have a pretty good grip on the current state of the system
396 # to attempt to manually finish it. If in doubt, 'make world' again.
400 # heirarchy - ensure that all the needed directories are present
403 cd ${.CURDIR}/etc && ${MAKE} distrib-dirs
406 # bootstrap - [re]build tools needed to run the actual build, this includes
407 # tools needed by 'make depend', as some tools are needed to generate source
408 # for the dependency information to be gathered from.
412 rm -f ${DESTDIR}/usr/src/sys
413 ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
414 cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
415 cd ${.CURDIR}/include && make symlinks
417 cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
418 ${MAKE} ${MK_FLAGS} all && \
419 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
420 cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
421 ${MAKE} ${MK_FLAGS} all && \
422 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
423 cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
424 ${MAKE} ${MK_FLAGS} -DNOLIB && \
425 ${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
426 .if !defined(NOOBJDIR)
427 cd ${.CURDIR}/usr.bin/lex && ${MAKE} obj
431 # include-tools - generally the same as 'bootstrap', except that it's for
432 # things that are specifically needed to generate include files.
434 # XXX should be merged with bootstrap, it's not worth keeeping them separate.
435 # Well, maybe it is now. We force 'cleandepend' here to avoid dependencies
436 # on cleaned away headers in ${WORLDTMP}.
439 cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} -B cleandepend depend && \
440 ${MAKE} ${MK_FLAGS} all && \
441 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
444 # includes - possibly generate and install the include files.
448 rm -rf ${DESTDIR}/usr/include/*
449 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
450 -p ${DESTDIR}/usr/include
452 cd ${.CURDIR}/include && ${MAKE} -B all install
453 cd ${.CURDIR}/gnu/include && ${MAKE} install
454 cd ${.CURDIR}/gnu/lib/libreadline && ${MAKE} beforeinstall
455 cd ${.CURDIR}/gnu/lib/libregex && ${MAKE} beforeinstall
456 cd ${.CURDIR}/gnu/lib/libstdc++ && ${MAKE} beforeinstall
457 cd ${.CURDIR}/gnu/lib/libg++ && ${MAKE} beforeinstall
458 cd ${.CURDIR}/gnu/lib/libdialog && ${MAKE} beforeinstall
459 .if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
460 cd ${.CURDIR}/eBones/include && ${MAKE} beforeinstall
461 cd ${.CURDIR}/eBones/lib/libkrb && ${MAKE} beforeinstall
462 cd ${.CURDIR}/eBones/lib/libkadm && ${MAKE} beforeinstall
464 cd ${.CURDIR}/lib/csu/i386 && ${MAKE} beforeinstall
465 cd ${.CURDIR}/lib/libalias && ${MAKE} beforeinstall
466 cd ${.CURDIR}/lib/libc && ${MAKE} beforeinstall
467 cd ${.CURDIR}/lib/libcurses && ${MAKE} beforeinstall
468 cd ${.CURDIR}/lib/libedit && ${MAKE} beforeinstall
469 cd ${.CURDIR}/lib/libftpio && ${MAKE} beforeinstall
470 cd ${.CURDIR}/lib/libmd && ${MAKE} beforeinstall
471 cd ${.CURDIR}/lib/libmytinfo && ${MAKE} beforeinstall
472 cd ${.CURDIR}/lib/libncurses && ${MAKE} beforeinstall
473 .if !defined(WANT_CSRG_LIBM)
474 cd ${.CURDIR}/lib/msun && ${MAKE} beforeinstall
476 cd ${.CURDIR}/lib/libpcap && ${MAKE} beforeinstall
477 cd ${.CURDIR}/lib/librpcsvc && ${MAKE} beforeinstall
478 cd ${.CURDIR}/lib/libskey && ${MAKE} beforeinstall
479 cd ${.CURDIR}/lib/libtermcap && ${MAKE} beforeinstall
480 cd ${.CURDIR}/lib/libcom_err && ${MAKE} beforeinstall
481 cd ${.CURDIR}/lib/libss && ${MAKE} beforeinstall
482 cd ${.CURDIR}/lib/libscsi && ${MAKE} beforeinstall
483 cd ${.CURDIR}/lib/libutil && ${MAKE} beforeinstall
484 cd ${.CURDIR}/lib/libz && ${MAKE} beforeinstall
487 # lib-tools - build tools to compile and install the libraries.
489 # XXX gperf is required for cc
490 # XXX a new ld and tsort is required for cc
506 cd ${.CURDIR}/$d && ${MAKE} depend && \
507 ${MAKE} ${MK_FLAGS} all && \
508 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
512 # libraries - build and install the libraries
515 .if exists(lib/csu/i386)
516 cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
517 ${MAKE} ${MK_FLAGS} all && \
518 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
520 .if exists(lib/libcompat)
521 cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
522 ${MAKE} ${MK_FLAGS} all && \
523 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
525 .if exists(lib/libncurses)
526 cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
527 ${MAKE} ${MK_FLAGS} all && \
528 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
530 .if exists(lib/libtermcap)
531 cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
532 ${MAKE} ${MK_FLAGS} all && \
533 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
536 cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
537 ${MAKE} ${MK_FLAGS} all && \
538 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
540 .if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
541 cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
542 ${MAKE} ${MK_FLAGS} all && \
543 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
546 cd ${.CURDIR}/lib && ${MAKE} depend && \
547 ${MAKE} ${MK_FLAGS} all && \
548 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
550 .if exists(usr.bin/lex/lib)
551 cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
552 ${MAKE} ${MK_FLAGS} all && \
553 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
555 .if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
556 cd ${.CURDIR}/kerberosIV/lib && ${MAKE} depend && \
557 ${MAKE} ${MK_FLAGS} all && \
558 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
560 .if exists(usr.sbin/pcvt/keycap)
561 cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
562 ${MAKE} ${MK_FLAGS} all && \
563 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
567 # build-tools - build and install any other tools needed to complete the
568 # compile and install.
570 # bc and cpp are required to build groff. Otherwise, the order here is
571 # mostly historical, i.e., bogus.
572 # chmod is used to build gcc's tmpmultilib[2] at obscure times.
574 # XXX uname is a bug - the target should not depend on the host.
598 gnu/usr.bin/man/makewhatis \
600 gnu/usr.bin/texinfo \
633 cd ${.CURDIR}/$d && ${MAKE} depend && \
634 ${MAKE} ${MK_FLAGS} all && \
635 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
638 .for __target in clean cleandir obj depend
639 .for entry in ${SUBDIR}
640 ${entry}.${__target}__D: .PHONY
641 if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
642 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
643 edir=${entry}.${MACHINE}; \
644 cd ${.CURDIR}/$${edir}; \
646 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
648 cd ${.CURDIR}/$${edir}; \
650 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
652 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
655 .include <bsd.subdir.mk>