Makefile revision 1.200
11.89Sjdolecek# $NetBSD: Makefile,v 1.200 2003/02/22 03:20:45 lukem Exp $ 21.86Sgmcgarry 31.86Sgmcgarry# 41.86Sgmcgarry# This is the top-level makefile for building NetBSD. For an outline of 51.86Sgmcgarry# how to build a snapshot or release, as well as other release engineering 61.86Sgmcgarry# information, see http://www.netbsd.org/developers/releng/index.html 71.86Sgmcgarry# 81.86Sgmcgarry# Not everything you can set or do is documented in this makefile. In 91.86Sgmcgarry# particular, you should review the files in /usr/share/mk (especially 101.86Sgmcgarry# bsd.README) for general information on building programs and writing 111.86Sgmcgarry# Makefiles within this structure, and see the comments in src/etc/Makefile 121.86Sgmcgarry# for further information on installation and release set options. 131.86Sgmcgarry# 141.86Sgmcgarry# Variables listed below can be set on the make command line (highest 151.86Sgmcgarry# priority), in /etc/mk.conf (middle priority), or in the environment 161.86Sgmcgarry# (lowest priority). 171.86Sgmcgarry# 181.86Sgmcgarry# Variables: 191.86Sgmcgarry# DESTDIR is the target directory for installation of the compiled 201.9Sgwr# software. It defaults to /. Note that programs are built against 211.86Sgmcgarry# libraries installed in DESTDIR. 221.21Sgwr# MKMAN, if set to `no', will prevent building of manual pages. 231.1Sglass# MKOBJDIRS, if not set to `no', will build object directories at 241.86Sgmcgarry# an appropriate point in a build. 251.63Shubertf# MKSHARE, if set to `no', will prevent building and installing 261.89Sjdolecek# anything in /usr/share. 271.1Sglass# UPDATE, if defined, will avoid a `make cleandir' at the start of 281.50Sgwr# `make build', as well as having the effects listed in 291.15Sgwr# /usr/share/mk/bsd.README. 301.21Sgwr# NOCLEANDIR, if defined, will avoid a `make cleandir' at the start 311.3Sglass# of the `make build'. 321.4Sgwr# NOINCLUDES will avoid the `make includes' usually done by `make build'. 331.3Sglass# 341.23Sgwr# Targets: 351.4Sgwr# build: 361.41Sgwr# Builds a full release of NetBSD in DESTDIR, except for the 371.41Sgwr# /etc configuration files. 381.41Sgwr# If BUILD_DONE is set, this is an empty target. 391.84Slukem# distribution: 401.84Slukem# Builds a full release of NetBSD in DESTDIR, including the /etc 411.84Slukem# configuration files. 421.84Slukem# buildworld: 431.41Sgwr# As per `make distribution', except that it ensures that DESTDIR 441.41Sgwr# is not the root directory. 451.52Sfair# installworld: 461.41Sgwr# Install the distribution from DESTDIR to INSTALLWORLDDIR (which 471.41Sgwr# defaults to the root directory). Ensures that INSTALLWORLDDIR 481.89Sjdolecek# is the not root directory if cross compiling. 491.30Sthorpej# release: 501.41Sgwr# Does a `make build', and then tars up the DESTDIR files 511.30Sthorpej# into RELEASEDIR/${MACHINE}, in release(7) format. 521.36Sgwr# (See etc/Makefile for more information on this.) 531.84Slukem# regression-tests: 541.30Sthorpej# Runs the regression tests in "regress" on this host. 551.83Slukem# 561.41Sgwr# Targets invoked by `make build,' in order: 571.41Sgwr# cleandir: cleans the tree. 581.43Slukem# obj: creates object directories. 591.41Sgwr# do-tools: builds host toolchain. 601.41Sgwr# do-distrib-dirs: creates the distribution directories. 611.41Sgwr# includes: installs include files. 621.41Sgwr# do-lib-csu: builds and installs prerequisites from lib/csu. 631.41Sgwr# do-lib-libc: builds and installs prerequisites from lib/libc. 641.40Smjacob# do-lib: builds and installs prerequisites from lib. 651.1Sglass# do-gnu-lib: builds and installs prerequisites from gnu/lib. 661.78Swiz# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 671.41Sgwr# do-build: builds and installs the entire system. 681.57Skleink# 691.41Sgwr 701.41Sgwr.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 711.41Sgwr.MAKEFLAGS: -m ${.CURDIR}/share/mk 721.41Sgwr.endif 731.45Skleink 741.59Saugustss# 751.77Schs# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 761.56Sitohy# not be the top level objdir, because "make obj" can happen in the *middle* 771.77Schs# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 781.80Sabs# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 791.41Sgwr# 801.4Sgwr_SRC_TOP_OBJ_= 811.41Sgwr 821.41Sgwr.include <bsd.own.mk> 831.38Slukem 841.38Slukem# 851.38Slukem# Sanity check: make sure that "make build" is not invoked simultaneously 861.38Slukem# with a standard recursive target. 871.62Swrstuden# 881.38Slukem 891.38Slukem.if make(build) || make(release) || make(snapshot) 901.38Slukem.for targ in ${TARGETS:Nobj:Ncleandir} 911.35Sthorpej.if make(${targ}) && !target(.BEGIN) 921.30Sthorpej.BEGIN: 931.41Sgwr @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 941.51Sbouyer @false 951.84Slukem.endif 961.61Sitojun.endfor 971.4Sgwr.endif 981.30Sthorpej 991.61Sitojun_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1001.61Sitojun_SUBDIR+= usr.sbin share rescue sys etc distrib regress 1011.61Sitojun 1021.61Sitojun# 1031.38Slukem# Weed out directories that don't exist. 1041.41Sgwr# 1051.41Sgwr 1061.41Sgwr.for dir in ${_SUBDIR} 1071.58Schristos.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1081.80SabsSUBDIR+= ${dir} 1091.41Sgwr.endif 1101.41Sgwr.endfor 1111.12Sgwr 1121.48Sgwr.if exists(regress) 1131.3Sglassregression-tests: 1141.35Sthorpej @echo Running regression tests... 1151.1Sglass @(cd ${.CURDIR}/regress && ${MAKE} regress) 1161.49Sgwr.endif 1171.49Sgwr 1181.49Sgwr.if defined(UNPRIVED) 1191.49SgwrNOPOSTINSTALL= # defined 1201.49Sgwr.endif 1211.49Sgwr 1221.49Sgwrafterinstall: 1231.49Sgwr.if ${MKMAN} != "no" 1241.49Sgwr (cd ${.CURDIR}/share/man && ${MAKE} makedb) 1251.49Sgwr.endif 1261.49Sgwr.if defined(UNPRIVED) && (${MKINFO} != "no") 1271.49Sgwr (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 1281.49Sgwr.endif 1291.49Sgwr.if !defined(NOPOSTINSTALL) 1301.49Sgwr (cd ${.CURDIR} && ${MAKE} postinstall-check) 1311.49Sgwr.endif 1321.25Sgwr 1331.27Sgwrpostinstall-check: 1341.27Sgwr @echo " === Post installation checks ===" 1351.38Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1361.38Slukem @echo " ================================" 1371.27Sgwr 1381.38Slukempostinstall-fix: .NOTMAIN 1391.38Slukem @echo " === Post installation fixes ===" 1401.27Sgwr sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1411.27Sgwr @echo " ================================" 1421.25Sgwr 1431.25Sgwr 1441.16Sgwr# 1451.25Sgwr# Targets (in order!) called by "make build". 1461.49Sgwr# 1471.84Slukem 1481.4SgwrBUILDTARGETS+= check-tools 1491.25Sgwr.if !defined(UPDATE) && !defined(NOCLEANDIR) 1501.49SgwrBUILDTARGETS+= cleandir 1511.49Sgwr.endif 1521.49Sgwr.if ${MKOBJDIRS} != "no" 1531.49SgwrBUILDTARGETS+= obj 1541.49Sgwr.endif 1551.12Sgwr.if ${USETOOLS} == "yes" 1561.25SgwrBUILDTARGETS+= do-tools 1571.25Sgwr.endif 1581.25Sgwr.if !defined(NODISTRIBDIRS) 1591.25SgwrBUILDTARGETS+= do-distrib-dirs 1601.25Sgwr.endif 1611.37Sgwr.if !defined(NOINCLUDES) 1621.37SgwrBUILDTARGETS+= includes 1631.31Sgwr.endif 1641.37SgwrBUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build 1651.37SgwrBUILDTARGETS+= do-obsolete 1661.37Sgwr 1671.37Sgwr# 1681.37Sgwr# Enforce proper ordering of some rules. 1691.37Sgwr# 1701.37Sgwr 1711.49Sgwr.ORDER: ${BUILDTARGETS} 1721.84Slukemincludes-lib: includes-include includes-sys 1731.84Slukemincludes-gnu: includes-lib 1741.49Sgwr 1751.49Sgwr# 1761.49Sgwr# Build the system and install into DESTDIR. 1771.49Sgwr# 1781.41Sgwr 1791.37SgwrSTART_TIME!= date 1801.49Sgwr 1811.49Sgwrbuild: 1821.49Sgwr.if defined(BUILD_DONE) 1831.41Sgwr @echo "Build already installed into ${DESTDIR}" 1841.25Sgwr.else 1851.25Sgwr @echo "Build started at: ${START_TIME}" 1861.25Sgwr.for tgt in ${BUILDTARGETS} 1871.49Sgwr @(cd ${.CURDIR} && ${MAKE} ${tgt}) 1881.49Sgwr.endfor 1891.49Sgwr @echo "Build started at: ${START_TIME}" 1901.49Sgwr @printf "Build finished at: " && date 1911.46Sgwr.endif 1921.46Sgwr 1931.46Sgwr# 1941.46Sgwr# Build a full distribution, but not a release (i.e. no sets into 1951.25Sgwr# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 1961.25Sgwr# 1971.10Sgwr 1981.50Sgwrdistribution buildworld: 1991.50Sgwr.if make(buildworld) && \ 2001.25Sgwr (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2011.25Sgwr @echo "Won't make ${.TARGET} with DESTDIR=/" 2021.50Sgwr @false 2031.25Sgwr.endif 2041.25Sgwr (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2051.50Sgwr (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 2061.25Sgwr.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2071.49Sgwr (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 2081.49Sgwr.endif 2091.25Sgwr @echo "make ${.TARGET} started at: ${START_TIME}" 2101.49Sgwr @printf "make ${.TARGET} finished at: " && date 2111.49Sgwr 2121.25Sgwr# 2131.25Sgwr# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2141.25Sgwr# If installing to /, ensures that the host's operating system is NetBSD and 2151.25Sgwr# the host's `uname -m` == ${MACHINE}. 2161.7Sgwr# 2171.14Sgwr 2181.37SgwrHOST_UNAME_S!= uname -s 2191.37SgwrHOST_UNAME_M!= uname -m 2201.37Sgwr 2211.37Sgwrinstallworld: 2221.37Sgwr.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2231.37Sgwr @echo "Can't make ${.TARGET} to DESTDIR=/" 2241.24Sgwr @false 2251.33Spk.endif 2261.38Slukem.if !defined(INSTALLWORLDDIR) || \ 2271.1Sglass ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2281.25Sgwr.if (${HOST_UNAME_S} != "NetBSD") 2291.38Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2301.38Slukem @false 2311.38Slukem.endif 2321.38Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2331.87Smartin @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2341.38Slukem @false 2351.55Shwr.endif 2361.37Sgwr.endif 2371.61Sitojun (cd ${.CURDIR}/distrib/sets && \ 2381.61Sitojun ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets) 2391.66Sitojun (cd ${.CURDIR} && \ 2401.75Sbouyer ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check) 2411.85Satatat @echo "make ${.TARGET} started at: ${START_TIME}" 2421.74Sitojun @printf "make ${.TARGET} finished at: " && date 2431.17Sgwr 2441.73Sjdolecek# 2451.67Stsutsui# Create sets from $DESTDIR into $RELEASEDIR 2461.38Slukem# 2471.54Soster 2481.65Ssimonbsets: 2491.88Soster (cd ${.CURDIR}/distrib/sets && ${MAKE} maketars) 2501.88Soster 2511.88Soster# 2521.88Soster# Build a release or snapshot (implies "make build"). Note that 2531.88Soster# in this case, the set lists will be checked before the tar files 2541.88Soster# are made. 2551.88Soster# 2561.88Soster 257release snapshot: 258 (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 259 (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 260 @echo "make ${.TARGET} started at: ${START_TIME}" 261 @printf "make ${.TARGET} finished at: " && date 262 263# 264# Special components of the "make build" process. 265# 266 267check-tools: 268.if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN) 269 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 270 @echo '*** May result in a failed build or corrupt binaries!' 271.elif defined(EXTERNAL_TOOLCHAIN) 272 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 273.endif 274.if defined(NBUILDJOBS) 275 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 276.endif 277 278do-distrib-dirs: 279.if !defined(DESTDIR) || ${DESTDIR} == "" 280 (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 281.else 282 (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 283.endif 284 285.for targ in cleandir obj includes 286do-${targ}: ${targ} 287 @true 288.endfor 289 290.for dir in tools lib/csu lib/libc lib gnu/lib 291do-${dir:S/\//-/}: 292.for targ in dependall install 293 (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 294.endfor 295.endfor 296 297do-ld.so: 298.for targ in dependall install 299.if (${OBJECT_FMT} == "a.out") 300 (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 301.endif 302.if (${OBJECT_FMT} == "ELF") 303 (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 304.endif 305.endfor 306 307do-build: 308.for targ in dependall install 309 (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 310.endfor 311 312do-obsolete: 313 (cd ${.CURDIR}/etc && ${MAKE} install-obsolete-lists) 314 315# 316# Speedup stubs for some subtrees that don't need to run these rules. 317# (Tells <bsd.subdir.mk> not to recurse for them.) 318# 319 320.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 321includes-${dir}: 322 @true 323.endfor 324.for dir in etc distrib regress 325install-${dir}: 326 @true 327.endfor 328 329# 330# XXX this needs to change when distrib Makefiles are recursion compliant 331# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 332# 333dependall-distrib depend-distrib all-distrib: 334 @true 335 336.include <bsd.obj.mk> 337.include <bsd.subdir.mk> 338 339build-docs: ${.CURDIR}/BUILDING 340${.CURDIR}/BUILDING: doc/BUILDING.mdoc 341 groff -mdoc -Tascii -P-b -P-u -P-o $> >$@ 342