4 # Make command line options:
5 # -DMAKE_KERBEROS4 to build KerberosIV
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 # -DNOPROFILE do not build profiled libraries
10 # -DNOSECURE do not go into secure subdir
11 # -DNOGAMES do not go into games subdir
12 # -DNOSHARE do not go into share subdir
13 # -DNOINFO do not make or install info files
14 # -DNOLIBC_R do not build libc_r.
15 # -DNO_FORTRAN do not build g77 and related libraries.
16 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # The intended user-driven targets are:
20 # buildworld - rebuild *everything*, including glue to help do upgrades
21 # installworld- install everything built by "buildworld"
22 # update - convenient way to update your source tree (eg: sup/cvs)
23 # most - build user commands, no libraries or include files
24 # installmost - install user commands, no libraries or include files
26 # Standard targets (not defined here) are documented in the makefiles in
27 # /usr/share/mk. These include:
28 # obj depend all install clean cleandepend cleanobj
30 # Put initial settings here.
33 # We must do share/info early so that installation of info `dir'
34 # entries works correctly. Do it first since it is less likely to
35 # grow dependencies on include and lib than vice versa.
36 .if exists(${.CURDIR}/share/info)
40 # We must do include and lib early so that the perl *.ph generation
41 # works correctly as it uses the header files installed by this.
42 .if exists(${.CURDIR}/include)
45 .if exists(${.CURDIR}/lib)
49 .if exists(${.CURDIR}/bin)
52 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
55 .if exists(${.CURDIR}/gnu)
58 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
59 !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
62 .if exists(${.CURDIR}/libexec)
65 .if exists(${.CURDIR}/sbin)
68 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
71 .if exists(${.CURDIR}/sys)
74 .if exists(${.CURDIR}/usr.bin)
77 .if exists(${.CURDIR}/usr.sbin)
80 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
84 # etc must be last for "distribute" to work
85 .if exists(${.CURDIR}/etc)
89 # These are last, since it is nice to at least get the base system
90 # rebuilt before you do them.
91 .if defined(LOCAL_DIRS)
92 .for _DIR in ${LOCAL_DIRS}
93 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
99 .if defined(NOCLEANDIR)
100 CLEANDIR= clean cleandepend
106 SUPFLAGS?= -g -L 2 -P -
108 MAKEOBJDIRPREFIX?= /usr/obj
109 TARGET_ARCH?= ${MACHINE_ARCH}
110 BUILD_ARCH!= sysctl -n hw.machine_arch
111 .if ${BUILD_ARCH} == ${MACHINE_ARCH}
112 OBJTREE= ${MAKEOBJDIRPREFIX}
114 OBJTREE= ${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
116 WORLDTMP= ${OBJTREE}${.CURDIR}/${BUILD_ARCH}
117 # /usr/games added for fortune which depend on strfile
118 STRICTTMPPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
119 TMPPATH= ${STRICTTMPPATH}:${PATH}
122 # Building a world goes through the following stages
124 # bootstrap-tool stage [BMAKE]
125 # This stage is responsible for creating programs that
126 # are needed for backward compatibility reasons. They
127 # are not built as cross-tools.
128 # build-tool stage [TMAKE]
129 # This stage is responsible for creating the object
130 # tree and building any tools that are needed during
132 # cross-tool stage [XMAKE]
133 # This stage is responsible for creating any tools that
134 # are needed for cross-builds. A cross-compiler is one
136 # world stage [WMAKE]
137 # This stage actually builds the world.
138 # install stage (optional) [IMAKE]
139 # This stage installs a previously built world.
142 # Common environment for bootstrap related stages
143 BOOTSTRAPENV= MAKEOBJDIRPREFIX=${WORLDTMP} \
144 DESTDIR=${WORLDTMP} \
145 INSTALL="sh ${.CURDIR}/tools/install.sh" \
146 MACHINE_ARCH=${BUILD_ARCH} \
147 TOOLS_PREFIX=${WORLDTMP} \
150 # Common environment for world related stages
151 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
152 COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
153 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
154 OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
155 PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.00503
157 # bootstrap-tool stage
158 BMAKEENV= ${BOOTSTRAPENV}
159 BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOMAN -DNOINFO
162 TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \
163 INSTALL="sh ${.CURDIR}/tools/install.sh" \
165 TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1
168 XMAKEENV= ${BOOTSTRAPENV} \
169 TARGET_ARCH=${MACHINE_ARCH}
170 XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNOMAN -DNOINFO \
171 -DNO_FORTRAN -DNO_GDB
174 WMAKEENV= ${CROSSENV} \
175 DESTDIR=${WORLDTMP} \
176 INSTALL="sh ${.CURDIR}/tools/install.sh" \
178 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1
181 IMAKEENV= ${CROSSENV}
182 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
184 USRDIRS= usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
185 usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc
187 .if ${MACHINE_ARCH} == "i386" && ${MACHINE} == "pc98"
188 USRDIRS+= usr/libexec/aout
191 INCDIRS= arpa g++/std objc protocols readline rpc rpcsvc openssl \
197 # Attempt to rebuild the entire system, with reasonable chance of
198 # success, regardless of how old your existing system is.
202 @echo "--------------------------------------------------------------"
203 @echo ">>> Rebuilding the temporary build tree"
204 @echo "--------------------------------------------------------------"
205 .if !defined(NOCLEAN)
208 for dir in bin games include lib sbin; do \
209 rm -rf ${WORLDTMP}/usr/$$dir; \
211 rm -f ${WORLDTMP}/sys
213 .for _dir in ${USRDIRS}
214 mkdir -p ${WORLDTMP}/${_dir}
216 .for _dir in ${INCDIRS}
217 mkdir -p ${WORLDTMP}/usr/include/${_dir}
219 ln -sf ${.CURDIR}/sys ${WORLDTMP}/sys
221 @echo "--------------------------------------------------------------"
222 @echo ">>> stage 1: bootstrap tools"
223 @echo "--------------------------------------------------------------"
224 cd ${.CURDIR}; ${BMAKE} bootstrap-tools
225 .if !defined(NOCLEAN)
227 @echo "--------------------------------------------------------------"
228 @echo ">>> stage 2: cleaning up the object tree"
229 @echo "--------------------------------------------------------------"
230 cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
233 @echo "--------------------------------------------------------------"
234 @echo ">>> stage 2: rebuilding the object tree"
235 @echo "--------------------------------------------------------------"
236 cd ${.CURDIR}; ${TMAKE} par-obj
238 @echo "--------------------------------------------------------------"
239 @echo ">>> stage 2: build tools"
240 @echo "--------------------------------------------------------------"
241 cd ${.CURDIR}; ${TMAKE} build-tools
243 @echo "--------------------------------------------------------------"
244 @echo ">>> stage 3: cross tools"
245 @echo "--------------------------------------------------------------"
246 cd ${.CURDIR}; ${XMAKE} cross-tools
248 @echo "--------------------------------------------------------------"
249 @echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
250 @echo "--------------------------------------------------------------"
251 cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
253 @echo "--------------------------------------------------------------"
254 @echo ">>> stage 4: building libraries"
255 @echo "--------------------------------------------------------------"
256 cd ${.CURDIR}; ${WMAKE} -DNOINFO -DNOMAN libraries
258 @echo "--------------------------------------------------------------"
259 @echo ">>> stage 4: make dependencies"
260 @echo "--------------------------------------------------------------"
261 cd ${.CURDIR}; ${WMAKE} par-depend
263 @echo "--------------------------------------------------------------"
264 @echo ">>> stage 4: building everything.."
265 @echo "--------------------------------------------------------------"
266 cd ${.CURDIR}; ${WMAKE} all
269 @echo "--------------------------------------------------------------"
270 @echo ">>> Building everything.."
271 @echo "--------------------------------------------------------------"
272 cd ${.CURDIR}; ${WMAKE} all
277 # Installs everything compiled by a 'buildworld'.
280 cd ${.CURDIR}; ${IMAKE} reinstall
285 # If you have a build server, you can NFS mount the source and obj directories
286 # and do a 'make reinstall' on the *client* to install new binaries from the
287 # most recent server build.
290 @echo "--------------------------------------------------------------"
291 @echo ">>> Making hierarchy"
292 @echo "--------------------------------------------------------------"
293 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
295 @echo "--------------------------------------------------------------"
296 @echo ">>> Installing everything.."
297 @echo "--------------------------------------------------------------"
298 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
301 @echo "--------------------------------------------------------------"
302 @echo ">>> Rebuilding man page indices"
303 @echo "--------------------------------------------------------------"
304 cd ${.CURDIR}/share/man; ${MAKE} makedb
310 # Update the source tree, by running sup and/or running cvs to update to the
314 .if defined(SUP_UPDATE)
315 @echo "--------------------------------------------------------------"
316 @echo ">>> Running ${SUP}"
317 @echo "--------------------------------------------------------------"
319 @${SUP} ${SUPFLAGS} ${SUPFILE}
321 .if defined(SUPFILE1)
322 @${SUP} ${SUPFLAGS} ${SUPFILE1}
324 .if defined(SUPFILE2)
325 @${SUP} ${SUPFLAGS} ${SUPFILE2}
327 .if defined(PORTSSUPFILE)
328 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
331 .if defined(CVS_UPDATE)
332 @echo "--------------------------------------------------------------"
333 @echo ">>> Updating ${.CURDIR} 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} all
348 cd ${.CURDIR}/sbin; ${MAKE} all
349 cd ${.CURDIR}/libexec; ${MAKE} all
350 cd ${.CURDIR}/usr.bin; ${MAKE} all
351 cd ${.CURDIR}/usr.sbin; ${MAKE} all
352 cd ${.CURDIR}/gnu/libexec; ${MAKE} all
353 cd ${.CURDIR}/gnu/usr.bin; ${MAKE} all
354 cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} all
359 # Install the binaries built by the 'most' target. This does not include
360 # libraries or include files.
363 @echo "--------------------------------------------------------------"
364 @echo ">>> Installing programs only"
365 @echo "--------------------------------------------------------------"
366 cd ${.CURDIR}/bin; ${MAKE} install
367 cd ${.CURDIR}/sbin; ${MAKE} install
368 cd ${.CURDIR}/libexec; ${MAKE} install
369 cd ${.CURDIR}/usr.bin; ${MAKE} install
370 cd ${.CURDIR}/usr.sbin; ${MAKE} install
371 cd ${.CURDIR}/gnu/libexec; ${MAKE} install
372 cd ${.CURDIR}/gnu/usr.bin; ${MAKE} install
373 cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} install
376 # ------------------------------------------------------------------------
378 # From here onwards are utility targets used by the 'make world' and
379 # related targets. If your 'world' breaks, you may like to try to fix
380 # the problem and manually run the following targets to attempt to
381 # complete the build. Beware, this is *not* guaranteed to work, you
382 # need to have a pretty good grip on the current state of the system
383 # to attempt to manually finish it. If in doubt, 'make world' again.
387 # bootstrap-tools: Build tools needed for compatibility
389 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
390 _strfile= games/fortune/strfile
394 .for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef gnu/usr.bin/bison
395 cd ${.CURDIR}/${_tool}; \
403 # build-tools: Build special purpose build tools
405 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
406 _games= games/adventure games/hack games/phantasia
409 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
410 _share= share/syscons/scrnmaps
413 .if !defined(NO_FORTRAN)
414 _fortran= gnu/usr.bin/cc/f771
417 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
418 !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
419 _libroken= kerberosIV/lib/libroken
423 .for _tool in bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
424 ${_libroken} lib/libncurses ${_share}
425 cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
429 # cross-tools: Build cross-building tools
431 # WARNING: Because the bootstrap tools are expected to run on the
432 # build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
433 # target is being made. TARGET_ARCH is *always* set to reflect the
434 # target-machine (which you can set by specifying MACHINE_ARCH on
435 # make's command-line, get it?).
436 # The reason is simple: we build these tools not to be run on the
437 # architecture we're cross-building, but on the architecture we're
438 # currently building on (ie the host-machine) and we expect these
439 # tools to produce output for the architecture we're trying to
442 .if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
443 _elf2exe= usr.sbin/elf2exe
446 # XXX - MACHINE should actually be TARGET. But we don't set that...
447 .if ${TARGET_ARCH} == "i386" && ${MACHINE} == "pc98"
448 _aout_tools= usr.bin/size usr.bin/strip gnu/usr.bin/as gnu/usr.bin/ld
452 .for _tool in ${_aout_tools} ${_elf2exe} usr.bin/genassym usr.bin/gensetdefs \
453 gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
454 cd ${.CURDIR}/${_tool}; \
462 # hierarchy - ensure that all the needed directories are present
465 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
468 # includes - possibly generate and install the include files.
471 cd ${.CURDIR}/include; ${MAKE} -B all install
472 cd ${.CURDIR}/gnu/include; ${MAKE} install
473 cd ${.CURDIR}/gnu/lib/libmp; ${MAKE} beforeinstall
474 cd ${.CURDIR}/gnu/lib/libobjc; ${MAKE} beforeinstall
475 cd ${.CURDIR}/gnu/lib/libreadline; ${MAKE} beforeinstall
476 cd ${.CURDIR}/gnu/lib/libregex; ${MAKE} beforeinstall
477 cd ${.CURDIR}/gnu/lib/libstdc++; ${MAKE} beforeinstall
478 cd ${.CURDIR}/gnu/lib/libdialog; ${MAKE} beforeinstall
479 cd ${.CURDIR}/gnu/lib/libgmp; ${MAKE} beforeinstall
480 cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus; ${MAKE} beforeinstall
481 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
482 .if exists(${.CURDIR}/secure/lib/libcrypto)
483 cd ${.CURDIR}/secure/lib/libcrypto; ${MAKE} beforeinstall
485 cd ${.CURDIR}/secure/lib/libdes; ${MAKE} beforeinstall
486 .if exists(${.CURDIR}/secure/lib/libssl)
487 cd ${.CURDIR}/secure/lib/libssl; ${MAKE} beforeinstall
490 .if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
491 defined(MAKE_KERBEROS4)
492 cd ${.CURDIR}/kerberosIV/lib/libacl; ${MAKE} beforeinstall
493 cd ${.CURDIR}/kerberosIV/lib/libkadm; ${MAKE} beforeinstall
494 cd ${.CURDIR}/kerberosIV/lib/libkafs; ${MAKE} beforeinstall
495 cd ${.CURDIR}/kerberosIV/lib/libkdb; ${MAKE} beforeinstall
496 cd ${.CURDIR}/kerberosIV/lib/libkrb; ${MAKE} beforeinstall
497 cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
499 cd ${.CURDIR}/lib/libtelnet; ${MAKE} beforeinstall
501 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
502 cd ${.CURDIR}/lib/csu/${MACHINE_ARCH}; ${MAKE} beforeinstall
504 cd ${.CURDIR}/lib/libalias; ${MAKE} beforeinstall
505 cd ${.CURDIR}/lib/libatm; ${MAKE} beforeinstall
506 cd ${.CURDIR}/lib/libdevstat; ${MAKE} beforeinstall
507 cd ${.CURDIR}/lib/libc; ${MAKE} beforeinstall
508 cd ${.CURDIR}/lib/libcalendar; ${MAKE} beforeinstall
509 cd ${.CURDIR}/lib/libcam; ${MAKE} beforeinstall
510 cd ${.CURDIR}/lib/libdisk; ${MAKE} beforeinstall
511 cd ${.CURDIR}/lib/libedit; ${MAKE} beforeinstall
512 cd ${.CURDIR}/lib/libftpio; ${MAKE} beforeinstall
513 cd ${.CURDIR}/lib/libkvm; ${MAKE} beforeinstall
514 cd ${.CURDIR}/lib/libmd; ${MAKE} beforeinstall
515 .if !defined(WANT_CSRG_LIBM)
516 cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
518 cd ${.CURDIR}/lib/libncp; ${MAKE} beforeinstall
519 cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
520 cd ${.CURDIR}/lib/libnetgraph; ${MAKE} beforeinstall
521 cd ${.CURDIR}/lib/libopie; ${MAKE} beforeinstall
522 cd ${.CURDIR}/lib/libpam/libpam; ${MAKE} beforeinstall
523 cd ${.CURDIR}/lib/libpcap; ${MAKE} beforeinstall
524 cd ${.CURDIR}/lib/libradius; ${MAKE} beforeinstall
525 cd ${.CURDIR}/lib/librpcsvc; ${MAKE} beforeinstall
526 cd ${.CURDIR}/lib/libskey; ${MAKE} beforeinstall
527 cd ${.CURDIR}/lib/libstand; ${MAKE} beforeinstall
528 cd ${.CURDIR}/lib/libtacplus; ${MAKE} beforeinstall
529 cd ${.CURDIR}/lib/libcom_err; ${MAKE} beforeinstall
530 cd ${.CURDIR}/lib/libss; ${MAKE} -B hdrs beforeinstall
531 cd ${.CURDIR}/lib/libutil; ${MAKE} beforeinstall
532 cd ${.CURDIR}/lib/libvgl; ${MAKE} beforeinstall
533 cd ${.CURDIR}/lib/libwrap; ${MAKE} beforeinstall
534 cd ${.CURDIR}/lib/libz; ${MAKE} beforeinstall
535 cd ${.CURDIR}/usr.bin/lex; ${MAKE} beforeinstall
538 # libraries - build all libraries, and install them under ${DESTDIR}.
540 # The following dependencies exist between the libraries:
545 # libdialog: libncurses
546 # libedit: libncurses
550 # libpam: libcom_err libcrypt libdes libgcc_pic libkrb libradius libskey \
553 # libreadline: libncurses
554 # libskey: libcrypt libmd
559 # Across directories this comes down to (rougly):
561 # gnu/lib: lib/libm lib/libncurses
562 # kerberosIV/lib: lib/libcrypt
563 # lib/libpam: secure/lib/libdes kerberosIV/lib/libkrb gnu/lib/libgcc
564 # secure/lib: lib/libmd
566 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
567 _csu= lib/csu/${MACHINE_ARCH}.pcc
568 .elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
569 _csu= lib/csu/i386-elf
571 _csu= lib/csu/${MACHINE_ARCH}
574 .if !defined(NOSECURE) && !defined(NOCRYPT)
575 _secure_lib= secure/lib
578 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
579 _kerberosIV_lib= kerberosIV/lib
582 .if defined(WANT_CSRG_LIBM)
589 _libperl= gnu/usr.bin/perl/libperl
592 .if ${MACHINE_ARCH} == "i386"
593 _libkeycap= usr.sbin/pcvt/keycap
597 .for _lib in ${_csu} lib/libmd lib/libcrypt ${_secure_lib} ${_kerberosIV_lib} \
598 gnu/lib/libgcc lib/libcom_err ${_libm} lib/libncurses lib/libradius \
599 lib/libskey lib/libtacplus lib/libutil lib gnu/lib ${_libperl} \
600 usr.bin/lex/lib ${_libkeycap}
601 .if exists(${.CURDIR}/${_lib})
602 cd ${.CURDIR}/${_lib}; \
609 .for __target in clean cleandepend cleandir depend obj
610 .for entry in ${SUBDIR}
611 ${entry}.${__target}__D: .PHONY
612 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
613 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
614 edir=${entry}.${MACHINE_ARCH}; \
615 cd ${.CURDIR}/$${edir}; \
617 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
619 cd ${.CURDIR}/$${edir}; \
621 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
623 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
626 .include <bsd.subdir.mk>