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 BUILD_ARCH!= sysctl -n hw.machine_arch
110 .if ${BUILD_ARCH} == ${MACHINE_ARCH}
111 OBJTREE= ${MAKEOBJDIRPREFIX}
113 OBJTREE= ${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
115 WORLDTMP= ${OBJTREE}${.CURDIR}/${BUILD_ARCH}
116 STRICTTMPPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/bin
117 TMPPATH= ${STRICTTMPPATH}:${PATH}
119 # bootstrap/tools make
120 BMAKEENV= MAKEOBJDIRPREFIX=${WORLDTMP} \
121 DESTDIR=${WORLDTMP} \
122 INSTALL="sh ${.CURDIR}/tools/install.sh" \
123 TARGET_ARCH=${MACHINE_ARCH} \
124 MACHINE_ARCH=${BUILD_ARCH} \
126 BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOMAN -DNOINFO \
127 -DNO_FORTRAN -DNO_GDB
129 CROSSENV= COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
130 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
131 OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
132 PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.00503 \
133 MAKEOBJDIRPREFIX=${OBJTREE}
135 # cross make used for compilation
136 XMAKEENV= ${CROSSENV} \
137 DESTDIR=${WORLDTMP} \
138 INSTALL="sh ${.CURDIR}/tools/install.sh" \
140 XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1
142 # cross make used for final installation
143 IMAKEENV= ${CROSSENV}
144 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
146 USRDIRS= usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
147 usr/libexec/${OBJFORMAT} usr/share/misc
149 .if ${MACHINE_ARCH} == "i386" && ${MACHINE} == "pc98"
150 USRDIRS+= usr/libexec/aout
153 INCDIRS= arpa g++/std objc protocols readline rpc rpcsvc security ss
158 # Attempt to rebuild the entire system, with reasonable chance of
159 # success, regardless of how old your existing system is.
163 @echo "--------------------------------------------------------------"
164 @echo ">>> Rebuilding the temporary build tree"
165 @echo "--------------------------------------------------------------"
166 .if !defined(NOCLEAN)
169 .for _dir in ${USRDIRS}
170 mkdir -p ${WORLDTMP}/${_dir}
172 .for _dir in ${INCDIRS}
173 mkdir -p ${WORLDTMP}/usr/include/${_dir}
176 rm -f ${WORLDTMP}/sys
178 ln -sf ${.CURDIR}/sys ${WORLDTMP}/sys
180 @echo "--------------------------------------------------------------"
181 @echo ">>> Rebuilding tools"
182 @echo "--------------------------------------------------------------"
183 cd ${.CURDIR}; ${BMAKE} tools
184 .if !defined(NOCLEAN)
186 @echo "--------------------------------------------------------------"
187 @echo ">>> Cleaning up the object tree"
188 @echo "--------------------------------------------------------------"
189 cd ${.CURDIR}; ${XMAKE} ${CLEANDIR:S/^/par-/}
192 @echo "--------------------------------------------------------------"
193 @echo ">>> Rebuilding the object tree"
194 @echo "--------------------------------------------------------------"
195 cd ${.CURDIR}; ${XMAKE} par-obj
197 @echo "--------------------------------------------------------------"
198 @echo ">>> Rebuilding ${WORLDTMP}/usr/include"
199 @echo "--------------------------------------------------------------"
200 cd ${.CURDIR}; ${XMAKE} includes
202 @echo "--------------------------------------------------------------"
203 @echo ">>> Building libraries"
204 @echo "--------------------------------------------------------------"
205 cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN libraries
207 @echo "--------------------------------------------------------------"
208 @echo ">>> Rebuilding dependencies"
209 @echo "--------------------------------------------------------------"
210 cd ${.CURDIR}; ${XMAKE} par-depend
212 @echo "--------------------------------------------------------------"
213 @echo ">>> Building everything.."
214 @echo "--------------------------------------------------------------"
215 cd ${.CURDIR}; ${XMAKE} all
218 @echo "--------------------------------------------------------------"
219 @echo ">>> Building everything.."
220 @echo "--------------------------------------------------------------"
221 cd ${.CURDIR}; ${XMAKE} all
226 # Installs everything compiled by a 'buildworld'.
229 cd ${.CURDIR}; ${IMAKE} reinstall
234 # If you have a build server, you can NFS mount the source and obj directories
235 # and do a 'make reinstall' on the *client* to install new binaries from the
236 # most recent server build.
239 @echo "--------------------------------------------------------------"
240 @echo ">>> Making hierarchy"
241 @echo "--------------------------------------------------------------"
242 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
244 @echo "--------------------------------------------------------------"
245 @echo ">>> Installing everything.."
246 @echo "--------------------------------------------------------------"
247 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
250 @echo "--------------------------------------------------------------"
251 @echo ">>> Rebuilding man page indices"
252 @echo "--------------------------------------------------------------"
253 cd ${.CURDIR}/share/man; ${MAKE} makedb
259 # Update the source tree, by running sup and/or running cvs to update to the
263 .if defined(SUP_UPDATE)
264 @echo "--------------------------------------------------------------"
265 @echo ">>> Running ${SUP}"
266 @echo "--------------------------------------------------------------"
267 @${SUP} ${SUPFLAGS} ${SUPFILE}
268 .if defined(SUPFILE1)
269 @${SUP} ${SUPFLAGS} ${SUPFILE1}
271 .if defined(SUPFILE2)
272 @${SUP} ${SUPFLAGS} ${SUPFILE2}
274 .if defined(PORTSSUPFILE)
275 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
278 .if defined(CVS_UPDATE)
279 @echo "--------------------------------------------------------------"
280 @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
281 @echo "--------------------------------------------------------------"
282 cd ${.CURDIR}; cvs -q update -P -d
288 # Build most of the user binaries on the existing system libs and includes.
291 @echo "--------------------------------------------------------------"
292 @echo ">>> Building programs only"
293 @echo "--------------------------------------------------------------"
294 cd ${.CURDIR}/bin; ${MAKE} all
295 cd ${.CURDIR}/sbin; ${MAKE} all
296 cd ${.CURDIR}/libexec; ${MAKE} all
297 cd ${.CURDIR}/usr.bin; ${MAKE} all
298 cd ${.CURDIR}/usr.sbin; ${MAKE} all
299 cd ${.CURDIR}/gnu/libexec; ${MAKE} all
300 cd ${.CURDIR}/gnu/usr.bin; ${MAKE} all
301 cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} all
306 # Install the binaries built by the 'most' target. This does not include
307 # libraries or include files.
310 @echo "--------------------------------------------------------------"
311 @echo ">>> Installing programs only"
312 @echo "--------------------------------------------------------------"
313 cd ${.CURDIR}/bin; ${MAKE} install
314 cd ${.CURDIR}/sbin; ${MAKE} install
315 cd ${.CURDIR}/libexec; ${MAKE} install
316 cd ${.CURDIR}/usr.bin; ${MAKE} install
317 cd ${.CURDIR}/usr.sbin; ${MAKE} install
318 cd ${.CURDIR}/gnu/libexec; ${MAKE} install
319 cd ${.CURDIR}/gnu/usr.bin; ${MAKE} install
320 cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} install
323 # ------------------------------------------------------------------------
325 # From here onwards are utility targets used by the 'make world' and
326 # related targets. If your 'world' breaks, you may like to try to fix
327 # the problem and manually run the following targets to attempt to
328 # complete the build. Beware, this is *not* guaranteed to work, you
329 # need to have a pretty good grip on the current state of the system
330 # to attempt to manually finish it. If in doubt, 'make world' again.
334 # tools - Build tools needed to run the actual build.
336 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
337 _strfile= games/fortune/strfile
340 .if ${MACHINE_ARCH} == "i386" && ${MACHINE} == "pc98"
341 _aout_tools= usr.bin/size usr.bin/strip gnu/usr.bin/as gnu/usr.bin/ld
345 .for _tool in ${_strfile} ${_aout_tools} usr.bin/gensetdefs \
346 gnu/usr.bin/binutils usr.bin/objformat usr.bin/yacc usr.bin/colldef \
347 gnu/usr.bin/bison gnu/usr.bin/cc
348 cd ${.CURDIR}/${_tool}; \
356 # hierarchy - ensure that all the needed directories are present
359 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
362 # includes - possibly generate and install the include files.
365 cd ${.CURDIR}/include; ${MAKE} SHARED=symlinks -B all install
366 cd ${.CURDIR}/gnu/include; ${MAKE} install
367 cd ${.CURDIR}/gnu/lib/libmp; ${MAKE} beforeinstall
368 cd ${.CURDIR}/gnu/lib/libobjc; ${MAKE} beforeinstall
369 cd ${.CURDIR}/gnu/lib/libreadline; ${MAKE} beforeinstall
370 cd ${.CURDIR}/gnu/lib/libregex; ${MAKE} beforeinstall
371 cd ${.CURDIR}/gnu/lib/libstdc++; ${MAKE} beforeinstall
372 cd ${.CURDIR}/gnu/lib/libdialog; ${MAKE} beforeinstall
373 cd ${.CURDIR}/gnu/lib/libgmp; ${MAKE} beforeinstall
374 cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus; ${MAKE} beforeinstall
375 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
376 cd ${.CURDIR}/secure/lib/libdes; ${MAKE} beforeinstall
378 .if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
379 defined(MAKE_KERBEROS4)
380 cd ${.CURDIR}/kerberosIV/lib/libacl; ${MAKE} beforeinstall
381 cd ${.CURDIR}/kerberosIV/lib/libkadm; ${MAKE} beforeinstall
382 cd ${.CURDIR}/kerberosIV/lib/libkafs; ${MAKE} beforeinstall
383 cd ${.CURDIR}/kerberosIV/lib/libkdb; ${MAKE} beforeinstall
384 cd ${.CURDIR}/kerberosIV/lib/libkrb; ${MAKE} beforeinstall
385 cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
387 cd ${.CURDIR}/lib/libtelnet; ${MAKE} beforeinstall
389 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
390 cd ${.CURDIR}/lib/csu/${MACHINE_ARCH}; ${MAKE} beforeinstall
392 cd ${.CURDIR}/lib/libalias; ${MAKE} beforeinstall
393 cd ${.CURDIR}/lib/libatm; ${MAKE} beforeinstall
394 cd ${.CURDIR}/lib/libdevstat; ${MAKE} beforeinstall
395 cd ${.CURDIR}/lib/libc; ${MAKE} beforeinstall
396 cd ${.CURDIR}/lib/libcalendar; ${MAKE} beforeinstall
397 cd ${.CURDIR}/lib/libcam; ${MAKE} beforeinstall
398 cd ${.CURDIR}/lib/libdisk; ${MAKE} beforeinstall
399 cd ${.CURDIR}/lib/libedit; ${MAKE} beforeinstall
400 cd ${.CURDIR}/lib/libftpio; ${MAKE} beforeinstall
401 cd ${.CURDIR}/lib/libkvm; ${MAKE} beforeinstall
402 cd ${.CURDIR}/lib/libmd; ${MAKE} beforeinstall
403 .if !defined(WANT_CSRG_LIBM)
404 cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
406 cd ${.CURDIR}/lib/libncp; ${MAKE} beforeinstall
407 cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
408 cd ${.CURDIR}/lib/libnetgraph; ${MAKE} beforeinstall
409 cd ${.CURDIR}/lib/libopie; ${MAKE} beforeinstall
410 cd ${.CURDIR}/lib/libpam/libpam; ${MAKE} beforeinstall
411 cd ${.CURDIR}/lib/libpcap; ${MAKE} beforeinstall
412 cd ${.CURDIR}/lib/libradius; ${MAKE} beforeinstall
413 cd ${.CURDIR}/lib/librpcsvc; ${MAKE} beforeinstall
414 cd ${.CURDIR}/lib/libskey; ${MAKE} beforeinstall
415 cd ${.CURDIR}/lib/libstand; ${MAKE} beforeinstall
416 cd ${.CURDIR}/lib/libtacplus; ${MAKE} beforeinstall
417 cd ${.CURDIR}/lib/libcom_err; ${MAKE} beforeinstall
418 cd ${.CURDIR}/lib/libss; ${MAKE} -B hdrs beforeinstall
419 cd ${.CURDIR}/lib/libutil; ${MAKE} beforeinstall
420 cd ${.CURDIR}/lib/libvgl; ${MAKE} beforeinstall
421 cd ${.CURDIR}/lib/libwrap; ${MAKE} beforeinstall
422 cd ${.CURDIR}/lib/libz; ${MAKE} beforeinstall
423 cd ${.CURDIR}/usr.bin/lex; ${MAKE} beforeinstall
426 # libraries - build all libraries, and install them under ${DESTDIR}.
428 # The following dependencies exist between the libraries:
433 # libdialog: libncurses
434 # libedit: libncurses
438 # libpam: libcom_err libcrypt libdes libgcc_pic libkrb libradius libskey \
441 # libreadline: libncurses
442 # libskey: libcrypt libmd
447 # Across directories this comes down to (rougly):
449 # gnu/lib: lib/libm lib/libncurses
450 # kerberosIV/lib: lib/libcrypt
451 # lib/libpam: secure/lib/libdes kerberosIV/lib/libkrb gnu/lib/libgcc
452 # secure/lib: lib/libmd
454 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
455 _csu= lib/csu/${MACHINE_ARCH}.pcc
456 .elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
457 _csu= lib/csu/i386-elf
459 _csu= lib/csu/${MACHINE_ARCH}
462 .if !defined(NOSECURE) && !defined(NOCRYPT)
463 _secure_lib= secure/lib
466 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
467 _kerberosIV_lib= kerberosIV/lib
470 .if defined(WANT_CSRG_LIBM)
477 _libperl= gnu/usr.bin/perl/libperl
481 .for _lib in ${_csu} lib/libmd lib/libcrypt ${_secure_lib} ${_kerberosIV_lib} \
482 gnu/lib/libgcc lib/libcom_err ${_libm} lib/libncurses lib/libradius \
483 lib/libskey lib/libtacplus lib/libutil lib gnu/lib ${_libperl} \
484 usr.bin/lex/lib usr.sbin/pcvt/keycap
485 .if exists(${.CURDIR}/${_lib})
486 cd ${.CURDIR}/${_lib}; \
493 .for __target in clean cleandepend cleandir depend obj
494 .for entry in ${SUBDIR}
495 ${entry}.${__target}__D: .PHONY
496 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
497 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
498 edir=${entry}.${MACHINE_ARCH}; \
499 cd ${.CURDIR}/$${edir}; \
501 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
503 cd ${.CURDIR}/$${edir}; \
505 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
507 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
510 .include <bsd.subdir.mk>