2 # $Id: Makefile,v 1.133 1997/08/05 03:49:45 asami 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 # -DNOLIBC_R do not build libc_r.
21 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24 # The intended user-driven targets are:
25 # buildworld - rebuild *everything*, including glue to help do upgrades
26 # installworld- install everything built by "buildworld"
27 # world - buildworld + installworld
28 # update - convenient way to update your source tree (eg: sup/cvs)
29 # most - build user commands, no libraries or include files
30 # installmost - install user commands, no libraries or include files
32 # Standard targets (not defined here) are documented in the makefiles in
33 # /usr/share/mk. These include:
34 # obj depend all install clean cleandepend cleanobj
36 .if (!make(world)) && (!make(buildworld)) && (!make(installworld))
37 .MAKEFLAGS:= ${.MAKEFLAGS} -m ${.CURDIR}/share/mk
40 # Put initial settings here.
43 # We must do include and lib first so that the perl *.ph generation
44 # works correctly as it uses the header files installed by this.
55 .if exists(games) && !defined(NOGAMES)
61 .if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
70 .if exists(share) && !defined(NOSHARE)
82 .if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
85 .if exists(lkm) && !defined(NOLKM)
89 # etc must be last for "distribute" to work
90 .if exists(etc) && make(distribute)
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(${_DIR}) & exists(${_DIR}/Makefile)
104 # Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
105 .if defined(NOOBJDIR)
114 .if defined(NOCLEANDIR)
125 # While building tools for bootstrapping, we dont need to waste time on
126 # profiled libraries or man pages. This speeds things up somewhat.
128 MK_FLAGS= -DNOINFO -DNOMAN -DNOPROFILE
133 # Attempt to rebuild and reinstall *everything*, with reasonable chance of
134 # success, regardless of how old your existing system is.
136 # >> Beware, it overwrites the local build environment! <<
139 @echo "--------------------------------------------------------------"
140 @echo "make world started on `LC_TIME=C date`"
141 @echo "--------------------------------------------------------------"
142 .if target(pre-world)
144 @echo "--------------------------------------------------------------"
145 @echo " Making 'pre-world' target"
146 @echo "--------------------------------------------------------------"
147 cd ${.CURDIR} && ${MAKE} pre-world
149 cd ${.CURDIR} && ${MAKE} buildworld
150 cd ${.CURDIR} && ${MAKE} installworld
151 .if target(post-world)
153 @echo "--------------------------------------------------------------"
154 @echo " Making 'post-world' target"
155 @echo "--------------------------------------------------------------"
156 cd ${.CURDIR} && ${MAKE} post-world
159 @echo "--------------------------------------------------------------"
160 @echo "make world completed on `LC_TIME=C date`"
161 @echo "--------------------------------------------------------------"
163 .if defined(MAKEOBJDIRPREFIX)
164 WORLDTMP= ${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
166 WORLDTMP= /usr/obj${.CURDIR}/tmp
168 STRICTTMPPATH= ${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
169 TMPPATH= ${STRICTTMPPATH}:${PATH}
171 # XXX COMPILER_PATH is needed for finding cc1, ld and as
172 # XXX GCC_EXEC_PREFIX is for *crt.o. It is probably unnecssary now
173 # tbat LIBRARY_PATH is set. We still can't use -nostdlib, since gcc
174 # wouldn't link *crt.o or libgcc if it were used.
175 # XXX LD_LIBRARY_PATH is for ld.so. It is also used by ld, although we don't
176 # want that - all compile-time library paths should be resolved by gcc.
177 # It fails for set[ug]id executables (are any used?).
178 COMPILER_ENV= BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
179 COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
180 GCC_EXEC_PREFIX=${WORLDTMP}/usr/lib/ \
181 LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
182 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
184 BMAKEENV= PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
185 XMAKEENV= PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
186 CC='cc -nostdinc' # XXX -nostdlib
188 # used to compile and install 'make' in temporary build tree
189 IBMAKE= ${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
191 BMAKE= ${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
192 # cross make used for compilation
193 XMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
194 # cross make used for final installation
195 IXMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
200 # Attempt to rebuild the entire system, with reasonable chance of
201 # success, regardless of how old your existing system is.
204 .if !defined(NOCLEAN)
206 @echo "--------------------------------------------------------------"
207 @echo " Cleaning up the temporary build tree"
208 @echo "--------------------------------------------------------------"
210 chflags -R noschg ${WORLDTMP}/
214 @echo "--------------------------------------------------------------"
216 @echo "--------------------------------------------------------------"
217 mkdir -p ${WORLDTMP}/usr/bin
218 cd ${.CURDIR}/usr.bin/make && \
219 ${IBMAKE} -I${.CURDIR}/share/mk ${OBJDIR} clean cleandepend depend && \
220 ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all install clean cleandepend
222 @echo "--------------------------------------------------------------"
223 @echo " Making hierarchy"
224 @echo "--------------------------------------------------------------"
225 cd ${.CURDIR} && ${BMAKE} hierarchy
226 .if !defined(NOCLEAN)
228 @echo "--------------------------------------------------------------"
229 @echo " Cleaning up the obj tree"
230 @echo "--------------------------------------------------------------"
231 cd ${.CURDIR} && ${BMAKE} ${CLEANDIR}
233 .if !defined(NOOBJDIR)
235 @echo "--------------------------------------------------------------"
236 @echo " Rebuilding the obj tree"
237 @echo "--------------------------------------------------------------"
238 cd ${.CURDIR} && ${BMAKE} obj
241 @echo "--------------------------------------------------------------"
242 @echo " Rebuilding bootstrap tools"
243 @echo "--------------------------------------------------------------"
244 cd ${.CURDIR} && ${BMAKE} bootstrap
246 @echo "--------------------------------------------------------------"
247 @echo " Rebuilding tools necessary to build the include files"
248 @echo "--------------------------------------------------------------"
249 cd ${.CURDIR} && ${BMAKE} include-tools
251 @echo "--------------------------------------------------------------"
252 @echo " Rebuilding /usr/include"
253 @echo "--------------------------------------------------------------"
254 cd ${.CURDIR} && ${BMAKE} includes
256 @echo "--------------------------------------------------------------"
257 @echo " Rebuilding tools needed to build the libraries"
258 @echo "--------------------------------------------------------------"
259 cd ${.CURDIR} && ${BMAKE} lib-tools
261 @echo "--------------------------------------------------------------"
262 @echo " Rebuilding /usr/lib"
263 @echo "--------------------------------------------------------------"
264 cd ${.CURDIR} && ${BMAKE} libraries
266 @echo "--------------------------------------------------------------"
267 @echo " Rebuilding all other tools needed to build the world"
268 @echo "--------------------------------------------------------------"
269 cd ${.CURDIR} && ${BMAKE} build-tools
271 @echo "--------------------------------------------------------------"
272 @echo " Rebuilding dependencies"
273 @echo "--------------------------------------------------------------"
274 cd ${.CURDIR} && ${XMAKE} depend
276 @echo "--------------------------------------------------------------"
277 @echo " Building everything.."
278 @echo "--------------------------------------------------------------"
279 cd ${.CURDIR} && ${XMAKE} all
284 # Installs everything compiled by a 'buildworld'.
287 cd ${.CURDIR} && ${IXMAKE} reinstall
292 # If you have a build server, you can NFS mount the source and obj directories
293 # and do a 'make reinstall' on the *client* to install new binaries from the
294 # most recent server build.
297 @echo "--------------------------------------------------------------"
298 @echo " Making hierarchy"
299 @echo "--------------------------------------------------------------"
300 cd ${.CURDIR} && ${MAKE} hierarchy
302 @echo "--------------------------------------------------------------"
303 @echo " Installing everything.."
304 @echo "--------------------------------------------------------------"
305 cd ${.CURDIR} && ${MAKE} install
307 @echo "--------------------------------------------------------------"
308 @echo " Rebuilding man page indexes"
309 @echo "--------------------------------------------------------------"
310 cd ${.CURDIR}/share/man && ${MAKE} makedb
315 # Update the source tree, by running sup and/or running cvs to update to the
319 .if defined(SUP_UPDATE)
320 @echo "--------------------------------------------------------------"
322 @echo "--------------------------------------------------------------"
323 @${SUP} ${SUPFLAGS} ${SUPFILE}
324 .if defined(SUPFILE1)
325 @${SUP} ${SUPFLAGS} ${SUPFILE1}
327 .if defined(SUPFILE2)
328 @${SUP} ${SUPFLAGS} ${SUPFILE2}
331 .if defined(CVS_UPDATE)
332 @echo "--------------------------------------------------------------"
333 @echo "Updating /usr/src from cvs repository" ${CVSROOT}
334 @echo "--------------------------------------------------------------"
335 cd ${.CURDIR} && cvs -q update -P -d
341 # Build most of the user binaries on the existing system libs and includes.
344 @echo "--------------------------------------------------------------"
345 @echo " Building programs only"
346 @echo "--------------------------------------------------------------"
347 cd ${.CURDIR}/bin && ${MAKE} ${.MAKEFLAGS} all
348 cd ${.CURDIR}/sbin && ${MAKE} ${.MAKEFLAGS} all
349 cd ${.CURDIR}/libexec && ${MAKE} ${.MAKEFLAGS} all
350 cd ${.CURDIR}/usr.bin && ${MAKE} ${.MAKEFLAGS} all
351 cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
352 cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} all
353 cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} all
354 cd ${.CURDIR}/gnu/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
355 #.if defined(MAKE_EBONES) && !defined(NOCRYPT)
356 # cd ${.CURDIR}/eBones && ${MAKE} ${.MAKEFLAGS} most
358 #.if !defined(NOSECURE) && !defined(NOCRYPT)
359 # cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} most
365 # Install the binaries built by the 'most' target. This does not include
366 # libraries or include files.
369 @echo "--------------------------------------------------------------"
370 @echo " Installing programs only"
371 @echo "--------------------------------------------------------------"
372 cd ${.CURDIR}/bin && ${MAKE} ${.MAKEFLAGS} install
373 cd ${.CURDIR}/sbin && ${MAKE} ${.MAKEFLAGS} install
374 cd ${.CURDIR}/libexec && ${MAKE} ${.MAKEFLAGS} install
375 cd ${.CURDIR}/usr.bin && ${MAKE} ${.MAKEFLAGS} install
376 cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} install
377 cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} install
378 cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} install
379 cd ${.CURDIR}/gnu/usr.sbin && ${MAKE} ${.MAKEFLAGS} install
380 #.if defined(MAKE_EBONES) && !defined(NOCRYPT)
381 # cd ${.CURDIR}/eBones && ${MAKE} ${.MAKEFLAGS} installmost
383 #.if !defined(NOSECURE) && !defined(NOCRYPT)
384 # cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} installmost
388 # ------------------------------------------------------------------------
390 # From here onwards are utility targets used by the 'make world' and
391 # related targets. If your 'world' breaks, you may like to try to fix
392 # the problem and manually run the following targets to attempt to
393 # complete the build. Beware, this is *not* guaranteed to work, you
394 # need to have a pretty good grip on the current state of the system
395 # to attempt to manually finish it. If in doubt, 'make world' again.
399 # heirarchy - ensure that all the needed directories are present
402 cd ${.CURDIR}/etc && ${MAKE} distrib-dirs
405 # bootstrap - [re]build tools needed to run the actual build, this includes
406 # tools needed by 'make depend', as some tools are needed to generate source
407 # for the dependency information to be gathered from.
411 rm -f ${DESTDIR}/usr/src/sys
412 ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
413 cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
414 cd ${.CURDIR}/include && make symlinks
416 cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
417 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
418 cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
419 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
420 cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
421 ${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
424 # include-tools - generally the same as 'bootstrap', except that it's for
425 # things that are specifically needed to generate include files.
427 # XXX should be merged with bootstrap, it's not worth keeeping them separate.
428 # Well, maybe it is now. We force 'cleandepend' here to avoid dependencies
429 # on cleaned away headers in ${WORLDTMP}.
432 cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} cleandepend depend && \
433 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
436 # includes - possibly generate and install the include files.
440 rm -rf ${DESTDIR}/usr/include/*
441 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
442 -p ${DESTDIR}/usr/include
444 cd ${.CURDIR}/include && ${MAKE} all install
445 cd ${.CURDIR}/gnu/include && ${MAKE} install
446 cd ${.CURDIR}/gnu/lib/libreadline && ${MAKE} beforeinstall
447 cd ${.CURDIR}/gnu/lib/libregex && ${MAKE} beforeinstall
448 cd ${.CURDIR}/gnu/lib/libstdc++ && ${MAKE} beforeinstall
449 cd ${.CURDIR}/gnu/lib/libg++ && ${MAKE} beforeinstall
450 cd ${.CURDIR}/gnu/lib/libdialog && ${MAKE} beforeinstall
451 .if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
452 cd ${.CURDIR}/eBones/include && ${MAKE} beforeinstall
453 cd ${.CURDIR}/eBones/lib/libkrb && ${MAKE} beforeinstall
454 cd ${.CURDIR}/eBones/lib/libkadm && ${MAKE} beforeinstall
456 cd ${.CURDIR}/lib/csu/i386 && ${MAKE} beforeinstall
457 cd ${.CURDIR}/lib/libalias && ${MAKE} beforeinstall
458 cd ${.CURDIR}/lib/libc && ${MAKE} beforeinstall
459 cd ${.CURDIR}/lib/libcurses && ${MAKE} beforeinstall
460 cd ${.CURDIR}/lib/libedit && ${MAKE} beforeinstall
461 cd ${.CURDIR}/lib/libftpio && ${MAKE} beforeinstall
462 cd ${.CURDIR}/lib/libmd && ${MAKE} beforeinstall
463 cd ${.CURDIR}/lib/libmytinfo && ${MAKE} beforeinstall
464 cd ${.CURDIR}/lib/libncurses && ${MAKE} beforeinstall
465 .if !defined(WANT_CSRG_LIBM)
466 cd ${.CURDIR}/lib/msun && ${MAKE} beforeinstall
468 cd ${.CURDIR}/lib/libpcap && ${MAKE} beforeinstall
469 cd ${.CURDIR}/lib/librpcsvc && ${MAKE} beforeinstall
470 cd ${.CURDIR}/lib/libskey && ${MAKE} beforeinstall
471 .if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
472 exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
473 cd ${.CURDIR}/lib/libtcl && ${MAKE} beforeinstall
475 cd ${.CURDIR}/lib/libtermcap && ${MAKE} beforeinstall
476 cd ${.CURDIR}/lib/libcom_err && ${MAKE} beforeinstall
477 cd ${.CURDIR}/lib/libss && ${MAKE} beforeinstall
478 cd ${.CURDIR}/lib/libscsi && ${MAKE} beforeinstall
479 cd ${.CURDIR}/lib/libutil && ${MAKE} beforeinstall
480 cd ${.CURDIR}/lib/libz && ${MAKE} beforeinstall
483 # lib-tools - build tools to compile and install the libraries.
485 # XXX gperf is required for cc
486 # XXX a new ld and tsort is required for cc
502 cd ${.CURDIR}/$d && ${MAKE} depend && \
503 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
507 # libraries - build and install the libraries
510 .if exists(lib/csu/i386)
511 cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
512 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
514 .if exists(lib/libcompat)
515 cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
516 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
518 .if exists(lib/libncurses)
519 cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
520 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
522 .if exists(lib/libtermcap)
523 cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
524 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
527 cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
528 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
530 .if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
531 cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
532 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
535 cd ${.CURDIR}/lib && ${MAKE} depend && \
536 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
538 .if exists(usr.bin/lex/lib)
539 cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
540 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
542 .if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
543 cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
544 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
546 .if exists(usr.sbin/pcvt/keycap)
547 cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
548 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
552 # build-tools - build and install any other tools needed to complete the
553 # compile and install.
555 # bc and cpp are required to build groff. Otherwise, the order here is
556 # mostly historical, i.e., bogus.
557 # chmod is used to build gcc's tmpmultilib[2] at obscure times.
559 # XXX uname is a bug - the target should not depend on the host.
583 gnu/usr.bin/man/makewhatis \
585 gnu/usr.bin/texinfo \
618 cd ${.CURDIR}/$d && ${MAKE} depend && \
619 ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
622 .include <bsd.subdir.mk>