Makefile revision 1.193
11.193Slukem# $NetBSD: Makefile,v 1.193 2002/12/21 16:43:33 lukem Exp $ 21.95Scjs 31.193Slukem# 41.95Scjs# This is the top-level makefile for building NetBSD. For an outline of 51.95Scjs# how to build a snapshot or release, as well as other release engineering 61.95Scjs# information, see http://www.netbsd.org/developers/releng/index.html 71.95Scjs# 81.95Scjs# Not everything you can set or do is documented in this makefile. In 91.95Scjs# particular, you should review the files in /usr/share/mk (especially 101.95Scjs# bsd.README) for general information on building programs and writing 111.95Scjs# Makefiles within this structure, and see the comments in src/etc/Makefile 121.95Scjs# for further information on installation and release set options. 131.95Scjs# 141.95Scjs# Variables listed below can be set on the make command line (highest 151.95Scjs# priority), in /etc/mk.conf (middle priority), or in the environment 161.95Scjs# (lowest priority). 171.95Scjs# 181.95Scjs# Variables: 191.101Ssommerfe# DESTDIR is the target directory for installation of the compiled 201.101Ssommerfe# software. It defaults to /. Note that programs are built against 211.101Ssommerfe# libraries installed in DESTDIR. 221.95Scjs# MKMAN, if set to `no', will prevent building of manual pages. 231.178Senami# MKOBJDIRS, if not set to `no', will build object directories at 241.101Ssommerfe# an appropriate point in a build. 251.95Scjs# MKSHARE, if set to `no', will prevent building and installing 261.95Scjs# anything in /usr/share. 271.125Smrg# UPDATE, if defined, will avoid a `make cleandir' at the start of 281.178Senami# `make build', as well as having the effects listed in 291.178Senami# /usr/share/mk/bsd.README. 301.125Smrg# NOCLEANDIR, if defined, will avoid a `make cleandir' at the start 311.178Senami# of the `make build'. 321.119Stoddpw# NOINCLUDES will avoid the `make includes' usually done by `make build'. 331.95Scjs# 341.95Scjs# Targets: 351.137Stv# build: 361.137Stv# Builds a full release of NetBSD in DESTDIR. If BUILD_DONE is 371.110Sjlam# set, this is an empty target. 381.137Stv# release: 391.137Stv# Does a `make build,' and then tars up the DESTDIR files 401.95Scjs# into RELEASEDIR, in release(7) format. (See etc/Makefile for 411.95Scjs# more information on this.) 421.137Stv# regression-tests: 431.137Stv# Runs the regression tests in "regress" on this host. 441.123Smrg# 451.137Stv# Targets invoked by `make build,' in order: 461.155Stv# cleandir: cleans the tree. 471.137Stv# obj: creates object directories. 481.152Stv# do-tools: builds host toolchain. 491.131Stv# do-distrib-dirs: creates the distribution directories. 501.137Stv# includes: installs include files. 511.168Stv# do-lib-csu: builds and installs prerequisites from lib/csu. 521.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 531.143Stv# do-lib: builds and installs prerequisites from lib. 541.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 551.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 561.137Stv# do-build: builds and installs the entire system. 571.193Slukem# 581.32Scgd 591.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 601.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 611.146Stv.endif 621.163Stv 631.193Slukem# 641.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 651.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 661.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 671.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 681.193Slukem# 691.163Stv_SRC_TOP_OBJ_= 701.148Sjmc 711.146Stv.include <bsd.own.mk> 721.4Scgd 731.193Slukem# 741.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 751.137Stv# with a standard recursive target. 761.193Slukem# 771.137Stv 781.137Stv.if make(build) || make(release) || make(snapshot) 791.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 801.137Stv.if make(${targ}) && !target(.BEGIN) 811.137Stv.BEGIN: 821.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 831.137Stv @false 841.137Stv.endif 851.137Stv.endfor 861.137Stv.endif 871.58Stv 881.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 891.183Slukem_SUBDIR+= usr.sbin share rescue sys etc distrib regress 901.105Sassar 911.193Slukem# 921.137Stv# Weed out directories that don't exist. 931.193Slukem# 941.36Sexplorer 951.137Stv.for dir in ${_SUBDIR} 961.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 971.137StvSUBDIR+= ${dir} 981.36Sexplorer.endif 991.137Stv.endfor 1001.21Scgd 1011.13Sbrezak.if exists(regress) 1021.10Scgdregression-tests: 1031.10Scgd @echo Running regression tests... 1041.152Stv @(cd ${.CURDIR}/regress && ${MAKE} regress) 1051.13Sbrezak.endif 1061.20Scgd 1071.179Sthorpej.if defined(UNPRIVED) 1081.179SthorpejNOPOSTINSTALL= # defined 1091.179Sthorpej.endif 1101.179Sthorpej 1111.176Slukemafterinstall: 1121.137Stv.if ${MKMAN} != "no" 1131.152Stv (cd ${.CURDIR}/share/man && ${MAKE} makedb) 1141.137Stv.endif 1151.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no") 1161.164Sjmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 1171.176Slukem.endif 1181.179Sthorpej.if !defined(NOPOSTINSTALL) 1191.180Sdrochner (cd ${.CURDIR} && ${MAKE} postinstall-check) 1201.159Sperry.endif 1211.170Slukem 1221.170Slukempostinstall-check: 1231.169Slukem @echo " === Post installation checks ===" 1241.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1251.171Slukem @echo " ================================" 1261.171Slukem 1271.171Slukempostinstall-fix: .NOTMAIN 1281.171Slukem @echo " === Post installation fixes ===" 1291.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1301.169Slukem @echo " ================================" 1311.169Slukem 1321.108Serh 1331.193Slukem# 1341.137Stv# Targets (in order!) called by "make build". 1351.193Slukem# 1361.123Smrg 1371.156StvBUILDTARGETS+= check-tools 1381.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR) 1391.155StvBUILDTARGETS+= cleandir 1401.155Stv.endif 1411.149Stv.if ${MKOBJDIRS} != "no" 1421.137StvBUILDTARGETS+= obj 1431.123Smrg.endif 1441.138Stv.if ${USETOOLS} == "yes" 1451.152StvBUILDTARGETS+= do-tools 1461.131Stv.endif 1471.137Stv.if !defined(NODISTRIBDIRS) 1481.137StvBUILDTARGETS+= do-distrib-dirs 1491.131Stv.endif 1501.137Stv.if !defined(NOINCLUDES) 1511.137StvBUILDTARGETS+= includes 1521.131Stv.endif 1531.189SitohyBUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build 1541.131Stv 1551.193Slukem# 1561.137Stv# Enforce proper ordering of some rules. 1571.193Slukem# 1581.123Smrg 1591.137Stv.ORDER: ${BUILDTARGETS} 1601.137Stvincludes-lib: includes-include includes-sys 1611.137Stvincludes-gnu: includes-lib 1621.123Smrg 1631.193Slukem# 1641.137Stv# Build the system and install into DESTDIR. 1651.193Slukem# 1661.123Smrg 1671.191SlukemSTART_TIME!= date 1681.191Slukem 1691.137Stvbuild: 1701.137Stv.if defined(BUILD_DONE) 1711.137Stv @echo "Build already installed into ${DESTDIR}" 1721.137Stv.else 1731.191Slukem @echo "Build started at: ${START_TIME}" 1741.145Stv.for tgt in ${BUILDTARGETS} 1751.173Ssommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt}) 1761.145Stv.endfor 1771.191Slukem @echo "Build started at: ${START_TIME}" 1781.172Sbjh21 @printf "Build finished at: " && date 1791.71Smycroft.endif 1801.160Sthorpej 1811.193Slukem# 1821.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 1831.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 1841.193Slukem# 1851.160Sthorpej 1861.193Slukemdistribution buildworld: 1871.193Slukem.if make(buildworld) && (${DESTDIR} == "" || ${DESTDIR} == "/") 1881.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 1891.193Slukem @false 1901.193Slukem.endif 1911.182Suwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 1921.160Sthorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 1931.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 1941.181Sthorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 1951.181Sthorpej.endif 1961.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 1971.185Slukem @printf "make ${.TARGET} finished at: " && date 1981.123Smrg 1991.193Slukem# 2001.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2011.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2021.193Slukem# the host's `uname -m` == ${MACHINE}. 2031.193Slukem# 2041.193Slukem 2051.193SlukemHOST_UNAME_S!= uname -s 2061.193SlukemHOST_UNAME_M!= uname -m 2071.193Slukem 2081.193Slukeminstallworld: 2091.193Slukem.if (${DESTDIR} == "" || ${DESTDIR} == "/") 2101.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2111.193Slukem @false 2121.193Slukem.endif 2131.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2141.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2151.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2161.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2171.193Slukem @false 2181.193Slukem.endif 2191.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2201.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2211.193Slukem @false 2221.193Slukem.endif 2231.193Slukem.endif 2241.193Slukem (cd ${.CURDIR}/distrib/sets && \ 2251.193Slukem ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets) 2261.193Slukem (cd ${.CURDIR} && \ 2271.193Slukem ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check) 2281.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2291.193Slukem @printf "make ${.TARGET} finished at: " && date 2301.193Slukem 2311.193Slukem# 2321.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 2331.181Sthorpej# in this case, the set lists will be checked before the tar files 2341.181Sthorpej# are made. 2351.193Slukem# 2361.123Smrg 2371.179Sthorpejrelease snapshot: 2381.179Sthorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2391.152Stv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 2401.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2411.185Slukem @printf "make ${.TARGET} finished at: " && date 2421.123Smrg 2431.193Slukem# 2441.137Stv# Special components of the "make build" process. 2451.193Slukem# 2461.156Stv 2471.156Stvcheck-tools: 2481.187Sthorpej.if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN) 2491.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 2501.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 2511.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 2521.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 2531.156Stv.endif 2541.173Ssommerfe.if defined(NBUILDJOBS) 2551.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 2561.173Ssommerfe.endif 2571.123Smrg 2581.137Stvdo-distrib-dirs: 2591.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 2601.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 2611.147Sjmc.else 2621.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 2631.147Sjmc.endif 2641.190Slukem 2651.190Slukem.for targ in cleandir obj includes 2661.190Slukemdo-${targ}: ${targ} 2671.190Slukem @true 2681.190Slukem.endfor 2691.123Smrg 2701.186Sthorpej.for dir in tools lib/csu lib/libc lib gnu/lib 2711.143Stvdo-${dir:S/\//-/}: 2721.137Stv.for targ in dependall install 2731.173Ssommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 2741.137Stv.endfor 2751.184Slukem.endfor 2761.184Slukem 2771.189Sitohydo-ld.so: 2781.184Slukem.for targ in dependall install 2791.189Sitohy.if (${OBJECT_FMT} == "a.out") 2801.189Sitohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 2811.189Sitohy.endif 2821.189Sitohy.if (${OBJECT_FMT} == "ELF") 2831.184Slukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 2841.189Sitohy.endif 2851.137Stv.endfor 2861.143Stv 2871.143Stvdo-build: 2881.154Stv.for targ in dependall install 2891.173Ssommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 2901.154Stv.endfor 2911.87Scjs 2921.193Slukem# 2931.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 2941.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 2951.193Slukem# 2961.129Stv 2971.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 2981.152Stvincludes-${dir}: 2991.152Stv @true 3001.152Stv.endfor 3011.152Stv.for dir in etc distrib regress 3021.152Stvinstall-${dir}: 3031.152Stv @true 3041.152Stv.endfor 3051.152Stv 3061.193Slukem# 3071.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3081.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3091.193Slukem# 3101.152Stvdependall-distrib depend-distrib all-distrib: 3111.136Snathanw @true 3121.130Stv 3131.151Stv.include <bsd.obj.mk> 3141.146Stv.include <bsd.subdir.mk> 3151.144Stv 3161.150Stvbuild-docs: ${.CURDIR}/BUILDING 3171.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 3181.150Stv groff -mdoc -Tascii -P-b -P-u -P-o $> >$@ 319