Makefile revision 1.191
11.191Slukem# $NetBSD: Makefile,v 1.191 2002/12/02 08:23:41 lukem Exp $ 21.95Scjs 31.95Scjs# This is the top-level makefile for building NetBSD. For an outline of 41.95Scjs# how to build a snapshot or release, as well as other release engineering 51.95Scjs# information, see http://www.netbsd.org/developers/releng/index.html 61.95Scjs# 71.95Scjs# Not everything you can set or do is documented in this makefile. In 81.95Scjs# particular, you should review the files in /usr/share/mk (especially 91.95Scjs# bsd.README) for general information on building programs and writing 101.95Scjs# Makefiles within this structure, and see the comments in src/etc/Makefile 111.95Scjs# for further information on installation and release set options. 121.95Scjs# 131.95Scjs# Variables listed below can be set on the make command line (highest 141.95Scjs# priority), in /etc/mk.conf (middle priority), or in the environment 151.95Scjs# (lowest priority). 161.95Scjs# 171.95Scjs# Variables: 181.101Ssommerfe# DESTDIR is the target directory for installation of the compiled 191.101Ssommerfe# software. It defaults to /. Note that programs are built against 201.101Ssommerfe# libraries installed in DESTDIR. 211.95Scjs# MKMAN, if set to `no', will prevent building of manual pages. 221.178Senami# MKOBJDIRS, if not set to `no', will build object directories at 231.101Ssommerfe# an appropriate point in a build. 241.95Scjs# MKSHARE, if set to `no', will prevent building and installing 251.95Scjs# anything in /usr/share. 261.125Smrg# UPDATE, if defined, will avoid a `make cleandir' at the start of 271.178Senami# `make build', as well as having the effects listed in 281.178Senami# /usr/share/mk/bsd.README. 291.125Smrg# NOCLEANDIR, if defined, will avoid a `make cleandir' at the start 301.178Senami# of the `make build'. 311.119Stoddpw# NOINCLUDES will avoid the `make includes' usually done by `make build'. 321.95Scjs# 331.95Scjs# Targets: 341.137Stv# build: 351.137Stv# Builds a full release of NetBSD in DESTDIR. If BUILD_DONE is 361.110Sjlam# set, this is an empty target. 371.137Stv# release: 381.137Stv# Does a `make build,' and then tars up the DESTDIR files 391.95Scjs# into RELEASEDIR, in release(7) format. (See etc/Makefile for 401.95Scjs# more information on this.) 411.137Stv# regression-tests: 421.137Stv# Runs the regression tests in "regress" on this host. 431.123Smrg# 441.137Stv# Targets invoked by `make build,' in order: 451.155Stv# cleandir: cleans the tree. 461.137Stv# obj: creates object directories. 471.152Stv# do-tools: builds host toolchain. 481.131Stv# do-distrib-dirs: creates the distribution directories. 491.137Stv# includes: installs include files. 501.168Stv# do-lib-csu: builds and installs prerequisites from lib/csu. 511.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 521.143Stv# do-lib: builds and installs prerequisites from lib. 531.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 541.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 551.137Stv# do-build: builds and installs the entire system. 561.32Scgd 571.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 581.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 591.146Stv.endif 601.163Stv 611.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 621.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 631.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 641.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 651.163Stv_SRC_TOP_OBJ_= 661.148Sjmc 671.146Stv.include <bsd.own.mk> 681.4Scgd 691.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 701.137Stv# with a standard recursive target. 711.137Stv 721.137Stv.if make(build) || make(release) || make(snapshot) 731.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 741.137Stv.if make(${targ}) && !target(.BEGIN) 751.137Stv.BEGIN: 761.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 771.137Stv @false 781.137Stv.endif 791.137Stv.endfor 801.137Stv.endif 811.58Stv 821.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 831.183Slukem_SUBDIR+= usr.sbin share rescue sys etc distrib regress 841.105Sassar 851.137Stv# Weed out directories that don't exist. 861.36Sexplorer 871.137Stv.for dir in ${_SUBDIR} 881.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 891.137StvSUBDIR+= ${dir} 901.36Sexplorer.endif 911.137Stv.endfor 921.21Scgd 931.13Sbrezak.if exists(regress) 941.10Scgdregression-tests: 951.10Scgd @echo Running regression tests... 961.152Stv @(cd ${.CURDIR}/regress && ${MAKE} regress) 971.13Sbrezak.endif 981.20Scgd 991.179Sthorpej.if defined(UNPRIVED) 1001.179SthorpejNOPOSTINSTALL= # defined 1011.179Sthorpej.endif 1021.179Sthorpej 1031.176Slukemafterinstall: 1041.137Stv.if ${MKMAN} != "no" 1051.152Stv (cd ${.CURDIR}/share/man && ${MAKE} makedb) 1061.137Stv.endif 1071.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no") 1081.164Sjmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 1091.176Slukem.endif 1101.179Sthorpej.if !defined(NOPOSTINSTALL) 1111.180Sdrochner (cd ${.CURDIR} && ${MAKE} postinstall-check) 1121.159Sperry.endif 1131.170Slukem 1141.170Slukempostinstall-check: 1151.169Slukem @echo " === Post installation checks ===" 1161.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1171.171Slukem @echo " ================================" 1181.171Slukem 1191.171Slukempostinstall-fix: .NOTMAIN 1201.171Slukem @echo " === Post installation fixes ===" 1211.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1221.169Slukem @echo " ================================" 1231.169Slukem 1241.108Serh 1251.137Stv# Targets (in order!) called by "make build". 1261.123Smrg 1271.156StvBUILDTARGETS+= check-tools 1281.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR) 1291.155StvBUILDTARGETS+= cleandir 1301.155Stv.endif 1311.149Stv.if ${MKOBJDIRS} != "no" 1321.137StvBUILDTARGETS+= obj 1331.123Smrg.endif 1341.138Stv.if ${USETOOLS} == "yes" 1351.152StvBUILDTARGETS+= do-tools 1361.131Stv.endif 1371.137Stv.if !defined(NODISTRIBDIRS) 1381.137StvBUILDTARGETS+= do-distrib-dirs 1391.131Stv.endif 1401.137Stv.if !defined(NOINCLUDES) 1411.137StvBUILDTARGETS+= includes 1421.131Stv.endif 1431.189SitohyBUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build 1441.131Stv 1451.137Stv# Enforce proper ordering of some rules. 1461.123Smrg 1471.137Stv.ORDER: ${BUILDTARGETS} 1481.137Stvincludes-lib: includes-include includes-sys 1491.137Stvincludes-gnu: includes-lib 1501.123Smrg 1511.137Stv# Build the system and install into DESTDIR. 1521.123Smrg 1531.191SlukemSTART_TIME!= date 1541.191Slukem 1551.137Stvbuild: 1561.137Stv.if defined(BUILD_DONE) 1571.137Stv @echo "Build already installed into ${DESTDIR}" 1581.137Stv.else 1591.191Slukem @echo "Build started at: ${START_TIME}" 1601.145Stv.for tgt in ${BUILDTARGETS} 1611.173Ssommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt}) 1621.145Stv.endfor 1631.191Slukem @echo "Build started at: ${START_TIME}" 1641.172Sbjh21 @printf "Build finished at: " && date 1651.71Smycroft.endif 1661.160Sthorpej 1671.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 1681.160Sthorpej# ${RELEASEDIR}). 1691.160Sthorpej 1701.179Sthorpejdistribution: 1711.182Suwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 1721.160Sthorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 1731.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 1741.181Sthorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 1751.181Sthorpej.endif 1761.185Slukem @printf "make ${.TARGET} finished at: " && date 1771.123Smrg 1781.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 1791.181Sthorpej# in this case, the set lists will be checked before the tar files 1801.181Sthorpej# are made. 1811.123Smrg 1821.179Sthorpejrelease snapshot: 1831.179Sthorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 1841.152Stv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 1851.185Slukem @printf "make ${.TARGET} finished at: " && date 1861.123Smrg 1871.137Stv# Special components of the "make build" process. 1881.156Stv 1891.156Stvcheck-tools: 1901.187Sthorpej.if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN) 1911.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 1921.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 1931.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 1941.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 1951.156Stv.endif 1961.173Ssommerfe.if defined(NBUILDJOBS) 1971.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 1981.173Ssommerfe.endif 1991.123Smrg 2001.137Stvdo-distrib-dirs: 2011.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 2021.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 2031.147Sjmc.else 2041.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 2051.147Sjmc.endif 2061.190Slukem 2071.190Slukem.for targ in cleandir obj includes 2081.190Slukemdo-${targ}: ${targ} 2091.190Slukem @true 2101.190Slukem.endfor 2111.123Smrg 2121.186Sthorpej.for dir in tools lib/csu lib/libc lib gnu/lib 2131.143Stvdo-${dir:S/\//-/}: 2141.137Stv.for targ in dependall install 2151.173Ssommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 2161.137Stv.endfor 2171.184Slukem.endfor 2181.184Slukem 2191.189Sitohydo-ld.so: 2201.184Slukem.for targ in dependall install 2211.189Sitohy.if (${OBJECT_FMT} == "a.out") 2221.189Sitohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 2231.189Sitohy.endif 2241.189Sitohy.if (${OBJECT_FMT} == "ELF") 2251.184Slukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 2261.189Sitohy.endif 2271.137Stv.endfor 2281.143Stv 2291.143Stvdo-build: 2301.154Stv.for targ in dependall install 2311.173Ssommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 2321.154Stv.endfor 2331.87Scjs 2341.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 2351.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 2361.129Stv 2371.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 2381.152Stvincludes-${dir}: 2391.152Stv @true 2401.152Stv.endfor 2411.152Stv.for dir in etc distrib regress 2421.152Stvinstall-${dir}: 2431.152Stv @true 2441.152Stv.endfor 2451.152Stv 2461.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 2471.152Stvdependall-distrib depend-distrib all-distrib: 2481.136Snathanw @true 2491.130Stv 2501.151Stv.include <bsd.obj.mk> 2511.146Stv.include <bsd.subdir.mk> 2521.144Stv 2531.150Stvbuild-docs: ${.CURDIR}/BUILDING 2541.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 2551.150Stv groff -mdoc -Tascii -P-b -P-u -P-o $> >$@ 256