Makefile revision 1.206
11.206Slukem# $NetBSD: Makefile,v 1.206 2003/05/10 07:12:37 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.196Slukem# Builds a full release of NetBSD in DESTDIR, except for the 371.196Slukem# /etc configuration files. 381.196Slukem# If BUILD_DONE is set, this is an empty target. 391.196Slukem# distribution: 401.196Slukem# Builds a full release of NetBSD in DESTDIR, including the /etc 411.196Slukem# configuration files. 421.196Slukem# buildworld: 431.196Slukem# As per `make distribution', except that it ensures that DESTDIR 441.196Slukem# is not the root directory. 451.196Slukem# installworld: 461.196Slukem# Install the distribution from DESTDIR to INSTALLWORLDDIR (which 471.196Slukem# defaults to the root directory). Ensures that INSTALLWORLDDIR 481.196Slukem# is the not root directory if cross compiling. 491.137Stv# release: 501.196Slukem# Does a `make build', and then tars up the DESTDIR files 511.196Slukem# into RELEASEDIR/${MACHINE}, in release(7) format. 521.196Slukem# (See etc/Makefile for more information on this.) 531.137Stv# regression-tests: 541.137Stv# Runs the regression tests in "regress" on this host. 551.206Slukem# sets: 561.206Slukem# Populate ${RELEASEDIR}/${MACHINE}/binary/sets from ${DESTDIR} 571.206Slukem# sourcesets: 581.206Slukem# Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR} 591.123Smrg# 601.137Stv# Targets invoked by `make build,' in order: 611.155Stv# cleandir: cleans the tree. 621.137Stv# obj: creates object directories. 631.152Stv# do-tools: builds host toolchain. 641.202Sthorpej# do-tools-compat: builds the "libnbcompat" library; needed for some 651.202Sthorpej# random host tool programs in the source tree. 661.131Stv# do-distrib-dirs: creates the distribution directories. 671.137Stv# includes: installs include files. 681.168Stv# do-lib-csu: builds and installs prerequisites from lib/csu. 691.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 701.143Stv# do-lib: builds and installs prerequisites from lib. 711.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 721.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 731.137Stv# do-build: builds and installs the entire system. 741.193Slukem# 751.32Scgd 761.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 771.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 781.146Stv.endif 791.163Stv 801.193Slukem# 811.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 821.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 831.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 841.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 851.193Slukem# 861.163Stv_SRC_TOP_OBJ_= 871.148Sjmc 881.146Stv.include <bsd.own.mk> 891.4Scgd 901.193Slukem# 911.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 921.137Stv# with a standard recursive target. 931.193Slukem# 941.137Stv 951.137Stv.if make(build) || make(release) || make(snapshot) 961.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 971.137Stv.if make(${targ}) && !target(.BEGIN) 981.137Stv.BEGIN: 991.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 1001.137Stv @false 1011.137Stv.endif 1021.137Stv.endfor 1031.137Stv.endif 1041.58Stv 1051.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1061.205Sthorpej_SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress 1071.105Sassar 1081.193Slukem# 1091.137Stv# Weed out directories that don't exist. 1101.193Slukem# 1111.36Sexplorer 1121.137Stv.for dir in ${_SUBDIR} 1131.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1141.137StvSUBDIR+= ${dir} 1151.36Sexplorer.endif 1161.137Stv.endfor 1171.21Scgd 1181.13Sbrezak.if exists(regress) 1191.10Scgdregression-tests: 1201.10Scgd @echo Running regression tests... 1211.152Stv @(cd ${.CURDIR}/regress && ${MAKE} regress) 1221.13Sbrezak.endif 1231.20Scgd 1241.179Sthorpej.if defined(UNPRIVED) 1251.179SthorpejNOPOSTINSTALL= # defined 1261.179Sthorpej.endif 1271.179Sthorpej 1281.176Slukemafterinstall: 1291.137Stv.if ${MKMAN} != "no" 1301.152Stv (cd ${.CURDIR}/share/man && ${MAKE} makedb) 1311.137Stv.endif 1321.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no") 1331.164Sjmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 1341.176Slukem.endif 1351.179Sthorpej.if !defined(NOPOSTINSTALL) 1361.180Sdrochner (cd ${.CURDIR} && ${MAKE} postinstall-check) 1371.159Sperry.endif 1381.170Slukem 1391.170Slukempostinstall-check: 1401.169Slukem @echo " === Post installation checks ===" 1411.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1421.171Slukem @echo " ================================" 1431.171Slukem 1441.171Slukempostinstall-fix: .NOTMAIN 1451.171Slukem @echo " === Post installation fixes ===" 1461.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1471.169Slukem @echo " ================================" 1481.169Slukem 1491.108Serh 1501.193Slukem# 1511.137Stv# Targets (in order!) called by "make build". 1521.193Slukem# 1531.123Smrg 1541.156StvBUILDTARGETS+= check-tools 1551.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR) 1561.155StvBUILDTARGETS+= cleandir 1571.155Stv.endif 1581.149Stv.if ${MKOBJDIRS} != "no" 1591.137StvBUILDTARGETS+= obj 1601.123Smrg.endif 1611.138Stv.if ${USETOOLS} == "yes" 1621.152StvBUILDTARGETS+= do-tools 1631.131Stv.endif 1641.137Stv.if !defined(NODISTRIBDIRS) 1651.137StvBUILDTARGETS+= do-distrib-dirs 1661.131Stv.endif 1671.137Stv.if !defined(NOINCLUDES) 1681.137StvBUILDTARGETS+= includes 1691.131Stv.endif 1701.202SthorpejBUILDTARGETS+= do-tools-compat 1711.204SthorpejBUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build 1721.200SlukemBUILDTARGETS+= do-obsolete 1731.131Stv 1741.193Slukem# 1751.137Stv# Enforce proper ordering of some rules. 1761.193Slukem# 1771.123Smrg 1781.137Stv.ORDER: ${BUILDTARGETS} 1791.137Stvincludes-lib: includes-include includes-sys 1801.137Stvincludes-gnu: includes-lib 1811.123Smrg 1821.193Slukem# 1831.137Stv# Build the system and install into DESTDIR. 1841.193Slukem# 1851.123Smrg 1861.191SlukemSTART_TIME!= date 1871.191Slukem 1881.137Stvbuild: 1891.137Stv.if defined(BUILD_DONE) 1901.137Stv @echo "Build already installed into ${DESTDIR}" 1911.137Stv.else 1921.191Slukem @echo "Build started at: ${START_TIME}" 1931.145Stv.for tgt in ${BUILDTARGETS} 1941.173Ssommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt}) 1951.145Stv.endfor 1961.191Slukem @echo "Build started at: ${START_TIME}" 1971.172Sbjh21 @printf "Build finished at: " && date 1981.71Smycroft.endif 1991.160Sthorpej 2001.193Slukem# 2011.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 2021.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 2031.193Slukem# 2041.160Sthorpej 2051.193Slukemdistribution buildworld: 2061.194Slukem.if make(buildworld) && \ 2071.194Slukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2081.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 2091.193Slukem @false 2101.193Slukem.endif 2111.182Suwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2121.160Sthorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 2131.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2141.181Sthorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 2151.181Sthorpej.endif 2161.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2171.185Slukem @printf "make ${.TARGET} finished at: " && date 2181.123Smrg 2191.193Slukem# 2201.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2211.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2221.193Slukem# the host's `uname -m` == ${MACHINE}. 2231.193Slukem# 2241.193Slukem 2251.193SlukemHOST_UNAME_S!= uname -s 2261.193SlukemHOST_UNAME_M!= uname -m 2271.193Slukem 2281.193Slukeminstallworld: 2291.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2301.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2311.193Slukem @false 2321.193Slukem.endif 2331.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2341.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2351.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2361.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2371.193Slukem @false 2381.193Slukem.endif 2391.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2401.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2411.193Slukem @false 2421.193Slukem.endif 2431.193Slukem.endif 2441.193Slukem (cd ${.CURDIR}/distrib/sets && \ 2451.193Slukem ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets) 2461.193Slukem (cd ${.CURDIR} && \ 2471.193Slukem ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check) 2481.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2491.193Slukem @printf "make ${.TARGET} finished at: " && date 2501.199Slukem 2511.199Slukem# 2521.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 2531.199Slukem# 2541.199Slukem 2551.206Slukem.for tgt in sets sourcesets 2561.206Slukem${tgt}: 2571.206Slukem (cd ${.CURDIR}/distrib/sets && ${MAKE} $@) 2581.206Slukem.endfor 2591.193Slukem 2601.193Slukem# 2611.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 2621.181Sthorpej# in this case, the set lists will be checked before the tar files 2631.181Sthorpej# are made. 2641.193Slukem# 2651.123Smrg 2661.179Sthorpejrelease snapshot: 2671.179Sthorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2681.152Stv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 2691.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2701.185Slukem @printf "make ${.TARGET} finished at: " && date 2711.123Smrg 2721.193Slukem# 2731.137Stv# Special components of the "make build" process. 2741.193Slukem# 2751.156Stv 2761.156Stvcheck-tools: 2771.187Sthorpej.if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN) 2781.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 2791.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 2801.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 2811.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 2821.156Stv.endif 2831.173Ssommerfe.if defined(NBUILDJOBS) 2841.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 2851.173Ssommerfe.endif 2861.123Smrg 2871.137Stvdo-distrib-dirs: 2881.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 2891.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 2901.147Sjmc.else 2911.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 2921.147Sjmc.endif 2931.190Slukem 2941.190Slukem.for targ in cleandir obj includes 2951.190Slukemdo-${targ}: ${targ} 2961.190Slukem @true 2971.190Slukem.endfor 2981.123Smrg 2991.204Sthorpej.for dir in tools tools/compat lib/csu lib/libc lib gnu/lib 3001.143Stvdo-${dir:S/\//-/}: 3011.137Stv.for targ in dependall install 3021.173Ssommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 3031.137Stv.endfor 3041.184Slukem.endfor 3051.184Slukem 3061.189Sitohydo-ld.so: 3071.184Slukem.for targ in dependall install 3081.189Sitohy.if (${OBJECT_FMT} == "a.out") 3091.189Sitohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 3101.189Sitohy.endif 3111.189Sitohy.if (${OBJECT_FMT} == "ELF") 3121.184Slukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 3131.189Sitohy.endif 3141.137Stv.endfor 3151.143Stv 3161.143Stvdo-build: 3171.154Stv.for targ in dependall install 3181.173Ssommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 3191.154Stv.endfor 3201.200Slukem 3211.200Slukemdo-obsolete: 3221.200Slukem (cd ${.CURDIR}/etc && ${MAKE} install-obsolete-lists) 3231.87Scjs 3241.193Slukem# 3251.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 3261.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 3271.193Slukem# 3281.129Stv 3291.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 3301.152Stvincludes-${dir}: 3311.152Stv @true 3321.152Stv.endfor 3331.152Stv.for dir in etc distrib regress 3341.152Stvinstall-${dir}: 3351.152Stv @true 3361.152Stv.endfor 3371.152Stv 3381.193Slukem# 3391.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3401.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3411.193Slukem# 3421.152Stvdependall-distrib depend-distrib all-distrib: 3431.136Snathanw @true 3441.130Stv 3451.151Stv.include <bsd.obj.mk> 3461.146Stv.include <bsd.subdir.mk> 3471.144Stv 3481.150Stvbuild-docs: ${.CURDIR}/BUILDING 3491.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 3501.150Stv groff -mdoc -Tascii -P-b -P-u -P-o $> >$@ 351